digitalfabrik / integreat-cms

Simplified content management back end for the Integreat App - a multilingual information platform for newcomers
https://digitalfabrik.github.io/integreat-cms/
Apache License 2.0
56 stars 35 forks source link

Allow to replace link text in link checker #2226

Open timobrembeck opened 1 year ago

timobrembeck commented 1 year ago

Motivation

In many cases, links are not only contained in the href attribute of the specific link:

<a href="https://some-link.tld">Readable link text</a>

But also in the link text itself:

<a href="https://some-link.tld">https://some-link.tld</a>

At the moment, it is only possible to replace the link in the href attribute, and not the link text. This is mostly due to the simpler implementation (we can just make use of lxml.html.rewrite_links() instead of some complex regex) and the fact that the URL is identical for all replaced link objects, but the link texts might differ.

Proposed Solution

At least in the case where all link texts are identical, I suggest to go the extra mile and allow the users to replace the link text as well. This would be a little bit more complicated, but can probably also be done with lxml (e.g. iterlinks()), so hopefully no regex matching.

Optionally, we could also think about allowing to "override" the link text even if it differs in the other sources.

Alternatives

Leave it up to the content creators to go through all affected pages and replace the link texts manually. However, since only the first link text is shown in the link checker, it's practically impossible to find the other occurrences of the link. Probably we could have to at least provide a simpler method of finding all occurrences of a specific link.

User Story

As a region manager or editor, I want to replace not only the links but also the link texts (in case they are URLs) to make sure that the app users see the correct link text for the new link target.

Additional Context

timobrembeck commented 1 year ago

As mentioned in #2307, making the link text editable via the form field led to several problems. Thus, I suggest to choose a more black-box feature instead: