comparison doc/components.rst @ 3978:97fbe11c4476

doc (components/AP Gateway): `html_redirect_dict` option
author Goffi <goffi@goffi.org>
date Fri, 11 Nov 2022 13:51:22 +0100
parents 199598223f82
children 425d809a505b
comparison
equal deleted inserted replaced
3977:6fa4ca0c047e 3978:97fbe11c4476
241 A boolean value indicating if received XMPP pubsub blog items bodies must be scanned to 241 A boolean value indicating if received XMPP pubsub blog items bodies must be scanned to
242 find ``@user@server.tld`` type mentions. If mentions are found, they'll be added to the 242 find ``@user@server.tld`` type mentions. If mentions are found, they'll be added to the
243 resulting AP items. 243 resulting AP items.
244 244
245 **default**: ``true`` 245 **default**: ``true``
246
247 ``html_redirect_dict``
248 A dictionary use to redirect HTTP requests when it's not an ActivityPub request (i.e.
249 when the ``Accept`` header is not set to ``application/json``). Several ActivityPub
250 implementations link to original server when clicking on some links such as post author
251 or item ID, and this result in a request to the corresponding ActivityPub endpoint, but
252 made to retrieve HTML instead of ActivityPub JSON data.
253
254 By default, this request is showing the corresponding AP JSON data, but if you set HTML
255 redirection, you can redirect the page to your XMPP client web frontend (or anything
256 making sense), which results in better user experience.
257
258 The expected dictionary is a mapping URL request types to destination URL.
259
260 The URL request types is the first path element after ``ap_path``, it can be:
261
262 ``actor``
263 Actor information. It should link to the profile page of the corresponding XMPP entity
264
265 ``item``
266 A specific publication. It should link to the rendered item
267
268 ``followers``
269 Entities publicly subscribed to the actor. It is usually not used for redirection.
270
271 ``following``
272 Entities that the actor is publicly subscribed to. It is usually not used for
273 redirection.
274
275 In the target URL you can uses template values in curly braces (something like
276 ``{item}``). The values that you can use are:
277
278 ``jid``
279 Full JID corresponding to the AP actor.
280
281 ``jid_user``
282 Only the user part of the JID (what is before the ``@``)
283
284 ``node``
285 Name of the pubsub node corresponding to the AP actor.
286
287 ``item``
288 ID of the XMPP pubsub item.
289
290 You can use a slash ``/`` followed by a part of a node name to filter only on specific
291 nodes. For instance, if you want to redirect microblog items to a different URL that
292 event items, you can use ``item/urn:xmpp:microblog:0`` and ``item/urn:xmpp:events:0``,
293 the first redirection to match will be used. Note that anything containing the filter
294 value will match, thus you can also use ``item/microblog`` (but it then would match an
295 event which has ``microblog`` in is node name).
296
297 You can also use a dictionary as value instead of the target URL. This can be useful to
298 filter on an other value than the node name, if you want to make specific redirection
299 for a particular user for instance. If you use a dictionary, you must use a ``url`` key
300 with the target URL (which may have template values as usual), and you may use a
301 ``filters`` key mapping to an other dictionary where each key is a filter on a specific
302 template value (in other words: key is the template value, like ``jid`` or ``node``, and
303 value is the filter to match).
304
305 *examples*
306
307 Redirect actor page to ``/profile/<JID user part>``, blogs items to ``/blog/<full
308 JID>/<node name>/<item id>`` and events items to ``/event/<full JID>/<node name>/<item
309 id>`` ::
310
311 html_redirect_dict = {
312 "actor": "/profile/{jid_user}",
313 "item/microblog": "/blog/{jid}/{node}/{item}",
314 "item/events": "/event/{jid}/{node}/{item}"
315 }
316
317 Redirect items of user ``louise@example.org`` to ``/b/<item>``::
318
319 html_redirect_dict = {
320 "item": {
321 "url": "/b/{item}",
322 filters: {
323 "jid": "louise@example.org"
324 }
325 }
326 }
246 327
247 328
248 .. _ap-actor-from-xmpp: 329 .. _ap-actor-from-xmpp:
249 330
250 How to Address an AP Actor from XMPP 331 How to Address an AP Actor from XMPP