From 67eb641bb874c8e4c8c5992754f38dbc60f0d0fd Mon Sep 17 00:00:00 2001 From: Kevin Ngai Date: Mon, 18 Mar 2024 16:47:48 +0000 Subject: [PATCH] Serve GCWeb theme (css/image/fonts) locally instead of from canada.ca due to potential IP block - import VueJS API via ESM import map - Debian rules unzip themes-gcweb.zip into theme/static - Dockerfile updated to unzip themes-gcweb.zip - gitignore theme/static/themes-gcweb - update README.md installation instructions --- .gitignore | 1 + Dockerfile | 6 ++++++ README.md | 11 ++++++++++- debian/rules | 8 +++++++- theme/static/js/composables/useCatalog.js | 2 +- theme/static/js/composables/useCollections.js | 2 +- theme/static/js/composables/useItems.js | 2 +- theme/static/js/composables/useMap.js | 2 +- theme/static/js/composables/useTableFilter.js | 2 +- theme/templates/_base.html | 13 +++++++++++-- theme/templates/collections/index.html | 2 +- theme/templates/collections/items/index.html | 2 +- theme/templates/stac/catalog.html | 2 +- 13 files changed, 43 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 2badee0b..10983d6a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist node_modules schemas.opengis.net .pot +theme/static/themes-gcweb \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 29fe0a70..81d65a23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -70,6 +70,12 @@ RUN cd msc-pygeoapi && \ pip3 install -U elasticsearch && \ # ensure cors enabled in config sed -i 's^# cors: true^cors: true^' $BASEDIR/msc-pygeoapi/deploy/default/msc-pygeoapi-config.yml && \ + # GCWeb theme files + curl -L https://github.com/wet-boew/GCWeb/releases/download/v14.6.0/themes-dist-14.6.0-gcweb.1.zip -o ./themes-gcweb.zip && \ + unzip -o ./themes-gcweb.zip "*/GCWeb/*" -d theme/static && \ + unzip -o ./themes-gcweb.zip "*/wet-boew/*" -d theme/static && \ + mv ./theme/static/themes-dist-14.6.0-gcweb ./theme/static/themes-gcweb && \ + rm -f ./themes-gcweb.zip && \ # install msc-pygeoapi python3 setup.py install && \ # show version diff --git a/README.md b/README.md index 354db92a..4f613299 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,18 @@ python3 -m venv --system-site-packages msc-pygeoapi cd msc-pygeoapi source bin/activate -# clone codebase and install +# clone codebase git clone https://github.com/ECCC-MSC/msc-pygeoapi.git cd msc-pygeoapi + +# add GCWeb theme files +curl -L https://github.com/wet-boew/GCWeb/releases/download/v14.6.0/themes-dist-14.6.0-gcweb.1.zip -o ./themes-gcweb.zip +unzip -o ./themes-gcweb.zip "*/GCWeb/*" -d theme/static +unzip -o ./themes-gcweb.zip "*/wet-boew/*" -d theme/static +mv ./theme/static/themes-dist-14.6.0-gcweb ./theme/static/themes-gcweb +rm -f ./themes-gcweb.zip + +# install codebase python setup.py build python setup.py install diff --git a/debian/rules b/debian/rules index 2398c53a..53e3d2e9 100755 --- a/debian/rules +++ b/debian/rules @@ -23,5 +23,11 @@ MSC_PYGEOAPI_VERSION=$(shell dpkg-parsechangelog -SVersion) && rm -f ./SCHEMAS_OPENGIS_NET.zip sed -i "s/MSC_PYGEOAPI_VERSION/$(MSC_PYGEOAPI_VERSION)/" theme/templates/_base.html + curl -L https://github.com/wet-boew/GCWeb/releases/download/v14.6.0/themes-dist-14.6.0-gcweb.1.zip -o ./themes-gcweb.zip + && unzip -o ./themes-gcweb.zip "*/GCWeb/*" -d theme/static + && unzip -o ./themes-gcweb.zip "*/wet-boew/*" -d theme/static + && mv ./theme/static/themes-dist-14.6.0-gcweb ./theme/static/themes-gcweb + && rm -f ./themes-gcweb.zip + override_dh_auto_test: - @echo "nocheck set, not running tests" + @echo "nocheck set, not running tests" \ No newline at end of file diff --git a/theme/static/js/composables/useCatalog.js b/theme/static/js/composables/useCatalog.js index ce19ac28..f4160447 100644 --- a/theme/static/js/composables/useCatalog.js +++ b/theme/static/js/composables/useCatalog.js @@ -1,4 +1,4 @@ -import { ref, computed } from 'https://cdnjs.cloudflare.com/ajax/libs/vue/3.0.7/vue.esm-browser.prod.js' +import { ref, computed } from 'vue' export default function useCatalog(initJsonData) { const catalogJson = ref(initJsonData) diff --git a/theme/static/js/composables/useCollections.js b/theme/static/js/composables/useCollections.js index ce89d77a..414fa43c 100644 --- a/theme/static/js/composables/useCollections.js +++ b/theme/static/js/composables/useCollections.js @@ -1,4 +1,4 @@ -import { ref, computed } from 'https://cdnjs.cloudflare.com/ajax/libs/vue/3.0.7/vue.esm-browser.prod.js' +import { ref, computed } from 'vue' export default function useCollections() { const collectionsJson = ref(JSON_DATA) // global JSON_DATA from jinja rendered JSON diff --git a/theme/static/js/composables/useItems.js b/theme/static/js/composables/useItems.js index c9ad444b..81e4f91c 100644 --- a/theme/static/js/composables/useItems.js +++ b/theme/static/js/composables/useItems.js @@ -1,4 +1,4 @@ -import { ref, computed } from 'https://cdnjs.cloudflare.com/ajax/libs/vue/3.0.7/vue.esm-browser.prod.js' +import { ref, computed } from 'vue' export default function useItems(itemsi18n) { // Items results diff --git a/theme/static/js/composables/useMap.js b/theme/static/js/composables/useMap.js index 9c8253e3..3778ace1 100644 --- a/theme/static/js/composables/useMap.js +++ b/theme/static/js/composables/useMap.js @@ -1,5 +1,5 @@ import * as L from 'https://unpkg.com/leaflet@1.7.1/dist/leaflet-src.esm.js' -import { ref, computed, watch, onMounted } from 'https://cdnjs.cloudflare.com/ajax/libs/vue/3.0.7/vue.esm-browser.prod.js' +import { ref, computed, watch, onMounted } from 'vue' export default function useMap(mapElemId, geoJsonData, itemsPath, tileLayerUrl, tileLayerAttr, bboxPermalink, locale) { let map, layerItems diff --git a/theme/static/js/composables/useTableFilter.js b/theme/static/js/composables/useTableFilter.js index b944c125..ea96d544 100644 --- a/theme/static/js/composables/useTableFilter.js +++ b/theme/static/js/composables/useTableFilter.js @@ -1,4 +1,4 @@ -import { ref, computed } from 'https://cdnjs.cloudflare.com/ajax/libs/vue/3.0.7/vue.esm-browser.prod.js' +import { ref, computed } from 'vue' export default function useTableFilter(rows, keyColumns, defaultSortCol, tableTexti18n) { // sort and filtering diff --git a/theme/templates/_base.html b/theme/templates/_base.html index f997e386..095d40fb 100644 --- a/theme/templates/_base.html +++ b/theme/templates/_base.html @@ -11,7 +11,7 @@ - + + {% block extrahead %} {% endblock %} @@ -166,7 +175,7 @@

{% trans %}About this site{% endtrans %}

{% trans %}Top of page{% endtrans %}
- {% trans %}Symbol of the Government of Canada{% endtrans %} + {% trans %}Symbol of the Government of Canada{% endtrans %}
diff --git a/theme/templates/collections/index.html b/theme/templates/collections/index.html index e6389d4d..9497982a 100644 --- a/theme/templates/collections/index.html +++ b/theme/templates/collections/index.html @@ -64,7 +64,7 @@

{% trans %}Collections in this service{% endtrans %}