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(
|
2023-08-02 19:48:20 +08:00
|
|
|
%w[
|
|
|
|
discourse-adplugin
|
|
|
|
discourse-affiliate
|
|
|
|
discourse-ai
|
|
|
|
discourse-akismet
|
|
|
|
discourse-algolia
|
|
|
|
discourse-apple-auth
|
|
|
|
discourse-assign
|
|
|
|
discourse-auto-deactivate
|
|
|
|
discourse-automation
|
|
|
|
discourse-bbcode
|
|
|
|
discourse-bbcode-color
|
|
|
|
discourse-bcc
|
|
|
|
discourse-cakeday
|
|
|
|
discourse-calendar
|
|
|
|
discourse-categories-suppressed
|
|
|
|
discourse-category-experts
|
|
|
|
discourse-characters-required
|
|
|
|
discourse-chat-integration
|
|
|
|
discourse-code-review
|
|
|
|
discourse-crowd
|
|
|
|
discourse-data-explorer
|
|
|
|
discourse-details
|
|
|
|
discourse-docs
|
|
|
|
discourse-encrypt
|
|
|
|
discourse-follow
|
|
|
|
discourse-fontawesome-pro
|
|
|
|
discourse-footnote
|
|
|
|
discourse-gamification
|
|
|
|
discourse-github
|
|
|
|
discourse-gradle-issue
|
|
|
|
discourse-graphviz
|
|
|
|
discourse-group-tracker
|
|
|
|
discourse-invite-tokens
|
|
|
|
discourse-lazy-videos
|
|
|
|
discourse-local-dates
|
|
|
|
discourse-login-with-amazon
|
|
|
|
discourse-logster-rate-limit-checker
|
|
|
|
discourse-logster-transporter
|
|
|
|
discourse-lti
|
|
|
|
discourse-math
|
|
|
|
discourse-moderator-attention
|
|
|
|
discourse-narrative-bot
|
|
|
|
discourse-newsletter-integration
|
|
|
|
discourse-no-bump
|
|
|
|
discourse-oauth2-basic
|
|
|
|
discourse-openid-connect
|
|
|
|
discourse-patreon
|
|
|
|
discourse-perspective-api
|
|
|
|
discourse-linkedin-auth
|
|
|
|
discourse-microsoft-auth
|
|
|
|
discourse-policy
|
|
|
|
discourse-post-voting
|
|
|
|
discourse-presence
|
|
|
|
discourse-prometheus
|
|
|
|
discourse-prometheus-alert-receiver
|
|
|
|
discourse-push-notifications
|
|
|
|
discourse-reactions
|
|
|
|
discourse-restricted-replies
|
|
|
|
discourse-rss-polling
|
|
|
|
discourse-salesforce
|
|
|
|
discourse-saml
|
|
|
|
discourse-saved-searches
|
|
|
|
discourse-shared-edits
|
|
|
|
discourse-signatures
|
|
|
|
discourse-sitemap
|
|
|
|
discourse-solved
|
|
|
|
discourse-spoiler-alert
|
|
|
|
discourse-staff-alias
|
|
|
|
discourse-steam-login
|
|
|
|
discourse-subscriptions
|
|
|
|
discourse-teambuild
|
|
|
|
discourse-templates
|
|
|
|
discourse-tooltips
|
|
|
|
discourse-topic-voting
|
|
|
|
discourse-translator
|
|
|
|
discourse-user-card-badges
|
|
|
|
discourse-user-notes
|
|
|
|
discourse-vk-auth
|
|
|
|
discourse-whos-online
|
|
|
|
discourse-yearly-review
|
|
|
|
discourse-zendesk-plugin
|
|
|
|
discourse-zoom
|
|
|
|
docker_manager
|
|
|
|
chat
|
|
|
|
poll
|
|
|
|
styleguide
|
|
|
|
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
|