From 205cccd27d0425eb03474a97b968d0a65e30e220 Mon Sep 17 00:00:00 2001 From: Ross Jones Date: Fri, 29 Jun 2018 15:59:51 +0100 Subject: [PATCH 01/25] Clarify how to get office doc default views. --- README.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 2f86e07..99e3de0 100644 --- a/README.rst +++ b/README.rst @@ -31,11 +31,17 @@ To install ckanext-officedocs: cd ckanext-officedocs python setup.py install -3. Add ``officedocs_view`` to the ``ckan.plugins`` setting in your CKAN +4. Add ``officedocs_view`` to the ``ckan.plugins`` setting in your CKAN config file (by default the config file is located at ``/etc/ckan/default/production.ini``). + +5. If you wish for views to be created automatically for you, then you should + add ``officedocs_view`` to the end of the ``ckan.views.default_views`` option in your + config file. -4. Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:: + ckan.views.default_views = ... officedocs_view + +6. Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:: sudo service apache2 reload From 3e54e1ac77a6323cded278cd6be1c028113c07fb Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Fri, 10 May 2019 20:01:08 -0400 Subject: [PATCH 02/25] Added link to MS Online Doc Viewer site --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 99e3de0..52eb692 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ ckanext-officedocs ============= -This plugin provides the option of using the Microsoft Office viewer for +This plugin provides the option of using the [Microsoft Online Doc Viewer](https://products.office.com/en/office-online/view-office-documents-online) for previewing both MS Office and OpenOffice documents as an IResourceView ------------ From 8c12453dacb7edcf0856ecff45e0d4ca4d5ac2e9 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Fri, 10 May 2019 20:08:21 -0400 Subject: [PATCH 03/25] Ooops... use RestructuredText markup, not Markdown --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 52eb692..255d8c5 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ ckanext-officedocs ============= -This plugin provides the option of using the [Microsoft Online Doc Viewer](https://products.office.com/en/office-online/view-office-documents-online) for +This plugin provides the option of using the `Microsoft Online Doc Viewer `_ for previewing both MS Office and OpenOffice documents as an IResourceView ------------ From 0093b1d069654d381e8f7c613e76154f0eff3b9d Mon Sep 17 00:00:00 2001 From: calexandr Date: Wed, 8 Jan 2020 14:12:24 +0200 Subject: [PATCH 04/25] add future module to requirements --- dev-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev-requirements.txt b/dev-requirements.txt index e69de29..7edade7 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -0,0 +1 @@ +future>=0.18.2 \ No newline at end of file From 4c8c5d0cdf0f24ed82cb161b943c0cf241e5ec10 Mon Sep 17 00:00:00 2001 From: calexandr Date: Wed, 8 Jan 2020 14:13:15 +0200 Subject: [PATCH 05/25] use urllib.quote_plus from future standart_library --- ckanext/officedocs/plugin.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/ckanext/officedocs/plugin.py b/ckanext/officedocs/plugin.py index e29dfab..a10cada 100644 --- a/ckanext/officedocs/plugin.py +++ b/ckanext/officedocs/plugin.py @@ -1,10 +1,18 @@ -import ckan.plugins as plugins +from __future__ import absolute_import +from future import standard_library + +standard_library.install_aliases() + +import ckan.lib.helpers as h +import ckan.plugins as p import ckan.plugins.toolkit as toolkit +from urllib import quote_plus + -class OfficeDocsPlugin(plugins.SingletonPlugin): - plugins.implements(plugins.IConfigurer) - plugins.implements(plugins.IResourceView) +class OfficeDocsPlugin(p.SingletonPlugin): + p.implements(p.IConfigurer) + p.implements(p.IResourceView) def update_config(self, config_): toolkit.add_template_directory(config_, 'templates') @@ -22,7 +30,6 @@ def info(self): } def setup_template_variables(self, context, data_dict): - from urllib import quote_plus url = quote_plus(data_dict["resource"]["url"]) return { "resource_url": url @@ -30,10 +37,13 @@ def setup_template_variables(self, context, data_dict): def can_view(self, data_dict): supported_formats = [ - "DOC", "DOCX", "XLS", "XLSX", "PPT", "PPTX", "PPS", "ODT", "ODS", "ODP" + "DOC", "DOCX", "XLS", + "XLSX", "PPT", "PPTX", + "PPS", "ODT", "ODS", "ODP" ] try: - return data_dict['resource'].get('format', '').upper() in supported_formats + res = data_dict['resource'].get('format', '').upper() + return res in supported_formats except: return False From 2fe43e9fa78b157b9ebf41f9c0e05bf5a227df0d Mon Sep 17 00:00:00 2001 From: calexandr Date: Wed, 8 Jan 2020 14:14:54 +0200 Subject: [PATCH 06/25] use one type of quotes --- ckanext/officedocs/plugin.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ckanext/officedocs/plugin.py b/ckanext/officedocs/plugin.py index a10cada..2ff514f 100644 --- a/ckanext/officedocs/plugin.py +++ b/ckanext/officedocs/plugin.py @@ -15,15 +15,15 @@ class OfficeDocsPlugin(p.SingletonPlugin): p.implements(p.IResourceView) def update_config(self, config_): - toolkit.add_template_directory(config_, 'templates') - toolkit.add_public_directory(config_, 'public') - toolkit.add_resource('fanstatic', 'officedocs') + toolkit.add_template_directory(config_, "templates") + toolkit.add_public_directory(config_, "public") + toolkit.add_resource("fanstatic", "officedocs") def info(self): return { "name": "officedocs_view", - "title": toolkit._('Office Previewer'), - "default_title": toolkit._('Preview'), + "title": toolkit._("Office Previewer"), + "default_title": toolkit._("Preview"), "icon": "compass", "always_available": True, "iframed": False, @@ -42,7 +42,7 @@ def can_view(self, data_dict): "PPS", "ODT", "ODS", "ODP" ] try: - res = data_dict['resource'].get('format', '').upper() + res = data_dict["resource"].get("format", "").upper() return res in supported_formats except: return False From 4215a155a6f0be6273a47b1208960a34d801cec6 Mon Sep 17 00:00:00 2001 From: calexandr Date: Mon, 13 Jan 2020 16:39:48 +0200 Subject: [PATCH 07/25] fix quote_plus import --- ckanext/officedocs/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/officedocs/plugin.py b/ckanext/officedocs/plugin.py index 2ff514f..b3dd59f 100644 --- a/ckanext/officedocs/plugin.py +++ b/ckanext/officedocs/plugin.py @@ -7,7 +7,7 @@ import ckan.plugins as p import ckan.plugins.toolkit as toolkit -from urllib import quote_plus +from six.moves.urllib.parse import quote_plus class OfficeDocsPlugin(p.SingletonPlugin): From 5f55e0b85144a32f2c1e45be58d62ac1c9356364 Mon Sep 17 00:00:00 2001 From: calexandr Date: Tue, 14 Jan 2020 13:46:27 +0200 Subject: [PATCH 08/25] add six to requirements --- ckanext/officedocs/plugin.py | 15 ++++++--------- dev-requirements.txt | 3 ++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ckanext/officedocs/plugin.py b/ckanext/officedocs/plugin.py index b3dd59f..772962a 100644 --- a/ckanext/officedocs/plugin.py +++ b/ckanext/officedocs/plugin.py @@ -1,11 +1,8 @@ from __future__ import absolute_import -from future import standard_library - -standard_library.install_aliases() import ckan.lib.helpers as h import ckan.plugins as p -import ckan.plugins.toolkit as toolkit +import ckan.plugins.toolkit as tk from six.moves.urllib.parse import quote_plus @@ -15,15 +12,15 @@ class OfficeDocsPlugin(p.SingletonPlugin): p.implements(p.IResourceView) def update_config(self, config_): - toolkit.add_template_directory(config_, "templates") - toolkit.add_public_directory(config_, "public") - toolkit.add_resource("fanstatic", "officedocs") + tk.add_template_directory(config_, "templates") + tk.add_public_directory(config_, "public") + tk.add_resource("fanstatic", "officedocs") def info(self): return { "name": "officedocs_view", - "title": toolkit._("Office Previewer"), - "default_title": toolkit._("Preview"), + "title": tk._("Office Previewer"), + "default_title": tk._("Preview"), "icon": "compass", "always_available": True, "iframed": False, diff --git a/dev-requirements.txt b/dev-requirements.txt index 7edade7..402f060 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1 +1,2 @@ -future>=0.18.2 \ No newline at end of file +future>=0.18.2 +six==1.11.0 \ No newline at end of file From da5fbd798f72c17cfd6fcb6cfdd9c28711e791be Mon Sep 17 00:00:00 2001 From: calexandr Date: Tue, 14 Jan 2020 13:51:11 +0200 Subject: [PATCH 09/25] delete unused future from requirements --- dev-requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 402f060..7f1bd5a 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,2 +1 @@ -future>=0.18.2 six==1.11.0 \ No newline at end of file From fac01df0d5d0e51d4e1125cff4461cf768a4ccd4 Mon Sep 17 00:00:00 2001 From: calexandr Date: Wed, 15 Jan 2020 15:13:04 +0200 Subject: [PATCH 10/25] delete future absolute_import, correct version of six --- ckanext/officedocs/plugin.py | 2 -- dev-requirements.txt | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/ckanext/officedocs/plugin.py b/ckanext/officedocs/plugin.py index 772962a..e093333 100644 --- a/ckanext/officedocs/plugin.py +++ b/ckanext/officedocs/plugin.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - import ckan.lib.helpers as h import ckan.plugins as p import ckan.plugins.toolkit as tk diff --git a/dev-requirements.txt b/dev-requirements.txt index 7f1bd5a..7ad83fc 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1 +1 @@ -six==1.11.0 \ No newline at end of file +six>=1.10.0 #pytest has requirement six>=1.10.0 \ No newline at end of file From 958ce86783480ff1546cb331939b6cc059ae6720 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Fri, 3 Dec 2021 09:54:25 -0500 Subject: [PATCH 11/25] Update .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e9876d1..a93e87d 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,5 @@ nosetests.xml coverage.xml # Sphinx documentation -docs/_build/ \ No newline at end of file +docs/_build/ +.vscode/ From 21280df1810857dbff2686f8614910de950e51c3 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Fri, 3 Dec 2021 09:56:34 -0500 Subject: [PATCH 12/25] Update README.rst * point to blog post about Microsoft Office Web Viewer. * show alternative way of restarting CKAN if using supervisor --- README.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 255d8c5..6d3216c 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ ckanext-officedocs ============= -This plugin provides the option of using the `Microsoft Online Doc Viewer `_ for +This plugin provides the option of using the `Microsoft Office Web Viewer `_ for previewing both MS Office and OpenOffice documents as an IResourceView ------------ @@ -45,6 +45,10 @@ To install ckanext-officedocs: sudo service apache2 reload +or if you're using `supervisor`: + + sudo supervisorctl restart ckan-uwsgi:* + ------------ FAQ From 4cba751f99773e902fad15445e94e2d64d307ab0 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Fri, 3 Dec 2021 10:05:44 -0500 Subject: [PATCH 13/25] quickly convert README to markdown --- README.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ README.rst | 59 ------------------------------------------------------ 2 files changed, 57 insertions(+), 59 deletions(-) create mode 100644 README.md delete mode 100644 README.rst diff --git a/README.md b/README.md new file mode 100644 index 0000000..576078d --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# ckanext-officedocs + +This plugin provides the option of using the [Microsoft Office Web +Viewer](https://www.microsoft.com/en-us/microsoft-365/blog/2013/04/10/office-web-viewer-view-office-documents-in-a-browser/) +for previewing both MS Office and OpenOffice documents as an +IResourceView + +## Supported formats + +This plugin will attempt to preview the following formats + +> \"DOC\", \"DOCX\", \"XLS\", \"XLSX\", \"PPT\", \"PPTX\", \"PPS\", +> \"ODT\", \"ODS\", \"ODP\" + +## Installation + +To install ckanext-officedocs: + +1. Clone this repository into the place where you normally install + extensions, by default this will be /usr/lib/ckan/default/src/ + +2. Activate your CKAN virtual environment, for example: + + . /usr/lib/ckan/default/bin/activate + +3. Install the ckanext-officedocs Python package into your virtual + environment: + + cd ckanext-officedocs + python setup.py install + +4. Add `officedocs_view` to the `ckan.plugins` setting in your CKAN + config file (by default the config file is located at + `/etc/ckan/default/production.ini`). + +5. If you wish for views to be created automatically for you, then you + should add `officedocs_view` to the end of the + `ckan.views.default_views` option in your config file. + + > ckan.views.default\_views = \... officedocs\_view + +6. Restart CKAN. For example if you\'ve deployed CKAN with Apache on + Ubuntu: + + sudo service apache2 reload + + or if you\'re using `supervisor`: + + sudo supervisorctl restart ckan-uwsgi:\* + +## FAQ + +Q: It doesn\'t work, my documents aren\'t previewing + +A: For this extension to work, the documents to be previewed must be +accessible to the wider internet, and will only work if you use a +hostname, and not just an IP address. diff --git a/README.rst b/README.rst deleted file mode 100644 index 6d3216c..0000000 --- a/README.rst +++ /dev/null @@ -1,59 +0,0 @@ -============= -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 ------------- - -This plugin will attempt to preview the following formats - - "DOC", "DOCX", "XLS", "XLSX", "PPT", "PPTX", "PPS", "ODT", "ODS", "ODP" - ------------- -Installation ------------- - -To install ckanext-officedocs: - -1. Clone this repository into the place where you normally install extensions, - by default this will be /usr/lib/ckan/default/src/ - -2. Activate your CKAN virtual environment, for example:: - - . /usr/lib/ckan/default/bin/activate - -3. Install the ckanext-officedocs Python package into your virtual environment:: - - cd ckanext-officedocs - python setup.py install - -4. Add ``officedocs_view`` to the ``ckan.plugins`` setting in your CKAN - config file (by default the config file is located at - ``/etc/ckan/default/production.ini``). - -5. If you wish for views to be created automatically for you, then you should - add ``officedocs_view`` to the end of the ``ckan.views.default_views`` option in your - config file. - - ckan.views.default_views = ... officedocs_view - -6. Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:: - - sudo service apache2 reload - -or if you're using `supervisor`: - - sudo supervisorctl restart ckan-uwsgi:* - - ------------- -FAQ ------------- -Q: It doesn't work, my documents aren't previewing - -A: For this extension to work, the documents to be previewed must be accessible to the -wider internet, and will only work if you use a hostname, and not just an IP address. From 337c5c9aea015f7e7bf3de748940e490ec116042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Lemayian=20=E2=9C=A8?= <877919+DavidLemayian@users.noreply.github.com> Date: Sat, 11 Dec 2021 20:09:14 +0300 Subject: [PATCH 14/25] fix: on install it tries to open the old rst file --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0a3c81e..a89ee3d 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ here = path.abspath(path.dirname(__file__)) # Get the long description from the relevant file -with open(path.join(here, 'README.rst'), encoding='utf-8') as f: +with open(path.join(here, 'README.md'), encoding='utf-8') as f: long_description = f.read() setup( From 9a45996a02cdcab288837dca39c0d5e3e775d8aa Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Mon, 13 Dec 2021 10:29:08 -0500 Subject: [PATCH 15/25] Add CSV, XLSB and PPSX to supported file formats --- ckanext/officedocs/plugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ckanext/officedocs/plugin.py b/ckanext/officedocs/plugin.py index e093333..f1e5ec5 100644 --- a/ckanext/officedocs/plugin.py +++ b/ckanext/officedocs/plugin.py @@ -32,9 +32,9 @@ def setup_template_variables(self, context, data_dict): def can_view(self, data_dict): supported_formats = [ - "DOC", "DOCX", "XLS", - "XLSX", "PPT", "PPTX", - "PPS", "ODT", "ODS", "ODP" + "DOC", "DOCX", "XLS", "CSV", + "XLSX", "XLSB", "PPT", "PPTX", + "PPS", "PPSX", "ODT", "ODS", "ODP" ] try: res = data_dict["resource"].get("format", "").upper() From 6dea847807eb7da88fabb19193ca1ef7e364967c Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Mon, 13 Dec 2021 10:35:13 -0500 Subject: [PATCH 16/25] Update author, dev status & supported python versions --- setup.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index a89ee3d..a550515 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # http://packaging.python.org/en/latest/tutorial.html#version - version='0.0.1', + version='1.0.1', description='''A ResourceView that uses Microsoft's Doc preview''', long_description=long_description, @@ -23,8 +23,8 @@ url='https://github.com/rossjones/ckanext-officedocs', # Author details - author='''Ross Jones''', - author_email='''ross@servercode.co.uk''', + author='''Ross Jones, Joel Natividad''', + author_email='''ross@servercode.co.uk, joel@dathere.com''', # Choose your license license='AGPL', @@ -35,15 +35,15 @@ # 3 - Alpha # 4 - Beta # 5 - Production/Stable - 'Development Status :: 4 - Beta', + 'Production/Stable :: 5', # Pick your license as you wish (should match "license" above) 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)', # Specify the Python versions you support here. In particular, ensure # that you indicate whether you support Python 2, Python 3 or both. - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.8', ], From cc7cd9accce7aa53f1bff9416c341a01f615dd35 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Sat, 18 Dec 2021 07:18:30 -0500 Subject: [PATCH 17/25] Remove CSV from supported formats it doesn't work reliably --- ckanext/officedocs/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/officedocs/plugin.py b/ckanext/officedocs/plugin.py index f1e5ec5..6333373 100644 --- a/ckanext/officedocs/plugin.py +++ b/ckanext/officedocs/plugin.py @@ -32,7 +32,7 @@ def setup_template_variables(self, context, data_dict): def can_view(self, data_dict): supported_formats = [ - "DOC", "DOCX", "XLS", "CSV", + "DOC", "DOCX", "XLS", "XLSX", "XLSB", "PPT", "PPTX", "PPS", "PPSX", "ODT", "ODS", "ODP" ] From 030199ac87684946df145bed4e0db0c5e2f1713d Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Sat, 18 Dec 2021 08:05:18 -0500 Subject: [PATCH 18/25] Private can_view check also change icon from compass to microsoft and set always_available to False --- ckanext/officedocs/plugin.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ckanext/officedocs/plugin.py b/ckanext/officedocs/plugin.py index 6333373..91d5392 100644 --- a/ckanext/officedocs/plugin.py +++ b/ckanext/officedocs/plugin.py @@ -19,8 +19,8 @@ def info(self): "name": "officedocs_view", "title": tk._("Office Previewer"), "default_title": tk._("Preview"), - "icon": "compass", - "always_available": True, + "icon": "microsoft", + "always_available": False, "iframed": False, } @@ -37,8 +37,12 @@ def can_view(self, data_dict): "PPS", "PPSX", "ODT", "ODS", "ODP" ] try: - res = data_dict["resource"].get("format", "").upper() - return res in supported_formats + pkg_private = data_dict["package"].get("private", False) + if not pkg_private: + res = data_dict["resource"].get("format", "").upper() + return res in supported_formats + else: + return False except: return False From 378eaed6458f97bb78999a037fdcd7f73f9906fd Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Sat, 18 Dec 2021 08:28:39 -0500 Subject: [PATCH 19/25] remove obsolete files --- .coveragerc | 5 ----- .travis.yml | 11 ---------- bin/travis-build.bash | 36 ------------------------------- bin/travis-run.sh | 6 ------ test.ini | 49 ------------------------------------------- 5 files changed, 107 deletions(-) delete mode 100644 .coveragerc delete mode 100644 .travis.yml delete mode 100644 bin/travis-build.bash delete mode 100644 bin/travis-run.sh delete mode 100644 test.ini diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 3138593..0000000 --- a/.coveragerc +++ /dev/null @@ -1,5 +0,0 @@ -[report] -omit = - */site-packages/* - */python?.?/* - ckan/* \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6e52d42..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: python -python: - - "2.6" - - "2.7" -env: PGVERSION=9.1 -install: - - bash bin/travis-build.bash - - pip install coveralls -script: sh bin/travis-run.sh -after_success: - - coveralls diff --git a/bin/travis-build.bash b/bin/travis-build.bash deleted file mode 100644 index d60b792..0000000 --- a/bin/travis-build.bash +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -set -e - -echo "This is travis-build.bash..." - -echo "Installing the packages that CKAN requires..." -sudo apt-get update -qq -sudo apt-get install postgresql-$PGVERSION solr-jetty libcommons-fileupload-java:amd64=1.2.2-1 - -echo "Installing CKAN and its Python dependencies..." -git clone https://github.com/ckan/ckan -cd ckan -git checkout release-v2.2 -python setup.py develop -pip install -r requirements.txt --allow-all-external -pip install -r dev-requirements.txt --allow-all-external -cd - - -echo "Creating the PostgreSQL user and database..." -sudo -u postgres psql -c "CREATE USER ckan_default WITH PASSWORD 'pass';" -sudo -u postgres psql -c 'CREATE DATABASE ckan_test WITH OWNER ckan_default;' - -echo "Initialising the database..." -cd ckan -paster db init -c test-core.ini -cd - - -echo "Installing ckanext-ckanext-gdoc and its requirements..." -python setup.py develop -pip install -r dev-requirements.txt - -echo "Moving test.ini into a subdir..." -mkdir subdir -mv test.ini subdir - -echo "travis-build.bash is done." \ No newline at end of file diff --git a/bin/travis-run.sh b/bin/travis-run.sh deleted file mode 100644 index 73b501f..0000000 --- a/bin/travis-run.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -e - -echo "NO_START=0\nJETTY_HOST=127.0.0.1\nJETTY_PORT=8983\nJAVA_HOME=$JAVA_HOME" | sudo tee /etc/default/jetty -sudo cp ckan/ckan/config/solr/schema.xml /etc/solr/conf/schema.xml -sudo service jetty restart -nosetests --nologcapture --with-pylons=subdir/test.ini --with-coverage --cover-package=ckanext.gdoc --cover-inclusive --cover-erase --cover-tests \ No newline at end of file diff --git a/test.ini b/test.ini deleted file mode 100644 index c7c70e7..0000000 --- a/test.ini +++ /dev/null @@ -1,49 +0,0 @@ -[DEFAULT] -debug = false -smtp_server = localhost -error_email_from = paste@localhost - -[server:main] -use = egg:Paste#http -host = 0.0.0.0 -port = 5000 - -[app:main] -use = config:../ckan/test-core.ini - -# Insert any custom config settings to be used when running your extension's -# tests here. - - -# Logging configuration -[loggers] -keys = root, ckan, sqlalchemy - -[handlers] -keys = console - -[formatters] -keys = generic - -[logger_root] -level = WARN -handlers = console - -[logger_ckan] -qualname = ckan -handlers = -level = INFO - -[logger_sqlalchemy] -handlers = -qualname = sqlalchemy.engine -level = WARN - -[handler_console] -class = StreamHandler -args = (sys.stdout,) -level = NOTSET -formatter = generic - -[formatter_generic] -format = %(asctime)s %(levelname)-5.5s [%(name)s] %(message)s \ No newline at end of file From fe531fbe9fe6df073fcf9162797b2a3edda4121b Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Sat, 18 Dec 2021 08:29:04 -0500 Subject: [PATCH 20/25] we're now using MD instead of RST --- MANIFEST.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 78362c3..f23f24b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,2 @@ -include README.rst -recursive-include ckanext/officedocs *.html *.json *.js *.less *.css \ No newline at end of file +include README.md +recursive-include ckanext/officedocs *.html *.json *.js *.less *.css From 6aee4f607d37aaa2d3dbff382a851e563929192f Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Sat, 18 Dec 2021 08:30:10 -0500 Subject: [PATCH 21/25] Use windows icon instead of microsoft we're still on Font Awesome 4 --- ckanext/officedocs/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/officedocs/plugin.py b/ckanext/officedocs/plugin.py index 91d5392..060777e 100644 --- a/ckanext/officedocs/plugin.py +++ b/ckanext/officedocs/plugin.py @@ -19,7 +19,7 @@ def info(self): "name": "officedocs_view", "title": tk._("Office Previewer"), "default_title": tk._("Preview"), - "icon": "microsoft", + "icon": "windows", "always_available": False, "iframed": False, } From fe451b4cd1c23d78ff1d0dbd892600ae98a903bc Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Sat, 18 Dec 2021 08:31:18 -0500 Subject: [PATCH 22/25] bump minor version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a550515..47f23ef 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # http://packaging.python.org/en/latest/tutorial.html#version - version='1.0.1', + version='1.1.0', description='''A ResourceView that uses Microsoft's Doc preview''', long_description=long_description, From 664f87a69509662b51f98aff53daaa232b8751d4 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Sat, 18 Dec 2021 08:41:25 -0500 Subject: [PATCH 23/25] XLSB and PPSX also supported; PUBLIC/PRIVATE note --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 576078d..e981e4e 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ IResourceView This plugin will attempt to preview the following formats -> \"DOC\", \"DOCX\", \"XLS\", \"XLSX\", \"PPT\", \"PPTX\", \"PPS\", -> \"ODT\", \"ODS\", \"ODP\" +> \"DOC\", \"DOCX\", \"XLS\", \"XLSX\", \"XLSB\", \"PPT\", \"PPTX\", \"PPS\", +> \"PPSX\", \"ODT\", \"ODS\", \"ODP\" ## Installation @@ -53,5 +53,5 @@ To install ckanext-officedocs: Q: It doesn\'t work, my documents aren\'t previewing A: For this extension to work, the documents to be previewed must be -accessible to the wider internet, and will only work if you use a -hostname, and not just an IP address. +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. From 9b4b5ee843cb81355ceca3e7e5d9e0045f545881 Mon Sep 17 00:00:00 2001 From: tino097 Date: Tue, 23 Jan 2024 23:05:22 +0100 Subject: [PATCH 24/25] Fix for 2.10 --- ckanext/officedocs/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/officedocs/plugin.py b/ckanext/officedocs/plugin.py index 060777e..7ed06a1 100644 --- a/ckanext/officedocs/plugin.py +++ b/ckanext/officedocs/plugin.py @@ -43,7 +43,7 @@ def can_view(self, data_dict): return res in supported_formats else: return False - except: + except KeyError: return False def view_template(self, context, data_dict): From b580cffaf25a8d0e6d319d6dea735c6e15ec5663 Mon Sep 17 00:00:00 2001 From: Mark Calvert Date: Thu, 1 Feb 2024 16:30:09 +1300 Subject: [PATCH 25/25] Refactor code to handle missing keys in data_dict --- ckanext/officedocs/plugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ckanext/officedocs/plugin.py b/ckanext/officedocs/plugin.py index 7ed06a1..93c6c39 100644 --- a/ckanext/officedocs/plugin.py +++ b/ckanext/officedocs/plugin.py @@ -37,13 +37,13 @@ def can_view(self, data_dict): "PPS", "PPSX", "ODT", "ODS", "ODP" ] try: - pkg_private = data_dict["package"].get("private", False) + pkg_private = data_dict.get("package",{}).get("private", False) if not pkg_private: - res = data_dict["resource"].get("format", "").upper() + res = data_dict.get("resource",{}).get("format", "").upper() return res in supported_formats else: return False - except KeyError: + except Exception: return False def view_template(self, context, data_dict):