mirror of
https://github.com/discourse/discourse.git
synced 2025-02-17 07:32:44 +08:00
Revert plugin js changes (#5139)
* Revert "Add disabled_plugins to preloadstore for login_required anonymous users (#5134)" This reverts commitb840170f8d
. * Revert "Do not load javascripts for disabled plugins (#5103)" This reverts commita14ab48829
.
This commit is contained in:
parent
a0daa7cad0
commit
7d350d0d75
|
@ -1,9 +1,7 @@
|
||||||
import { buildResolver } from 'discourse-common/resolver';
|
import { buildResolver } from 'discourse-common/resolver';
|
||||||
import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
|
import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
|
||||||
import PreloadStore from 'preload-store';
|
|
||||||
|
|
||||||
const _pluginCallbacks = [];
|
const _pluginCallbacks = [];
|
||||||
const _pluginDefinitions = {};
|
|
||||||
|
|
||||||
const Discourse = Ember.Application.extend({
|
const Discourse = Ember.Application.extend({
|
||||||
rootElement: '#main',
|
rootElement: '#main',
|
||||||
|
@ -103,16 +101,6 @@ const Discourse = Ember.Application.extend({
|
||||||
|
|
||||||
$('noscript').remove();
|
$('noscript').remove();
|
||||||
|
|
||||||
// Load plugin definions.
|
|
||||||
const disabledPlugins = PreloadStore.get('site').disabled_plugins;
|
|
||||||
Object.keys(_pluginDefinitions).forEach((key) => {
|
|
||||||
if(!(disabledPlugins.includes(key))){ // Not disabled, so load it
|
|
||||||
_pluginDefinitions[key].forEach((func) => {
|
|
||||||
func();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.keys(requirejs._eak_seen).forEach(function(key) {
|
Object.keys(requirejs._eak_seen).forEach(function(key) {
|
||||||
if (/\/pre\-initializers\//.test(key)) {
|
if (/\/pre\-initializers\//.test(key)) {
|
||||||
const module = requirejs(key, null, null, true);
|
const module = requirejs(key, null, null, true);
|
||||||
|
@ -166,13 +154,6 @@ const Discourse = Ember.Application.extend({
|
||||||
_pluginCallbacks.push({ version, code });
|
_pluginCallbacks.push({ version, code });
|
||||||
},
|
},
|
||||||
|
|
||||||
_registerPluginScriptDefinition(pluginName, definition) {
|
|
||||||
if(!(pluginName in _pluginDefinitions)){
|
|
||||||
_pluginDefinitions[pluginName] = [];
|
|
||||||
}
|
|
||||||
_pluginDefinitions[pluginName].push(definition);
|
|
||||||
},
|
|
||||||
|
|
||||||
assetVersion: Ember.computed({
|
assetVersion: Ember.computed({
|
||||||
get() {
|
get() {
|
||||||
return this.get("currentAssetVersion");
|
return this.get("currentAssetVersion");
|
||||||
|
|
|
@ -87,8 +87,7 @@ class Site
|
||||||
filters: Discourse.filters.map(&:to_s),
|
filters: Discourse.filters.map(&:to_s),
|
||||||
user_fields: UserField.all.map do |userfield|
|
user_fields: UserField.all.map do |userfield|
|
||||||
UserFieldSerializer.new(userfield, root: false, scope: guardian)
|
UserFieldSerializer.new(userfield, root: false, scope: guardian)
|
||||||
end,
|
end
|
||||||
disabled_plugins: Discourse.disabled_plugin_names
|
|
||||||
}.to_json
|
}.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
require 'discourse_wrap_plugin_js'
|
|
||||||
|
|
||||||
Rails.application.config.assets.configure do |env|
|
|
||||||
env.register_preprocessor('application/javascript', DiscourseWrapPluginJS)
|
|
||||||
end
|
|
|
@ -1,31 +0,0 @@
|
||||||
class DiscourseWrapPluginJS
|
|
||||||
def initialize(options = {}, &block)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.instance
|
|
||||||
@instance ||= new
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.call(input)
|
|
||||||
instance.call(input)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Add stuff around javascript
|
|
||||||
def call(input)
|
|
||||||
path = input[:environment].context_class.new(input).pathname.to_s
|
|
||||||
data = input[:data]
|
|
||||||
|
|
||||||
# Only apply to plugin paths
|
|
||||||
return data unless (path =~ /\/plugins\//)
|
|
||||||
|
|
||||||
# Find the folder name of the plugin
|
|
||||||
folder_name = path[/\/plugins\/(\S+?)\//, 1]
|
|
||||||
|
|
||||||
# Lookup plugin name
|
|
||||||
plugin = Discourse.plugins.find { |p| p.path =~ /\/plugins\/#{folder_name}\// }
|
|
||||||
plugin_name = plugin.name
|
|
||||||
|
|
||||||
"Discourse._registerPluginScriptDefinition('#{plugin_name}', function(){#{data}}); \n"
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
Loading…
Reference in New Issue
Block a user