Skip to content

Commit 1c42bc3

Browse files
committed
Use remote viewer
1 parent 3628118 commit 1c42bc3

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

.github/workflows/validate-and-process.yml

+23-30
Original file line numberDiff line numberDiff line change
@@ -139,33 +139,6 @@ jobs:
139139
run: |
140140
sudo find "${{ inputs.annotated_path }}" -name _visited_properties.tsv -delete
141141
sudo find "${{ inputs.annotated_path }}" -name _visited_properties.tsv.gz -delete
142-
- name: Create GH Pages index
143-
if: ${{ !inputs.deploy_viewer && github.event.repository.has_pages && !inputs.skip-pages }}
144-
shell: python
145-
run: |
146-
import json
147-
148-
with open('${{ inputs.register_file }}') as f:
149-
bblocks = json.load(f)
150-
if isinstance(bblocks, dict):
151-
bblocks = bblocks.get('bblocks', ())
152-
153-
with open('index.html', 'w') as f:
154-
f.write('<!doctype html><html><head><meta charset="utf-8"/><title>')
155-
f.write('${{ github.repository }}')
156-
f.write(' - Building Blocks</title><style>.validation-failed::before{color:red;content:"❌ "}.validation-passed::before{color:green;content:"✅️ "}</style></head><body><h1>')
157-
f.write('${{ github.repository }}')
158-
f.write('</h1><ul>')
159-
for bblock in sorted(bblocks, key=lambda x: x['itemIdentifier']):
160-
link = bblock.get('documentation', {}).get('slate', {}).get('url')
161-
name = bblock['name']
162-
identifier = bblock['itemIdentifier']
163-
validation = 'passed' if bblock.get('validationPassed', True) else 'failed'
164-
if link:
165-
f.write(f'<li class="validation-{validation}"><a href="{link}"><tt>{identifier}</tt> - {name}</a></li>')
166-
else:
167-
f.write(f'<li class="validation-{validation}"><tt>{identifier}</tt> - {name}</li>')
168-
f.write('</ul><p style="margin-top:1em"><a href="${{ inputs.test_outputs_path }}/report.html">Validation report</a></p></body></html>')
169142
- name: Deploy Building Blocks viewer
170143
if: ${{ inputs.deploy_viewer && github.event.repository.has_pages && !inputs.skip-pages }}
171144
run: |
@@ -184,25 +157,45 @@ jobs:
184157
else
185158
BASE_URL=${BASE_URL#./}
186159
fi
187-
wget -q -O - https://github.com/ogcincubator/bblocks-viewer/archive/refs/heads/dist.tar.gz | tar zx --strip-components=1
188-
sed -i -r "s,/@BASE_URL@/,/${{ github.event.repository.name }}/${BASE_URL},g" index.html 404.html assets/*.js assets/*.css
160+
161+
cat << EOF > index.html
162+
<!DOCTYPE html>
163+
<html lang="en">
164+
<head>
165+
<meta charset="UTF-8" />
166+
<link rel="icon" href="https://ogcincubator.github.io/bblocks-viewer/favicon.ico" />
167+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
168+
<title>OGC Location Building Blocks</title>
169+
<script src="/${{ github.event.repository.name }}/${BASE_URL}/config.js"></script>
170+
<script type="module" crossorigin src="https://ogcincubator.github.io/bblocks-viewer/assets/index.js"></script>
171+
<link rel="stylesheet" href="https://ogcincubator.github.io/bblocks-viewer/assets/index.css">
172+
</head>
173+
<body>
174+
<div id="app"></div>
175+
</body>
176+
</html>
177+
EOF
178+
189179
cat << EOF > config.js
190180
window.bblocksRegister = '${{ format('https://{0}.github.io/{1}/{2}', github.repository_owner, github.event.repository.name, inputs.register_file) }}';
191181
window.bblocksViewer = {
192182
title: $(jq '.name // "${{ github.event.repository.name }}"' < "$REGISTER_FILE"),
193183
showImported: ${{ inputs.viewer_show_imported }},
184+
baseUrl: '/${{ github.event.repository.name }}/${BASE_URL}/',
194185
};
195186
EOF
187+
196188
if [ -f GIT_INFO ]; then
197189
TEMPFILE="$(mktemp)"
198190
jq -s '.[0].tooling."bblocks-viewer" = .[1] | .[0]' "$REGISTER_FILE" GIT_INFO > "$TEMPFILE"
199191
mv "$TEMPFILE" "$REGISTER_FILE"
200192
rm -f "$TEMPFILE"
201193
fi
194+
202195
cd "$OLD_WD"
203196
204197
if [ ! -f "404.html" ]; then
205-
cp "${{ inputs.viewer_path }}/404.html" .
198+
cp "${{ inputs.viewer_path }}/index.html" 404.html
206199
fi
207200
- name: Setup Pages
208201
if: ${{ github.event.repository.has_pages && !inputs.skip-pages }}

0 commit comments

Comments
 (0)