From: Joey Hess <joey@kodama.kitenet.net>
Date: Thu, 11 Dec 2008 19:04:38 +0000 (-0500)
Subject: inline: Support emptyfeeds=no option to skip generating empty feeds.
X-Git-Tag: 2.71~160
X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/63eb9d834e2f7e08535473934e169cfe7d7debe6?ds=inline;hp=--cc

inline: Support emptyfeeds=no option to skip generating empty feeds.
---

63eb9d834e2f7e08535473934e169cfe7d7debe6
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index 0c8f50384..5e4df95f4 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -161,6 +161,7 @@ sub preprocess_inline (@) { #{{{
 	my $atom=(($config{atom} || $config{allowatom}) && exists $params{atom}) ? yesno($params{atom}) : $config{atom};
 	my $quick=exists $params{quick} ? yesno($params{quick}) : 0;
 	my $feeds=exists $params{feeds} ? yesno($params{feeds}) : !$quick;
+	my $emptyfeeds=exists $params{emptyfeeds} ? yesno($params{emptyfeeds}) : 1;
 	my $feedonly=yesno($params{feedonly});
 	if (! exists $params{show} && ! $archive) {
 		$params{show}=10;
@@ -289,8 +290,13 @@ sub preprocess_inline (@) { #{{{
 				gettext("Add a new post titled:"));
 		}
 		$ret.=$formtemplate->output;
+	    	
+		# The post form includes the feed buttons, so
+		# emptyfeeds cannot be hidden.
+		$emptyfeeds=1;
 	}
-	elsif ($feeds && !$params{preview}) {
+	elsif ($feeds && !$params{preview} &&
+	       ! (! $emptyfeeds && ! @feedlist)) {
 		# Add feed buttons.
 		my $linktemplate=template("feedlink.tmpl", blind_cache => 1);
 		$linktemplate->param(rssurl => $rssurl) if $rss;
@@ -367,7 +373,7 @@ sub preprocess_inline (@) { #{{{
 		}
 	}
 	
-	if ($feeds) {
+	if ($feeds && ! (! $emptyfeeds && ! @feedlist)) {
 		if ($rss) {
 			my $rssp=rsspage($params{destpage}).$feednum;
 			will_render($params{destpage}, $rssp);
diff --git a/debian/changelog b/debian/changelog
index 8d2b6661f..7f6844366 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,7 @@ ikiwiki (2.71) UNRELEASED; urgency=low
   * Fix handling of wrappergroup option.
   * Correct --dumpsetup to include the srcdir in the setup file.
   * German translation update from Kai Wasserbäch. Closes: #507056
+  * inline: Support emptyfeeds=no option to skip generating empty feeds.
 
  -- Joey Hess <joeyh@debian.org>  Mon, 17 Nov 2008 14:02:10 -0500
 
diff --git a/doc/ikiwiki/directive/inline.mdwn b/doc/ikiwiki/directive/inline.mdwn
index 9889cda11..82b532e0c 100644
--- a/doc/ikiwiki/directive/inline.mdwn
+++ b/doc/ikiwiki/directive/inline.mdwn
@@ -73,6 +73,8 @@ Here are some less often needed parameters:
   configured to `allowatom`, set to "yes" to enable.
 * `feeds` - controls generation of all types of feeds. Set to "no" to
   disable generating any feeds.
+* `emptyfeeds` - Set to "no" to disable generation of empty feeds.
+  Has no effect if `rootpage` or `postform` is set.
 * `template` - Specifies the template to fill out to display each inlined
   page. By default the `inlinepage` template is used, while
   the `archivepage` template is used for archives. Set this parameter to
@@ -97,7 +99,7 @@ Here are some less often needed parameters:
   in the blog. The format string is passed to the strftime(3) function.
 * `feedpages` - A [[PageSpec]] of inlined pages to include in the rss/atom
   feeds. The default is the same as the `pages` value above, and only pages
-  matches by that value are included, but some of those can be excluded by
+  matched by that value are included, but some of those can be excluded by
   specifying a tighter [[PageSpec]] here.
 * `guid` - If a URI is given here (perhaps a UUID prefixed with `urn:uuid:`),
   the Atom feed will have this as its `<id>`. The default is to use the URL
diff --git a/doc/todo/inline_plugin:_hide_feed_buttons_if_empty.mdwn b/doc/todo/inline_plugin:_hide_feed_buttons_if_empty.mdwn
index f998d5654..d046c0cd0 100644
--- a/doc/todo/inline_plugin:_hide_feed_buttons_if_empty.mdwn
+++ b/doc/todo/inline_plugin:_hide_feed_buttons_if_empty.mdwn
@@ -2,3 +2,6 @@
                drop the rss/atom buttons for comments when there are none yet
 
 This seems to me like something that applies to the [[plugins/inline]] plugin in general, rather than the [[plugins/contrib/comments]] plugin specifically. --[[smcv]]
+
+>> [[done]] as emptyfeeds option, not on by default for inline, but I think
+>> it should be for comments --[[Joey]]