Skip to content

Commit 6c782d9

Browse files
committed
Add viewer.show-imported-depth to bblocks-config.yaml
Allows configuring the bblocks-viewer's showImported level directly in bblocks-config.yaml under a viewer.show-imported-depth key, rather than only via the viewer_show_imported workflow input. The value is written to register.json as viewer.showImported so the viewer can read it without a deployed config.js. The workflow input is kept for backwards compatibility but deprecated in favour of the config file key.
1 parent e7a9626 commit 6c782d9

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ on:
6464
viewer_show_imported:
6565
type: number
6666
description: |
67-
Level up to which the deployed building blocks viewer will show imported building
67+
Level up to which the deployed building blocks viewer will show imported building
6868
blocks as well as local ones. 0 means "only local", and a negative number means
6969
"all imports".
70+
Deprecated: set viewer.show-imported-depth in bblocks-config.yaml instead.
71+
If that key is present, it takes precedence over this input.
7072
default: 0
7173
fallback_rainbow_instances:
7274
type: string
@@ -298,11 +300,17 @@ jobs:
298300
BBLOCKS_SPARQL='${{ inputs.fallback_sparql_endpoints }}'
299301
BBLOCKS_SPARQL="${BBLOCKS_SPARQL:-[]}"
300302
303+
# Prefer viewer.show-imported-depth from bblocks-config.yaml if present
304+
SHOW_IMPORTED=$(yq '.viewer."show-imported-depth" // null' '${{ inputs.config_file }}' 2>/dev/null)
305+
if [ "$SHOW_IMPORTED" = "null" ] || [ -z "$SHOW_IMPORTED" ]; then
306+
SHOW_IMPORTED='${{ inputs.viewer_show_imported }}'
307+
fi
308+
301309
cat << EOF > config.js
302310
window.bblocksRegister = '${{ steps.get-pages-url.outputs.result }}/${{ inputs.register_file }}';
303311
window.bblocksViewer = {
304312
title: $(jq '.name // "${{ github.event.repository.name }}"' < "$REGISTER_FILE"),
305-
showImported: ${{ inputs.viewer_show_imported }},
313+
showImported: ${SHOW_IMPORTED},
306314
baseUrl: '${PAGES_PATH}${BASE_URL}',
307315
bblocksFallbackRainbowInstances: ${BBLOCKS_RAINBOW},
308316
bblocksFallbackSparqlEndpoints: ${BBLOCKS_SPARQL},

ogc/bblocks/entrypoint.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@
231231
register_additional_metadata['sparqlEndpoint'] = sparql_conf['query']
232232
schema_oas30_downcompile = bb_config.get('schema-oas30-downcompile', False)
233233

234+
viewer_config = {}
235+
if bb_config:
236+
raw_viewer = bb_config.get('viewer', {}) or {}
237+
if 'show-imported-depth' in raw_viewer:
238+
viewer_config['showImported'] = raw_viewer['show-imported-depth']
239+
234240
bb_local_config_file = Path('bblocks-config-local.yml')
235241
local_url_mappings = None
236242
if bb_local_config_file.is_file():
@@ -307,6 +313,7 @@
307313
git_repo_path=git_repo_path,
308314
viewer_path=(args.viewer_path or '.') if deploy_viewer else None,
309315
additional_metadata=register_additional_metadata,
316+
viewer_config=viewer_config,
310317
schemas_oas30_downcompile=schema_oas30_downcompile,
311318
local_url_mappings=local_url_mappings,
312319
links=[

ogc/bblocks/postprocess.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def postprocess(registered_items_path: str | Path = 'registereditems',
5151
additional_metadata: dict | None = None,
5252
schemas_oas30_downcompile=False,
5353
local_url_mappings: dict | None = None,
54-
links: list[dict] = None) -> list[dict]:
54+
links: list[dict] = None,
55+
viewer_config: dict | None = None) -> list[dict]:
5556

5657
cwd = Path().resolve()
5758

@@ -513,6 +514,9 @@ def do_postprocess(bblock: BuildingBlock, light: bool = False) -> bool:
513514
output_register_json['imports'] = list(imported_bblocks.real_metadata_urls.values())
514515
output_register_json['bblocks'] = output_bblocks
515516

517+
if viewer_config:
518+
output_register_json['viewer'] = viewer_config
519+
516520
if transform_plugins:
517521
output_register_json['transformPlugins'] = transform_plugins
518522

0 commit comments

Comments
 (0)