2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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([
|
2018-10-14 22:53:21 -04:00
|
|
|
# TODO: Remove this after everyone upgraded `discourse-canned-replies`
|
|
|
|
# to the renamed version.
|
2018-09-09 13:41:26 -04:00
|
|
|
"Canned Replies",
|
2016-11-14 19:42:55 -05:00
|
|
|
"discourse-adplugin",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-affiliate",
|
2016-11-14 19:42:55 -05:00
|
|
|
"discourse-akismet",
|
2020-09-11 16:44:06 -04:00
|
|
|
"discourse-algolia",
|
2021-12-13 00:29:02 -05:00
|
|
|
"discourse-apple-auth",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-assign",
|
|
|
|
"discourse-auto-deactivate",
|
2022-02-22 16:31:54 -05:00
|
|
|
"discourse-automation",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-bbcode",
|
|
|
|
"discourse-bbcode-color",
|
2022-03-22 13:18:09 -04:00
|
|
|
"discourse-bcc",
|
2016-11-14 19:42:55 -05:00
|
|
|
"discourse-cakeday",
|
2018-10-12 10:12:31 -04:00
|
|
|
"discourse-calendar",
|
2021-09-27 21:44:10 -04:00
|
|
|
"discourse-canned-replies",
|
2020-03-04 12:35:04 -05:00
|
|
|
"discourse-categories-suppressed",
|
2021-10-19 22:04:54 -04:00
|
|
|
"discourse-category-experts",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-characters-required",
|
2022-08-03 08:23:57 -04:00
|
|
|
"discourse-chat",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-chat-integration",
|
|
|
|
"discourse-checklist",
|
2019-01-24 02:44:50 -05:00
|
|
|
"discourse-code-review",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-crowd",
|
2016-11-14 19:42:55 -05:00
|
|
|
"discourse-data-explorer",
|
|
|
|
"discourse-details",
|
2021-01-18 11:58:05 -05:00
|
|
|
"discourse-docs",
|
2019-05-28 22:20:46 -04:00
|
|
|
"discourse-encrypt",
|
2022-02-20 15:32:46 -05:00
|
|
|
"discourse-follow",
|
2021-09-27 21:44:10 -04:00
|
|
|
"discourse-fontawesome-pro",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-footnote",
|
2022-05-04 15:06:06 -04:00
|
|
|
"discourse-gamification",
|
2018-10-12 10:12:31 -04:00
|
|
|
"discourse-github",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-gradle-issue",
|
2018-10-12 10:12:31 -04:00
|
|
|
"discourse-graphviz",
|
2022-06-01 10:07:51 -04:00
|
|
|
"discourse-group-tracker",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-invite-tokens",
|
|
|
|
"discourse-local-dates",
|
2021-09-27 21:44:10 -04:00
|
|
|
"discourse-login-with-amazon",
|
2018-10-12 10:12:31 -04:00
|
|
|
"discourse-logster-rate-limit-checker",
|
|
|
|
"discourse-logster-transporter",
|
2021-10-06 13:19:12 -04:00
|
|
|
"discourse-lti",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-math",
|
|
|
|
"discourse-moderator-attention",
|
|
|
|
"discourse-narrative-bot",
|
|
|
|
"discourse-no-bump",
|
2017-07-18 12:09:27 -04:00
|
|
|
"discourse-oauth2-basic",
|
2021-09-27 21:44:10 -04:00
|
|
|
"discourse-openid-connect",
|
2017-10-23 19:27:10 -04:00
|
|
|
"discourse-patreon",
|
2020-10-14 15:05:10 -04:00
|
|
|
"discourse-perspective-api",
|
2021-12-03 12:42:14 -05:00
|
|
|
"discourse-linkedin-auth",
|
2021-12-03 07:05:05 -05:00
|
|
|
"discourse-microsoft-auth",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-policy",
|
2018-04-22 21:26:13 -04:00
|
|
|
"discourse-presence",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-prometheus",
|
2018-10-12 10:12:31 -04:00
|
|
|
"discourse-prometheus-alert-receiver",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-push-notifications",
|
2022-08-05 05:01:58 -04:00
|
|
|
"discourse-question-answer",
|
2021-09-27 21:44:10 -04:00
|
|
|
"discourse-reactions",
|
|
|
|
"discourse-restricted-replies",
|
|
|
|
"discourse-rss-polling",
|
2022-08-24 04:42:43 -04:00
|
|
|
"discourse-salesforce",
|
2021-12-13 10:50:57 -05:00
|
|
|
"discourse-saml",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-saved-searches",
|
2021-10-18 22:38:06 -04:00
|
|
|
"discourse-shared-edits",
|
2018-04-25 22:31:53 -04:00
|
|
|
"discourse-signatures",
|
|
|
|
"discourse-sitemap",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-solved",
|
2018-10-12 10:12:31 -04:00
|
|
|
"discourse-spoiler-alert",
|
2021-09-27 21:44:10 -04:00
|
|
|
"discourse-staff-alias",
|
|
|
|
"discourse-steam-login",
|
2020-11-02 13:59:30 -05:00
|
|
|
"discourse-subscriptions",
|
2020-10-09 17:50:00 -04:00
|
|
|
"discourse-teambuild",
|
2022-07-18 15:46:49 -04:00
|
|
|
"discourse-templates",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-tooltips",
|
|
|
|
"discourse-translator",
|
2018-04-26 15:28:06 -04:00
|
|
|
"discourse-user-card-badges",
|
2021-09-27 21:44:10 -04:00
|
|
|
"discourse-user-notes",
|
2021-12-13 17:54:28 -05:00
|
|
|
"discourse-vk-auth",
|
2018-09-09 13:41:26 -04:00
|
|
|
"discourse-voting",
|
2022-02-11 07:00:24 -05:00
|
|
|
"discourse-whos-online",
|
2019-01-24 02:44:50 -05:00
|
|
|
"discourse-yearly-review",
|
2020-01-24 07:53:21 -05:00
|
|
|
"discourse-zendesk-plugin",
|
2018-09-09 13:41:26 -04:00
|
|
|
"docker_manager",
|
2019-08-21 05:02:55 -04:00
|
|
|
"lazy-yt",
|
2019-12-11 09:07:22 -05:00
|
|
|
"poll",
|
2021-09-27 21:44:10 -04:00
|
|
|
"styleguide",
|
2016-11-14 19:42:55 -05:00
|
|
|
])
|
|
|
|
|
2021-01-28 11:17:00 -05:00
|
|
|
FIELDS ||= [:name, :about, :version, :authors, :contact_emails, :url, :required_version, :transpile_js]
|
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)
|
2019-05-06 21:27:05 -04:00
|
|
|
self.public_send("#{attribute}=", description.strip)
|
2013-08-23 02:21:52 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|