mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 05:33:40 +08:00
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) || ""
|
DiscoursePluginRegistry.build_html(name, controller) || ""
|
||||||
end
|
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)
|
def theme_lookup(name)
|
||||||
lookup = Theme.lookup_field(theme_key, mobile_view? ? :mobile : :desktop, name)
|
lookup = Theme.lookup_field(theme_key, mobile_view? ? :mobile : :desktop, name)
|
||||||
lookup.html_safe if lookup
|
lookup.html_safe if lookup
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<%= replace_plugin_html('server:simple-header') do %>
|
||||||
<header class="d-header">
|
<header class="d-header">
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<div class="contents">
|
<div class="contents">
|
||||||
|
@ -20,3 +21,4 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<h1 class="page-not-found"><%= t 'page_not_found.title' %></h1>
|
<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? %>
|
<% unless SiteSetting.login_required? && current_user.nil? %>
|
||||||
<div class="row page-not-found-topics">
|
<div class="row page-not-found-topics">
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
|
|
||||||
<%= yield :head %>
|
<%= yield :head %>
|
||||||
|
|
||||||
<%= raw build_plugin_html 'server:before-head-close' %>
|
<%= build_plugin_html 'server:before-head-close' %>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="<%= body_classes %>">
|
<body class="<%= body_classes %>">
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
|
|
||||||
<%- unless customization_disabled? || loading_admin? %>
|
<%- unless customization_disabled? || loading_admin? %>
|
||||||
<%= theme_lookup("header") %>
|
<%= theme_lookup("header") %>
|
||||||
<%= raw build_plugin_html 'server:header' %>
|
<%= build_plugin_html 'server:header' %>
|
||||||
<%- end %>
|
<%- end %>
|
||||||
|
|
||||||
<section id='main'>
|
<section id='main'>
|
||||||
|
@ -124,6 +124,6 @@
|
||||||
<%- unless customization_disabled? %>
|
<%- unless customization_disabled? %>
|
||||||
<%= raw theme_lookup("body_tag") %>
|
<%= raw theme_lookup("body_tag") %>
|
||||||
<%- end %>
|
<%- end %>
|
||||||
<%= raw build_plugin_html 'server:before-body-close' %>
|
<%= build_plugin_html 'server:before-body-close' %>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
|
|
||||||
<%= theme_lookup("head_tag") %>
|
<%= theme_lookup("head_tag") %>
|
||||||
<%= yield(:no_ember_head) %>
|
<%= yield(:no_ember_head) %>
|
||||||
<%= raw build_plugin_html 'server:before-head-close' %>
|
<%= build_plugin_html 'server:before-head-close' %>
|
||||||
</head>
|
</head>
|
||||||
<body <% if @custom_body_class %>class="<%= @custom_body_class %>"<% end %>>
|
<body <% if @custom_body_class %>class="<%= @custom_body_class %>"<% end %>>
|
||||||
<%= theme_lookup("header") %>
|
<%= theme_lookup("header") %>
|
||||||
<%= raw build_plugin_html 'server:header' %>
|
<%= build_plugin_html 'server:header' %>
|
||||||
<section id='main'>
|
<section id='main'>
|
||||||
<%= render partial: 'header' %>
|
<%= render partial: 'header' %>
|
||||||
<div id="main-outlet" class="<%= @container_class ? @container_class : 'wrap' %>">
|
<div id="main-outlet" class="<%= @container_class ? @container_class : 'wrap' %>">
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<%= theme_lookup("footer") %>
|
<%= theme_lookup("footer") %>
|
||||||
<%= raw build_plugin_html 'no-client:footer' %>
|
<%= build_plugin_html 'no-client:footer' %>
|
||||||
<%= raw build_plugin_html 'server:before-body-close' %>
|
<%= build_plugin_html 'server:before-body-close' %>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -143,7 +143,7 @@ class DiscoursePluginRegistry
|
||||||
|
|
||||||
def self.build_html(name, ctx = nil)
|
def self.build_html(name, ctx = nil)
|
||||||
builders = html_builders[name] || []
|
builders = html_builders[name] || []
|
||||||
builders.map { |b| b.call(ctx) }.join("\n")
|
builders.map { |b| b.call(ctx) }.join("\n").html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def javascripts
|
def javascripts
|
||||||
|
|
Loading…
Reference in New Issue
Block a user