Skip to content

Commit a5208ac

Browse files
kngaiKevin Ngai
and
Kevin Ngai
authored
Serve GCWeb theme (css/image/fonts) locally instead of from canada.ca due to potential IP block (#322)
- 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 Co-authored-by: Kevin Ngai <[email protected]>
1 parent 86cd866 commit a5208ac

File tree

13 files changed

+43
-12
lines changed

13 files changed

+43
-12
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ dist
77
node_modules
88
schemas.opengis.net
99
.pot
10+
theme/static/themes-gcweb

Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ RUN cd msc-pygeoapi && \
7070
pip3 install -U elasticsearch && \
7171
# ensure cors enabled in config
7272
sed -i 's^# cors: true^cors: true^' $BASEDIR/msc-pygeoapi/deploy/default/msc-pygeoapi-config.yml && \
73+
# GCWeb theme files
74+
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 && \
75+
unzip -o ./themes-gcweb.zip "*/GCWeb/*" -d theme/static && \
76+
unzip -o ./themes-gcweb.zip "*/wet-boew/*" -d theme/static && \
77+
mv ./theme/static/themes-dist-14.6.0-gcweb ./theme/static/themes-gcweb && \
78+
rm -f ./themes-gcweb.zip && \
7379
# install msc-pygeoapi
7480
python3 setup.py install && \
7581
# show version

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,18 @@ python3 -m venv --system-site-packages msc-pygeoapi
2929
cd msc-pygeoapi
3030
source bin/activate
3131

32-
# clone codebase and install
32+
# clone codebase
3333
git clone https://github.com/ECCC-MSC/msc-pygeoapi.git
3434
cd msc-pygeoapi
35+
36+
# add GCWeb theme files
37+
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
38+
unzip -o ./themes-gcweb.zip "*/GCWeb/*" -d theme/static
39+
unzip -o ./themes-gcweb.zip "*/wet-boew/*" -d theme/static
40+
mv ./theme/static/themes-dist-14.6.0-gcweb ./theme/static/themes-gcweb
41+
rm -f ./themes-gcweb.zip
42+
43+
# install codebase
3544
python setup.py build
3645
python setup.py install
3746

debian/rules

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@ MSC_PYGEOAPI_VERSION=$(shell dpkg-parsechangelog -SVersion)
2323
&& rm -f ./SCHEMAS_OPENGIS_NET.zip
2424
sed -i "s/MSC_PYGEOAPI_VERSION/$(MSC_PYGEOAPI_VERSION)/" theme/templates/_base.html
2525

26+
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
27+
&& unzip -o ./themes-gcweb.zip "*/GCWeb/*" -d theme/static
28+
&& unzip -o ./themes-gcweb.zip "*/wet-boew/*" -d theme/static
29+
&& mv ./theme/static/themes-dist-14.6.0-gcweb ./theme/static/themes-gcweb
30+
&& rm -f ./themes-gcweb.zip
31+
2632
override_dh_auto_test:
27-
@echo "nocheck set, not running tests"
33+
@echo "nocheck set, not running tests"

theme/static/js/composables/useCatalog.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ref, computed } from 'https://cdnjs.cloudflare.com/ajax/libs/vue/3.0.7/vue.esm-browser.prod.js'
1+
import { ref, computed } from 'vue'
22

33
export default function useCatalog(initJsonData) {
44
const catalogJson = ref(initJsonData)

theme/static/js/composables/useCollections.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ref, computed } from 'https://cdnjs.cloudflare.com/ajax/libs/vue/3.0.7/vue.esm-browser.prod.js'
1+
import { ref, computed } from 'vue'
22

33
export default function useCollections() {
44
const collectionsJson = ref(JSON_DATA) // global JSON_DATA from jinja rendered JSON

theme/static/js/composables/useItems.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ref, computed } from 'https://cdnjs.cloudflare.com/ajax/libs/vue/3.0.7/vue.esm-browser.prod.js'
1+
import { ref, computed } from 'vue'
22

33
export default function useItems(itemsi18n) {
44
// Items results

theme/static/js/composables/useMap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as L from 'https://unpkg.com/[email protected]/dist/leaflet-src.esm.js'
2-
import { ref, computed, watch, onMounted } from 'https://cdnjs.cloudflare.com/ajax/libs/vue/3.0.7/vue.esm-browser.prod.js'
2+
import { ref, computed, watch, onMounted } from 'vue'
33

44
export default function useMap(mapElemId, geoJsonData, itemsPath, tileLayerUrl, tileLayerAttr, bboxPermalink, locale) {
55
let map, layerItems

theme/static/js/composables/useTableFilter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ref, computed } from 'https://cdnjs.cloudflare.com/ajax/libs/vue/3.0.7/vue.esm-browser.prod.js'
1+
import { ref, computed } from 'vue'
22

33
export default function useTableFilter(rows, keyColumns, defaultSortCol, tableTexti18n) {
44
// sort and filtering

theme/templates/_base.html

+11-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<!-- GCWeb theme -->
1313
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
14-
<link rel="stylesheet" href="https://www.canada.ca/etc/designs/canada/cdts/gcweb/v4_0_32/css/theme.min.css">
14+
<link rel="stylesheet" href="{{ config['server']['url'] }}/static/themes-gcweb/GCWeb/css/theme.min.css">
1515

1616
<link rel="stylesheet" href="{{ config['server']['url'] }}/static/css/default.css">
1717
<!--[if lt IE 9]>
@@ -24,6 +24,15 @@
2424
<link rel="{{ link['rel'] }}" type="{{ link['type'] }}" title="{{ link['title'] }}" href="{{ link['href'] }}?lang={{ (locale|lower)[:2] }}"/>
2525
{% endif %}
2626
{% endfor %}
27+
28+
<!-- ESM import map -->
29+
<script type="importmap">
30+
{
31+
"imports": {
32+
"vue": "https://cdnjs.cloudflare.com/ajax/libs/vue/3.0.7/vue.esm-browser.prod.js"
33+
}
34+
}
35+
</script>
2736
{% block extrahead %}
2837
{% endblock %}
2938
</head>
@@ -166,7 +175,7 @@ <h2 class="wb-inv">{% trans %}About this site{% endtrans %}</h2>
166175
<a href="#wb-cont">{% trans %}Top of page{% endtrans %} <span class="glyphicon glyphicon-chevron-up"></span></a>
167176
</div>
168177
<div class="col-xs-6 col-md-3 col-lg-2 text-right">
169-
<img src="https://www.canada.ca/etc/designs/canada/cdts/gcweb/v4_0_32/assets/wmms-blk.svg" alt="{% trans %}Symbol of the Government of Canada{% endtrans %}" />
178+
<img src="{{ config['server']['url'] }}/static/themes-gcweb/GCWeb/assets/wmms-blk.svg" alt="{% trans %}Symbol of the Government of Canada{% endtrans %}" />
170179
</div>
171180
</div>
172181
</div>

theme/templates/collections/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ <h1>{% trans %}Collections in this service{% endtrans %}</h1>
6464
<script type="module">
6565
import useCollections from '{{ config['server']['url'] }}/static/js/composables/useCollections.js?v={{ version }}'
6666
import useTableFilter from '{{ config['server']['url'] }}/static/js/composables/useTableFilter.js?v={{ version }}'
67-
import { createApp, ref, computed } from 'https://cdnjs.cloudflare.com/ajax/libs/vue/3.0.7/vue.esm-browser.prod.js'
67+
import { createApp, ref, computed } from 'vue'
6868

6969
const app = createApp({
7070
delimiters: ['[%', '%]'],

theme/templates/collections/items/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ <h1>{% for l in data['links'] if l.rel == 'collection' %} {{ l['title'] }} {% en
185185
import useItems from '{{ config['server']['url'] }}/static/js/composables/useItems.js?v={{ version }}'
186186
import useTableFilter from '{{ config['server']['url'] }}/static/js/composables/useTableFilter.js?v={{ version }}'
187187
import useMap from '{{ config['server']['url'] }}/static/js/composables/useMap.js?v={{ version }}'
188-
import { createApp, ref, computed, onBeforeMount, onMounted, watch } from 'https://cdnjs.cloudflare.com/ajax/libs/vue/3.0.7/vue.esm-browser.prod.js'
188+
import { createApp, ref, computed, onBeforeMount, onMounted, watch } from 'vue'
189189

190190
const app = createApp({
191191
delimiters: ['[%', '%]'],

theme/templates/stac/catalog.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ <h2>{% trans %}Links{% endtrans %}</h2>
8585
<script type="module">
8686
import useCatalog from '{{ config['server']['url'] }}/static/js/composables/useCatalog.js?v={{ version }}'
8787
import useTableFilter from '{{ config['server']['url'] }}/static/js/composables/useTableFilter.js?v={{ version }}'
88-
import { createApp, ref, computed } from 'https://cdnjs.cloudflare.com/ajax/libs/vue/3.0.7/vue.esm-browser.prod.js'
88+
import { createApp, ref, computed } from 'vue'
8989

9090
const app = createApp({
9191
delimiters: ['[%', '%]'],

0 commit comments

Comments
 (0)