diff options
-rw-r--r-- | blog.php | 69 |
1 files changed, 50 insertions, 19 deletions
@@ -1,16 +1,16 @@ <?php -// blogRight! version 2.2 (2008-03-16) -// Copyright (C) 2004, 2005, 2006, 2007, 2008 Wojciech Polak. +// blogRight! version 2.5 (2010-04-19) +// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Wojciech Polak. // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the // Free Software Foundation; either version 3 of the License, or (at your // option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along @@ -62,24 +62,28 @@ if (isset ($_GET['q'])) ///////////////////////////// if (isset ($CONF['path.data']) && $CONF['path.data'] != '') { $cwd = $CONF['path.data']; } else { $CONF['path.data'] = ''; $cwd = getcwd (); } +$feed_titles_idx = array (); +if (isset ($CONF['feed.titles.idx'])) + @include $CONF['path.data'].$CONF['feed.titles.idx']; + if (isset ($CONF['orderfile']) && file_exists ($CONF['path.data'].$CONF['orderfile'])) { $lines = file ($CONF['path.data'].$CONF['orderfile']); foreach ($lines as $line) $searchdirs[] = chop ($line); $searchdirs = array_unique ($searchdirs); } else if (isset ($search_y)) { $searchdirs[] = $search_y; } @@ -257,40 +261,42 @@ if (isset ($RSS)) { $month = $res[1]; $day = $res[2]; } $fmtime = mktime (0, 0, 0, $month, $day, $year); } else { $fmtime = filemtime ($inc); } $pubDate = date ("D, d M Y H:i:s O", $fmtime); - $itemTitle = date ('d M Y', $fmtime); + $idx = substr ($inc, strlen ($cwd)); + $itemTitle = isset ($feed_titles_idx[$idx]) ? $feed_titles_idx[$idx] : + date ('d M Y', $fmtime); $permaLink = date ($CONF['permalinkFmt'], $fmtime); echo " <item>\n"; echo " <title>$itemTitle</title>\n"; echo " <link>".$CONF['url.site']."/". $CONF['qpattern'].$permaLink."</link>\n"; if ($CONF['feed.CDATA']) { echo " <description><![CDATA[\n"; - indent_include (9, $inc, $CONF['feed.CDATA']); - echo " ]]></description>\n"; + indent_include (0, $inc, $CONF['feed.CDATA']); + echo "]]></description>\n"; } else { echo " <description>\n"; - indent_include (9, $inc, $CONF['feed.CDATA']); + indent_include (0, $inc, $CONF['feed.CDATA']); echo " </description>\n"; } echo " <guid isPermaLink=\"true\">". $CONF['url.site']."/".$CONF['qpattern']. $permaLink."</guid>\n"; echo " <pubDate>$pubDate</pubDate>\n"; echo " </item>\n"; } } echo " </channel>\n"; @@ -349,49 +355,51 @@ else if (isset ($ATOM)) { $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); + $idx = substr ($inc, strlen ($cwd)); + $itemTitle = isset ($feed_titles_idx[$idx]) ? $feed_titles_idx[$idx] : + date ('d M Y', $fmtime); $permaLink = date ($CONF['permalinkFmt'], $fmtime); echo " <entry>\n"; echo " <id>".$CONF['feed.tagUri']."/$permaLink</id>\n"; echo " <updated>$pubDate</updated>\n"; echo " <title>$itemTitle</title>\n"; echo " <link rel=\"alternate\" type=\"text/html\" href=\"". $CONF['url.site']."/".$CONF['qpattern'].$permaLink."\"/>\n"; if ($CONF['feed.XHTML']) { echo " <content type=\"xhtml\" xml:space=\"preserve\">\n"; echo " <div xmlns=\"http://www.w3.org/1999/xhtml\">\n"; - indent_include (6, $inc, $CONF['feed.XHTML']); + indent_include (0, $inc, $CONF['feed.XHTML']); echo " </div>\n"; echo " </content>\n"; } else if ($CONF['feed.CDATA']) { echo " <content type=\"html\" xml:space=\"preserve\"><![CDATA[\n"; - indent_include (6, $inc, $CONF['feed.CDATA']); - echo " ]]></content>\n"; + indent_include (0, $inc, $CONF['feed.CDATA']); + echo "]]></content>\n"; } else { echo " <content type=\"html\" xml:space=\"preserve\">\n"; - indent_include (6, $inc, $CONF['feed.CDATA']); + indent_include (0, $inc, $CONF['feed.CDATA']); echo " </content>\n"; } echo " </entry>\n"; } } echo '</feed>'."\n"; } else // HTML { echo '<?xml version="1.0" encoding="'.$CONF['charsetEncoding'].'"?>'."\n"; @@ -408,33 +416,33 @@ else // HTML @include ($CONF['path.header_file']); echo "\n<div id=\"content\" class=\"hfeed\">\n\n"; foreach ($include_files as $inc) { // the query engine... if (isset ($search_m)) { if (isset ($search_d)) { if (ereg ("^$search_m-$search_d.*\.html\$", basename ($inc))) - include_file ($inc); + include_file ($inc, 'd'); } else if (ereg ("^$search_m-.*\.html\$", basename ($inc))) - include_file ($inc); + include_file ($inc, 'm'); } else if (ereg (".*\.html\$", basename ($inc))) - include_file ($inc); + include_file ($inc, 'y'); } // Calculate a copyright footnote. $copyrightYear = ''; if (count ($year_array)) { $year_array = array_unique ($year_array); sort ($year_array); foreach ($year_array as $y) $copyrightYear .= "$y, "; $copyrightYear = substr ($copyrightYear, 0, -2); } @@ -595,27 +603,27 @@ function process_footnotes ($out, $data) } } // Simple printer (alias for print, to be used with process_footnotes) function printer ($data, $string) { echo $string; } ///////////////////////////// // HTML output -function include_file ($file) +function include_file ($file, $type) { - global $CONF, $search_d, $local_fn, $year_array; + global $CONF, $search_y, $search_m, $local_fn, $year_array; $res = array (); $cdd = basename (dirname ($file)); // current data dir $local_fn = 0; if (is_numeric ($cdd)) { ereg ('^(.*)-(.*)\.', basename ($file), $res); $year = $cdd; // assume that... $year_array[] = intval ($cdd); if (isset ($res[1]) && isset ($res[2])) @@ -650,29 +658,52 @@ function include_file ($file) unset ($GLOBALS['collect']); foreach ($fd as $line) { $line = process_line ($line); if ($line) echo ($line); } process_footnotes ('printer', 0); echo '</div>'."\n"; echo '<div class="entry-footer">'."\n"; echo '<a href="./'.$CONF['qpattern']. - $permaLink.'" rel="bookmark" title="'.$entryDate. - '"><abbr class="published" title="'. + $permaLink.'" class="bookmark" rel="bookmark" title="'. + $entryDate.'"><abbr class="published" title="'. $pubDate.'">'.$entryDate.'</abbr></a>'."\n"; echo '<address class="vcard"><span class="fn">'. $CONF['feed.authorName'].'</span></address>'; + + /* disqus support */ + if (isset ($CONF['disqus.account']) && $CONF['disqus.account'] != '') { + if ($type == 'd') { + echo "\n"; + echo '<div id="disqus_thread"></div>'; + echo '<script type="text/javascript" src="http://disqus.com/forums/'. + $CONF['disqus.account'].'/embed.js"></script>'; + if (isset ($CONF['disqus.showNoScript'])) { + echo '<noscript><div><a href="http://'.$CONF['disqus.account']. + '.disqus.com/?url=ref">View the forum thread.</a></div></noscript>'; + } + echo '<a href="http://disqus.com" class="dsq-brlink">'. + 'comments powered by <span class="logo-disqus">Disqus</span>'. + '</a>'."\n"; + } + else if (isset ($CONF['recent']) && + (!isset ($search_y) || isset ($search_m))) { + echo '<a href="./'.$CONF['qpattern'].$permaLink. + '#disqus_thread" title="View comments">Comments</a>'."\n"; + } + } + echo '</div>'."\n"; echo '</div>'."\n\n"; } } function printer_html ($level, $string) { for ($i = 0; $i < $level; $i++) echo ' '; echo (htmlentities ($string) . "\n"); } @@ -730,25 +761,25 @@ function printCalendar () echo "<div id=\"calendar\">\n"; echo "<table class=\"calendar-table\"><tr>\n"; foreach ($searchdirs as $dir) { if (!($dp = opendir ($dir))) continue; $dir = basename ($dir); echo "\n <!-- $dir -->\n"; echo " <td><div class=\"calendar-year\"><a href=\"./". - $CONF['qpattern'].$dir."/\">$dir</a></div>\n"; + $CONF['qpattern'].$dir."/\" rel=\"nofollow\">$dir</a></div>\n"; echo " <table class=\"calendar-months\">\n\n"; $mtab = array (); while ($name = readdir ($dp)) { if (ereg ("^(.*)-(.*)\.html\$", $name, $res)) { if (!($dir >= $cur_y && $res[1] > $cur_m)) $mtab[0 + $res[1]]++; } } closedir ($dp); |