Skip to content

Commit

Permalink
Add expand parameter for Treedoc Viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
avillar committed Aug 24, 2023
1 parent d1f97da commit 440ba4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ogc/bblocks/examples-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ items:
type: array
items:
type: string
expand-level:
description: Default expand level for Treedoc Viewer, where applicable (JSON, YAML)
type: integer
minimum: 1
oneOf:
- required:
- code
Expand Down
7 changes: 4 additions & 3 deletions ogc/bblocks/templates/slate/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ ${example['content'].replace('@@assets@@', assets_rel or '')}
<%
snippet_lang = lang_aliases.get(snippet['language'].lower(), snippet['language'])
snippet_url = snippet.get('url')
snippet_expand = snippet.get('expand-level', 2)
%>
```${snippet_lang}
${snippet['code']}
Expand All @@ -103,7 +104,7 @@ ${snippet['code']}
% if snippet_lang == 'json':

<blockquote class="lang-specific ${snippet_lang}">
<p><a target="_blank" href="https://avillar.github.io/TreedocViewer/?dataParser=json&amp;dataUrl=${urllib.parse.quote_plus(snippet_url)}${treedocviewer_options}">View on JSON Viewer</a></p>
<p><a target="_blank" href="https://avillar.github.io/TreedocViewer/?dataParser=json&amp;dataUrl=${urllib.parse.quote_plus(snippet_url)}&amp;expand=${snippet_expand}${treedocviewer_options}">View on JSON Viewer</a></p>
</blockquote>

% elif snippet_lang in ('json-ld', 'jsonld'):
Expand All @@ -115,7 +116,7 @@ ${snippet['code']}
% elif snippet_lang == 'yaml':

<blockquote class="lang-specific ${snippet_lang}">
<p><a target="_blank" href="https://avillar.github.io/TreedocViewer/?dataParser=yaml&amp;dataUrl=${urllib.parse.quote_plus(snippet_url)}${treedocviewer_options}">View on YAML Viewer</a></p>
<p><a target="_blank" href="https://avillar.github.io/TreedocViewer/?dataParser=yaml&amp;dataUrl=${urllib.parse.quote_plus(snippet_url)}&amp;expand=${snippet_expand}${treedocviewer_options}">View on YAML Viewer</a></p>
</blockquote>

% endif
Expand All @@ -133,7 +134,7 @@ ${'#'} JSON Schema
${bblock.annotated_schema_contents}
```

> <a target="_blank" href="https://avillar.github.io/TreedocViewer/?dataParser=yaml&amp;dataUrl=${urllib.parse.quote_plus(bblock.metadata['schema']['application/yaml'])}${treedocviewer_options}">View on YAML Viewer</a>
> <a target="_blank" href="https://avillar.github.io/TreedocViewer/?dataParser=yaml&amp;dataUrl=${urllib.parse.quote_plus(bblock.metadata['schema']['application/yaml'])}&amp;expand=2${treedocviewer_options}">View on YAML Viewer</a>
Links to the schema:

Expand Down

0 comments on commit 440ba4f

Please sign in to comment.