From c1a42e76bc6667bfb2882a12d53c25d9f952ca82 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 2 Apr 2010 00:28:02 +0100 Subject: implement typed links; add tagged_is_strict config option --- doc/plugins/tag.mdwn | 5 +++++ doc/plugins/write.mdwn | 21 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'doc/plugins') diff --git a/doc/plugins/tag.mdwn b/doc/plugins/tag.mdwn index 8ff70a069..8cd79da41 100644 --- a/doc/plugins/tag.mdwn +++ b/doc/plugins/tag.mdwn @@ -8,6 +8,11 @@ These directives allow tagging pages. It also provides the `tagged()` [[ikiwiki/PageSpec]], which can be used to match pages that are tagged with a specific 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. + [[!if test="enabled(tag)" then=""" This wiki has the tag plugin enabled, so you'll see a note below that this page is tagged with the "tags" tag. diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 96a2aa16d..fe7cf0183 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -633,6 +633,22 @@ reference. Do not modify this hash directly; call `add_link()`. $links{"foo"} = ["bar", "baz"]; +### `%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`. + ### `%pagesources` The `%pagesources` has can be used to look up the source filename @@ -939,11 +955,14 @@ Optionally, a third parameter can be passed, to specify the preferred filename of the page. For example, `targetpage("foo", "rss", "feed")` will yield something like `foo/feed.rss`. -### `add_link($$)` +### `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]]). + ## Miscellaneous ### Internal use pages -- cgit v1.2.3 From ef6344144051ed70649ccbff01bcc4fce927ee2f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 4 Apr 2010 00:24:27 +0100 Subject: Remove tagged_is_strict option, and just behave as though it was enabled Jon was worried about the backwards-compatibility break involved in making tagged() not match non-tag links, but Joey seems less concerned about it. --- IkiWiki/Plugin/tag.pm | 17 +---------------- doc/bugs/tagged__40____41___matching_wikilinks.mdwn | 3 +-- doc/plugins/tag.mdwn | 5 ----- t/tag.t | 1 - 4 files changed, 2 insertions(+), 24 deletions(-) (limited to 'doc/plugins') diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm index af4bff1bc..7a85874f6 100644 --- a/IkiWiki/Plugin/tag.pm +++ b/IkiWiki/Plugin/tag.pm @@ -34,13 +34,6 @@ sub getsetup () { safe => 1, rebuild => 1, }, - tagged_is_strict => { - type => "boolean", - default => 0, - description => "if 1, tagged() doesn't match normal WikiLinks to tag pages", - safe => 1, - rebuild => 1, - }, } sub tagpage ($) { @@ -132,15 +125,7 @@ sub pagetemplate (@) { package IkiWiki::PageSpec; sub match_tagged ($$;@) { - my $page = shift; - my $glob = shift; - - if ($IkiWiki::config{tagged_is_strict}) { - return match_link($page, IkiWiki::Plugin::tag::tagpage($glob), linktype => 'tag'); - } - else { - return match_link($page, IkiWiki::Plugin::tag::tagpage($glob)); - } + return match_link($_[0], IkiWiki::Plugin::tag::tagpage($_[1]), linktype => 'tag'); } 1 diff --git a/doc/bugs/tagged__40____41___matching_wikilinks.mdwn b/doc/bugs/tagged__40____41___matching_wikilinks.mdwn index 9037d6c02..a211654f1 100644 --- a/doc/bugs/tagged__40____41___matching_wikilinks.mdwn +++ b/doc/bugs/tagged__40____41___matching_wikilinks.mdwn @@ -28,8 +28,7 @@ rationale on this, or what am I doing wrong, and how to achieve what I want? >> is valid. [[todo/matching_different_kinds_of_links]] is probably >> how it will eventually be solved. --[[Joey]] ->>> [[Done]]: you can now set the `tagged_is_strict` config option to `1` ->>> if you don't want `tagged` to match other wikilinks. --[[smcv]] +>>> [[Done]]: `tagged` no longer matches other wikilinks. --[[smcv]] > And this is an illustration why a clean work-around (without changing the software) is not possible: while thinking about [[todo/matching_different_kinds_of_links]], I thought one could work around the problem by simply explicitly including the kind of the relation into the link target (like the tagbase in tags), and by having a separate page without the "tagbase" to link to when one wants simply to refer to the tag without tagging. But this won't work: one has to at least once refer to the real tag page if one wants to talk about it, and this reference will count as tagging (unwanted). --Ivan Z. diff --git a/doc/plugins/tag.mdwn b/doc/plugins/tag.mdwn index 8cd79da41..8ff70a069 100644 --- a/doc/plugins/tag.mdwn +++ b/doc/plugins/tag.mdwn @@ -8,11 +8,6 @@ These directives allow tagging pages. It also provides the `tagged()` [[ikiwiki/PageSpec]], which can be used to match pages that are tagged with a specific 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. - [[!if test="enabled(tag)" then=""" This wiki has the tag plugin enabled, so you'll see a note below that this page is tagged with the "tags" tag. diff --git a/t/tag.t b/t/tag.t index 3383fd475..cf3bbdf01 100755 --- a/t/tag.t +++ b/t/tag.t @@ -12,7 +12,6 @@ ok(! system("rm -rf t/tmp; mkdir t/tmp")); $config{userdir} = "users"; $config{tagbase} = "tags"; -$config{tagged_is_strict} = 1; %oldrenderedfiles=%pagectime=(); %pagesources=%pagemtime=%oldlinks=%links=%depends=%typedlinks=%oldtypedlinks= -- cgit v1.2.3