better preview link (requires "rtrim" filter from Grav)

This commit is contained in:
Andy Miller
2015-08-28 13:39:34 -06:00
parent 193e4c9a86
commit ec8a9adbec

View File

@@ -25,6 +25,7 @@
{% set page_lang = context.language %}
{% block stylesheets %}
{{ dump(base_url_relative_frontend ~ (context.home ? '' : context.route)) }}
{% if mode == 'edit' %}
{% do assets.addCss(theme_url~'/css/codemirror/codemirror.css') %}
{% endif %}
@@ -41,7 +42,8 @@
{{ parent() }}
{% endblock %}
{% set preview_link = '<a class="preview" href="'~ base_url_relative_frontend ~ (context.home ? '' : context.route) ~'"><i class="fa fa-fw fa-angle-double-right"></i></a>' %}
{% set preview_html = (base_url_relative_frontend|rtrim('/') ~ (context.home ? '' : context.route)) ?: '/' %}
{% set preview_link = '<a class="preview" target="_blank" href="' ~ preview_html ~ '"><i class="fa fa-fw fa-angle-double-right"></i></a>' %}
{% macro loop(page, depth, twig_vars) %}
{% set separator = twig_vars['config'].system.param_sep %}
@@ -161,7 +163,7 @@
<h1><i class="fa fa-fw fa-file-text-o"></i> {{ "PLUGIN_ADMIN.ADD_PAGE"|tu }}</h1>
{% elseif mode == 'edit' %}
<h1><i class="fa fa-fw fa-file-text-o"></i>
{{ context.exists ? "PLUGIN_ADMIN.EDIT"|tu ~ " '#{context.menu}'" ~ preview_link : "PLUGIN_ADMIN.CREATE"|tu ~ " '#{context.menu}'" }}
{{ context.exists ? "PLUGIN_ADMIN.EDIT"|tu ~ " <i>#{context.menu}</i>" ~ preview_link : "PLUGIN_ADMIN.CREATE"|tu ~ " <i>#{context.menu}</i>" }}
</h1>
{% else %}
<h1><i class="fa fa-fw fa-file-text-o"></i> {{ "PLUGIN_ADMIN.MANAGE_PAGES"|tu }}</h1>