2013-08-23 14:21:52 +08:00
|
|
|
# loaded really early
|
|
|
|
module Plugin; end
|
|
|
|
|
|
|
|
class Plugin::Metadata
|
2016-11-15 08:42:55 +08:00
|
|
|
|
2017-08-12 10:18:04 +08:00
|
|
|
OFFICIAL_PLUGINS ||= Set.new([
|
2016-11-15 08:42:55 +08: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-24 09:44:11 +08:00
|
|
|
"discourse-chat-integration",
|
2016-11-15 08:42:55 +08: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-19 00:09:27 +08:00
|
|
|
"discourse-oauth2-basic",
|
|
|
|
"discourse-math",
|
|
|
|
"discourse-bbcode-color",
|
2018-05-20 08:03:49 +08:00
|
|
|
"discourse-bbcode",
|
2017-07-19 00:09:27 +08:00
|
|
|
"discourse-affiliate",
|
|
|
|
"discourse-translator",
|
2017-10-24 07:27:10 +08:00
|
|
|
"discourse-patreon",
|
2018-03-06 21:45:37 +08:00
|
|
|
"discourse-prometheus",
|
2018-04-06 10:54:58 +08:00
|
|
|
"discourse-assign",
|
|
|
|
"discourse-narrative-bot",
|
2018-04-23 09:26:13 +08:00
|
|
|
"discourse-presence",
|
|
|
|
"discourse-staff-notes",
|
2018-04-25 13:02:33 +08:00
|
|
|
"discourse-voting",
|
2018-04-25 17:58:39 +08:00
|
|
|
"docker_manager",
|
2018-04-26 10:31:53 +08:00
|
|
|
"discourse-signatures",
|
2018-05-04 14:11:33 +08:00
|
|
|
"discourse-local-dates",
|
2018-04-26 10:31:53 +08:00
|
|
|
"discourse-crowd",
|
|
|
|
"discourse-footnote",
|
|
|
|
"discourse-gradle-issue",
|
|
|
|
"discourse-no-bump",
|
|
|
|
"discourse-moderator-attention",
|
|
|
|
"discourse-sitemap",
|
|
|
|
"discourse-tooltips",
|
|
|
|
"discourse-styleguide",
|
|
|
|
"discourse-saved-searches",
|
2018-04-27 03:28:06 +08:00
|
|
|
"discourse-user-card-badges",
|
2018-05-30 04:57:05 +08:00
|
|
|
"discourse-policy",
|
2016-11-15 08:42:55 +08:00
|
|
|
])
|
|
|
|
|
2015-04-28 01:06:53 +08:00
|
|
|
FIELDS ||= [:name, :about, :version, :authors, :url, :required_version]
|
2016-11-15 08:42:55 +08:00
|
|
|
attr_accessor(*FIELDS)
|
2013-08-23 14:21:52 +08:00
|
|
|
|
|
|
|
def self.parse(text)
|
|
|
|
metadata = self.new
|
|
|
|
text.each_line do |line|
|
|
|
|
break unless metadata.parse_line(line)
|
|
|
|
end
|
|
|
|
metadata
|
|
|
|
end
|
|
|
|
|
2016-11-15 08:42:55 +08:00
|
|
|
def official?
|
|
|
|
OFFICIAL_PLUGINS.include?(name)
|
|
|
|
end
|
|
|
|
|
2013-08-23 14:21:52 +08: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-28 01:06:53 +08:00
|
|
|
attribute = attribute.strip.gsub(/ /, '_').to_sym
|
2013-08-23 14:21:52 +08:00
|
|
|
|
|
|
|
if FIELDS.include?(attribute)
|
|
|
|
self.send("#{attribute}=", description.strip)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|