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