2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

FEATURE: split JavaScript application bundle, so plugins live in own file

This adds plugin.js and plugin_third_party.js files
This commit is contained in:
Sam 2016-11-15 11:42:55 +11:00
parent 67edb6ce5c
commit f4c754b389
11 changed files with 141 additions and 23 deletions

View file

@ -393,6 +393,37 @@ JS
end
end
def handlebars_includes
assets.map do |asset, opts|
next if opts == :admin
next unless asset =~ DiscoursePluginRegistry::HANDLEBARS_REGEX
asset
end.compact
end
def javascript_includes
assets.map do |asset, opts|
next if opts == :admin
next unless asset =~ DiscoursePluginRegistry::JS_REGEX
asset
end.compact
end
def each_globbed_asset
if @path
# Automatically include all ES6 JS and hbs files
root_path = "#{File.dirname(@path)}/assets/javascripts"
Dir.glob("#{root_path}/**/*") do |f|
if File.directory?(f)
yield [f,true]
elsif f.to_s.ends_with?(".js.es6") || f.to_s.ends_with?(".hbs")
yield [f,false]
end
end
end
end
protected
def register_assets!

View file

@ -2,8 +2,34 @@
module Plugin; end
class Plugin::Metadata
OFFICIAL_PLUGINS = Set.new([
"customer-flair",
"discourse-adplugin",
"discourse-akismet",
"discourse-backup-uploads-to-s3",
"discourse-cakeday",
"Canned Replies",
"discourse-data-explorer",
"discourse-details",
"discourse-nginx-performance-report",
"discourse-push-notifications",
"discourse-slack-official",
"discourse-solved",
"Spoiler Alert!",
"staff-notes",
"GitHub badges",
"hosted-site",
"lazyYT",
"logster-rate-limit-checker",
"poll",
"discourse-plugin-linkedin-auth",
"discourse-plugin-office365-auth",
"discourse-oauth2-basic"
])
FIELDS ||= [:name, :about, :version, :authors, :url, :required_version]
attr_accessor *FIELDS
attr_accessor(*FIELDS)
def self.parse(text)
metadata = self.new
@ -13,6 +39,10 @@ class Plugin::Metadata
metadata
end
def official?
OFFICIAL_PLUGINS.include?(name)
end
def parse_line(line)
line = line.strip