Skip to content

Commit 9908bc8

Browse files
committed
Merge branch 'release/22.0.0'
2 parents 7d1583d + 06721ac commit 9908bc8

File tree

15 files changed

+118
-89
lines changed

15 files changed

+118
-89
lines changed

.github/workflows/test-build.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: mfr_ci_testing
2+
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
jobs:
6+
7+
build:
8+
runs-on: ubuntu-20.04
9+
env:
10+
GHA_DISTRO: ubuntu-20.04
11+
if: "!contains(github.event.head_commit.message, 'skip ci')"
12+
strategy:
13+
matrix:
14+
python-version: [3.6]
15+
steps:
16+
- name: Git checkout
17+
uses: actions/checkout@v2
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- name: Cache Build Requirements
23+
id: pip-cache-step
24+
uses: actions/cache@v2
25+
with:
26+
path: ${{ env.pythonLocation }}
27+
key: ${{ env.GHA_DISTRO }}-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'dev-requirements.txt') }}
28+
- name: install dependencies
29+
if: steps.pip-cache-step.outputs.cache-hit != 'true'
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install -r dev-requirements.txt
33+
34+
runtests:
35+
name: Run unit tests
36+
needs: build
37+
runs-on: ubuntu-20.04
38+
env:
39+
GHA_DISTRO: ubuntu-20.04
40+
steps:
41+
- uses: actions/checkout@v2
42+
- name: Set up Python 3.6
43+
uses: actions/setup-python@v2
44+
with:
45+
python-version: 3.6
46+
- name: Cache pip
47+
uses: actions/cache@v2
48+
with:
49+
path: ${{ env.pythonLocation }}
50+
key: ${{ env.GHA_DISTRO }}-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'dev-requirements.txt') }}
51+
- name: run syntax checks
52+
run: |
53+
flake8 .
54+
- name: build plugins
55+
run: |
56+
python setup.py develop
57+
- name: run unit tests
58+
run: |
59+
py.test --cov-report term-missing --cov mfr tests
60+
- name: Upload coverage data to coveralls.io
61+
run: coveralls --service=github
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.travis.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

CHANGELOG

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
ChangeLog
33
*********
44

5+
22.0.0 (2022-05-27)
6+
===================
7+
- Feature: Improve Hypothes.is annotations by allowing the parent frame to pass in its url when
8+
turning on the annotator.
9+
- Feature: Enable syntax highlighting for .boa files (https://boa.cs.iastate.edu/) and bump Pygments
10+
dep to 2.12.0.
11+
- Code: Upgrade MFR's Dockerfile to be based off python3.6 and Debian buster. Remove manual gosu
12+
installation and fetch from apt-get instead. python3.6 is now the only supported python version.
13+
- Code: Migrate CI from TravisCI to Github Actions.
14+
515
20.0.1 (2020-10-21)
616
===================
717
- Feature: Add flags to toggle logging of MFR events to specific Keen collections.

CONTRIBUTING.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ Clone the repo:
2323
Configure development environment and install the development dependencies.
2424

2525
.. note::
26-
Python 3.5 or greater, `R`_, and `pspp`_ are required.
27-
Python 3.6 is reccomended. It's recommended that a python version manager such as `pyenv`_ is used and that you use a virtual environment such as `pyenv-virtualenv`_ during development.
26+
Python 3.6 or greater, `R`_, and `pspp`_ are required.
27+
It's recommended that a python version manager such as `pyenv`_ is used and that you use a virtual environment such as `pyenv-virtualenv`_ during development.
2828

2929
.. _R: https://www.r-project.org/
3030
.. _pspp: https://www.gnu.org/software/pspp/

Dockerfile

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.5-slim-buster
1+
FROM python:3.6-slim-buster
22

33
# ensure unoconv can locate the uno library
44
ENV PYTHONPATH /usr/lib/python3/dist-packages
@@ -25,49 +25,32 @@ RUN usermod -d /home www-data \
2525
libxml2-dev \
2626
libxslt1-dev \
2727
zlib1g-dev \
28+
gnupg2 \
2829
# convert .step to jsc3d-compatible format
2930
freecad \
3031
# pspp dependencies
3132
pspp \
3233
# unoconv dependencies
3334
libreoffice \
34-
# gosu dependencies
35-
curl \
36-
gnupg2 \
37-
# gosu
38-
&& export GOSU_VERSION='1.10' \
39-
&& mkdir ~/.gnupg && chmod 600 ~/.gnupg && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf \
40-
&& for server in hkp://ipv4.pool.sks-keyservers.net:80 \
41-
hkp://ha.pool.sks-keyservers.net:80 \
42-
hkp://pgp.mit.edu:80 \
43-
hkp://keyserver.pgp.com:80 \
44-
; do \
45-
gpg --keyserver "$server" --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 && break || echo "Trying new server..." \
46-
; done \
47-
&& curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
48-
&& curl -o /usr/local/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
49-
&& gpg --verify /usr/local/bin/gosu.asc \
50-
&& rm /usr/local/bin/gosu.asc \
51-
&& chmod +x /usr/local/bin/gosu \
52-
# /gosu
35+
# grab gosu for easy step-down from root
36+
gosu \
5337
&& apt-get clean \
5438
&& apt-get autoremove -y \
55-
curl \
56-
gnupg2 \
57-
&& rm -rf /var/lib/apt/lists/* \
58-
&& pip install -U pip \
59-
&& pip install setuptools==37.0.0 \
60-
&& mkdir -p /code \
61-
&& pip install unoconv==0.8.2
39+
&& rm -rf /var/lib/apt/lists/*
6240

41+
RUN mkdir -p /code
6342
WORKDIR /code
6443

65-
COPY ./requirements.txt ./
44+
RUN pip install -U pip==18.1
45+
RUN pip install setuptools==37.0.0
46+
RUN pip install unoconv==0.8.2
47+
48+
COPY ./requirements.txt /code/
6649

6750
RUN pip install --no-cache-dir -r ./requirements.txt
6851

6952
# Copy the rest of the code over
70-
COPY ./ ./
53+
COPY ./ /code/
7154

7255
ARG GIT_COMMIT=
7356
ENV GIT_COMMIT ${GIT_COMMIT}

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
# MFR (Modular File Renderer)
22

3-
`master` Build Status: [![Build Status](https://travis-ci.org/CenterForOpenScience/modular-file-renderer.svg?branch=master)](https://travis-ci.org/CenterForOpenScience/modular-file-renderer)
3+
`master` Build Status: ![Build Status](https://github.com/CenterForOpenScience/modular-file-renderer/actions/workflows/test-build.yml/badge.svg?branch=master)[![Coverage Status](https://coveralls.io/repos/github/CenterForOpenScience/modular-file-renderer/badge.svg?branch=master)](https://coveralls.io/github/CenterForOpenScience/modular-file-renderer?branch=master)
44

5-
`develop` Build Status: [![Build Status](https://travis-ci.org/CenterForOpenScience/modular-file-renderer.svg?branch=develop)](https://travis-ci.org/CenterForOpenScience/modular-file-renderer)
6-
7-
[![Coverage Status](https://coveralls.io/repos/github/CenterForOpenScience/modular-file-renderer/badge.svg)](https://coveralls.io/github/CenterForOpenScience/modular-file-renderer)
5+
`develop` Build Status: ![Build Status](https://github.com/CenterForOpenScience/modular-file-renderer/actions/workflows/test-build.yml/badge.svg?branch=develop)[![Coverage Status](https://coveralls.io/repos/github/CenterForOpenScience/modular-file-renderer/badge.svg?branch=develop)](https://coveralls.io/github/CenterForOpenScience/modular-file-renderer?branch=develop)
86

97
A Python package for rendering files to HTML via an embeddable iframe.
108

119
### Compatibility
1210

13-
MFR is compatible with Python 3.5 (tested up to 3.5.3) and 3.6.
11+
MFR is compatible with Python 3.6.
1412

1513
### Documentation
1614

1715
Documentation available at: http://modular-file-renderer.readthedocs.io/en/latest/
1816

1917
### Setting up
2018

21-
Install the latest version of python3.5.
19+
Install the latest version of python3.6.
2220

2321
For MacOSX users:
2422

@@ -35,12 +33,12 @@ apt-get install python3
3533
apt-get install pspp unoconv
3634
```
3735

38-
After installing python3.5, create the virtual environment with the following commands:
36+
After installing python3.6, create the virtual environment with the following commands:
3937

4038
```bash
4139
pip install virtualenv
4240
pip install virtualenvwrapper
43-
mkvirtualenv --python=`which python3.5` mfr
41+
mkvirtualenv --python=`which python3.6` mfr
4442

4543
pip install setuptools==37.0.0
4644
pip install invoke==0.13.0
@@ -100,7 +98,7 @@ Interested in adding support for a new provider or file format? Check out the CO
10098

10199
### License
102100

103-
Copyright 2013-2018 Center for Open Science
101+
Copyright 2013-2022 Center for Open Science
104102

105103
Licensed under the Apache License, Version 2.0 (the "License");
106104
you may not use this file except in compliance with the License.

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
beautifulsoup4
77
colorlog==2.5.0
8+
coveralls
89
flake8==3.0.4
910
ipdb
1011
mccabe
1112
pydevd==0.0.6
1213
pyflakes
1314
pytest==2.8.2
1415
pytest-cov==2.2.0
15-
python-coveralls==2.9.1
1616
pyzmq==14.4.1

mfr/extensions/codepygments/render.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import logging
23

34
import chardet
45
from humanfriendly import format_size
@@ -13,6 +14,8 @@
1314
from mfr.extensions.codepygments import settings
1415
from mfr.extensions.codepygments import exceptions
1516

17+
logger = logging.getLogger(__name__)
18+
1619

1720
class CodePygmentsRenderer(extension.BaseRenderer):
1821

@@ -98,9 +101,12 @@ def _render_html(self, fp, ext, *args, **kwargs):
98101
# check if there is a lexer available for more obscure file types
99102
if ext in settings.lexer_lib.keys():
100103
lexer = pygments.lexers.get_lexer_by_name(settings.lexer_lib[ext])
104+
logger.debug('found pygments lexer by name')
101105
else:
102106
lexer = pygments.lexers.guess_lexer_for_filename(ext, content)
107+
logger.debug('found pygments lexer by guessing')
103108
except ClassNotFound:
109+
logger.debug('pygments lexer class not found! using default')
104110
self.metrics.add('default_lexer', True)
105111
lexer = self.DEFAULT_LEXER()
106112

mfr/server/static/js/mfr.child.hypothesis.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@
22
'use strict';
33

44
var hypothesisLoaded = false;
5+
var parentWindowUrl = undefined;
6+
7+
window.pymChild.onMessage('setParentUrl', setParentWindowUrl);
58

69
window.pymChild.onMessage('startHypothesis', startHypothesis);
710

811
window.addEventListener('message', function(event) {
9-
if (event.data === 'startHypothesis') {
12+
if (event.data.type === 'startHypothesis') {
13+
setParentWindowUrl(event.data.parentUrl);
1014
startHypothesis(event);
1115
}
1216
});
1317

18+
function setParentWindowUrl(parentUrl) {
19+
parentWindowUrl = parentUrl;
20+
}
21+
1422
function startHypothesis(event) {
1523
if (hypothesisLoaded) {
1624
return;
@@ -53,7 +61,7 @@
5361
// point to the export/download url, meaning the annotations could never be viewed in
5462
// context. By linking to the referrer, the annotations can be viewed in the context of
5563
// the preprint.
56-
window.PDFViewerApplication.url = document.referrer;
64+
window.PDFViewerApplication.url = parentWindowUrl;
5765

5866
// Load the hypothes.is client
5967
var script = window.document.createElement('script');

mfr/server/static/js/mfr.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
};
113113

114114
self.startHypothesis = function() {
115+
self.pymParent.sendMessage('setParentUrl', window.location.toString());
115116
self.pymParent.sendMessage('startHypothesis');
116117
};
117118

0 commit comments

Comments
 (0)