X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/df6f6a1d53493de0ee4f451220b8c8d34af6642a..59ba938822ba0752e8d97e769c0d14f2eb0bbeb3:/doc/todo/matching_different_kinds_of_links.mdwn diff --git a/doc/todo/matching_different_kinds_of_links.mdwn b/doc/todo/matching_different_kinds_of_links.mdwn index b71d7cc5f..20acdde49 100644 --- a/doc/todo/matching_different_kinds_of_links.mdwn +++ b/doc/todo/matching_different_kinds_of_links.mdwn @@ -35,3 +35,83 @@ Besides pagespecs, the `rel=` attribute could be used for styles. --Ivan Z. > was not available, which is why I didn't make it differentiate from > normal links.) Might be better to go ahead and add the variable to > core though. --[[Joey]] + +>> I've implemented this with the data structure you suggested, except that +>> I called it `%typedlinks` instead of `%linktype` (it seemed to make more +>> sense that way). I also ported `tag` to it, and added a `tagged_is_strict` +>> config option. See below! --[[smcv]] + +I saw somewhere else here some suggestions for the wiki-syntax for specifying the relation name of a link. One more suggestion---[the syntax used in Semantic MediaWiki](http://en.wikipedia.org/wiki/Semantic_MediaWiki#Basic_usage), like this: + +
+... the capital city is \[[Has capital::Berlin]] ... ++ +So a part of the effect of [[`\[[!taglink TAG\]\]`|plugins/tag]] could be represented as something like `\[[tag::TAG]]` or (more understandable relation name in what concerns the direction) `\[[tagged::TAG]]`. + +I don't have any opinion on this syntax (whether it's good or not)...--Ivan Z. + +------- + +>> [[!template id=gitbranch author="[[Simon_McVittie|smcv]]" branch=smcv/link-types]] +>> [[!tag patch]] + +## Documentation for smcv's branch + +### added to [[ikiwiki/pagespec]] + +* "`typedlink(type glob)`" - matches pages that link to a given page (or glob) + with a given link type. Plugins can create links with a specific type: + for instance, the tag plugin creates links of type `tag`. + +### added to [[plugins/tag]] + +If the `tagged_is_strict` config option is set, `tagged()` will only match +tags explicitly set with [[ikiwiki/directive/tag]] or +[[ikiwiki/directive/taglink]]; if not (the default), it will also match +any other [[WikiLinks|ikiwiki/WikiLink]] to the tag page. + +### added to [[plugins/write]] + +#### `%typedlinks` + +The `%typedlinks` hash records links of specific types. Do not modify this +hash directly; call `add_link()`. The keys are page names, and the values +are hash references. In each page's hash reference, the keys are link types +defined by plugins, and the values are hash references with link targets +as keys, and 1 as a dummy value, something like this: + + $typedlinks{"foo"} = { + tag => { short_word => 1, metasyntactic_variable => 1 }, + next_page => { bar => 1 }, + }; + +Ordinary [[WikiLinks|ikiwiki/WikiLink]] appear in `%links`, but not in +`%typedlinks`. + +#### `add_link($$;$)` + + This adds a link to `%links`, ensuring that duplicate links are not + added. Pass it the page that contains the link, and the link text. + +An optional third parameter sets the link type (`undef` produces an ordinary +[[ikiwiki/WikiLink]]). + +> Some code refers to `oldtypedlinks`, and other to `oldlinktypes`. +> +> I'm curious what your reasoning was for adding a new variable +> rather than using `pagestate`. Was it only because you needed +> the `old` version to detect change, or was there other complexity? +> +> I have not convinced myself this is a real problem, but.. +> If a page has a typed link, there seems to be no way to tell +> if it also has a separate, regular link. `add_link` will add +> to `@links` when adding a typed, or untyped link. If only untyped +> links were recorded there, one could tell the difference. But then +> typed links would not show up at all in eg, a linkmap, +> unless it was changed to check for typed links too. +> (Or, regular links could be recorded in typedlinks too, +> with a empty type. (Bloaty.)) +> +> I suspect we could get away without having `tagged_is_strict` +> without too much transitional trouble. --[[Joey]]