aboutsummaryrefslogtreecommitdiff
path: root/doc/todo/alias_directive.mdwn
blob: 71a2efc76f6ebef50b3a12e8189125370c830bbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
An alias directive could work like an inverse redirect, but in a more
maintainable way. Currently, a page might have several redirects leading to it,
without an easy way of enumerating them. Therefore, the following directive is
suggested for addition (possibly by means of a plugin):

> The `alias` and `aliastext` directives implicitly create
> redirect pages to the page they are used on. If two or more pages claim a
> non-existing page to be an alias, a disambiguation page will automatically
> generated. If an existing page is claimed as an alias, it will be prefixed
> with a note that its topic is also an alias for other pages.
>
> All aliases to a page are automatically listed below the backlink and tag
> lists at the bottom of a page by default. This can be configured globally by
> setting the `alias_list` configuration option to `false`, or set explicitly
> per alias by specifying `list=true` or `list=false`.
>
> Similar to the `taglink` directive, `aliastext` produces the alias name as
> well as registering it.
>
> ## Usage example
>
> `Greece.mdwn`:
>
> >     Greece, also known as \[[!aliastext Hellas]] and officially the
> >     \[[!aliastext "Hellenic Republic"]], is a …
> >     
> >     <!-- there are so many people who misspell this, let's create a redirect -->
> >     \[[!alias Grece list=false]] 
>
> This page by itself will redirect from the "Hellas", "Hellenic Republic" and
> "Grece" pages as if they both contained just:
>
> >     \[[!meta redir="Greece"]]
>
> If, on the other hand, `Hellas Planitia` also claims `[[!alias Hellas]]`, the
> Hellas page will look like this:
>
> >     **Hellas** is an alias for the following pages:
> >
> >     * \[[Greece]]
> >     * \[[Hellas Planitia]]

The proposed plugin/directive could be extended, eg. by also including
old-style redirects in the alias list, but that might introduce unwanted
coupling with the meta directive.

-----------------

On second thought, implementing this might have similarities with
[[todo/auto-create tag pages according to a template]] -- the auto-created
pages would, if the way of the alias directive is followed, not create physical
files, though, but be created just when someone edits them.

If multiple plugins do such a trick, they would have to fight over who comes
first. If, for example, we have a setup where not yet created tag pages are
automatically generated as "\[[!inline  pages="link(<TMPL_VAR TAG>)"
archive="yes"]]" and aliases are enabled, and a non-tag pages grabs a tag as an
alias (as to redirect all taglinks of the tag to itself), there are two
possibilities:

* The autotag plugin comes first:
    * autotag sees the missing tag and creates its "\[[!inline" stuff
    * alias sees that there is already content and adds its prefix
* The alias plugin comes first (this is the prefered way):
    * alias sees the empty page, sees it is not contested by other alias
      directives and creates its "\[[!meta" redirect
    * autotag sees there is already content and doesn't do anything

That issue could be handled with "priority number" on the hook, with plugins
with a lower number being called first.

[[!tag wishlist]]