Added the ability to disable publishing an RSS feed, renamed the rss_posts directive to a clearer name, recent_posts

This commit is contained in:
Matthew Connelly 2015-04-08 02:34:07 +01:00
parent 8dbb07a23f
commit 9cfcf90d6a
3 changed files with 7 additions and 4 deletions

View File

@ -147,7 +147,7 @@ sub generate_feed {
link => $_->{permaurl},
description => ($blog->{config}->{rss_excerpt}? $_->{excerpt} : $_->{body}),
dc => { creator => $blog->{author}, },
) for @posts[0 .. ($#posts > ($blog->{config}->{rss_posts}-1)? ($blog->{config}->{rss_posts}-1) : $#posts)];
) for @posts[0 .. ($#posts > ($blog->{config}->{recent_posts}-1)? ($blog->{config}->{recent_posts}-1) : $#posts)];
$feed->save("$basedir/public/feed-rss2.xml");
}
sub do_cache {
@ -175,8 +175,8 @@ sub do_cache {
push @nav, {navname => $_, navurl => $blog->{links}->{$_},} for sort { $b cmp $a } keys $blog->{links};
generate_feed;
%defparams = (
INDEX => 0, NAV => [@nav], url => $blog->{url}, recent => [@posts[0 .. ($#posts > ($blog->{config}->{rss_posts}-1)? ($blog->{config}->{rss_posts}-1) : $#posts)]],
gentime => timefmt($lastcache, '%H:%M %e/%-m/%y %Z'), genworktime => sprintf("%.2f ms", tv_interval($st)*100), host => $HOST,
INDEX => 0, NAV => [@nav], url => $blog->{url}, recent => [@posts[0 .. ($#posts > ($blog->{config}->{recent_posts}-1)? ($blog->{config}->{recent_posts}-1) : $#posts)]],
gentime => timefmt($lastcache, '%H:%M %e/%-m/%y %Z'), genworktime => sprintf("%.2f ms", tv_interval($st)*100), host => $HOST, rss_enabled => $blog->{rss_publish},
about => $blog->{about}, author => $blog->{author}, name => $blog->{name}, tagline => $blog->{tagline}, keywords => $blog->{keywords},
robots => $blog->{config}->{indexable}? '<meta name="ROBOTS" content="INDEX, FOLLOW" />' : '<meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />',
);

3
config
View File

@ -9,8 +9,9 @@ posturlprepend: wrote/
config:
indexable: 1
per_page: 6
recent_posts: 8
rss_publish: 1
rss_excerpt: 1
rss_posts: 8
date_format: "%H:%M on %A, %d/%m/%y"
links:
Twitter: https://twitter.com/maffsie

View File

@ -13,7 +13,9 @@
<TMPL_VAR NAME="robots">
<meta name="google-site-verification" content="QtCkt_CI6tmKhrNsw0KvEpScFjDRQQPvmwHGdSTYnGE" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<TMPL_IF NAME="rss_enabled">
<link rel="alternate" type="application/rss+xml" title="<TMPL_VAR NAME="title"> (RSS 2.0)" href="<TMPL_VAR NAME="url">/feed-rss2.xml" />
</TMPL_IF>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.2/custom/bootstrap.min.css" />
<link rel="stylesheet" href="/main.css" />
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/solarized_dark.min.css" />