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([
|
2018-10-14 21:53:21 -05:00
|
|
|
# TODO: Remove this after everyone upgraded `discourse-canned-replies`
|
|
|
|
# to the renamed version.
|
2018-09-09 12:41:26 -05:00
|
|
|
"Canned Replies",
|
2016-11-14 18:42:55 -06:00
|
|
|
"customer-flair",
|
|
|
|
"discourse-adplugin",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-affiliate",
|
2016-11-14 18:42:55 -06:00
|
|
|
"discourse-akismet",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-assign",
|
|
|
|
"discourse-auto-deactivate",
|
2016-11-14 18:42:55 -06:00
|
|
|
"discourse-backup-uploads-to-s3",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-bbcode",
|
|
|
|
"discourse-bbcode-color",
|
2016-11-14 18:42:55 -06:00
|
|
|
"discourse-cakeday",
|
2018-10-14 21:53:21 -05:00
|
|
|
"discourse-canned-replies",
|
2018-10-12 09:12:31 -05:00
|
|
|
"discourse-calendar",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-characters-required",
|
|
|
|
"discourse-chat-integration",
|
|
|
|
"discourse-checklist",
|
2019-01-24 01:44:50 -06:00
|
|
|
"discourse-code-review",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-crowd",
|
2016-11-14 18:42:55 -06:00
|
|
|
"discourse-data-explorer",
|
|
|
|
"discourse-details",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-footnote",
|
2018-10-12 09:12:31 -05:00
|
|
|
"discourse-github",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-gradle-issue",
|
2018-10-12 09:12:31 -05:00
|
|
|
"discourse-graphviz",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-invite-tokens",
|
|
|
|
"discourse-local-dates",
|
2018-10-12 09:12:31 -05:00
|
|
|
"discourse-logster-rate-limit-checker",
|
|
|
|
"discourse-logster-transporter",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-math",
|
|
|
|
"discourse-moderator-attention",
|
|
|
|
"discourse-narrative-bot",
|
2016-11-14 18:42:55 -06:00
|
|
|
"discourse-nginx-performance-report",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-no-bump",
|
2017-07-18 11:09:27 -05:00
|
|
|
"discourse-oauth2-basic",
|
2017-10-23 18:27:10 -05:00
|
|
|
"discourse-patreon",
|
2018-10-12 09:12:31 -05:00
|
|
|
"discourse-perspective",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-plugin-discord-auth",
|
|
|
|
"discourse-plugin-linkedin-auth",
|
|
|
|
"discourse-plugin-office365-auth",
|
|
|
|
"discourse-policy",
|
2018-04-22 20:26:13 -05:00
|
|
|
"discourse-presence",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-prometheus",
|
2018-10-12 09:12:31 -05:00
|
|
|
"discourse-prometheus-alert-receiver",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-push-notifications",
|
|
|
|
"discourse-saved-searches",
|
2018-04-25 21:31:53 -05:00
|
|
|
"discourse-signatures",
|
|
|
|
"discourse-sitemap",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-solved",
|
2018-10-12 09:12:31 -05:00
|
|
|
"discourse-spoiler-alert",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-staff-notes",
|
2018-04-25 21:31:53 -05:00
|
|
|
"discourse-styleguide",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-tooltips",
|
|
|
|
"discourse-translator",
|
2018-04-26 14:28:06 -05:00
|
|
|
"discourse-user-card-badges",
|
2018-09-09 12:41:26 -05:00
|
|
|
"discourse-voting",
|
2019-01-24 01:44:50 -06:00
|
|
|
"discourse-yearly-review",
|
2018-12-06 10:16:47 -06:00
|
|
|
"discourse-openid-connect",
|
2019-04-03 04:30:49 -05:00
|
|
|
"discourse-yearly-review",
|
2018-09-09 12:41:26 -05:00
|
|
|
"docker_manager",
|
|
|
|
"lazyYT",
|
2018-10-12 09:12:31 -05:00
|
|
|
"poll"
|
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)
|
2019-05-06 20:27:05 -05:00
|
|
|
self.public_send("#{attribute}=", description.strip)
|
2013-08-23 01:21:52 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|