Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
acc547b
adding base tornado server aspects
megankelly Apr 20, 2015
12b942e
checking in
megankelly May 8, 2015
9a859a0
implemented waterbutler'ish stream server, working pdf renderer example
icereval May 8, 2015
ef06305
Merge pull request #1 from icereval/feature/mfr
megankelly May 8, 2015
b0c3bb2
osf provider download and url caching
icereval May 9, 2015
0c5f266
add requires_file render class property, not all renderer's need the …
icereval May 9, 2015
9b71dad
property named renderer plugins
icereval May 9, 2015
a84395d
renamed tests folder ext to extensions to match
icereval May 9, 2015
c498445
ipython notebook renderer and cleanup
icereval May 9, 2015
6e6ef93
ipython notebook mathjax support, also split up css for future custom…
icereval May 10, 2015
ec13d6e
Merge pull request #2 from icereval/feature/mfr
megankelly May 10, 2015
132b3f7
removing handlers from the extensions
megankelly May 10, 2015
e2c1e93
Adding in the abstract property for renderers
megankelly May 10, 2015
430cf66
changing file path for audio & movie renderers
megankelly May 12, 2015
3173220
rst and docx renderers
megankelly May 13, 2015
ebc869b
docx renderer
megankelly May 13, 2015
9f595eb
updated docx for python3
megankelly May 14, 2015
ff73d14
fixed tabular renderer
megankelly May 14, 2015
ab7cec9
added file extension to base extension
megankelly May 14, 2015
f71df67
fixed js imports for pdb renderer
megankelly May 14, 2015
9a55e05
moving tests out of the extensions
megankelly May 15, 2015
5544e8f
clearing out old mfr code
megankelly May 15, 2015
85313c9
enabled .csv, .tsv, and .sav for the tabular renderer
megankelly May 15, 2015
3d62623
starting to clean up documentation
megankelly May 20, 2015
7747d9a
starting to setup extensions and server testing
megankelly May 21, 2015
2e29d34
http provider, cleanup
icereval May 26, 2015
dbfe224
http provider, cleanup
icereval May 26, 2015
052c631
removed import
icereval May 26, 2015
1b9e577
No prepare on options requests
chrisseto May 26, 2015
9bfbfb4
implement options method for base handler for cors support
chrisseto May 26, 2015
9945bba
Accept Authorization header
chrisseto May 26, 2015
9978364
Helper method for sending stream to the end users
chrisseto May 27, 2015
545f1c3
Refactor logic to cache to watertbuler providers
chrisseto May 27, 2015
07022a6
Helper and the like
chrisseto May 27, 2015
e4bf0a0
Add preliminary server exceptions
chrisseto May 27, 2015
8701ce0
Bump line length to 110
chrisseto May 27, 2015
d1598f9
Add defualt settings for mfr caching
chrisseto May 27, 2015
399a76b
Waterbutler no return etags
chrisseto May 27, 2015
1d6e599
wip export and standardize on waterbutler classes
icereval May 27, 2015
d485606
Update unique key
chrisseto May 28, 2015
2f6174d
Bump waterbutler version
chrisseto May 28, 2015
bab21e0
Pull waterbutler develop
chrisseto May 28, 2015
26406f6
Merge branch 'feature/mfr' of github.com:icereval/modular-file-render…
icereval May 28, 2015
e6485b0
Merge branch 'feature/mfr' of github.com:icereval/modular-file-render…
icereval May 28, 2015
365ff96
none extension
icereval May 28, 2015
7d411f0
tabular
icereval May 29, 2015
aa68a34
updated
icereval May 29, 2015
566377d
pdb heigh
icereval May 29, 2015
770fb28
pdb dynamic canvas height
icereval May 29, 2015
68a0b2f
error handling
icereval May 29, 2015
0bdc94e
No need to install lxml
chrisseto May 29, 2015
ecede3d
Dont send bearer token to redirects
chrisseto May 29, 2015
e6f6972
loldoyouevenfuturebrah
chrisseto May 29, 2015
94d17bf
json schema is required for ipython notebook rendering
chrisseto May 29, 2015
bb0459f
ipython needs jinja2
chrisseto May 29, 2015
7d34b40
lowercase exporter and render plugin name lookup
icereval May 29, 2015
0cec558
jax file renderer
icereval May 29, 2015
187e0b3
give the user a decent global exception message
icereval May 29, 2015
aff2596
global bad request
icereval May 29, 2015
4de648c
jax file renderer
icereval Jun 1, 2015
4be82bf
mfr iframe wrap w/ pymjs
icereval Jun 1, 2015
0a47a7d
standardize static file handler endpoint for global assets
icereval Jun 1, 2015
9f2dc14
Handle the case of no token
chrisseto Jun 1, 2015
dc1f5a7
Merge branch 'feature/mfr' of https://github.com/chrisseto/modular-fi…
chrisseto Jun 1, 2015
1e873d6
mfr iframe extensions for all
icereval Jun 2, 2015
251cba2
Merge branch 'feature/mfr' of https://github.com/chrisseto/modular-fi…
chrisseto Jun 2, 2015
d3ad00a
optimize mfr caching and file downloads
icereval Jun 2, 2015
9428d58
Merge branch 'feature/mfr' of https://github.com/chrisseto/modular-fi…
chrisseto Jun 2, 2015
c9355e9
simplify mfr js includes
icereval Jun 2, 2015
99689c0
spacing
icereval Jun 2, 2015
6cd5c2c
render r markdown files as text
chrisseto Jun 2, 2015
3dc4adf
Merge branch 'feature/mfr' of https://github.com/chrisseto/modular-fi…
chrisseto Jun 2, 2015
863f88c
beginnings of loading indicator
icereval Jun 2, 2015
7e4e559
Merge branch 'feature/mfr' of github.com:chrisseto/modular-file-rende…
icereval Jun 2, 2015
3e87776
Add do, sas, and sps as viewable text files
chrisseto Jun 2, 2015
5682950
Merge branch 'feature/mfr' of https://github.com/chrisseto/modular-fi…
chrisseto Jun 2, 2015
1eabd68
cleanup code pygments
icereval Jun 2, 2015
83dc4ea
Assume everything is utf-16 text as utf-8 is not enough
chrisseto Jun 3, 2015
b4a66a9
Merge branch 'feature/mfr' of https://github.com/chrisseto/modular-fi…
chrisseto Jun 3, 2015
4a26cdc
utf-16 != utf-8
chrisseto Jun 3, 2015
cf43528
send height on window resizes
chrisseto Jun 3, 2015
b3f2078
resize child message
icereval Jun 4, 2015
eb217f3
Merge branch 'feature/mfr' of github.com:chrisseto/modular-file-rende…
icereval Jun 4, 2015
8e393ad
offload cache upload operation via asyncio
icereval Jun 4, 2015
888dcbe
comment typo
icereval Jun 4, 2015
2862b7b
spinner
icereval Jun 4, 2015
672bb93
Only ready from fp once
chrisseto Jun 4, 2015
41957e7
Strip off irrelevant url parameters
chrisseto Jun 4, 2015
8d7daba
Remove jquery cache busting
chrisseto Jun 4, 2015
b8da6ba
dynamic sizing of video embed
icereval Jun 4, 2015
48a33b9
dynamic sizing of video embed
icereval Jun 4, 2015
b6f4ff3
dynamic sizing of video embed
icereval Jun 4, 2015
3f6fe6a
video/audio tests
icereval Jun 5, 2015
41fa8c4
video/audio tests
icereval Jun 5, 2015
552700f
Add tests for handlers
chrisseto Jun 5, 2015
928ef65
embed-responsive-pdf show a single full width page by default
icereval Jun 5, 2015
8038dc5
embed-responsive-pdf show a single full width page by default
icereval Jun 5, 2015
053acb4
embed-responsive-pdf show a single full width page by default
icereval Jun 7, 2015
ec4deae
layout
icereval Jun 7, 2015
507a2c7
pdf tests
icereval Jun 7, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ Thumbs.db
# Python
#######################
*.py[cod]
*.so
*.py[cod]
**/*.pyc

# C extensions
*.so
Expand Down
6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ language: python
sudo: false

python:
- "2.6"
- "2.7"
- "3.3"
- "3.4"
# TODO(asmacdo)
# pypy is unable to install numpy and pandas. The test should either not
# install pandas or it should install from the pypy repo.
# - "pypy"

install:
- travis_retry pip install -r dev-requirements.txt
Expand Down
5 changes: 4 additions & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ Contributors
- Lyndsy Simon `@lyndsysimon <https://github.com/lyndsysimon>`_
- Jeffrey Spies `@JeffSpies <https://github.com/JeffSpies>`_
- Matt Frazier `@mfraezz <https://github.com/mfraezz>`_
- Casey Rollins `@caseyrollins <https://github.com/caseyrollins>`_
- Casey Rollins `@caseyrollins <https://github.com/caseyrollins>`_
- Michael Haselton `@icereval <https://github.com/icereval>`_
- Megan Kelly `@megankelly <https://github.com/megankelly>`_
- Chris Seto `@chrisseto <https://github.com/chrisseto>`_
114 changes: 36 additions & 78 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ Install the development dependencies.

::

$ pip install -r dev-requirements.txt


$ pip install -U -r dev-requirements.txt


Lastly, install mfr in development mode. ::

$ python setup.py develop

$ invoke server

Running tests
-------------
Expand All @@ -59,16 +58,17 @@ You can also use pytest directly. ::
Writing tests
-------------

Unit tests should be written for all rendering, exporting, and detection code.
Unit tests should be written for all rendering code.

Tests can be written as functions, like so:
Tests should be encapsulated within a class and written as functions, like so:

.. code-block:: python

# in test_myformat.py

from mfr_something import render


def test_render_html():
with open('testfile.mp4') as fp:
assert render.render_html(fp) == '<p>rendered testfile.mp4</p>'
Expand All @@ -88,34 +88,6 @@ The above test can be rewritten like so:

.. _pytest fixtures: https://pytest.org/latest/fixture.html

Using the player
----------------

The mfr comes with a Flask app for previewing rendered files. Create a ``files/`` subdirectory in ``player`` and copy the files you want to render into it. Then run the app from the ``player`` directory with ::

$ invoke player

Then browse to ``localhost:5000`` in your browser.

Configuring the player
++++++++++++++++++++++

You will likely want to add additional filehandler modules to the player. The first time you run ``invoke player``, a file is created at ``player/mfr_config_local.py``. You can add additional handlers to the ``HANDLERS`` list and add any additional configuration here.

.. code-block:: python

# in player/mfr_config_local.py

import mfr_image
import mfr_code_pygments

# Add additional handlers here
HANDLERS = [
mfr_image.Handler,
mfr_code_pygments.Handler,
]



Writing A File Format Package
-----------------------------
Expand All @@ -126,15 +98,14 @@ There are two main pieces of a file format package are
- Your :class:`FileHandler <mfr.core.FileHandler>`


Rendering/Exporting Code
Rendering Code
++++++++++++++++++++++++

Renderers are simply callables (functions or methods) that take a file as their first argument and return a :class:`RenderResult <mfr.core.RenderResult>` which contains content(a string of the rendered HTML) and assets (a dictionary that points to lists of javascript or css sources).
Renderers are simply callables (functions or methods) that take a file as their first argument and return

Here is a very simple example of function that takes a filepointer and outputs a render result with an HTML image tag.

.. code-block:: python
from mfr import RenderResult

def render_img_tag(filepointer):
filename = filepointer.name
Expand Down Expand Up @@ -205,51 +176,38 @@ Each package has its own directory. At a minimum, your package should include:

Apart from those files, you are free to organize your rendering and export code however you want.

A typical directory structure might look like this:
A typical extension plugin directory structure might look like this:

::

mfr
└──mfr-something
├── export-requirements.txt
├── render-requirements.txt
├── __init__.py
├── render.py
├── export.py
├── static
│ ├── js
│ └── css
├── tests
│ ├── __init__.py
│ └── test_something.py
├── templates
│ └── something.html
├── libs
│ ├── __init__.py
│ └── something_tools.py
├── setup.py
├── README.rst
└── configuration.py

where "something" is a file format, e.g. "mfr_image", "mfr_movie".

.. note::

You may decide to make subdirectories for rendering and exporting code if single files start to become very large.


Use a template
++++++++++++++

The fastest way to get started on a module is to use `cookiecutter template`_ for mfr modules. This will create the directory structure above.

::

$ pip install cookiecutter
$ cookiecutter https://github.com/CenterForOpenScience/cookiecutter-mfr.git

.. _cookiecutter template: https://github.com/CenterForOpenScience/cookiecutter-mfr

modular-file-renderer
├──mfr
│ ├── __init__.py
│ └──extensions
│ ├── __init__.py
│ └──custom-plugin
│ ├── __init__.py
│ ├── render.py
│ ├── export.py
│ ├── settings.py
│ ├── static
│ │ ├── css
│ │ └── js
│ ├── templates
│ │ └── viewer.mako
│ └── libs
│ ├── __init__.py
│ └── tools.py
├──tests
│ ├── __init__.py
│ └──extnesions
│ ├── __init__.py
│ └──custom-plugin
│ ├── __init__.py
│ └── test_custom_plugin.py
├── setup.py
├── README.md
└── requirements.py


Documentation
Expand Down
7 changes: 0 additions & 7 deletions HISTORY.rst

This file was deleted.

1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

36 changes: 0 additions & 36 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -1,38 +1,2 @@
mfr includes code from 3rd-party libraries, whose licenses are listed below.

Flask License
=============

Copyright (c) 2014 by Armin Ronacher and contributors. See AUTHORS
for more details.

Some rights reserved.

Redistribution and use in source and binary forms of the software as well
as documentation, with or without modification, are permitted provided
that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* The names of the contributors may not be used to endorse or
promote products derived from this software without specific
prior written permission.

THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE AND DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#MFR

**WARNING: mfr is in a very alpha stage of development. As such, it's API is in constant flux. Expect many breaking changes.**

**mfr** (short for "modular file renderer") is a Python package for rendering files to HTML.

### startup commands

```bash
# Make sure that you are using >= python3.3
pip install -U -r requirements.txt
python setup.py develop
invoke server
```

### Create your own module

Interested in adding support for a new provider or file format? Check out the CONTRIBUTING.rst docs.

### License

Copyright 2013-2015 Center for Open Science

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
61 changes: 0 additions & 61 deletions README.rst

This file was deleted.

19 changes: 0 additions & 19 deletions conftest.py

This file was deleted.

Loading