]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* meta: Run in scan mode again (more intelligently) and re-add support for
authorJoey Hess <joey@kodama.kitenet.net>
Wed, 9 Jan 2008 07:38:43 +0000 (02:38 -0500)
committerJoey Hess <joey@kodama.kitenet.net>
Wed, 9 Jan 2008 07:38:43 +0000 (02:38 -0500)
  meta link.
* Fix support for the case where metadata appears after an inline directive.
  This was broken in version 2.16.

IkiWiki/Plugin/inline.pm
IkiWiki/Plugin/meta.pm
debian/NEWS
debian/changelog
doc/plugins/meta.mdwn
doc/plugins/write.mdwn

index 53b051816740db8a2448ac76c04192e887843eb1..59eabb606e9967a0a3fb58bc5f0f338a3339f405 100644 (file)
@@ -152,7 +152,12 @@ sub preprocess_inline (@) { #{{{
        # that if they are removed or otherwise changed, the inline will be
        # sure to be updated.
        add_depends($params{page}, join(" or ", @list));
        # that if they are removed or otherwise changed, the inline will be
        # sure to be updated.
        add_depends($params{page}, join(" or ", @list));
-       
+       # Force a scan of this page so any metadata that appears after this
+       # inline directive is available when inlining. The page normally 
+       # wouldn't be scanned if it's only being rebuilt because of a
+       # depedency.
+       IkiWiki::scan($pagesources{$params{page}});
+
        my $feednum="";
 
        my $feedid=join("\0", map { $_."\0".$params{$_} } sort keys %params);
        my $feednum="";
 
        my $feedid=join("\0", map { $_."\0".$params{$_} } sort keys %params);
index 88c942fa4f85ba2664eb9756e60421ee22aacc44..586dbcb811a45b3091957dd120c8833a8d69ba07 100644 (file)
@@ -16,7 +16,7 @@ my %copyright;
 
 sub import { #{{{
        hook(type => "needsbuild", id => "meta", call => \&needsbuild);
 
 sub import { #{{{
        hook(type => "needsbuild", id => "meta", call => \&needsbuild);
-       hook(type => "preprocess", id => "meta", call => \&preprocess);
+       hook(type => "preprocess", id => "meta", call => \&preprocess, scan => 1);
        hook(type => "pagetemplate", id => "meta", call => \&pagetemplate);
 } # }}}
 
        hook(type => "pagetemplate", id => "meta", call => \&pagetemplate);
 } # }}}
 
@@ -77,13 +77,10 @@ sub preprocess (@) { #{{{
        # fully encoded.
        $value=decode_entities($value);
 
        # fully encoded.
        $value=decode_entities($value);
 
+       # Metadata collection that needs to happen during the scan pass.
        if ($key eq 'title') {
                $title{$page}=HTML::Entities::encode_numeric($value);
        }
        if ($key eq 'title') {
                $title{$page}=HTML::Entities::encode_numeric($value);
        }
-       elsif ($key eq 'permalink') {
-               $permalink{$page}=$value;
-               push @{$meta{$page}}, scrub('<link rel="bookmark" href="'.encode_entities($value).'" />');
-       }
        elsif ($key eq 'date') {
                eval q{use Date::Parse};
                if (! $@) {
        elsif ($key eq 'date') {
                eval q{use Date::Parse};
                if (! $@) {
@@ -91,6 +88,40 @@ sub preprocess (@) { #{{{
                        $IkiWiki::pagectime{$page}=$time if defined $time;
                }
        }
                        $IkiWiki::pagectime{$page}=$time if defined $time;
                }
        }
+       elsif ($key eq 'license') {
+               push @{$meta{$page}}, '<link rel="license" href="#page_license" />';
+               $license{$page}=$value;
+               return "";
+       }
+       elsif ($key eq 'copyright') {
+               push @{$meta{$page}}, '<link rel="copyright" href="#page_copyright" />';
+               $copyright{$page}=$value;
+               return "";
+       }
+       elsif ($key eq 'link' && ! %params) {
+               # hidden WikiLink
+               push @{$links{$page}}, $value;
+               return "";
+       }
+       elsif ($key eq 'author') {
+               $author{$page}=$value;
+               # fallthorough
+       }
+       elsif ($key eq 'authorurl') {
+               $authorurl{$page}=$value;
+               # fallthrough
+       }
+
+       if (! defined wantarray) {
+               # avoid collecting duplicate data during scan pass
+               return;
+       }
+
+       # Metadata collection that happens only during preprocessing pass.
+       if ($key eq 'permalink') {
+               $permalink{$page}=$value;
+               push @{$meta{$page}}, scrub('<link rel="bookmark" href="'.encode_entities($value).'" />');
+       }
        elsif ($key eq 'stylesheet') {
                my $rel=exists $params{rel} ? $params{rel} : "alternate stylesheet";
                my $title=exists $params{title} ? $params{title} : $value;
        elsif ($key eq 'stylesheet') {
                my $rel=exists $params{rel} ? $params{rel} : "alternate stylesheet";
                my $title=exists $params{title} ? $params{title} : $value;
@@ -113,14 +144,6 @@ sub preprocess (@) { #{{{
                push @{$meta{$page}}, '<link href="'.encode_entities($value).
                        '" rel="openid.delegate" />';
        }
                push @{$meta{$page}}, '<link href="'.encode_entities($value).
                        '" rel="openid.delegate" />';
        }
-       elsif ($key eq 'license') {
-               push @{$meta{$page}}, '<link rel="license" href="#page_license" />';
-               $license{$page}=$value;
-       }
-       elsif ($key eq 'copyright') {
-               push @{$meta{$page}}, '<link rel="copyright" href="#page_copyright" />';
-               $copyright{$page}=$value;
-       }
        elsif ($key eq 'redir') {
                return "" if $page ne $destpage;
                my $safe=0;
        elsif ($key eq 'redir') {
                return "" if $page ne $destpage;
                my $safe=0;
@@ -160,17 +183,17 @@ sub preprocess (@) { #{{{
                push @{$meta{$page}}, $redir;
        }
        elsif ($key eq 'link') {
                push @{$meta{$page}}, $redir;
        }
        elsif ($key eq 'link') {
-               return "[[meta ".gettext("link is no longer supported")."]]";
+               if (%params) {
+                       $meta{$page}.=scrub("<link href=\"".encode_entities($value)."\" ".
+                               join(" ", map {
+                                       encode_entities($_)."=\"".encode_entities(decode_entities($params{$_}))."\""
+                               } keys %params).
+                               " />\n");
+               }
        }
        else {
                push @{$meta{$page}}, scrub('<meta name="'.encode_entities($key).
                        '" content="'.encode_entities($value).'" />');
        }
        else {
                push @{$meta{$page}}, scrub('<meta name="'.encode_entities($key).
                        '" content="'.encode_entities($value).'" />');
-               if ($key eq 'author') {
-                       $author{$page}=$value;
-               }
-               elsif ($key eq 'authorurl') {
-                       $authorurl{$page}=$value;
-               }
        }
 
        return "";
        }
 
        return "";
@@ -197,15 +220,6 @@ sub pagetemplate (@) { #{{{
                if exists $author{$page} && $template->query(name => "author");
        $template->param(authorurl => $authorurl{$page})
                if exists $authorurl{$page} && $template->query(name => "authorurl");
                if exists $author{$page} && $template->query(name => "author");
        $template->param(authorurl => $authorurl{$page})
                if exists $authorurl{$page} && $template->query(name => "authorurl");
-               
-       if ($page ne $destpage &&
-           ((exists $license{$page}   && ! exists $license{$destpage}) ||
-            (exists $copyright{$page} && ! exists $copyright{$destpage}))) {
-               # Force a scan of the destpage to get its copyright/license
-               # info. If the info is declared after an inline, it will
-               # otherwise not be available at this point.
-               IkiWiki::scan($pagesources{$destpage});
-       }
 
        if (exists $license{$page} && $template->query(name => "license") &&
            ($page eq $destpage || ! exists $license{$destpage} ||
 
        if (exists $license{$page} && $template->query(name => "license") &&
            ($page eq $destpage || ! exists $license{$destpage} ||
index 203f31e1aa69e057a529b4191862b2aeb9b4ae1c..c8228d4bd171e51757d7754d68a4e4ddc4daafbe 100644 (file)
@@ -5,10 +5,6 @@ ikiwiki (2.16) unstable; urgency=low
   Redirection pages have been left behind for these moved pages temporarily,
   and will be removed later.
 
   Redirection pages have been left behind for these moved pages temporarily,
   and will be removed later.
 
-  The meta plugin no longer supports setting internal or external links
-  with "meta link". Instead, use "meta openid" for openid links, and use tags
-  for in-wiki invisible links between pages.
-
   If you use the calendar plugin, ikiwiki is now smarter and your nightly
   cron job to update the wiki doesn't need to rebuild everything. Just pass
   --refresh to ikiwiki in the cron job and it will update only pages that
   If you use the calendar plugin, ikiwiki is now smarter and your nightly
   cron job to update the wiki doesn't need to rebuild everything. Just pass
   --refresh to ikiwiki in the cron job and it will update only pages that
index d5117d867d1915226e870f096a49a9ea49ea8a55..db64abe815478b682aa35bb4eaa4caa5f6c591bf 100644 (file)
@@ -2,7 +2,18 @@ ikiwiki (2.20) UNRELEASED; urgency=low
 
   * inline: Add copyright/license info on a per-post basis to atom
     feeds if available. (rss doesn't allow such info on a per-post basis)
 
   * inline: Add copyright/license info on a per-post basis to atom
     feeds if available. (rss doesn't allow such info on a per-post basis)
+  * Also include overall copyright/license and author info in atom feeds if
+    available.
   * meta: Allow copyright/license metadata to contain arbitrary markup.
   * meta: Allow copyright/license metadata to contain arbitrary markup.
+  * Call preprocessor hooks in void context during the scan pass. This allows
+    the hook to determine if it's just scanning, and avoid expensive
+    operations.
+  * img: Detect scan mode and avoid generating and writing the image file
+    during it, for a 2x speedup.
+  * meta: Run in scan mode again (more intelligently) and re-add support for
+    meta link.
+  * Fix support for the case where metadata appears after an inline directive.
+    This was broken in version 2.16.
 
  -- Joey Hess <joeyh@debian.org>  Wed, 09 Jan 2008 00:34:46 -0500
 
 
  -- Joey Hess <joeyh@debian.org>  Wed, 09 Jan 2008 00:34:46 -0500
 
index ec4348e4132d2fc67917cf6db9b18e79b6c120a9..0bcd11b67289fbdfb833a3d27df6cdfa549dd24f 100644 (file)
@@ -69,6 +69,21 @@ Supported fields:
        \\[[meta openid="http://joeyh.myopenid.com/"
        server="http://www.myopenid.com/server"]]
 
        \\[[meta openid="http://joeyh.myopenid.com/"
        server="http://www.myopenid.com/server"]]
 
+* link
+
+  Specifies a link to another page. This can be used as a way to make the
+  wiki treat one page as linking to another without displaying a user-visible
+  [[ikiwiki/WikiLink]]:
+
+       \[[meta link=otherpage]]
+
+  It can also be used to insert a html &lt;link&gt; tag. For example:
+
+       \[[meta link="http://joeyh.myopenid.com/" rel="openid.delegate"]]
+
+  However, this latter syntax won't be allowed if the [[htmlscrubber]] is
+  enabled, since it can be used to insert unsafe content.
+
 * redir
 
   Causes the page to redirect to another page in the wiki.
 * redir
 
   Causes the page to redirect to another page in the wiki.
index 34caf83f68e8aa469febccf1031a1dae95896a7f..0da425402fb53b826eab803fb619e3daa8ed97c6 100644 (file)
@@ -123,7 +123,9 @@ An optional "scan" parameter, if set to a true value, makes the hook be
 called during the preliminary scan that ikiwiki makes of updated pages,
 before begining to render pages. This parameter should be set to true if
 the hook modifies data in `%links`. Note that doing so will make the hook
 called during the preliminary scan that ikiwiki makes of updated pages,
 before begining to render pages. This parameter should be set to true if
 the hook modifies data in `%links`. Note that doing so will make the hook
-be run twice per page build, so avoid doing it for expensive hooks.
+be run twice per page build, so avoid doing it for expensive hooks. (As an
+optimisation, if your preprocessor hook is called in a void contets, you
+can assume it's being run in scan mode.)
 
 Note that if the [[htmlscrubber]] is enabled, html in
 [[ikiwiki/PreProcessorDirective]] output is sanitised, which may limit what
 
 Note that if the [[htmlscrubber]] is enabled, html in
 [[ikiwiki/PreProcessorDirective]] output is sanitised, which may limit what