Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Markdown in Add-on Listing Fields #22956

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/topics/api/addons.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ This endpoint allows you to fetch a specific add-on by id, slug or guid.
:>json string created: The date the add-on was created.
:>json object current_version: Object holding the current :ref:`version <version-detail-object>` of the add-on. For performance reasons the ``license`` field omits the ``text`` property from both the search and detail endpoints.
:>json string default_locale: The add-on default locale for translations.
:>json object|null description: The add-on description (See :ref:`translated fields <api-overview-translations>`). This field might contain some HTML tags.
:>json object|null description: The add-on description (See :ref:`translated fields <api-overview-translations>`). This field might contain markdown.
:>json object|null developer_comments: Additional information about the add-on provided by the developer. (See :ref:`translated fields <api-overview-translations>`).
:>json string edit_url: The URL to the developer edit page for the add-on.
:>json string guid: The add-on `extension identifier <https://developer.mozilla.org/en-US/Add-ons/Install_Manifests#id>`_.
Expand Down Expand Up @@ -203,7 +203,7 @@ This endpoint allows you to fetch a specific add-on by id, slug or guid.
:>json string review_url: The URL to the reviewer review page for the add-on.
:>json string slug: The add-on slug.
:>json string status: The :ref:`add-on status <addon-detail-status>`.
:>json object|null summary: The add-on summary (See :ref:`translated fields <api-overview-translations>`). This field supports "linkification" and therefore might contain HTML hyperlinks.
:>json object|null summary: The add-on summary (See :ref:`translated fields <api-overview-translations>`). This field supports "linkification" and therefore might contain Markdown hyperlinks.
:>json object|null support_email: The add-on support email (See :ref:`translated fields <api-overview-translations>`).
:>json object|null support_url: The add-on support URL (See :ref:`translated fields <api-overview-translations>` and :ref:`Outgoing Links <api-overview-outgoing>`).
:>json array tags: List containing the tag names set on the add-on.
Expand Down Expand Up @@ -311,7 +311,7 @@ is compatible with.
:<json array categories[app_name]: Array holding the :ref:`category slugs <category-list>` the add-on belongs to for a given :ref:`add-on application <addon-detail-application>`.
:<json string contributions_url: URL to the (external) webpage where the addon's authors collect monetary contributions. Only a limited number of services are `supported <https://github.com/mozilla/addons-server/blob/0b5db7d544a21f6b887e8e8032496778234ade33/src/olympia/constants/base.py#L214:L226>`_.
:<json string default_locale: The fallback locale for translated fields for this add-on. Note this only applies to the fields here - the default locale for :ref:`version release notes <version-create-request>` and custom license text is fixed to `en-US`.
:<json object|null description: The add-on description (See :ref:`translated fields <api-overview-translations>`). This field can contain some HTML tags.
:<json object|null description: The add-on description (See :ref:`translated fields <api-overview-translations>`). This field can contain some Markdown.
:<json object|null developer_comments: Additional information about the add-on. (See :ref:`translated fields <api-overview-translations>`).
:<json object|null homepage: The add-on homepage (See :ref:`translated fields <api-overview-translations>` and :ref:`Outgoing Links <api-overview-outgoing>`).
:<json boolean is_disabled: Whether the add-on is disabled or not.
Expand Down Expand Up @@ -347,7 +347,7 @@ This endpoint allows an add-on's AMO metadata to be edited.
:<json array categories[app_name]: Array holding the :ref:`category slugs <category-list>` the add-on belongs to for a given :ref:`add-on application <addon-detail-application>`.
:<json string contributions_url: URL to the (external) webpage where the addon's authors collect monetary contributions. Only a limited number of services are `supported <https://github.com/mozilla/addons-server/blob/0b5db7d544a21f6b887e8e8032496778234ade33/src/olympia/constants/base.py#L214:L226>`_.
:<json string default_locale: The fallback locale for translated fields for this add-on. Note this only applies to the fields here - the default locale for :ref:`version release notes <version-create-request>` and custom license text is fixed to `en-US`.
:<json object|null description: The add-on description (See :ref:`translated fields <api-overview-translations>`). This field can contain some HTML tags.
:<json object|null description: The add-on description (See :ref:`translated fields <api-overview-translations>`). This field can contain some Markdown.
:<json object|null developer_comments: Additional information about the add-on. (See :ref:`translated fields <api-overview-translations>`).
:<json object|null homepage: The add-on homepage (See :ref:`translated fields <api-overview-translations>` and :ref:`Outgoing Links <api-overview-outgoing>`).
:<json null icon: To clear the icon, i.e. revert to the default add-on icon, send ``null``. See :ref:`addon icon <addon-icon>` to upload a new icon.
Expand Down
2 changes: 1 addition & 1 deletion docs/topics/api/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ Note, if the field is also a translated field then the ``url`` and ``outgoing``
values could be an object rather than a string
(See :ref:`translated fields <api-overview-translations>` for translated field representations).

Fields supporting some HTML, such as add-on ``description`` or ``summary``,
Fields supporting some HTML or Markdown, such as add-on ``description`` or ``summary``,
always wrap any links directly inside the content (the original url is not available).


Expand Down
3 changes: 3 additions & 0 deletions requirements/prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1208,3 +1208,6 @@ watchdog[watchmedo]==3.0.0 \
django-node-assets==0.9.14 \
--hash=sha256:80cbe3d10521808309712b2aa5ef6d69799bbcafef844cf7f223d3c93f405768 \
--hash=sha256:d5b5c472136084d533268f52ab77897327863a102e25c81f484aae85eb806987
Markdown==3.7 \
--hash=sha256:2ae2471477cfd02dbbf038d5d9bc226d40def84b4fe2986e49b59b6b472bbed2 \
--hash=sha256:7eb6df5690b81a1d7942992c97fad2938e956e79df20cbc6186e9c3a77b1c803
12 changes: 7 additions & 5 deletions src/olympia/addons/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
from olympia.tags.models import Tag
from olympia.translations.fields import (
NoURLsField,
PurifiedField,
PurifiedMarkdownField,
TranslatedField,
save_signal,
)
Expand Down Expand Up @@ -501,12 +501,14 @@ class Addon(OnChangeMixin, ModelBase):
homepage = TranslatedField(max_length=255)
support_email = TranslatedField(db_column='supportemail', max_length=100)
support_url = TranslatedField(db_column='supporturl', max_length=255)
description = PurifiedField(short=False, max_length=15000)
description = PurifiedMarkdownField(short=False, max_length=15000)

summary = NoURLsField(max_length=250)
developer_comments = PurifiedField(db_column='developercomments', max_length=3000)
eula = PurifiedField(max_length=350000)
privacy_policy = PurifiedField(db_column='privacypolicy', max_length=150000)
developer_comments = PurifiedMarkdownField(
db_column='developercomments', max_length=3000
)
eula = PurifiedMarkdownField(max_length=350000)
privacy_policy = PurifiedMarkdownField(db_column='privacypolicy', max_length=150000)

average_rating = models.FloatField(
max_length=255, default=0, null=True, db_column='averagerating'
Expand Down
Loading
Loading