summaryrefslogtreecommitdiffabout
authorWojciech Polak <polak@gnu.org>2006-01-14 18:52:27 (GMT)
committer Wojciech Polak <polak@gnu.org>2006-01-14 18:52:27 (GMT)
commit34ae1ce7b55a0c106c604912db9bf94424fb9113 (patch) (side-by-side diff)
treedfab56c86092927c055e16ac6624fa5d49b729b0
parent44c5fc1252c3d3a671be89582472908d6f46f176 (diff)
downloadblogright-34ae1ce7b55a0c106c604912db9bf94424fb9113.tar.gz
blogright-34ae1ce7b55a0c106c604912db9bf94424fb9113.tar.bz2
version 2.1
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--blog.php100
-rw-r--r--config.php17
2 files changed, 102 insertions, 15 deletions
diff --git a/blog.php b/blog.php
index be52bce..9410630 100644
--- a/blog.php
+++ b/blog.php
@@ -1,6 +1,6 @@
<?php
-// blogRight! version 2.0.1 (2006-01-05)
+// blogRight! version 2.1 (2006-01-14)
// Copyright (C) 2004, 2005, 2006 Wojciech Polak.
//
// This program is free software; you can redistribute it and/or modify
@@ -213,17 +213,19 @@ if (isset ($RSS) || isset ($_REQUEST['rss']))
header ("ETag: $ETag");
echo '<?xml version="1.0" encoding="'.$charsetEncoding.'"?>'."\n";
+ if ($feedStylesheet)
+ echo "<?xml-stylesheet href=\"$site/$weblogdir/css/rss.css\" type=\"text/css\"?>\n";
echo '<rss version="2.0">'."\n";
echo " <channel>\n";
- echo " <title>$rssTitle</title>\n";
- echo " <description>$rssDescription</description>\n";
+ echo " <title>$feedTitle</title>\n";
+ echo " <description>$feedDescription</description>\n";
echo " <link>$site/$weblogdir/</link>\n";
- echo " <copyright>$rssCopyright</copyright>\n";
- echo " <language>$rssLanguage</language>\n";
+ echo " <copyright>$feedCopyright</copyright>\n";
+ echo " <language>$feedLanguage</language>\n";
echo " <pubDate>$pubDate</pubDate>\n";
echo " <docs>http://blogs.law.harvard.edu/tech/rss</docs>\n";
echo " <generator>blogRight!</generator>\n";
- echo " <managingEditor>$rssEditor</managingEditor>\n";
+ echo " <managingEditor>$feedEditor</managingEditor>\n";
foreach ($include_files as $inc)
{
@@ -266,7 +268,89 @@ if (isset ($RSS) || isset ($_REQUEST['rss']))
}
echo " </channel>\n";
- echo '</rss>'."\n";
+ echo "</rss>\n";
+}
+else if (isset ($ATOM) || isset ($_REQUEST['atom'])) {
+
+ $pubDate = date ('Y-m-d\TH:i:s\Z', filemtime ($include_files[0]));
+ $lastModified = date ('Y-m-d\TH:i:s\Z', filemtime ($include_files[0]));
+ $ETag = '"'.md5 ($lastModified).'"';
+
+ $headers = getallheaders ();
+ if (array_key_exists ('If-Modified-Since', $headers) &&
+ array_key_exists ('If-None-Match', $headers))
+ {
+ if ($headers['If-Modified-Since'] == $lastModified &&
+ $headers['If-None-Match'] == $ETag)
+ {
+ header ('HTTP/1.1 304 Not Modified');
+ exit ();
+ }
+ }
+ header ("Content-Type: text/xml; charset=$charsetEncoding");
+ header ("Last-Modified: $lastModified");
+ header ("ETag: $ETag");
+
+ $tagUri = "tag:$feedAuthorEmail,2004:blog";
+
+ echo '<?xml version="1.0" encoding="'.$charsetEncoding.'"?>'."\n";
+ if ($feedStylesheet)
+ echo "<?xml-stylesheet href=\"$site/$weblogdir/css/atom.css\" type=\"text/css\"?>\n";
+ echo '<feed xmlns="http://www.w3.org/2005/Atom">'."\n";
+ echo " <title>$feedTitle</title>\n";
+ echo " <subtitle>$feedDescription</subtitle>\n";
+ echo " <updated>$pubDate</updated>\n";
+ echo " <author>\n";
+ echo " <name>$feedAuthorName</name>\n";
+ echo " <email>$feedAuthorEmail</email>\n";
+ echo " </author>\n";
+ echo " <rights>$feedCopyright</rights>\n";
+ echo " <generator>blogRight!</generator>\n";
+ echo " <id>$tagUri</id>\n";
+ echo " <link rel=\"self\" type=\"application/atom+xml\" href=\"$site/$weblogdir/atom/\"/>\n";
+ echo " <link rel=\"alternate\" type=\"text/html\" href=\"$site/$weblogdir/\"/>\n";
+
+ foreach ($include_files as $inc)
+ {
+ if (ereg (".*$suffix\$", basename ($inc)))
+ {
+ $cdd = basename (dirname ($inc)); // current data dir
+ if (is_numeric ($cdd))
+ {
+ ereg ('^(.*)-(.*)\.', basename ($inc), $res);
+ $year = $cdd;
+
+ if (isset ($res[1]) && isset ($res[2]))
+ {
+ $month = $res[1];
+ $day = $res[2];
+ }
+
+ $fmtime = mktime (0, 0, 0, $month, $day, $year);
+ }
+ else {
+ $fmtime = filemtime ($inc);
+ }
+
+ $pubDate = date ('Y-m-d\TH:i:s\Z', $fmtime);
+ $itemTitle = date ('d M Y', $fmtime);
+ $permaLink = date ('Ymd', $fmtime);
+
+ echo " <entry>\n";
+ echo " <id>$tagUri/$permaLink</id>\n";
+ echo " <updated>$pubDate</updated>\n";
+ echo " <title>$itemTitle</title>\n";
+ echo " <link rel=\"alternate\" type=\"text/html\" href=\"$site/$weblogdir/?q=$permaLink\"/>\n";
+ echo " <content type=\"html\" xml:space=\"preserve\">\n";
+
+ indent_include (6, $inc);
+
+ echo " </content>\n";
+ echo " </entry>\n";
+ }
+ }
+
+ echo '</feed>'."\n";
}
else // HTML
{
@@ -514,7 +598,7 @@ function printer_html ($level, $string)
echo (htmlentities ($string) . "\n");
}
-// RSS 2.0 output
+// Atom/RSS 2.0 output
function indent_include ($level, $file)
{
global $site, $imagedir, $photodir, $weblogdir, $local_fn;
diff --git a/config.php b/config.php
index e017d2f..5c6fe27 100644
--- a/config.php
+++ b/config.php
@@ -1,6 +1,6 @@
<?php
-// blogRight! version 2.0
+// blogRight! version 2.1
// BEGIN CONFIG
$site = 'http://your.site.name';
@@ -25,12 +25,15 @@ $defaultGallery = 'photoblog';
$thumbnailPrefix['default'] = 'small/small-';
$thumbnailPrefix['photoblog'] = 'photoblog/small/small-';
-// RSS
-$rssTitle = "RSS Title";
-$rssDescription = "Some descriptive title";
-$rssCopyright = "Your Name";
-$rssEditor = "Editor Name";
-$rssLanguage = "qu"; // Two-letter language code as per ISO 639
+// RSS/Atom
+$feedStylesheet = true; // $site/$weblogdir/css/(atom|rss).css
+$feedTitle = 'title';
+$feedDescription = "description";
+$feedCopyright = 'Copyright (C) Your Name';
+$feedAuthorName = 'Your Name';
+$feedAuthorEmail = 'Your e-mail address';
+$feedEditor = "$feedAuthorEmail ($feedAuthorName)";
+$feedLanguage = 'en'; // Two-letter language code as per ISO 639
// Calendar
$calendarEmptyMonths = false;

Return to:

Send suggestions and report system problems to the System administrator.