Extract `discourse_javascript.html.erb` to a scrip include
* extract omniauth auth complete inline JS * extract Ember error logging inline JS * transpile `authentication-complete` This is CSP related work
This commit is contained in:
parent
1c9b5e75e7
commit
acba7d2a5d
|
@ -0,0 +1,17 @@
|
|||
(function() {
|
||||
const authenticationData = JSON.parse(
|
||||
document.getElementById("data-authentication").dataset.authenticationData
|
||||
);
|
||||
|
||||
Discourse.showingSignup = true;
|
||||
require("discourse/routes/application").default.reopen({
|
||||
actions: {
|
||||
didTransition: function() {
|
||||
Em.run.next(function() {
|
||||
Discourse.authenticationComplete(authenticationData);
|
||||
});
|
||||
return this._super();
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
|
@ -39,4 +39,26 @@
|
|||
Discourse.S3CDN = setupData.s3Cdn;
|
||||
Discourse.S3BaseUrl = setupData.s3BaseUrl;
|
||||
}
|
||||
|
||||
Ember.RSVP.configure("onerror", function(e) {
|
||||
// Ignore TransitionAborted exceptions that bubble up
|
||||
if (e && e.message === "TransitionAborted") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Discourse.Environment === "development") {
|
||||
if (e) {
|
||||
if (e.message || e.stack) {
|
||||
console.log(e.message);
|
||||
console.log(e.stack);
|
||||
} else {
|
||||
console.log("Uncaught promise: ", e);
|
||||
}
|
||||
} else {
|
||||
console.log("A promise failed but was not caught.");
|
||||
}
|
||||
}
|
||||
|
||||
window.onerror(e && e.message, null, null, null, e);
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
<script>
|
||||
Ember.RSVP.configure('onerror', function(e) {
|
||||
// Ignore TransitionAborted exceptions that bubble up
|
||||
if (e && e.message === "TransitionAborted") { return; }
|
||||
|
||||
<% if Rails.env.development? %>
|
||||
if (e) {
|
||||
if (e.message || e.stack) {
|
||||
console.log(e.message);
|
||||
console.log(e.stack);
|
||||
} else {
|
||||
console.log("Uncaught promise: ", e);
|
||||
}
|
||||
} else {
|
||||
console.log("A promise failed but was not caught.");
|
||||
}
|
||||
<% end %>
|
||||
window.onerror(e && e.message, null,null,null,e);
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
<%- if !current_user && flash[:authentication_data] %>
|
||||
Discourse.showingSignup = true
|
||||
require('discourse/routes/application').default.reopen({
|
||||
actions: {
|
||||
didTransition: function() {
|
||||
Em.run.next(function(){
|
||||
Discourse.authenticationComplete(<%=flash[:authentication_data].html_safe%>);
|
||||
});
|
||||
return this._super();
|
||||
}
|
||||
}
|
||||
});
|
||||
<%- end %>
|
||||
</script>
|
||||
|
||||
<%= preload_script 'browser-update' %>
|
|
@ -55,6 +55,11 @@
|
|||
<%= build_plugin_html 'server:before-head-close' %>
|
||||
|
||||
<%= tag.meta id: 'data-discourse-setup', data: client_side_setup_data %>
|
||||
|
||||
<%- if !current_user && flash[:authentication_data] %>
|
||||
<meta id="data-authentication" data-authentiation-data="<%= flash[:authentication_data] %>">
|
||||
<%= preload_script "authentication-complete" %>
|
||||
<%- end %>
|
||||
</head>
|
||||
|
||||
<body class="<%= body_classes %>">
|
||||
|
@ -106,7 +111,7 @@
|
|||
|
||||
<%= yield :data %>
|
||||
|
||||
<%= render :partial => "common/discourse_javascript" %>
|
||||
<%= preload_script 'browser-update' %>
|
||||
|
||||
<%- unless customization_disabled? %>
|
||||
<%= raw theme_lookup("body_tag") %>
|
||||
|
|
|
@ -120,6 +120,7 @@ module Discourse
|
|||
google-tag-manager.js
|
||||
google-universal-analytics.js
|
||||
preload-application-data.js
|
||||
authentication-complete.js
|
||||
}
|
||||
|
||||
# Precompile all available locales
|
||||
|
|
Loading…
Reference in New Issue