mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
Better error messages when embedding fails
This commit is contained in:
@ -116,17 +116,33 @@ img.emoji {
|
|||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.clearfix {
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
header.discourse {
|
header.discourse {
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
padding-bottom: 8px;
|
padding-bottom: 8px;
|
||||||
font-size: 1.286em;
|
font-size: 1.286em;
|
||||||
border-bottom: 3px solid #ddd;
|
border-bottom: 3px solid #ddd;
|
||||||
|
|
||||||
.button {
|
display: flex;
|
||||||
float:right;
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
margin: 0 auto 0 0;
|
||||||
|
font-size: 1.0em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.embed-error {
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
font-size: 1.286em;
|
font-size: 1.286em;
|
||||||
margin-top: 0.5em;
|
margin-top: 0.5em;
|
||||||
|
@ -6,6 +6,16 @@ class EmbedController < ApplicationController
|
|||||||
|
|
||||||
layout 'embed'
|
layout 'embed'
|
||||||
|
|
||||||
|
rescue_from Discourse::InvalidAccess do
|
||||||
|
response.headers['X-Frame-Options'] = "ALLOWALL"
|
||||||
|
if current_user.try(:admin?)
|
||||||
|
@setup_url = "#{Discourse.base_url}/admin/customize/embedding"
|
||||||
|
@show_reason = true
|
||||||
|
@hosts = EmbeddableHost.all
|
||||||
|
end
|
||||||
|
render 'embed_error'
|
||||||
|
end
|
||||||
|
|
||||||
def comments
|
def comments
|
||||||
embed_url = params[:embed_url]
|
embed_url = params[:embed_url]
|
||||||
embed_username = params[:discourse_username]
|
embed_username = params[:discourse_username]
|
||||||
|
25
app/views/embed/embed_error.html.erb
Normal file
25
app/views/embed/embed_error.html.erb
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<header class='discourse'>
|
||||||
|
<h3><%= t 'embed.error' %></h3>
|
||||||
|
<%= link_to(image_tag(SiteSetting.logo_url, class: 'logo'), Discourse.base_url) %>
|
||||||
|
<div class='clearfix'></div>
|
||||||
|
</header>
|
||||||
|
<%- if @show_reason %>
|
||||||
|
<div class='embed-error'>
|
||||||
|
<%- if @hosts.present? %>
|
||||||
|
<p><%= t 'embed.referer' %><code><%= request.referer %></code></p>
|
||||||
|
<p><%= t 'embed.mismatch' %></p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<%- @hosts.each do |eh| %>
|
||||||
|
<li>
|
||||||
|
<%= eh.host %><%- if eh.path_whitelist.present? %><%= eh.path_whitelist %><% end %>
|
||||||
|
</li>
|
||||||
|
<%- end %>
|
||||||
|
</ul>
|
||||||
|
<%- else %>
|
||||||
|
<p><%= t 'embed.no_hosts' %></p>
|
||||||
|
<%- end %>
|
||||||
|
|
||||||
|
<p><%= link_to(t('embed.configure'), @setup_url, target: '_blank') %></p>
|
||||||
|
</div>
|
||||||
|
<%- end %>
|
@ -1,12 +1,12 @@
|
|||||||
<header>
|
<header class='discourse'>
|
||||||
<%= t 'embed.loading' %>
|
<h3><%= t 'embed.loading' %></h3>
|
||||||
<%= link_to(image_tag(SiteSetting.logo_url, class: 'logo'), Discourse.base_url) %>
|
<%= link_to(image_tag(SiteSetting.logo_url, class: 'logo'), Discourse.base_url) %>
|
||||||
|
<div class='clearfix'></div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function() {
|
(function() {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
document.location.reload();
|
document.location.reload();
|
||||||
}, 30000);
|
}, 30000);
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
@ -158,6 +158,11 @@ en:
|
|||||||
embed:
|
embed:
|
||||||
start_discussion: "Start Discussion"
|
start_discussion: "Start Discussion"
|
||||||
continue: "Continue Discussion"
|
continue: "Continue Discussion"
|
||||||
|
error: "Error Embedding"
|
||||||
|
referer: "Referer:"
|
||||||
|
mismatch: "The referer did not match any of the following hosts:"
|
||||||
|
no_hosts: "No hosts were set up for embedding."
|
||||||
|
configure: "Configure Embedding"
|
||||||
more_replies:
|
more_replies:
|
||||||
one: "1 more reply"
|
one: "1 more reply"
|
||||||
other: "%{count} more replies"
|
other: "%{count} more replies"
|
||||||
|
Reference in New Issue
Block a user