diff options
author | Joey Hess <joey@kitenet.net> | 2007-12-08 17:40:50 -0500 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2007-12-08 17:40:50 -0500 |
commit | 055179cb4cc9b8bc9b204e1a9f83b1f59e13824e (patch) | |
tree | 1a48f2f93684238180b355df67f2aa48dcfb1be4 /IkiWiki | |
parent | 2fbca21390d2752a89a2e1167fe33d4d201359cf (diff) | |
download | ikiwiki-055179cb4cc9b8bc9b204e1a9f83b1f59e13824e.tar ikiwiki-055179cb4cc9b8bc9b204e1a9f83b1f59e13824e.tar.gz |
* Finally implemented a simple per-page data storage mechanism for plugins,
via the %pagestate hash.
* Use pagestate in meta to detect potential redir loops.
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/external.pm | 18 | ||||
-rw-r--r-- | IkiWiki/Plugin/meta.pm | 7 |
2 files changed, 25 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/external.pm b/IkiWiki/Plugin/external.pm index f76b42c99..8d1baa587 100644 --- a/IkiWiki/Plugin/external.pm +++ b/IkiWiki/Plugin/external.pm @@ -132,6 +132,24 @@ sub setvar ($$$;@) { #{{{ return $ret; } #}}} +sub getstate ($$$$) { #{{{ + my $plugin=shift; + my $page=shift; + my $id=shift; + my $key=shift; + + return $IkiWiki::pagestate{$page}{$id}{$key}; +} #}}} + +sub setstate ($$$$;@) { #{{{ + my $plugin=shift; + my $page=shift; + my $id=shift; + my $key=shift; + + return $IkiWiki::pagestate{$page}{$id}{$key}=@_; +} #}}} + sub inject ($@) { #{{{ # Bind a given perl function name to a particular RPC request. my $plugin=shift; diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index ac8890795..968e6ccee 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -24,6 +24,7 @@ sub filter (@) { #{{{ my %params=@_; $meta{$params{page}}=''; + delete $pagestate{$params{page}}{meta}{redir}; return $params{content}; } # }}} @@ -72,10 +73,16 @@ sub preprocess (@) { #{{{ elsif ($key eq 'redir') { my $safe=0; if ($value !~ /^\w+:\/\//) { + add_depends($page, $value); my $link=bestlink($page, $value); if (! length $link) { return "[[meta ".gettext("redir page not found")."]]"; } + $pagestate{$page}{meta}{redir}=$link; + if ($pagestate{$link}{meta}{redir}) { + # TODO: real cycle detection + return "[[meta ".gettext("redir not allowed to point to a page that contains a redir")."]]"; + } $value=urlto($link, $destpage); $safe=1; } |