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
|
2017-08-12 10:18:04 +08:00
|
|
|
OFFICIAL_PLUGINS ||=
|
2023-01-09 20:10:19 +08:00
|
|
|
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
|
|
|
"discourse-adplugin",
|
2018-09-10 01:41:26 +08:00
|
|
|
"discourse-affiliate",
|
2023-07-14 23:29:42 +08:00
|
|
|
"discourse-ai",
|
2016-11-15 08:42:55 +08:00
|
|
|
"discourse-akismet",
|
2020-09-12 04:44:06 +08:00
|
|
|
"discourse-algolia",
|
2021-12-13 13:29:02 +08:00
|
|
|
"discourse-apple-auth",
|
2018-09-10 01:41:26 +08:00
|
|
|
"discourse-assign",
|
|
|
|
"discourse-auto-deactivate",
|
2022-02-23 05:31:54 +08:00
|
|
|
"discourse-automation",
|
2018-09-10 01:41:26 +08:00
|
|
|
"discourse-bbcode",
|
|
|
|
"discourse-bbcode-color",
|
2022-03-23 01:18:09 +08:00
|
|
|
"discourse-bcc",
|
2016-11-15 08:42:55 +08:00
|
|
|
"discourse-cakeday",
|
2018-10-12 22:12:31 +08:00
|
|
|
"discourse-calendar",
|
2021-09-28 09:44:10 +08:00
|
|
|
"discourse-canned-replies",
|
2020-03-05 01:35:04 +08:00
|
|
|
"discourse-categories-suppressed",
|
2021-10-20 10:04:54 +08:00
|
|
|
"discourse-category-experts",
|
2018-09-10 01:41:26 +08:00
|
|
|
"discourse-characters-required",
|
|
|
|
"discourse-chat-integration",
|
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",
|
2021-01-19 00:58:05 +08:00
|
|
|
"discourse-docs",
|
2019-05-29 10:20:46 +08:00
|
|
|
"discourse-encrypt",
|
2022-02-21 04:32:46 +08:00
|
|
|
"discourse-follow",
|
2021-09-28 09:44:10 +08:00
|
|
|
"discourse-fontawesome-pro",
|
2018-09-10 01:41:26 +08:00
|
|
|
"discourse-footnote",
|
2022-05-05 03:06:06 +08:00
|
|
|
"discourse-gamification",
|
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",
|
2022-06-01 22:07:51 +08:00
|
|
|
"discourse-group-tracker",
|
2018-09-10 01:41:26 +08:00
|
|
|
"discourse-invite-tokens",
|
2023-03-29 23:54:25 +08:00
|
|
|
"discourse-lazy-videos",
|
2018-09-10 01:41:26 +08:00
|
|
|
"discourse-local-dates",
|
2021-09-28 09:44:10 +08:00
|
|
|
"discourse-login-with-amazon",
|
2018-10-12 22:12:31 +08:00
|
|
|
"discourse-logster-rate-limit-checker",
|
|
|
|
"discourse-logster-transporter",
|
2021-10-07 01:19:12 +08:00
|
|
|
"discourse-lti",
|
2018-09-10 01:41:26 +08:00
|
|
|
"discourse-math",
|
|
|
|
"discourse-moderator-attention",
|
|
|
|
"discourse-narrative-bot",
|
2023-06-09 23:18:36 +08:00
|
|
|
"discourse-newsletter-integration",
|
2018-09-10 01:41:26 +08:00
|
|
|
"discourse-no-bump",
|
2017-07-19 00:09:27 +08:00
|
|
|
"discourse-oauth2-basic",
|
2021-09-28 09:44:10 +08:00
|
|
|
"discourse-openid-connect",
|
2017-10-24 07:27:10 +08:00
|
|
|
"discourse-patreon",
|
2020-10-15 03:05:10 +08:00
|
|
|
"discourse-perspective-api",
|
2021-12-04 01:42:14 +08:00
|
|
|
"discourse-linkedin-auth",
|
2021-12-03 20:05:05 +08:00
|
|
|
"discourse-microsoft-auth",
|
2018-09-10 01:41:26 +08:00
|
|
|
"discourse-policy",
|
2022-11-03 11:41:25 +08:00
|
|
|
"discourse-post-voting",
|
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",
|
2021-09-28 09:44:10 +08:00
|
|
|
"discourse-reactions",
|
|
|
|
"discourse-restricted-replies",
|
|
|
|
"discourse-rss-polling",
|
2022-08-24 16:42:43 +08:00
|
|
|
"discourse-salesforce",
|
2021-12-13 23:50:57 +08:00
|
|
|
"discourse-saml",
|
2018-09-10 01:41:26 +08:00
|
|
|
"discourse-saved-searches",
|
2021-10-19 10:38:06 +08:00
|
|
|
"discourse-shared-edits",
|
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",
|
2021-09-28 09:44:10 +08:00
|
|
|
"discourse-staff-alias",
|
|
|
|
"discourse-steam-login",
|
2020-11-03 02:59:30 +08:00
|
|
|
"discourse-subscriptions",
|
2020-10-10 05:50:00 +08:00
|
|
|
"discourse-teambuild",
|
2022-07-19 03:46:49 +08:00
|
|
|
"discourse-templates",
|
2018-09-10 01:41:26 +08:00
|
|
|
"discourse-tooltips",
|
2022-11-03 11:41:25 +08:00
|
|
|
"discourse-topic-voting",
|
2018-09-10 01:41:26 +08:00
|
|
|
"discourse-translator",
|
2018-04-27 03:28:06 +08:00
|
|
|
"discourse-user-card-badges",
|
2021-09-28 09:44:10 +08:00
|
|
|
"discourse-user-notes",
|
2021-12-14 06:54:28 +08:00
|
|
|
"discourse-vk-auth",
|
2022-02-11 20:00:24 +08:00
|
|
|
"discourse-whos-online",
|
2019-01-24 15:44:50 +08:00
|
|
|
"discourse-yearly-review",
|
2020-01-24 20:53:21 +08:00
|
|
|
"discourse-zendesk-plugin",
|
2023-06-06 08:01:58 +08:00
|
|
|
"discourse-zoom",
|
2018-09-10 01:41:26 +08:00
|
|
|
"docker_manager",
|
2023-01-09 20:10:19 +08:00
|
|
|
"chat",
|
|
|
|
"poll",
|
2021-09-28 09:44:10 +08:00
|
|
|
"styleguide",
|
2023-08-02 17:17:24 +08:00
|
|
|
"checklist",
|
2023-01-09 20:10:19 +08:00
|
|
|
],
|
|
|
|
)
|
2016-11-15 08:42:55 +08:00
|
|
|
|
2018-10-12 22:12:31 +08:00
|
|
|
FIELDS ||= %i[name about version authors contact_emails url required_version transpile_js]
|
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 { |line| break unless metadata.parse_line(line) }
|
|
|
|
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
|
|
|
|
2019-05-07 09:27:05 +08:00
|
|
|
self.public_send("#{attribute}=", description.strip) if FIELDS.include?(attribute)
|
2013-08-23 14:21:52 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|