2021-03-13 18:15:14 +01:00
|
|
|
<div id="linkifier-settings" class="settings-section" data-name="linkifier-settings">
|
2017-04-26 04:47:00 +02:00
|
|
|
<div class="admin-table-wrapper">
|
2016-12-14 23:55:32 +01:00
|
|
|
|
2017-04-26 04:47:00 +02:00
|
|
|
<p>
|
2023-03-15 23:51:27 +01:00
|
|
|
{{t "Configure regular expression patterns that will be used to
|
|
|
|
automatically transform any matching text in Zulip messages
|
|
|
|
and topics into links." }}
|
2017-04-26 04:47:00 +02:00
|
|
|
</p>
|
2018-12-17 21:44:44 +01:00
|
|
|
<p>
|
2023-03-15 23:51:27 +01:00
|
|
|
{{t "Linkifiers make it easy to refer to issues or tickets in
|
|
|
|
third party issue trackers, like GitHub, Salesforce, Zendesk,
|
|
|
|
and others. For instance, you can add a linkifier that
|
|
|
|
automatically turns #2468 into a link to the GitHub issue
|
|
|
|
in the Zulip repository with:" }}
|
2018-12-17 21:44:44 +01:00
|
|
|
</p>
|
|
|
|
<ul>
|
|
|
|
<li>
|
2023-02-28 13:46:28 +01:00
|
|
|
{{t "Pattern" }}: <span class="rendered_markdown"><code>#(?P<id>[0-9]+)</code></span>
|
|
|
|
</li>
|
|
|
|
<li>
|
linkifier: Support URL templates for linkifiers.
This swaps out url_format_string from all of our APIs and replaces it
with url_template. Note that the documentation changes in the following
commits will be squashed with this commit.
We change the "url_format" key to "url_template" for the
realm_linkifiers events in event_schema, along with updating
LinkifierDict. "url_template" is the name chosen to normalize
mixed usages of "url_format_string" and "url_format" throughout
the backend.
The markdown processor is updated to stop handling the format string
interpolation and delegate the task template expansion to the uri_template
library instead.
This change affects many test cases. We mostly just replace "%(name)s"
with "{name}", "url_format_string" with "url_template" to make sure that
they still pass. There are some test cases dedicated for testing "%"
escaping, which aren't relevant anymore and are subject to removal.
But for now we keep most of them as-is, and make sure that "%" is always
escaped since we do not use it for variable substitution any more.
Since url_format_string is not populated anymore, a migration is created
to remove this field entirely, and make url_template non-nullable since
we will always populate it. Note that it is possible to have
url_template being null after migration 0422 and before 0424, but
in practice, url_template will not be None after backfilling and the
backend now is always setting url_template.
With the removal of url_format_string, RealmFilter model will now be cleaned
with URL template checks, and the old checks for escapes are removed.
We also modified RealmFilter.clean to skip the validation when the
url_template is invalid. This avoids raising mulitple ValidationError's
when calling full_clean on a linkifier. But we might eventually want to
have a more centric approach to data validation instead of having
the same validation in both the clean method and the validator.
Fixes #23124.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-10-05 20:55:31 +02:00
|
|
|
{{t "URL template" }}: <span class="rendered_markdown"><code>https://github.com/zulip/zulip/issues/{id}</code></span>
|
2018-12-17 21:44:44 +01:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p>
|
2021-04-14 03:04:02 +02:00
|
|
|
{{#tr}}
|
2023-02-28 13:46:28 +01:00
|
|
|
For more examples, see the <z-link>help center documentation</z-link>
|
|
|
|
on adding linkifiers.
|
2021-04-10 05:53:13 +02:00
|
|
|
{{#*inline "z-link"}}<a href="/help/add-a-custom-linkifier" target="_blank" rel="noopener noreferrer">{{> @partial-block}}</a>{{/inline}}
|
2018-12-17 21:44:44 +01:00
|
|
|
{{/tr}}
|
|
|
|
</p>
|
2016-12-14 23:55:32 +01:00
|
|
|
|
2019-08-16 07:53:04 +02:00
|
|
|
{{#if is_admin}}
|
2023-01-10 11:13:05 +01:00
|
|
|
<form class="admin-linkifier-form">
|
2021-03-13 18:15:14 +01:00
|
|
|
<div class="add-new-linkifier-box grey-box">
|
|
|
|
<div class="new-linkifier-form wrapper">
|
2023-02-28 13:46:28 +01:00
|
|
|
<div class="settings-section-title new-linkifier-section-title">
|
|
|
|
{{t "Add a new linkifier" }}
|
|
|
|
{{> ../help_link_widget link="/help/add-a-custom-linkifier" }}
|
|
|
|
</div>
|
2021-03-13 18:15:14 +01:00
|
|
|
<div class="alert" id="admin-linkifier-status"></div>
|
2022-08-09 09:10:53 +02:00
|
|
|
<div class="input-group">
|
|
|
|
<label for="linkifier_pattern">{{t "Pattern" }}</label>
|
2023-06-22 16:18:13 +02:00
|
|
|
<input type="text" id="linkifier_pattern" class="settings_text_input" name="pattern" placeholder="#(?P<id>[0-9]+)" />
|
2021-03-13 18:15:14 +01:00
|
|
|
<div class="alert" id="admin-linkifier-pattern-status"></div>
|
2019-08-16 07:53:04 +02:00
|
|
|
</div>
|
2022-08-09 09:10:53 +02:00
|
|
|
<div class="input-group">
|
2022-10-05 22:52:26 +02:00
|
|
|
<label for="linkifier_template">{{t "URL template" }}</label>
|
2023-06-22 16:18:13 +02:00
|
|
|
<input type="text" id="linkifier_template" class="settings_text_input" name="url_template" placeholder="https://github.com/zulip/zulip/issues/{id}" />
|
2022-10-05 22:52:26 +02:00
|
|
|
<div class="alert" id="admin-linkifier-template-status"></div>
|
2019-08-16 07:53:04 +02:00
|
|
|
</div>
|
|
|
|
<button type="submit" class="button rounded sea-green">
|
|
|
|
{{t 'Add linkifier' }}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
{{/if}}
|
|
|
|
|
2022-03-04 13:06:28 +01:00
|
|
|
<div class="settings_panel_list_header">
|
|
|
|
<h3>{{t "Linkifiers"}}</h3>
|
2022-03-20 17:58:28 +01:00
|
|
|
<div class="alert-notification edit-linkifier-status" id="linkifier-field-status"></div>
|
2023-06-23 13:22:29 +02:00
|
|
|
<input type="text" class="search filter_text_input" placeholder="{{t 'Filter linkifiers' }}" aria-label="{{t 'Filter linkifiers' }}"/>
|
2022-03-04 13:06:28 +01:00
|
|
|
</div>
|
|
|
|
|
2020-04-15 12:22:23 +02:00
|
|
|
<div class="progressive-table-wrapper" data-simplebar>
|
2023-08-07 09:32:19 +02:00
|
|
|
<table class="table table-striped wrapped-table admin_linkifiers_table">
|
2021-02-23 06:23:24 +01:00
|
|
|
<thead class="table-sticky-headers">
|
2023-08-10 06:20:27 +02:00
|
|
|
<th>{{t "Pattern" }}</th>
|
|
|
|
<th>{{t "URL template" }}</th>
|
2019-08-22 06:23:41 +02:00
|
|
|
{{#if is_admin}}
|
|
|
|
<th class="actions">{{t "Actions" }}</th>
|
|
|
|
{{/if}}
|
|
|
|
</thead>
|
2021-03-14 12:16:39 +01:00
|
|
|
<tbody id="admin_linkifiers_table" class="required-text" data-empty="{{t 'No linkifiers set.' }}"></tbody>
|
2019-08-16 07:53:04 +02:00
|
|
|
</table>
|
2016-02-13 19:17:15 +01:00
|
|
|
</div>
|
2019-08-16 07:53:04 +02:00
|
|
|
</div>
|
2016-02-13 19:17:15 +01:00
|
|
|
</div>
|