FIX: Further improvements for plugin list (#24622)

Followup e37fb3042d6f56a27a01614e57bc7029f472b0c9

* Automatically remove the prefix `Discourse ` from all the plugin titles to avoid repetition
* Remove the :discourse_dev: icon from the author. Consider a "By Discourse" with no labels as official
* We add a `label` metadata to plugin.rb
  * Only plugins made by us in `discourse` and `discourse-org` GitHub organizations will show these in the list
* Make the plugin author font size a little smaller
* Make the commit sha look like a link so it's more obvious it goes to the code

Also I added some validation and truncation for plugin metadata
parsing since currently you can put absolutely anything in there
and it will show on the plugin list.
This commit is contained in:
Martin Brennan
2023-11-30 10:53:17 +10:00
committed by GitHub
parent bcb7e86c24
commit c58cd697d2
7 changed files with 98 additions and 32 deletions

View File

@ -12,6 +12,7 @@ RSpec.describe Plugin::Metadata do
# url: http://discourse.org
# required version: 1.3.0beta6+48
# meta_topic_id: 1234
# label: experimental
some_ruby
TEXT
@ -23,7 +24,8 @@ TEXT
expect(metadata.contact_emails).to eq("frankz@example.com")
expect(metadata.url).to eq("http://discourse.org")
expect(metadata.required_version).to eq("1.3.0beta6+48")
expect(metadata.meta_topic_id).to eq("1234")
expect(metadata.meta_topic_id).to eq(1234)
expect(metadata.label).to eq("experimental")
end
end
@ -50,4 +52,40 @@ TEXT
official("discourse-data-explorer")
unofficial("babble")
end
it "does not support anything but integer for meta_topic_id" do
metadata = Plugin::Metadata.parse <<TEXT
# meta_topic_id: 1234
TEXT
expect(metadata.meta_topic_id).to eq(1234)
metadata = Plugin::Metadata.parse <<TEXT
# meta_topic_id: t/1234 blah
TEXT
expect(metadata.meta_topic_id).to eq(nil)
end
it "truncates long field lengths" do
metadata = Plugin::Metadata.parse <<TEXT
# name: #{"a" * 100}
# about: #{"a" * 400}
# authors: #{"a" * 300}
# contact_emails: #{"a" * 300}
# url: #{"a" * 600}
# label: #{"a" * 100}
# required_version: #{"a" * 1500}
TEXT
expect(metadata.name.length).to eq(Plugin::Metadata::MAX_FIELD_LENGTHS[:name])
expect(metadata.about.length).to eq(Plugin::Metadata::MAX_FIELD_LENGTHS[:about])
expect(metadata.authors.length).to eq(Plugin::Metadata::MAX_FIELD_LENGTHS[:authors])
expect(metadata.contact_emails.length).to eq(
Plugin::Metadata::MAX_FIELD_LENGTHS[:contact_emails],
)
expect(metadata.url.length).to eq(Plugin::Metadata::MAX_FIELD_LENGTHS[:url])
expect(metadata.label.length).to eq(Plugin::Metadata::MAX_FIELD_LENGTHS[:label])
expect(metadata.required_version.length).to eq(1000)
end
end