link_policy

Link policy for editors and site configuration.

m.link_policy.editor[id] returns policy for a visible resource; approval controls also require resource edit and property update permission. editor without an id returns policy for a new resource (normal insert ACLs still apply on save). nofollow and noreferrer expose the public site defaults, both true when unset.

For example, retrieve approval controls for the resource being edited:

{% with m.link_policy.editor[id] as policy %}
    {% if policy.can_approve %}
        <p>{_ You can approve external URLs for this page. _}</p>
    {% endif %}
{% endwith %}

The editor policy is a map with these fields:

FieldValue
idResource id, or undefined for a new resource.
can_approveWhether the current user may change URL approvals. New resources still require insert permission when saved.
urlsList of approved, unescaped URL binaries; empty for a new resource.
hostsSite hostname and host aliases for editor URL classification.
nofollowBoolean default for new external links inserted by eligible editors.
noreferrerBoolean indicating whether external links suppress referrer information.

The model returns enoent for an unknown resource, eacces for an invisible resource, and unknown_path for an unsupported model path. The default-setting paths m.link_policy.nofollow and m.link_policy.noreferrer are public.

site.link_nofollow is a new-link default only for users with approval rights (normally use.mod_admin, plus permission to edit the resource). For these editors, true means the follow checkbox is unchecked after entering a new external URL; false means checked. They can override this choice per URL. An empty-URL dialog initially shows the checkbox checked; entering a URL recalculates it. Existing external links reflect their stored URL approval.

Users without approval rights see status but no checkbox. Their unapproved external URLs always receive nofollow, regardless of the configured default; existing resource approvals remain effective. site.link_noreferrer applies to all users independently of approval and defaults to true.

There are no model write routes: approvals are saved with normal resource updates.

resanitize/2 re-applies current settings to an editable resource's stored HTML. Configuration changes do not rewrite historical content automatically. To migrate existing resources, call this function for the desired ids with an authorized context. It preserves the resource allow-list and checks ordinary update ACLs. This is a direct Erlang API, not a model write path:

m_link_policy:resanitize(Id, Context).

It returns {ok, Id} or an error from the resource update, such as {error, eacces} when the context lacks the required permissions.

Edit on GitHub