mirror of
https://github.com/discourse/discourse.git
synced 2025-06-13 01:46:29 +08:00
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:
@ -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.S3CDN = setupData.s3Cdn;
|
||||||
Discourse.S3BaseUrl = setupData.s3BaseUrl;
|
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' %>
|
<%= build_plugin_html 'server:before-head-close' %>
|
||||||
|
|
||||||
<%= tag.meta id: 'data-discourse-setup', data: client_side_setup_data %>
|
<%= 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>
|
</head>
|
||||||
|
|
||||||
<body class="<%= body_classes %>">
|
<body class="<%= body_classes %>">
|
||||||
@ -106,7 +111,7 @@
|
|||||||
|
|
||||||
<%= yield :data %>
|
<%= yield :data %>
|
||||||
|
|
||||||
<%= render :partial => "common/discourse_javascript" %>
|
<%= preload_script 'browser-update' %>
|
||||||
|
|
||||||
<%- unless customization_disabled? %>
|
<%- unless customization_disabled? %>
|
||||||
<%= raw theme_lookup("body_tag") %>
|
<%= raw theme_lookup("body_tag") %>
|
||||||
|
@ -120,6 +120,7 @@ module Discourse
|
|||||||
google-tag-manager.js
|
google-tag-manager.js
|
||||||
google-universal-analytics.js
|
google-universal-analytics.js
|
||||||
preload-application-data.js
|
preload-application-data.js
|
||||||
|
authentication-complete.js
|
||||||
}
|
}
|
||||||
|
|
||||||
# Precompile all available locales
|
# Precompile all available locales
|
||||||
|
Reference in New Issue
Block a user