A ResourceView that uses Microsoft's Doc preview
Project description
ckanext-officedocs
This plugin provides the option of using the Microsoft Office Web Viewer for previewing both MS Office and OpenOffice documents as an IResourceView
Supported formats
By default, this plugin will attempt to preview the following formats:
"DOC", "DOCX", "XLS", "XLSX", "XLSB", "PPT", "PPTX", "PPS", "PPSX", "ODT", "ODS", "ODP"
The supported formats can be configured in your CKAN configuration file:
ckanext.officedocs.supported_formats = DOC DOCX XLS XLSX XLSB PPT PPTX PPS PPSX ODT ODS ODP
Formats are separated by spaces and matched case-insensitively. For example, to add macro-enabled Microsoft Office formats:
ckanext.officedocs.supported_formats = DOC DOCX DOCM XLS XLSX XLSM XLSB PPT PPTX PPTM PPS PPSX PPSM ODT ODS ODP
Private package fallback
Microsoft's online viewer can only render resources that are publicly reachable, so by default the previewer is not offered for resources in private datasets.
You can opt in to a client-side fallback for private resources:
ckanext.officedocs.enable_private_fallback = true
When enabled, private Office resources show a fallback panel instead of the online viewer:
- On a Chromium-based browser (Chrome, Edge, Brave, Opera), the panel offers an "Open document" link and suggests installing an Office viewer extension (Office or Office Editing for Docs, Sheets & Slides). With such an extension installed, opening the document renders it in the browser using the viewer's own session, which can reach the private resource.
- On other browsers (Firefox, Safari), the panel explains that previewing private files requires a Chromium-based browser with one of those extensions.
Note: browser extensions cannot be detected from a web page, so the fallback always shows the tip/link rather than auto-detecting whether an extension is present.
Viewer height
The height of the Office viewer iframe (used for public resources) is configurable:
ckanext.officedocs.iframe_height = 400px
Any valid CSS length is accepted (e.g. 600px, 75vh). Defaults to 400px.
Configuration reference
All options are declared via CKAN's config declaration, so you can inspect
them with ckan config declaration officedocs and validate your config with
ckan config validate.
| Option | Default | Description |
|---|---|---|
ckanext.officedocs.supported_formats |
DOC DOCX XLS XLSX XLSB PPT PPTX PPS PPSX ODT ODS ODP |
Space-separated formats to preview (case-insensitive). |
ckanext.officedocs.enable_private_fallback |
false |
Enable the Chromium fallback preview for private resources. |
ckanext.officedocs.iframe_height |
400px |
CSS height of the public-resource viewer iframe. |
Installation
To install ckanext-officedocs:
-
Clone this repository into the place where you normally install extensions, by default this will be /usr/lib/ckan/default/src/
-
Activate your CKAN virtual environment, for example:
. /usr/lib/ckan/default/bin/activate -
Install the ckanext-officedocs Python package into your virtual environment:
cd ckanext-officedocs python setup.py install -
Add
officedocs_viewto theckan.pluginssetting in your CKAN config file (by default the config file is located at/etc/ckan/default/production.ini). -
If you wish for views to be created automatically for you, then you should add
officedocs_viewto the end of theckan.views.default_viewsoption in your config file.ckan.views.default_views = ... officedocs_view
-
Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:
sudo service apache2 reloador if you're using
supervisor:sudo supervisorctl restart ckan-uwsgi:\*
FAQ
Q: It doesn't work, my documents aren't previewing
A: For the Microsoft online viewer to work, the documents to be previewed must be accessible to the wider internet (i.e. the Dataset Package is PUBLIC, not PRIVATE), and will only work if you use a hostname, and not just an IP address. To preview private resources, see the Private package fallback section above.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ckanext_officedocs-2.0.0.tar.gz.
File metadata
- Download URL: ckanext_officedocs-2.0.0.tar.gz
- Upload date:
- Size: 21.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5932e13c5a9a2f6b600cbe52005ecad6ba952daf74e8323379354bf92b7c41e1
|
|
| MD5 |
609db394ba13dd60b38e2b5c4e472831
|
|
| BLAKE2b-256 |
8c07d26b42a78145a63375cea7c7dbfa2e31b3f3734b5cb99e3f86c03c54fead
|
Provenance
The following attestation bundles were made for ckanext_officedocs-2.0.0.tar.gz:
Publisher:
publish.yml on jqnatividad/ckanext-officedocs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ckanext_officedocs-2.0.0.tar.gz -
Subject digest:
5932e13c5a9a2f6b600cbe52005ecad6ba952daf74e8323379354bf92b7c41e1 - Sigstore transparency entry: 1803364644
- Sigstore integration time:
-
Permalink:
jqnatividad/ckanext-officedocs@b936b89b6f2c81c347f4a6cd7e6fa0762db53b33 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/jqnatividad
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b936b89b6f2c81c347f4a6cd7e6fa0762db53b33 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ckanext_officedocs-2.0.0-py3-none-any.whl.
File metadata
- Download URL: ckanext_officedocs-2.0.0-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a45d9eb0c942a21dea5211ab18dc23345a34898086c0944201ee1ed4d1a4adb4
|
|
| MD5 |
c4f394906b1d41ac0669b2911a3e878f
|
|
| BLAKE2b-256 |
8379531dc282238de40de8b49ba60f823a6fff54fbc5872b5fd6cdcc07388e05
|
Provenance
The following attestation bundles were made for ckanext_officedocs-2.0.0-py3-none-any.whl:
Publisher:
publish.yml on jqnatividad/ckanext-officedocs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ckanext_officedocs-2.0.0-py3-none-any.whl -
Subject digest:
a45d9eb0c942a21dea5211ab18dc23345a34898086c0944201ee1ed4d1a4adb4 - Sigstore transparency entry: 1803364662
- Sigstore integration time:
-
Permalink:
jqnatividad/ckanext-officedocs@b936b89b6f2c81c347f4a6cd7e6fa0762db53b33 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/jqnatividad
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b936b89b6f2c81c347f4a6cd7e6fa0762db53b33 -
Trigger Event:
push
-
Statement type: