Permalink
Browse files

added rss

  • Loading branch information...
1 parent 06bfd1c commit 86e67c1a7f9e45f2531bc65204887d8dfae2d9c0 mucker committed Jan 4, 2012
Showing with 28 additions and 5 deletions.
  1. +2 −0 README
  2. +5 −1 blosxom.psgi
  3. +4 −4 template.html
  4. +17 −0 template.rss
View
2 README
@@ -22,6 +22,8 @@ There is no pagination. By default two months blogs posts are displayed.
/2012/Jan
/2012/Jan/Tue
+/all.rss -> RSS feed
+
Perl syntax highlighting is provided with
- http://alexgorbatchev.com/SyntaxHighlighter/
View
6 blosxom.psgi
@@ -13,6 +13,7 @@ my $config = {
data_dir => 'data/',
title => "Welcome to my Mucking Blog!",
author => "mucker",
+ domain => "http://localhost"
};
sub get_entries {
@@ -61,6 +62,9 @@ sub mainapp {
elsif ( $path_info =~ m{^/all$} ) {
#do nothing. leave @entries as it is
}
+ elsif ( $path_info =~ m{^/rss$} ) {
+ #do nothing. leave @entries as it is for rss
+ }
elsif ( $path_info =~
m{/(?<year>\d{4})(?:/(?<month>\w\w\w)(?:/(?<day>\w\w\w))?)?$} )
{
@@ -94,7 +98,7 @@ sub mainapp {
"template$flavor",
{
entries => \@entries,
- home => $env->{"SCRIPT_NAME"} // '/',
+ port => $env->{"SERVER_PORT"},
%$config,
}
);
View
8 template.html
@@ -4,7 +4,6 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?= $args->{title} ?></title>
- <link rel="alternate" title="Atom" type="application/atom+xml" href="<?= $args->{home} ?>/index.atom"/>
<!-- Include required JS files -->
@@ -136,15 +135,16 @@
</head>
<body>
<div class="all">
- <h1 id="top"><a href="<?= $args->{home} ?>/"><?= $args->{title} ?></a></h1>
+ <h1 id="top"><?= $args->{title} ?></h1>
- <div align="left"><a href="/all">View all</a></div>
+ <div align="left"><a href="/all">View all</a>&nbsp;
+ <a style="align:right" href="/all.rss">RSS</a></div>
<div id="content" class="hfeed">
<? for my $entry (@{ $args->{entries} }) { ?>
<div class="hentry">
<div class="entry-title">
- <a href="/<?= $args->{home} ?><?= $entry->{name} ?>"><?= $entry->{title} ?></a>
+ <a href='<?= "$args->{domain}:$args->{port}/$entry->{name}" ?>'><?= $entry->{title} ?></a>
<div class="entry-date" align="right"><?= $entry->{mtime}->mdy("/") ?></div>
</div>
<div class="entry-content">
View
17 template.rss
@@ -0,0 +1,17 @@
+?= encoded_string("\<\?xml version=\"1.0\" encoding=\"UTF-8\" \?\>")
+<? use Text::MicroTemplate qw(encoded_string);?>
+<? my $args = shift;?>
+<rss version="2.0">
+ <channel>
+ <title></title>
+ <link>http://liftoff.msfc.nasa.gov/</link>
+ <language>en-us</language>
+? for my $entry (@{ $args->{entries} }) {
+ <item>
+ <title><?= $entry->{title} ?></title>
+ <link><?= "$args->{domain}:$args->{port}/$entry->{name}" ?></link>
+ <description><?= $entry->{content} ?></description>
+ </item>
+? }
+ </channel>
+</rss>

0 comments on commit 86e67c1

Please sign in to comment.