API Docs

Invenio module for previewing files.

class invenio_previewer.ext.InvenioPreviewer(app, **kwargs)[source]

Invenio-Previewer extension.

Extension initialization.

init_app(app, entry_point_group='invenio_previewer.previewers')[source]

Flask application initialization.

init_config(app)[source]

Initialize configuration.

invenio_previewer.ext.load_or_import_from_config(key, app=None, default=None)[source]

Load or import value from config.

invenio_previewer.ext.obj_or_import_string(value, default=None)[source]

Import string or return object.

Views

View method for Invenio-Records-UI for previewing files.

invenio_previewer.views.blueprint = <flask.blueprints.Blueprint object>

Blueprint used to register template and static folders.

invenio_previewer.views.is_previewable(extension)[source]

Test if a file can be previewed checking its extension.

invenio_previewer.views.preview(pid, record, template=None, **kwargs)[source]

Preview file for given record.

Plug this method into your RECORDS_UI_ENDPOINTS configuration:

RECORDS_UI_ENDPOINTS = dict(
    recid=dict(
        # ...
        route='/records/<pid_value/preview/<path:filename>',
        view_imp='invenio_previewer.views.preview',
        record_class='invenio_records_files.api:Record',
    )
)

Previewers

CSV (d3.js)

Render a CSV file using d3.js.

invenio_previewer.extensions.csv_dthreejs.can_preview(file)[source]

Determine if the given file can be previewed.

invenio_previewer.extensions.csv_dthreejs.preview(file)[source]

Render appropiate template with embed flag.

invenio_previewer.extensions.csv_dthreejs.validate_csv(file)[source]

Return dialect information about given csv file.

Default

Default rendering returning a default web page.

invenio_previewer.extensions.default.can_preview(file)[source]

Return if file type can be previewed.

invenio_previewer.extensions.default.preview(file)[source]

Return appropriate template and passes the file and an embed flag.

JSON (prism.js)

Previews a JSON file.

invenio_previewer.extensions.json_prismjs.can_preview(file)[source]

Determine if the given file can be previewed.

invenio_previewer.extensions.json_prismjs.preview(file)[source]

Render appropiate template with embed flag.

invenio_previewer.extensions.json_prismjs.render(file)[source]

Pretty print the JSON file for rendering.

invenio_previewer.extensions.json_prismjs.validate_json(file)[source]

Validate a JSON file.

Markdown

Markdown rendering using mistune library.

invenio_previewer.extensions.mistune.can_preview(file)[source]

Determine if file can be previewed.

invenio_previewer.extensions.mistune.preview(file)[source]

Render Markdown.

invenio_previewer.extensions.mistune.render(file)[source]

Render HTML from Markdown file content.

PDF (pdf.js)

PDF previewer based on pdf.js.

invenio_previewer.extensions.pdfjs.can_preview(file)[source]

Check if file can be previewed.

invenio_previewer.extensions.pdfjs.preview(file)[source]

Preview file.

Simple Images

Previews simple image files.

invenio_previewer.extensions.simple_image.can_preview(file)[source]

Determine if the given file can be previewed.

invenio_previewer.extensions.simple_image.preview(file)[source]

Render appropiate template with embed flag.

invenio_previewer.extensions.simple_image.validate(file)[source]

Validate a simple image file.

XML (prism.js)

Previews an XML file.

invenio_previewer.extensions.xml_prismjs.can_preview(file)[source]

Determine if the given file can be previewed.

invenio_previewer.extensions.xml_prismjs.preview(file)[source]

Render appropiate template with embed flag.

invenio_previewer.extensions.xml_prismjs.render(file)[source]

Pretty print the XML file for rendering.

invenio_previewer.extensions.xml_prismjs.validate_xml(file)[source]

Validate an XML file.

ZIP

Simple ZIP archive previewer.

invenio_previewer.extensions.zip.can_preview(file)[source]

Return True if filetype can be previewed.

invenio_previewer.extensions.zip.children_to_list(node)[source]

Organize children structure.

invenio_previewer.extensions.zip.make_tree(file)[source]

Create tree structure from ZIP archive.

invenio_previewer.extensions.zip.preview(file)[source]

Return appropriate template and pass the file and an embed flag.

Bundles

Previewer bundles.

invenio_previewer.bundles.csv_previewer_js = <Bundle output=gen/csv_previewer.%(version)s.js, filters=(), contents=(<NpmBundle output=None, filters=(), contents=()>, <Bundle output=None, filters=[<invenio_assets.filters.RequireJSFilter object>], contents=(u'js/csv_previewer/init.js',)>)>

JavaScript bundle for D3.js CSV previewer.

invenio_previewer.bundles.fullscreen_js = <Bundle output=gen/fullscreen.%(version)s.js, filters=[<webassets.filter.uglifyjs.UglifyJS object>], contents=(u'js/zip/fullscreen.js',)>

JavaScript bundle for ZIP file previewer.

invenio_previewer.bundles.pdfjs_css = <Bundle output=gen/pdfjs.%(version)s.css, filters=(), contents=(u'css/pdfjs/viewer.css',)>

CSS bundle for PDFjs previewer.

invenio_previewer.bundles.pdfjs_js = <Bundle output=gen/pdfjs.%(version)s.js, filters=(), contents=(<NpmBundle output=None, filters=(), contents=()>, u'node_modules/pdfjs-dist/web/compatibility.js', u'node_modules/pdfjs-dist/build/pdf.js', u'js/pdfjs/l10n.js', u'js/pdfjs/viewer.js')>

JavaScript bundle for PDFjs previewer.

invenio_previewer.bundles.previewer_base_css = <Bundle output=gen/previewer-base.%(version)s.css, filters=(), contents=(u'node_modules/bootstrap/dist/css/bootstrap.css', <NpmBundle output=None, filters=(), contents=()>)>

CSS bundle for ZIP file previewer.

invenio_previewer.bundles.previewer_base_js = <Bundle output=gen/previewer-base.%(version)s.js, filters=(), contents=(<NpmBundle output=None, filters=(), contents=()>, u'node_modules/bootstrap/dist/js/bootstrap.js')>

JavaScript bundle for basic tools.

invenio_previewer.bundles.prism_css = <Bundle output=gen/prism.%(version)s.css, filters=(), contents=(<NpmBundle output=None, filters=(), contents=()>, u'node_modules/prismjs/themes/prism.css', u'css/prismjs/simple.css')>

CSS bundle for prism.js syntax highlighter.

invenio_previewer.bundles.prism_js = <Bundle output=gen/prism.%(version)s.js, filters=[<webassets.filter.uglifyjs.UglifyJS object>], contents=(<NpmBundle output=None, filters=(), contents=()>, u'node_modules/prismjs/prism.js', u'node_modules/prismjs/components/prism-json.js')>

JavaScript bundle for prism.js syntax highlighter.