]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Make aggregator save permalinks and author name to pages as metadata.
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Fri, 4 Aug 2006 00:01:51 +0000 (00:01 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Fri, 4 Aug 2006 00:01:51 +0000 (00:01 +0000)
* Add permalink and author support to meta plugin, affecting RSS feeds
  and blog pages.
* Change titlepage() to encode utf-8 alnum characters. This is necessary
  to avoid UTF-8 creeping into filenames in urls. (There are still
  some other ways that it can get in.)

IkiWiki.pm
IkiWiki/Plugin/aggregate.pm
IkiWiki/Plugin/inline.pm
IkiWiki/Plugin/meta.pm
debian/changelog
doc/plugins/meta.mdwn
doc/todo/aggregation.mdwn
templates/aggregatepost.tmpl
templates/inlinepage.tmpl
templates/rssitem.tmpl
templates/rsspage.tmpl

index a732be99956bda3c0539c5a6c1e9650ccc595376..1a5cf52ddea717bf366351e4a79c18460be3006a 100644 (file)
@@ -272,7 +272,9 @@ sub pagetitle ($) { #{{{
 sub titlepage ($) { #{{{
        my $title=shift;
        $title=~y/ /_/;
-       $title=~s/([^-[:alnum:]_:+\/.])/"__".ord($1)."__"/eg;
+       # Note: [:alnum:] is not used here, on purpose; unicode
+       # not allowed in urls.
+       $title=~s/([^-A-Za-z0-9_:+\/.])/"__".ord($1)."__"/eg;
        return $title;
 } #}}}
 
index d6592fef30f96fdfe20c5d812ef38fc77c373fd5..c6ed6b209d634eed3f30bfaaefe5ab60adbb331d 100644 (file)
@@ -289,9 +289,8 @@ sub add_page (@) { #{{{
        $template->param(title => $params{title})
                if defined $params{title} && length($params{title});
        $template->param(content => htmlescape(htmlabs($params{content}, $feed->{feedurl})));
-       $template->param(url => $feed->{url});
        $template->param(name => $feed->{name});
-       $template->param(link => urlabs($params{link}, $feed->{feedurl}))
+       $template->param(permalink => urlabs($params{link}, $feed->{feedurl}))
                if defined $params{link};
        if (ref $feed->{tags}) {
                $template->param(tags => [map { tag => $_ }, @{$feed->{tags}}]);
index d8f2ca0d8baf6b70dc1d560d20a977b7a719993a..71e71c02e4b4cb3aeccf2ec42247e9efa08dde96 100644 (file)
@@ -173,6 +173,7 @@ sub genrss ($@) { #{{{
                $itemtemplate->param(
                        title => pagetitle(basename($p)),
                        url => "$config{url}/$renderedfiles{$p}",
+                       permalink => "$config{url}/$renderedfiles{$p}",
                        pubdate => date_822($pagectime{$p}),
                        content => absolute_urls(get_inline_content($p, $page), $url),
                );
@@ -180,6 +181,7 @@ sub genrss ($@) { #{{{
                        shift->(page => $p, destpage => $page,
                                template => $itemtemplate);
                });
+
                $content.=$itemtemplate->output;
                $itemtemplate->clear_params;
        }
@@ -191,7 +193,6 @@ sub genrss ($@) { #{{{
                pageurl => $url,
                content => $content,
        );
-       
        run_hooks(pagetemplate => sub {
                shift->(page => $page, destpage => $page,
                        template => $template);
index bac16346932d2a00e1bc034d500a1fe8a08abebb..b6226ed88a19deca8c72b49ad658263993bff8c0 100644 (file)
@@ -8,6 +8,8 @@ use IkiWiki;
 
 my %meta;
 my %title;
+my %permalink;
+my %author;
 
 sub import { #{{{
        IkiWiki::hook(type => "preprocess", id => "meta", 
@@ -57,9 +59,15 @@ sub preprocess (@) { #{{{
        elsif ($key eq 'title') {
                $title{$page}=$value;
        }
+       elsif ($key eq 'permalink') {
+               $permalink{$page}=$value;
+       }
        else {
                $meta{$page}.="<meta name=\"".encode_entities($key).
                        "\" content=\"".encode_entities($value)."\" />\n";
+               if ($key eq 'author') {
+                       $author{$page}=$value;
+               }
        }
 
        return "";
@@ -74,6 +82,11 @@ sub pagetemplate (@) { #{{{
                if exists $meta{$page} && $template->query(name => "meta");
        $template->param(title => $title{$page})
                if exists $title{$page} && $template->query(name => "title");
+       $template->param(permalink => $permalink{$page})
+               if exists $permalink{$page} && $template->query(name => "permalink");
+       $template->param(author => $author{$page})
+               if exists $author{$page} && $template->query(name => "author");
+       
 } # }}}
 
 1
index ab053e4968e8eb15d70681e0935d3d40c0761cfe..aca30fc816b6f4e0a46232dfdf21241d88a786d1 100644 (file)
@@ -4,8 +4,14 @@ ikiwiki (1.16) UNRELEASED; urgency=low
     the current support is a crude hack due to limitations of XML::Feed:
     xml:base is not supported, neither is Content-Location. And of course,
     relative links in RSS feeds are ill-undefined..
-
- -- Joey Hess <joeyh@debian.org>  Thu,  3 Aug 2006 17:29:51 -0400
+  * Make aggregator save permalinks and author name to pages as metadata.
+  * Add permalink and author support to meta plugin, affecting RSS feeds
+    and blog pages.
+  * Change titlepage() to encode utf-8 alnum characters. This is necessary
+    to avoid UTF-8 creeping into filenames in urls. (There are still
+    some other ways that it can get in.)
+
+ -- Joey Hess <joeyh@debian.org>  Thu,  3 Aug 2006 18:45:36 -0400
 
 ikiwiki (1.15) unstable; urgency=low
 
index 32392ed546b3f67d1016751139b1d47d464cd4ff..cacb462c9564e8f2efdb55f270c3a191f27be4d1 100644 (file)
@@ -36,6 +36,10 @@ You can use any field names you like, but here are some predefined ones:
 
   Specifies the author of a page.
 
+* permalink
+
+  Specifies the permalink to the page, for use in RSS feeds.
+
 If the field is not treated specially (as the link and title fields are),
 the metadata will be written to the generated html page as a &lt;meta&gt;
 header.
index dec242ea67db45d106426e643cb33367136f2465..53b3133e2c4c25389d79cbb39a4d25f057cff3c9 100644 (file)
@@ -1,4 +1 @@
 * Still need to support feed expiry.
-* Need to store page author metadata and include it in the rss feed.
-  Permalink to? Also, that stuff could be presented better in the html blog
-  view, also using the metadata.
index 689a23341b9e283f37c770e52ca7fb35e4a56aea..50c09fff8c0ff2e1e8dc34e042463f47cf6e04b4 100644 (file)
@@ -1,15 +1,12 @@
 <TMPL_VAR CONTENT>
-<p>
-<i>
-From <a href="<TMPL_VAR URL>"><TMPL_VAR NAME></a>
-<TMPL_IF NAME="LINK">
-; <a href="<TMPL_VAR LINK>">permalink</a>
-</TMPL_IF>
-</i>
-</p>
+<br/>
 <TMPL_LOOP NAME="TAGS">
 [[tag <TMPL_VAR TAG>]]
 </TMPL_LOOP>
 <TMPL_IF NAME="TITLE">
 [[meta title="<TMPL_VAR NAME="TITLE" ESCAPE=HTML>"]]
 </TMPL_IF>
+<TMPL_IF NAME="PERMALINK">
+[[meta permalink="<TMPL_VAR NAME="PERMALINK" ESCAPE=HTML>"]]
+</TMPL_IF>
+[[meta author="<TMPL_VAR NAME="NAME" ESCAPE=HTML>"]]
index c2ddff8676805b0756da3232669ad7227ca30146..6840f36817a8ce0956a97988405ea55e5963569d 100644 (file)
@@ -5,6 +5,12 @@
 
 <span class="pageinfo">
 Posted <TMPL_VAR CTIME>
+<TMPL_IF NAME="AUTHOR">
+by <TMPL_VAR NAME=AUTHOR>
+</TMPL_IF>
+<TMPL_IF NAME="PERMALINK">
+(<a href="<TMPL_VAR NAME=PERMALINK>">permalink</a>)
+</TMPL_IF>
 </span>
 
 <span class="tags">
index 421600591ea50189a2e38a06b4d3a13003df2444..c7e587e1c7d6121f2474019d7f649c50f68b7fe7 100644 (file)
@@ -1,10 +1,15 @@
 <item>
+       <TMPL_IF NAME="AUTHOR">
+       <title><TMPL_VAR AUTHOR ESCAPE=HTML>: <TMPL_VAR TITLE ESCAPE=HTML></title>
+       <dc:creator><TMPL_VAR AUTHOR ESCAPE=HTML></dc:creator>
+       <TMPL_ELSE>
        <title><TMPL_VAR TITLE ESCAPE=HTML></title>
+       </TMPL_IF>
        <guid><TMPL_VAR URL></guid>
-       <link><TMPL_VAR URL></link>
+       <link><TMPL_VAR PERMALINK></link>
        <TMPL_IF NAME="CATEGORIES">
        <TMPL_LOOP NAME="CATEGORIES">
-       <category><TMPL_VAR NAME=CATEGORY></category>
+       <category><TMPL_VAR CATEGORY></category>
        </TMPL_LOOP>
        </TMPL_IF>
        <pubDate><TMPL_VAR PUBDATE></pubDate>
index e7676ebbd11253ceb3ad9aa55d7cf46c6ee0350d..d78f94edfbc2738fe31e6f347c1511b5a273f99a 100644 (file)
@@ -1,5 +1,6 @@
 <?xml version="1.0"?>
-<rss version="2.0">
+<rss version="2.0"
+       xmlns:dc="http://purl.org/dc/elements/1.1/">
 <channel>
 <title><TMPL_VAR TITLE ESCAPE=HTML></title>
 <link><TMPL_VAR PAGEURL></link>