UX: Support for custom error pages and headers in plugins
This commit is contained in:
parent
1c56e1c063
commit
d07ebf9d4c
|
@ -356,6 +356,11 @@ module ApplicationHelper
|
|||
DiscoursePluginRegistry.build_html(name, controller) || ""
|
||||
end
|
||||
|
||||
# If there is plugin HTML return that, otherwise yield to the template
|
||||
def replace_plugin_html(name)
|
||||
build_plugin_html(name).presence || yield
|
||||
end
|
||||
|
||||
def theme_lookup(name)
|
||||
lookup = Theme.lookup_field(theme_key, mobile_view? ? :mobile : :desktop, name)
|
||||
lookup.html_safe if lookup
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
<header class="d-header">
|
||||
<div class="wrap">
|
||||
<div class="contents">
|
||||
<div class="row">
|
||||
<div class="title span13">
|
||||
<a href="<%= path "/" %>">
|
||||
<%- if application_logo_url.present? %>
|
||||
<img src="<%= application_logo_url %>" alt="<%= SiteSetting.title %>" id="site-logo">
|
||||
<%- else %>
|
||||
<h2 id='site-text-logo'><%= SiteSetting.title %></h2>
|
||||
<%- end %>
|
||||
</a>
|
||||
<%= replace_plugin_html('server:simple-header') do %>
|
||||
<header class="d-header">
|
||||
<div class="wrap">
|
||||
<div class="contents">
|
||||
<div class="row">
|
||||
<div class="title span13">
|
||||
<a href="<%= path "/" %>">
|
||||
<%- if application_logo_url.present? %>
|
||||
<img src="<%= application_logo_url %>" alt="<%= SiteSetting.title %>" id="site-logo">
|
||||
<%- else %>
|
||||
<h2 id='site-text-logo'><%= SiteSetting.title %></h2>
|
||||
<%- end %>
|
||||
</a>
|
||||
</div>
|
||||
<% unless current_user %>
|
||||
<div class='panel clearfix'>
|
||||
<a href="<%= path "/login"%>" class='btn btn-primary btn-small login-button'><i class="fa fa-user"></i> <%= I18n.t('log_in') %></a>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% unless current_user %>
|
||||
<div class='panel clearfix'>
|
||||
<a href="<%= path "/login"%>" class='btn btn-primary btn-small login-button'><i class="fa fa-user"></i> <%= I18n.t('log_in') %></a>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
</header>
|
||||
<% end %>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<h1 class="page-not-found"><%= t 'page_not_found.title' %></h1>
|
||||
|
||||
<%= raw build_plugin_html 'server:not-found-before-topics' %>
|
||||
<%= build_plugin_html 'server:not-found-before-topics' %>
|
||||
|
||||
<% unless SiteSetting.login_required? && current_user.nil? %>
|
||||
<div class="row page-not-found-topics">
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
<%= yield :head %>
|
||||
|
||||
<%= raw build_plugin_html 'server:before-head-close' %>
|
||||
<%= build_plugin_html 'server:before-head-close' %>
|
||||
</head>
|
||||
|
||||
<body class="<%= body_classes %>">
|
||||
|
@ -88,7 +88,7 @@
|
|||
|
||||
<%- unless customization_disabled? || loading_admin? %>
|
||||
<%= theme_lookup("header") %>
|
||||
<%= raw build_plugin_html 'server:header' %>
|
||||
<%= build_plugin_html 'server:header' %>
|
||||
<%- end %>
|
||||
|
||||
<section id='main'>
|
||||
|
@ -124,6 +124,6 @@
|
|||
<%- unless customization_disabled? %>
|
||||
<%= raw theme_lookup("body_tag") %>
|
||||
<%- end %>
|
||||
<%= raw build_plugin_html 'server:before-body-close' %>
|
||||
<%= build_plugin_html 'server:before-body-close' %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
|
||||
<%= theme_lookup("head_tag") %>
|
||||
<%= yield(:no_ember_head) %>
|
||||
<%= raw build_plugin_html 'server:before-head-close' %>
|
||||
<%= build_plugin_html 'server:before-head-close' %>
|
||||
</head>
|
||||
<body <% if @custom_body_class %>class="<%= @custom_body_class %>"<% end %>>
|
||||
<%= theme_lookup("header") %>
|
||||
<%= raw build_plugin_html 'server:header' %>
|
||||
<%= build_plugin_html 'server:header' %>
|
||||
<section id='main'>
|
||||
<%= render partial: 'header' %>
|
||||
<div id="main-outlet" class="<%= @container_class ? @container_class : 'wrap' %>">
|
||||
|
@ -23,7 +23,7 @@
|
|||
</div>
|
||||
</section>
|
||||
<%= theme_lookup("footer") %>
|
||||
<%= raw build_plugin_html 'no-client:footer' %>
|
||||
<%= raw build_plugin_html 'server:before-body-close' %>
|
||||
<%= build_plugin_html 'no-client:footer' %>
|
||||
<%= build_plugin_html 'server:before-body-close' %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -143,7 +143,7 @@ class DiscoursePluginRegistry
|
|||
|
||||
def self.build_html(name, ctx = nil)
|
||||
builders = html_builders[name] || []
|
||||
builders.map { |b| b.call(ctx) }.join("\n")
|
||||
builders.map { |b| b.call(ctx) }.join("\n").html_safe
|
||||
end
|
||||
|
||||
def javascripts
|
||||
|
|
Loading…
Reference in New Issue