Skip to content

Commit db18e66

Browse files
committed
Use remote viewer
1 parent 3628118 commit db18e66

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

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

+27-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,49 @@ 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+
# Add trailing slash to BASE_URL if not empty
161+
if [[ "${BASE_URL}" =~ [^/]$ ]]; then
162+
BASE_URL="${BASE_URL}/"
163+
fi
164+
165+
cat << EOF > index.html
166+
<!DOCTYPE html>
167+
<html lang="en">
168+
<head>
169+
<meta charset="UTF-8" />
170+
<link rel="icon" href="https://ogcincubator.github.io/bblocks-viewer/favicon.ico" />
171+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
172+
<title>OGC Location Building Blocks</title>
173+
<script src="/${{ github.event.repository.name }}/${BASE_URL}config.js"></script>
174+
<script type="module" crossorigin src="https://ogcincubator.github.io/bblocks-viewer/assets/index.js"></script>
175+
<link rel="stylesheet" href="https://ogcincubator.github.io/bblocks-viewer/assets/index.css">
176+
</head>
177+
<body>
178+
<div id="app"></div>
179+
</body>
180+
</html>
181+
EOF
182+
189183
cat << EOF > config.js
190184
window.bblocksRegister = '${{ format('https://{0}.github.io/{1}/{2}', github.repository_owner, github.event.repository.name, inputs.register_file) }}';
191185
window.bblocksViewer = {
192186
title: $(jq '.name // "${{ github.event.repository.name }}"' < "$REGISTER_FILE"),
193187
showImported: ${{ inputs.viewer_show_imported }},
188+
baseUrl: '/${{ github.event.repository.name }}/${BASE_URL}',
194189
};
195190
EOF
191+
196192
if [ -f GIT_INFO ]; then
197193
TEMPFILE="$(mktemp)"
198194
jq -s '.[0].tooling."bblocks-viewer" = .[1] | .[0]' "$REGISTER_FILE" GIT_INFO > "$TEMPFILE"
199195
mv "$TEMPFILE" "$REGISTER_FILE"
200196
rm -f "$TEMPFILE"
201197
fi
198+
202199
cd "$OLD_WD"
203200
204201
if [ ! -f "404.html" ]; then
205-
cp "${{ inputs.viewer_path }}/404.html" .
202+
cp "${{ inputs.viewer_path }}/index.html" 404.html
206203
fi
207204
- name: Setup Pages
208205
if: ${{ github.event.repository.has_pages && !inputs.skip-pages }}

0 commit comments

Comments
 (0)