beatonma / django-wm

Automatic Webmention functionality for Django models
https://beatonma.org/webmentions_tester/
GNU General Public License v3.0
12 stars 2 forks source link

[Feature Request] Exclude domains and/or URLs from outgoing webmentions #52

Closed campegg closed 7 months ago

campegg commented 7 months ago

Not at all critical, but there are times when I have multiple links in a post and know that some of the sites don't accept webmentions. It would be cool if there was a way to exclude outgoing webmentions from being sent to those domains that are known not to accept them to stop them from clogging up the admin. I could see this being done either as a setting (e.g.):

WEBMENTIONS_EXCLUDE_DOMAINS = ["domain1.com", "domain2.com"]

…or even as a class added to a link on a case-by-case basis (e.g.):

<a class="wm-nosend" href="https://domain.com/page.html">link text</a>

beatonma commented 7 months ago

Good suggestion - might be useful to go more general and allow either an include or exclude list and a class to override that.

Will include this soon.

beatonma commented 7 months ago

Included in 4.1.1: release notes.

Sample settings:


WEBMENTIONS_DOMAINS_OUTGOING_DENY = [
  "domain1.com",
  "sub.domain2.com",
  "*.domain3.com",  # Also include any subdomain
]

WEBMENTIONS_DOMAINS_OUTGOING_TAG_DENY: str = "wm-nosend"

Override tag can be included as a class, data attribute or custom attribute:

<a class="wm-nosend" href="...">link text</a>
<a data-wm-nosend href="...">link text</a>
<a wm-nosend href="...">link text</a>

Let me know if you have any issues!

campegg commented 7 months ago

This is brilliant—thank you!