Skip to content
Snippets Groups Projects
Commit 3ccd6783 authored by Jake's avatar Jake
Browse files

automatically redirect renderer link pages

parent 8d6914b3
No related branches found
No related tags found
No related merge requests found
Pipeline #328365 passed
...@@ -33,7 +33,9 @@ ...@@ -33,7 +33,9 @@
"slug_suffix": "", "slug_suffix": "",
"edit_url_text": "[Seite bearbeiten]", "edit_url_text": "[Seite bearbeiten]",
"view_url_text": "[Quelltext]", "view_url_text": "[Quelltext]",
"history_url_text": "[Historie]" "history_url_text": "[Historie]",
"redirect_prefix": "Diese Seite verlinkt auf eine andere Seite. Du wirst in kürze auf ",
"redirect_suffix": " weitergeleitet. Falls die automatische Weiterleitung nicht funktioniert, einfach den Link direkt klicken."
}, },
"tag": { "tag": {
"edit_url_text": "[Text bearbeiten]", "edit_url_text": "[Text bearbeiten]",
......
...@@ -133,12 +133,14 @@ ...@@ -133,12 +133,14 @@
{%- macro render_link(link, content, lang, attr = None, title = None) -%} {%- macro render_link(link, content, lang, attr = None, title = None) -%}
{%- call(objtype, obj) render_link_raw(link, content, lang, attr, title) -%} {%- call(objtype, obj, url, relation) render_link_raw(link, content, lang, attr, title) -%}
{%- if content is string or content is none -%} {%- if content is string or content is none -%}
{%- if content is string and content|length -%} {%- if content is string and content|length -%}
{{ encoded_span(content) }} {{ encoded_span(content) }}
{%- else -%} {%- elif obj -%}
{{ encoded_span(obj.title) }} {{ encoded_span(obj.title) }}
{%- else -%}
{{ encoded_span(url) }}
{%- endif -%} {%- endif -%}
{%- else -%} {%- else -%}
<strong>ERROR: Cannot render link with formatted content here.</strong> <strong>ERROR: Cannot render link with formatted content here.</strong>
...@@ -163,7 +165,7 @@ ...@@ -163,7 +165,7 @@
{%- endcall -%} {%- endcall -%}
{%- set target = config.link_target[ns.relation] -%} {%- set target = config.link_target[ns.relation] -%}
<a {{ render_attr(attr, lang, extra_classes=[ns.relation], extra={"href": ns.url, "title": {"value":title, "escape": true}, "target": target}) }}> <a {{ render_attr(attr, lang, extra_classes=[ns.relation], extra={"href": ns.url, "title": {"value":title, "escape": true}, "target": target}) }}>
{{- caller(ns.objtype, ns.obj) -}} {{- caller(ns.objtype, ns.obj,ns.url,ns.relation) -}}
</a> </a>
{%- endmacro -%} {%- endmacro -%}
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
{%- endmacro -%} {%- endmacro -%}
{%- macro render_link(link, content, lang, attr = None, title = None) -%} {%- macro render_link(link, content, lang, attr = None, title = None) -%}
{%- call(objtype, obj) common.render_link_raw(link, content, lang, attr, title) -%} {%- call(objtype, obj, url, relation) common.render_link_raw(link, content, lang, attr, title) -%}
{%- if content is string or content is none -%} {%- if content is string or content is none -%}
{%- if content is string and content|length -%} {%- if content is string and content|length -%}
{{ common.encoded_span(content) }} {{ common.encoded_span(content) }}
......
...@@ -3,6 +3,21 @@ ...@@ -3,6 +3,21 @@
{% block title %}{{ t[l].title_prefix }}{{ common.encoded_span(page.title)|striptags }}{{ t[l].title_seperator }}{{ common.encoded_span(page.category.title)|striptags }}{{ t[l].title_seperator }}{{ t[l].sitename }}{{ t[l].title_suffix }}{% endblock %} {% block title %}{{ t[l].title_prefix }}{{ common.encoded_span(page.title)|striptags }}{{ t[l].title_seperator }}{{ common.encoded_span(page.category.title)|striptags }}{{ t[l].title_seperator }}{{ t[l].sitename }}{{ t[l].title_suffix }}{% endblock %}
{% block extra_head %} {% block extra_head %}
{%- if page.link.alias -%}
{#- If page is a link and the user somehow got non-aliased link (e.g. from an old qr-code), redirect them to the linked url. -#}
{%- set ns = namespace(relation=None, url=None) -%}
{%- call(resolvedlink, objtype, obj) common.resolve_link(page.link) -%}
{%- set ns.url = resolvedlink.urlwithanchor -%}
{%- if not resolvedlink.is_external -%}
{%- set ns.relation = "internal" -%}
{%- if resolvedlink.url|length -%}
{%- set ns.url = [siteurl, ns.url]|join("/") -%}
{%- endif -%}
{%- endif -%}
{%- endcall -%}
<meta http-equiv="refresh" content="5; url={{ ns.url }}" >
{%- endif -%}
{% endblock %} {% endblock %}
{% block breadcrumb %} {% block breadcrumb %}
...@@ -15,7 +30,15 @@ ...@@ -15,7 +30,15 @@
{{ common.render_header(page.title, 1, None, lang) }} {{ common.render_header(page.title, 1, None, lang) }}
{% endblock %} {% endblock %}
{% block page_content %} {% block page_content %}
{{ render.section({"type": "page", "page": page, "title_mode": "prevent"}, l, 1) }} {%- if page.link.alias -%}
<div class="info">
<p>
{{ t[l].page.redirect_prefix }}{{ common.render_link(page.link.alias, None, l) }}{{ t[l].page.redirect_suffix }}
</p>
</div>
{%- else -%}
{{ render.section({"type": "page", "page": page, "title_mode": "prevent"}, l, 1) }}
{%- endif -%}
{% endblock %} {% endblock %}
</article> </article>
{% endblock %} {% endblock %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment