mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
Allow plugins to specify a minimum requires version
This commit is contained in:
parent
6af71bd601
commit
de42c627c5
6 changed files with 85 additions and 11 deletions
|
@ -31,13 +31,6 @@ class Plugin::Instance
|
|||
def initialize(metadata=nil, path=nil)
|
||||
@metadata = metadata
|
||||
@path = path
|
||||
|
||||
if @path
|
||||
# Automatically include all ES6 JS and hbs files
|
||||
root_path = "#{File.dirname(@path)}/assets/javascripts"
|
||||
DiscoursePluginRegistry.register_glob(root_path, 'js.es6')
|
||||
DiscoursePluginRegistry.register_glob(root_path, 'hbs')
|
||||
end
|
||||
end
|
||||
|
||||
def add_admin_route(label, location)
|
||||
|
@ -216,6 +209,14 @@ class Plugin::Instance
|
|||
# this allows us to present information about a plugin in the UI
|
||||
# prior to activations
|
||||
def activate!
|
||||
|
||||
if @path
|
||||
# Automatically include all ES6 JS and hbs files
|
||||
root_path = "#{File.dirname(@path)}/assets/javascripts"
|
||||
DiscoursePluginRegistry.register_glob(root_path, 'js.es6')
|
||||
DiscoursePluginRegistry.register_glob(root_path, 'hbs')
|
||||
end
|
||||
|
||||
self.instance_eval File.read(path), path
|
||||
if auto_assets = generate_automatic_assets!
|
||||
assets.concat auto_assets.map{|a| [a]}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
module Plugin; end
|
||||
|
||||
class Plugin::Metadata
|
||||
FIELDS ||= [:name, :about, :version, :authors, :url]
|
||||
FIELDS ||= [:name, :about, :version, :authors, :url, :required_version]
|
||||
attr_accessor *FIELDS
|
||||
|
||||
def self.parse(text)
|
||||
|
@ -21,7 +21,7 @@ class Plugin::Metadata
|
|||
attribute, *description = line[1..-1].split(":")
|
||||
|
||||
description = description.join(":")
|
||||
attribute = attribute.strip.to_sym
|
||||
attribute = attribute.strip.gsub(/ /, '_').to_sym
|
||||
|
||||
if FIELDS.include?(attribute)
|
||||
self.send("#{attribute}=", description.strip)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue