mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
Plugins: Prefix discourse/plugins/PLUGINNAME
for plugin export names.
This commit is contained in:
parent
57c970b692
commit
ba8b45792c
5 changed files with 11 additions and 65 deletions
|
@ -11,20 +11,6 @@ module ES6ModuleTranspiler
|
||||||
@compile_to = target
|
@compile_to = target
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.prefix_patterns
|
|
||||||
@prefix_patterns ||= []
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.add_prefix_pattern(pattern, prefix)
|
|
||||||
prefix_patterns << [pattern, prefix]
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.lookup_prefix(path)
|
|
||||||
_, prefix = prefix_patterns.detect {|pattern, prefix| pattern =~ path }
|
|
||||||
|
|
||||||
prefix
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.transform=(transform)
|
def self.transform=(transform)
|
||||||
@transform = transform
|
@transform = transform
|
||||||
end
|
end
|
||||||
|
|
|
@ -83,13 +83,17 @@ module Tilt
|
||||||
end
|
end
|
||||||
|
|
||||||
def module_name(root_path, logical_path)
|
def module_name(root_path, logical_path)
|
||||||
path = ''
|
path = nil
|
||||||
if prefix = ES6ModuleTranspiler.lookup_prefix(File.join(root_path, logical_path))
|
|
||||||
path = File.join(prefix, logical_path)
|
# If the resource is a plugin, use the plugin name as a prefix
|
||||||
else
|
if root_path =~ /(.*\/discourse\/plugins\/[^\/]+)\//
|
||||||
path = logical_path
|
plugin_path = "#{Regexp.last_match[1]}/plugin.rb"
|
||||||
|
|
||||||
|
plugin = Discourse.plugins.find {|p| p.path == plugin_path }
|
||||||
|
path = "discourse/plugins/#{plugin.name}/#{logical_path.sub(/javascripts\//, '')}" if plugin
|
||||||
end
|
end
|
||||||
|
|
||||||
|
path ||= logical_path
|
||||||
if ES6ModuleTranspiler.transform
|
if ES6ModuleTranspiler.transform
|
||||||
path = ES6ModuleTranspiler.transform.call(path)
|
path = ES6ModuleTranspiler.transform.call(path)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
export default Discourse.Controller.extend({
|
|
||||||
poll: null,
|
|
||||||
showResults: Em.computed.oneWay('poll.closed'),
|
|
||||||
disableRadio: Em.computed.any('poll.closed', 'loading'),
|
|
||||||
showToggleClosePoll: function() {
|
|
||||||
return this.get('poll.post.topic.details.can_edit') && !Discourse.SiteSettings.allow_user_locale;
|
|
||||||
}.property('poll.post.topic.details.can_edit'),
|
|
||||||
|
|
||||||
actions: {
|
|
||||||
selectOption: function(option) {
|
|
||||||
if (this.get('disableRadio')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.get('currentUser.id')) {
|
|
||||||
this.get('postController').send('showLogin');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.set('loading', true);
|
|
||||||
this.get('poll').saveVote(option).then(function() {
|
|
||||||
this.set('loading', false);
|
|
||||||
this.set('showResults', true);
|
|
||||||
}.bind(this));
|
|
||||||
},
|
|
||||||
|
|
||||||
toggleShowResults: function() {
|
|
||||||
this.set('showResults', !this.get('showResults'));
|
|
||||||
},
|
|
||||||
|
|
||||||
toggleClosePoll: function() {
|
|
||||||
this.set('loading', true);
|
|
||||||
return Discourse.ajax("/poll/toggle_close", {
|
|
||||||
type: "PUT",
|
|
||||||
data: {post_id: this.get('poll.post.id')}
|
|
||||||
}).then(function(topicJson) {
|
|
||||||
this.set('poll.post.topic.title', topicJson.basic_topic.title);
|
|
||||||
this.set('poll.post.topic.fancy_title', topicJson.basic_topic.title);
|
|
||||||
this.set('loading', false);
|
|
||||||
}.bind(this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ var Poll = Discourse.Model.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var PollController = require("javascripts/poll-controller").default;
|
var PollController = require("discourse/plugins/poll/controllers/poll").default;
|
||||||
|
|
||||||
var PollView = Ember.View.extend({
|
var PollView = Ember.View.extend({
|
||||||
templateName: "poll",
|
templateName: "poll",
|
||||||
|
|
|
@ -142,7 +142,7 @@ after_initialize do
|
||||||
end
|
end
|
||||||
|
|
||||||
# Poll UI.
|
# Poll UI.
|
||||||
register_asset "javascripts/poll-controller.js.es6"
|
register_asset "javascripts/controllers/poll.js.es6"
|
||||||
register_asset "javascripts/discourse/templates/poll.js.handlebars"
|
register_asset "javascripts/discourse/templates/poll.js.handlebars"
|
||||||
register_asset "javascripts/poll_ui.js"
|
register_asset "javascripts/poll_ui.js"
|
||||||
register_asset "javascripts/poll_bbcode.js", :server_side
|
register_asset "javascripts/poll_bbcode.js", :server_side
|
||||||
|
|
Loading…
Reference in a new issue