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