|
80 | 80 | <a href="{{ config['server']['url'] }}">{% trans %}Home{% endtrans %}</a> |
81 | 81 | {% endblock %} |
82 | 82 | <span style="float: inline-end"> |
83 | | - {% set links_found = namespace(json=0, jsonld=0) %} |
| 83 | + {% set links_found = namespace(json='', jsonld='') %} |
84 | 84 |
|
85 | 85 | {% for link in data['links'] %} |
86 | 86 | {% if link['rel'] == 'alternate' and link['type'] and link['type'] in ['application/json', 'application/geo+json', 'application/prs.coverage+json'] %} |
87 | | - {% set links_found.json = 1 %} |
| 87 | + {% set links_found.json = link.href | string | safe %} |
88 | 88 | <a href="{{ link['href'] }}">{% trans %}json{% endtrans %}</a> |
89 | 89 | {% elif link['rel'] == 'alternate' and link['type'] and link['type'] == 'application/ld+json' %} |
90 | | - {% set links_found.jsonld = 1 %} |
| 90 | + {% set links_found.jsonld = link.href | string | safe %} |
91 | 91 | <a href="{{ link['href'] }}">{% trans %}jsonld{% endtrans %}</a> |
92 | 92 | {% endif %} |
93 | 93 | {% endfor %} |
94 | 94 |
|
95 | | - {% if links_found.json == 0 %} |
| 95 | + {% if links_found.json == '' %} |
96 | 96 | <a href="?f=json">{% trans %}json{% endtrans %}</a> |
97 | 97 | {% endif %} |
98 | | - {% if links_found.jsonld == 0 %} |
| 98 | + {% if links_found.jsonld == '' %} |
99 | 99 | <a href="?f=jsonld">{% trans %}jsonld{% endtrans %}</a> |
100 | 100 | {% endif %} |
101 | 101 |
|
|
127 | 127 | <script> |
128 | 128 | // Requests and embeds JSON-LD representation of current page |
129 | 129 | var xhr = new XMLHttpRequest(); |
| 130 | + {% if links_found.jsonld == '' -%} |
130 | 131 | var path = window.location.protocol + "//" + window.location.host + window.location.pathname + "?f=jsonld"; |
| 132 | + {%- else -%} |
| 133 | + var path = "{{ links_found.jsonld }}"; |
| 134 | + {%- endif %} |
131 | 135 | xhr.open('GET', path); |
132 | 136 | xhr.onload = function() { |
133 | 137 | if (xhr.status === 200) { |
|
0 commit comments