aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki.pm
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2007-03-21 23:11:09 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2007-03-21 23:11:09 +0000
commit2a0d91af2f8f6ca3142c8f73ea6869e7a914bb30 (patch)
treed4c7c3dae158e8603cd1a3c01fd8784ef478ba2e /IkiWiki.pm
parent0daec2bf14871072a4b3d3aebbbfc5eaa7608ef5 (diff)
downloadikiwiki-2a0d91af2f8f6ca3142c8f73ea6869e7a914bb30.tar
ikiwiki-2a0d91af2f8f6ca3142c8f73ea6869e7a914bb30.tar.gz
* Fix link() PageSpecs to not just look at the raw link text, but at where
that given link points based on the page doing the linking. Note that this could make such PageSpecs match different things than before, if you relied on the old behavior of them only matching the raw link text. * This required changing the match_* interface, adding a third parameter. * Allow link() PageSpecs to match relative, as is allowed with globs.a * Add postform option to inline plugin. * Add an bug tracker to the softwaresite example.
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r--IkiWiki.pm33
1 files changed, 23 insertions, 10 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 9e71cc153..2d0f3c383 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -921,7 +921,7 @@ sub pagespec_translate ($) { #{{{
}
elsif ($word =~ /^(\w+)\((.*)\)$/) {
if (exists $IkiWiki::PageSpec::{"match_$1"}) {
- $code.=" IkiWiki::PageSpec::match_$1(\$page, ".safequote($2).")";
+ $code.="IkiWiki::PageSpec::match_$1(\$page, ".safequote($2).", \$from)";
}
else {
$code.=" 0";
@@ -968,22 +968,35 @@ sub match_glob ($$$) { #{{{
return $page=~/^$glob$/i;
} #}}}
-sub match_link ($$) { #{{{
+sub match_link ($$$) { #{{{
my $page=shift;
my $link=lc(shift);
+ my $from=shift;
+ if (! defined $from){
+ $from = "";
+ }
+
+ # relative matching
+ if ($link =~ m!^\.! && defined $from) {
+ $from=~s!/?[^/]+$!!;
+ $link=~s!^\./!!;
+ $link="$from/$link" if length $from;
+ }
my $links = $IkiWiki::links{$page} or return undef;
+ return 0 unless @$links;
+ my $bestlink = IkiWiki::bestlink($from, $link);
foreach my $p (@$links) {
- return 1 if lc $p eq $link;
+ return 1 if $bestlink eq IkiWiki::bestlink($page, $p);
}
return 0;
} #}}}
-sub match_backlink ($$) { #{{{
- match_link(pop, pop);
+sub match_backlink ($$$) { #{{{
+ match_link($_[1], $_[0], $_[3]);
} #}}}
-sub match_created_before ($$) { #{{{
+sub match_created_before ($$$) { #{{{
my $page=shift;
my $testpage=shift;
@@ -995,7 +1008,7 @@ sub match_created_before ($$) { #{{{
}
} #}}}
-sub match_created_after ($$) { #{{{
+sub match_created_after ($$$) { #{{{
my $page=shift;
my $testpage=shift;
@@ -1007,15 +1020,15 @@ sub match_created_after ($$) { #{{{
}
} #}}}
-sub match_creation_day ($$) { #{{{
+sub match_creation_day ($$$) { #{{{
return ((gmtime($IkiWiki::pagectime{shift()}))[3] == shift);
} #}}}
-sub match_creation_month ($$) { #{{{
+sub match_creation_month ($$$) { #{{{
return ((gmtime($IkiWiki::pagectime{shift()}))[4] + 1 == shift);
} #}}}
-sub match_creation_year ($$) { #{{{
+sub match_creation_year ($$$) { #{{{
return ((gmtime($IkiWiki::pagectime{shift()}))[5] + 1900 == shift);
} #}}}