From 0ba0e6ceaabf35556c29c43b6d8ef7b65007ca18 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 2 Jan 2011 19:56:27 +0100 Subject: [PATCH] inline: feedlinks parameter This allows the user to choose where the feed links will be placed, with possibilities being head, body, both or none. --- IkiWiki/Plugin/inline.pm | 25 ++++++++++++++++++++++--- doc/ikiwiki/directive/inline.mdwn | 6 ++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index db9019410..ff29a4ee9 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -170,6 +170,24 @@ sub preprocess_inline (@) { my $feeds=exists $params{feeds} ? yesno($params{feeds}) : !$quick && ! $raw; my $emptyfeeds=exists $params{emptyfeeds} ? yesno($params{emptyfeeds}) : 1; my $feedonly=yesno($params{feedonly}); + + # where to put the feed links: head (1), body (2), both (3) + my $feedlinkloc = 3; + if (exists $params{feedlinks}) { + if ($params{feedlinks} eq 'both') { + $feedlinkloc = 3; + } elsif ($params{feedlinks} eq 'body') { + $feedlinkloc = 2; + } elsif ($params{feedlinks} eq 'head') { + $feedlinkloc = 1; + } elsif ($params{feedlinks} eq 'none') { + $feedlinkloc = 0; + } else { + print STDERR sprintf(gettext("warning: unknown feedlinks location %s"), + $params{feedlinks})."\n"; + } + } + if (! exists $params{show} && ! $archive) { $params{show}=10; } @@ -355,7 +373,8 @@ sub preprocess_inline (@) { # emptyfeeds cannot be hidden. $emptyfeeds=1; } - elsif ($feeds && !$params{preview} && ($emptyfeeds || @feedlist)) { + elsif ($feeds && !$params{preview} && ($emptyfeeds || @feedlist) + && ($feedlinkloc & 2)) { # Add feed buttons. my $linktemplate=template_depends("feedlink.tmpl", $params{page}, blind_cache => 1); if ($rss) { @@ -462,7 +481,7 @@ sub preprocess_inline (@) { genfeed("rss", $config{url}."/".$rssp, $feedtitle, $desc, $params{guid}, $params{page}, @feedlist)); $toping{$params{destpage}}=1 unless $config{rebuild}; - $feedlinks{$params{destpage}}.=qq{}; + $feedlinks{$params{destpage}}.=qq{} if ($feedlinkloc & 1); } } if ($atom) { @@ -472,7 +491,7 @@ sub preprocess_inline (@) { writefile($atomp, $config{destdir}, genfeed("atom", $config{url}."/".$atomp, $feedtitle, $desc, $params{guid}, $params{page}, @feedlist)); $toping{$params{destpage}}=1 unless $config{rebuild}; - $feedlinks{$params{destpage}}.=qq{}; + $feedlinks{$params{destpage}}.=qq{} if ($feedlinkloc & 1); } } } diff --git a/doc/ikiwiki/directive/inline.mdwn b/doc/ikiwiki/directive/inline.mdwn index c6a23ce3c..0a87d0e4e 100644 --- a/doc/ikiwiki/directive/inline.mdwn +++ b/doc/ikiwiki/directive/inline.mdwn @@ -109,6 +109,12 @@ Here are some less often needed parameters: For example, set "feedfile=feed" to cause it to generate `page/feed.atom` and/or `page/feed.rss`. This option is not supported if the wiki is configured not to use `usedirs`. +* `feedlinks` - Can be used to change where the feed links are inserted. + A value of `head` means that links to the feeds will only be put in the + document head: there will be no visible link, but the feeds will be found by + the autodiscover feature in most moder browser. A value of `body` means that + links to the feeds will be inserted in the page body. It is also possible to + specify `both` (the default) or `none`. * `pagenames` - If given instead of `pages`, this is interpreted as a space-separated list of links to pages (with the same [[SubPage/LinkingRules]] as in a [[ikiwiki/WikiLink]]), and they are inlined -- 2.32.0.93.g670b81a890