2013-08-23 01:21:52 -05:00
|
|
|
# loaded really early
|
|
|
|
module Plugin; end
|
|
|
|
|
|
|
|
class Plugin::Metadata
|
2016-11-14 18:42:55 -06:00
|
|
|
|
2017-08-11 21:18:04 -05:00
|
|
|
OFFICIAL_PLUGINS ||= Set.new([
|
2016-11-14 18:42:55 -06:00
|
|
|
"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",
|
2017-10-23 20:44:11 -05:00
|
|
|
"discourse-chat-integration",
|
2016-11-14 18:42:55 -06:00
|
|
|
"discourse-solved",
|
|
|
|
"Spoiler Alert!",
|
|
|
|
"staff-notes",
|
|
|
|
"GitHub badges",
|
|
|
|
"lazyYT",
|
|
|
|
"logster-rate-limit-checker",
|
|
|
|
"poll",
|
|
|
|
"discourse-plugin-linkedin-auth",
|
|
|
|
"discourse-plugin-office365-auth",
|
2017-07-18 11:09:27 -05:00
|
|
|
"discourse-oauth2-basic",
|
|
|
|
"discourse-math",
|
|
|
|
"discourse-bbcode-color",
|
|
|
|
"discourse-bbcode",
|
|
|
|
"discourse-affiliate",
|
|
|
|
"discourse-translator",
|
2017-10-23 18:27:10 -05:00
|
|
|
"discourse-patreon",
|
2018-03-06 07:45:37 -06:00
|
|
|
"discourse-prometheus",
|
2018-04-05 21:54:58 -05:00
|
|
|
"discourse-assign",
|
|
|
|
"discourse-narrative-bot",
|
2018-04-22 20:26:13 -05:00
|
|
|
"discourse-presence",
|
|
|
|
"discourse-staff-notes",
|
2018-04-25 00:02:33 -05:00
|
|
|
"discourse-voting",
|
2018-04-25 04:58:39 -05:00
|
|
|
"docker_manager",
|
|
|
|
"discourse-signatures"
|
2016-11-14 18:42:55 -06:00
|
|
|
])
|
|
|
|
|
2015-04-27 12:06:53 -05:00
|
|
|
FIELDS ||= [:name, :about, :version, :authors, :url, :required_version]
|
2016-11-14 18:42:55 -06:00
|
|
|
attr_accessor(*FIELDS)
|
2013-08-23 01:21:52 -05:00
|
|
|
|
|
|
|
def self.parse(text)
|
|
|
|
metadata = self.new
|
|
|
|
text.each_line do |line|
|
|
|
|
break unless metadata.parse_line(line)
|
|
|
|
end
|
|
|
|
metadata
|
|
|
|
end
|
|
|
|
|
2016-11-14 18:42:55 -06:00
|
|
|
def official?
|
|
|
|
OFFICIAL_PLUGINS.include?(name)
|
|
|
|
end
|
|
|
|
|
2013-08-23 01:21:52 -05:00
|
|
|
def parse_line(line)
|
|
|
|
line = line.strip
|
|
|
|
|
|
|
|
unless line.empty?
|
|
|
|
return false unless line[0] == "#"
|
|
|
|
attribute, *description = line[1..-1].split(":")
|
|
|
|
|
|
|
|
description = description.join(":")
|
2015-04-27 12:06:53 -05:00
|
|
|
attribute = attribute.strip.gsub(/ /, '_').to_sym
|
2013-08-23 01:21:52 -05:00
|
|
|
|
|
|
|
if FIELDS.include?(attribute)
|
|
|
|
self.send("#{attribute}=", description.strip)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|