|
67 | 67 | <a href="{{ config['server']['url'] }}">{% trans %}Home{% endtrans %}</a>
|
68 | 68 | {% endblock %}
|
69 | 69 | <span style="float: inline-end">
|
70 |
| - {% set links_found = namespace(json=0, jsonld=0) %} |
| 70 | + {% set links_found = namespace(json='', jsonld='') %} |
71 | 71 |
|
72 | 72 | {% for link in data['links'] %}
|
73 | 73 | {% if link['rel'] == 'alternate' and link['type'] and link['type'] in ['application/json', 'application/geo+json', 'application/prs.coverage+json'] %}
|
74 |
| - {% set links_found.json = 1 %} |
| 74 | + {% set links_found.json = link.href | string | safe %} |
75 | 75 | <a href="{{ link['href'] }}">{% trans %}json{% endtrans %}</a>
|
76 | 76 | {% elif link['rel'] == 'alternate' and link['type'] and link['type'] == 'application/ld+json' %}
|
77 |
| - {% set links_found.jsonld = 1 %} |
| 77 | + {% set links_found.jsonld = link.href | string | safe %} |
78 | 78 | <a href="{{ link['href'] }}">{% trans %}jsonld{% endtrans %}</a>
|
79 | 79 | {% endif %}
|
80 | 80 | {% endfor %}
|
81 | 81 |
|
82 |
| - {% if links_found.json == 0 %} |
| 82 | + {% if links_found.json == '' %} |
83 | 83 | <a href="?f=json">{% trans %}json{% endtrans %}</a>
|
84 | 84 | {% endif %}
|
85 |
| - {% if links_found.jsonld == 0 %} |
| 85 | + {% if links_found.jsonld == '' %} |
86 | 86 | <a href="?f=jsonld">{% trans %}jsonld{% endtrans %}</a>
|
87 | 87 | {% endif %}
|
88 | 88 |
|
|
114 | 114 | <script>
|
115 | 115 | // Requests and embeds JSON-LD representation of current page
|
116 | 116 | var xhr = new XMLHttpRequest();
|
| 117 | + {% if links_found.jsonld == '' -%} |
117 | 118 | var path = window.location.protocol + "//" + window.location.host + window.location.pathname + "?f=jsonld";
|
| 119 | + {%- else -%} |
| 120 | + var path = "{{ links_found.jsonld }}"; |
| 121 | + {%- endif %} |
118 | 122 | xhr.open('GET', path);
|
119 | 123 | xhr.onload = function() {
|
120 | 124 | if (xhr.status === 200) {
|
|
0 commit comments