Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24957
Modified Files:
Tag: branch-smarty
NEWS index.php rss.php serendipity_config.inc.php
serendipity_functions.inc.php serendipity_sidebar_items.php
serendipity_xmlrpc.php
Log Message:
Extended path rewrite:
- Use diffirent URI for browsing months
- Allow the browsing of weeks
- Call "-short" "/summary"
- Use rewritten links in syndication plugin
- Allow access to rss1.0 feeds through rewritten URLs
- Allow access to comment feeds by doing /feeds/comments.(rss|atom|rss1|rss2)
- Add the ability to show months, weeks or days in the archive plugin sidebar
- Add the ability to define how many months, weeks or days that should be displayed in the archive plugin sidebar
- Implement serendipity_rewriteURL() to handle all the rewrite path logic, makes the code MUCH cleaner
TODO: Needs version bump, but I want to have it tested before we do so
TODO: The [RSS] buttons for the category listing still uses the old rss.php syntax, need to figure out how to solve that
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.214.2.35
retrieving revision 1.214.2.36
diff -u -d -r1.214.2.35 -r1.214.2.36
--- NEWS 16 Oct 2004 09:12:15 -0000 1.214.2.35
+++ NEWS 16 Oct 2004 17:27:11 -0000 1.214.2.36
@@ -3,6 +3,15 @@
Version 0.8 ()
------------------------------------------------------------------------
+ * Improve overall rewrite path syntax (tomsommer)
+
+ * Allow the display of month, weeks and days in archive sidebar
+ (tomsommer)
+
+ * Add ability to display entries based on week (tomsommer)
+
+ * Use rewrite paths in the syndication plugin (tomsommer)
+
* Added import tool for Movable Type data files and WordPress
databases. (tadpole9)
Index: serendipity_config.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_config.inc.php,v
retrieving revision 1.93.2.15
retrieving revision 1.93.2.16
diff -u -d -r1.93.2.15 -r1.93.2.16
--- serendipity_config.inc.php 10 Oct 2004 00:39:07 -0000 1.93.2.15
+++ serendipity_config.inc.php 16 Oct 2004 17:27:12 -0000 1.93.2.16
@@ -77,8 +77,7 @@
@define('PAT_UNSUBSCRIBE', '@/'.PATH_UNSUBSCRIBE.'/(.*)/([0-9]+)@');
@define('PAT_APPROVE', '@/'.PATH_APPROVE.'/(.*)/(.*)/([0-9]+)@');
@define('PAT_DELETE', '@/'.PATH_DELETE.'/(.*)/(.*)/([0-9]+)@');
-@define('PAT_ARCHIVES', '@/'.PATH_ARCHIVES.'/([0-9]+)\.html@');
-@define('PAT_ARCHIVES_SHORT', '@/'.PATH_ARCHIVES.'/([0-9]+)[_\-]short\.html@');
+@define('PAT_ARCHIVES', '@/'.PATH_ARCHIVES.'([/A-Za-z0-9]+)\.html@');
@define('PAT_COMMENTSUB', '@/([0-9]+)[_\-][' . PAT_FILENAME . ']*\.html@i');
@define('PAT_FEEDS', '@/'.PATH_FEEDS.'/@');
@define('PAT_FEED', '@/(index|atom|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)$@');
Index: serendipity_sidebar_items.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_sidebar_items.php,v
retrieving revision 1.84.2.7
retrieving revision 1.84.2.8
diff -u -d -r1.84.2.7 -r1.84.2.8
--- serendipity_sidebar_items.php 11 Oct 2004 09:21:15 -0000 1.84.2.7
+++ serendipity_sidebar_items.php 16 Oct 2004 17:27:13 -0000 1.84.2.8
@@ -36,21 +36,17 @@
$title = CALENDAR;
- /* TODO: Patch this out */
- if (!isset($serendipity['GET']['calendarZoom'])) {
- if (!isset($serendipity['GET']['range'])) {
- $calendarZoom = date('Y') . date('m');
- } else {
- $calendarZoom = $serendipity['GET']['range'];
- }
- } else {
- $calendarZoom = $serendipity['GET']['calendarZoom'];
- }
+ if (!isset($serendipity['GET']['calendarZoom'])) {
+ if (!isset($serendipity['range'])) {
+ $serendipity['GET']['calendarZoom'] = time();
+ } else {
+ $serendipity['GET']['calendarZoom'] = $serendipity['range'][0];
+ }
+ }
- /* TODO: must change */
- $year = substr($calendarZoom, 0, 4);
- $month = substr($calendarZoom, 4, 2);
+ $month = date('m', $serendipity['GET']['calendarZoom']);
+ $year = date('Y', $serendipity['GET']['calendarZoom']);
$bow = (int)$this->get_config('beginningOfWeek', 1);
// Check for faulty input, is so - run the default
@@ -116,8 +112,8 @@
$categoryid = serendipity_db_escape_string($serendipity['GET']['category']);
if (is_numeric($categoryid)) {
- $base_query = 'serendipity[category]=' . $categoryid;
- $add_query = '&' . $base_query;
+ $base_query = 'C' . $categoryid;
+ $add_query = '/' . $base_query;
$querystring = "SELECT timestamp
FROM {$serendipity['dbPrefix']}entries e,
{$serendipity['dbPrefix']}category c,
@@ -184,7 +180,7 @@
}
if (isset($activeDays[$currDay]) && $activeDays[$currDay] > 1) {
$cellProps['Active'] = 1;
- $cellProps['Link'] = serendipity_archiveDateUrl(sprintf('%4d%02d%02d', $year, $month, $currDay)) . $base_query;
+ $cellProps['Link'] = serendipity_archiveDateUrl(sprintf('%4d/%02d/%02d', $year, $month, $currDay) . $add_query );
}
$currDay++;
}
@@ -204,9 +200,9 @@
$serendipity['smarty']->assign('plugin_calendar_head', array('month_date' => $ts,
- 'uri_previous' => $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] .'?serendipity[calendarZoom]='. $previousYear . sprintf('%02d',$previousMonth) . $add_query,
- 'uri_month' => serendipity_archiveDateUrl($year . sprintf('%02d', $month)) . $base_query,
- 'uri_next' => $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] .'?serendipity[calendarZoom]='. $previousYear . sprintf('%02d',$nextMonth) . $add_query,
+ 'uri_previous' => serendipity_archiveDateUrl(sprintf('%04d/%02d', $previousYear, $previousMonth). $add_query),
+ 'uri_month' => serendipity_archiveDateUrl(sprintf('%04d/%02d', $year, $month)),
+ 'uri_next' => serendipity_archiveDateUrl(sprintf('%04d/%02d',$nextYear, $nextMonth) . $add_query),
'minScroll' => $minmax[0]['min'],
'maxScroll' => $minmax[0]['max']));
echo serendipity_smarty_fetch('CALENDAR', 'plugin_calendar.tpl');
@@ -243,6 +239,30 @@
{
$propbag->add('name', ARCHIVES);
$propbag->add('description', BROWSE_ARCHIVES);
+ $propbag->add('configuration', array('frequency', 'count'));
+ }
+
+ function introspect_config_item($name, &$propbag)
+ {
+ switch($name) {
+ case 'count' :
+ $propbag->add('type', 'string');
+ $propbag->add('name', ARCHIVE_COUNT);
+ $propbag->add('description', ARCHIVE_COUNT_DESC);
+ $propbag->add('default', 3);
+ break;
+
+ case 'frequency' :
+ $propbag->add('type', 'select');
+ $propbag->add('name', ARCHIVE_FREQUENCY);
+ $propbag->add('select_values', array('months' => MONTHS, 'weeks' => WEEKS, 'days' => DAYS));
+ $propbag->add('description', ARCHIVE_FREQUENCY_DESC);
+ $propbag->add('default', 'months');
+ break;
+ default:
+ return false;
+ }
+ return true;
}
function generate_content(&$title)
@@ -251,22 +271,35 @@
$title = ARCHIVES;
- $ts = mktime(0, 0, 0, (date('m')+1), 1, date('Y'));
-
- for($x = 0; $x < 3; $x++) {
- $ts -= 1;
+ $ts = mktime(0, 0, 0);
- $link = $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . PATH_ARCHIVES.'/' . date('Ym', $ts) . '.html';
+ for($x = 0; $x < $this->get_config('count', 3); $x++) {
- $ts_title = ucfirst(strftime("%B %Y", $ts));
+ switch($this->get_config('frequency', 'months')) {
+ case 'months' :
+ $linkStamp = date('Y/m', $ts);
+ $ts_title = serendipity_formatTime("%B %Y", $ts);
+ $ts = mktime(0, 0, 0, date('m', $ts)-1, 1, date('Y', $ts)); // Must be last in 'case' statement
+ break;
+ case 'weeks' :
+ $linkStamp = date('Y/\WW', $ts);
+ $ts_title = WEEK . ' '. date('W, Y', $ts);
+ $ts = mktime(0, 0, 0, date('m', $ts), date('d', $ts)-7, date('Y', $ts));
+ break;
+ case 'days' :
+ $linkStamp = date('Y/m/d', $ts);
+ $ts_title = serendipity_formatTime("%B %e. %Y", $ts);
+ $ts = mktime(0, 0, 0, date('m', $ts), date('d', $ts)-1, date('Y', $ts)); // Must be last in 'case' statement
+ break;
+ }
+ $link = serendipity_rewriteURL(PATH_ARCHIVES.'/' . $linkStamp . '.html', 'serendipityHTTPPath');
echo '<a href="' . $link . '" title="' . $ts_title . '">' . $ts_title . '</a><br />' . "\n";
- $ts = mktime(0, 0, 0, date('m', $ts), 1, date('Y', $ts));
}
- echo "<a href='{$serendipity['serendipityHTTPPath']}'>" . RECENT . "</a><br />\n";
- echo "<a href='{$serendipity['serendipityHTTPPath']}" . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . PATH_ARCHIVE."'>" . OLDER . "</a>\n";
+ echo '<a href="'. $serendipity['serendipityHTTPPath'] .'">' . RECENT . '</a><br />' . "\n";
+ echo '<a href="'. serendipity_rewriteURL(PATH_ARCHIVE) .'">' . OLDER . '</a>'. "\n";
}
}
@@ -537,8 +570,8 @@
if (serendipity_db_bool($this->get_config('show_0.91', true))) {
?>
<div style="padding-bottom: 2px;">
- <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>rss.php?version=0.91<?php echo $cache; ?>"><img src="<?php echo serendipity_getTemplateFile('img/xml.gif'); ?>" <?php echo ($serendipity['XHTML11'] ? 'style="border: 0px"' : 'border="0"'); ?> alt="XML" style="vertical-align: text-bottom" /></a>
- <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>rss.php?version=0.91<?php echo $cache; ?>">RSS 0.91 feed</a>
+ <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/index.rss', 'serendipityHTTPPath') ?>"><img src="<?php echo serendipity_getTemplateFile('img/xml.gif'); ?>" <?php echo ($serendipity['XHTML11'] ? 'style="border: 0px"' : 'border="0"'); ?> alt="XML" style="vertical-align: text-bottom" /></a>
+ <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/index.rss', 'serendipityHTTPPath') ?>">RSS 0.91 feed</a>
</div>
<?php
}
@@ -546,8 +579,8 @@
if (serendipity_db_bool($this->get_config('show_1.0', true))) {
?>
<div style="padding-bottom: 2px;">
- <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>rss.php?version=1.0<?php echo $cache; ?>"><img src="<?php echo serendipity_getTemplateFile('img/xml.gif'); ?>" <?php echo ($serendipity['XHTML11'] ? 'style="border: 0px"' : 'border="0"'); ?> alt="XML" style="vertical-align: text-bottom" /></a>
- <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>rss.php?version=1.0<?php echo $cache; ?>">RSS 1.0 feed</a>
+ <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/index.rss1', 'serendipityHTTPPath') ?>"><img src="<?php echo serendipity_getTemplateFile('img/xml.gif'); ?>" <?php echo ($serendipity['XHTML11'] ? 'style="border: 0px"' : 'border="0"'); ?> alt="XML" style="vertical-align: text-bottom" /></a>
+ <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/index.rss1', 'serendipityHTTPPath') ?>">RSS 1.0 feed</a>
</div>
<?php
}
@@ -555,8 +588,8 @@
if (serendipity_db_bool($this->get_config('show_2.0', true))) {
?>
<div style="padding-bottom: 2px;">
- <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>rss.php?version=2.0<?php echo $cache; ?>"><img src="<?php echo serendipity_getTemplateFile('img/xml.gif'); ?>" <?php echo ($serendipity['XHTML11'] ? 'style="border: 0px"' : 'border="0"'); ?> alt="XML" style="vertical-align: text-bottom" /></a>
- <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>rss.php?version=2.0<?php echo $cache; ?>">RSS 2.0 feed</a>
+ <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/index.rss2', 'serendipityHTTPPath') ?>"><img src="<?php echo serendipity_getTemplateFile('img/xml.gif'); ?>" <?php echo ($serendipity['XHTML11'] ? 'style="border: 0px"' : 'border="0"'); ?> alt="XML" style="vertical-align: text-bottom" /></a>
+ <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/index.rss2', 'serendipityHTTPPath') ?>">RSS 2.0 feed</a>
</div>
<?php
}
@@ -564,8 +597,8 @@
if (serendipity_db_bool($this->get_config('show_atom0.3', true))) {
?>
<div style="padding-bottom: 2px;">
- <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>rss.php?version=atom0.3<?php echo $cache; ?>"><img src="<?php echo serendipity_getTemplateFile('img/xml.gif'); ?>" <?php echo ($serendipity['XHTML11'] ? 'style="border: 0px"' : 'border="0"'); ?> alt="ATOM/XML" style="vertical-align: text-bottom" /></a>
- <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>rss.php?version=atom0.3<?php echo $cache; ?>">ATOM 0.3 feed</a>
+ <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/atom.xml', 'serendipityHTTPPath') ?>"><img src="<?php echo serendipity_getTemplateFile('img/xml.gif'); ?>" <?php echo ($serendipity['XHTML11'] ? 'style="border: 0px"' : 'border="0"'); ?> alt="ATOM/XML" style="vertical-align: text-bottom" /></a>
+ <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/atom.xml', 'serendipityHTTPPath') ?>">ATOM 0.3 feed</a>
</div>
<?php
}
@@ -573,8 +606,8 @@
if (serendipity_db_bool($this->get_config('show_2.0c', true))) {
?>
<div style="padding-bottom: 2px;">
- <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>rss.php?version=2.0&type=comments<?php echo $cache; ?>"><img src="<?php echo serendipity_getTemplateFile('img/xml.gif'); ?>" <?php echo ($serendipity['XHTML11'] ? 'style="border: 0px"' : 'border="0"'); ?> alt="XML" style="vertical-align: text-bottom" /></a>
- <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>rss.php?version=2.0&type=comments<?php echo $cache; ?>"><?php echo ($serendipity['XHTML11'] ? '<span style="white-space: nowrap">' : '<nobr>'); ?>RSS 2.0 <?php echo COMMENTS; ?><?php echo ($serendipity['XHTML11'] ? '</span>' : '</nobr>'); ?></a>
+ <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/comments.rss2', 'serendipityHTTPPath') ?>"><img src="<?php echo serendipity_getTemplateFile('img/xml.gif'); ?>" <?php echo ($serendipity['XHTML11'] ? 'style="border: 0px"' : 'border="0"'); ?> alt="XML" style="vertical-align: text-bottom" /></a>
+ <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/comments.rss2', 'serendipityHTTPPath') ?>"><?php echo ($serendipity['XHTML11'] ? '<span style="white-space: nowrap">' : '<nobr>'); ?>RSS 2.0 <?php echo COMMENTS; ?><?php echo ($serendipity['XHTML11'] ? '</span>' : '</nobr>'); ?></a>
</div>
<?php
}
@@ -582,8 +615,8 @@
if (serendipity_db_bool($this->get_config('show_opml1.0', false))) {
?>
<div style="padding-bottom: 2px;">
- <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>rss.php?version=opml1.0<?php echo $cache; ?>"><img src="<?php echo serendipity_getTemplateFile('img/xml.gif'); ?>" <?php echo ($serendipity['XHTML11'] ? 'style="border: 0px"' : 'border="0"'); ?> alt="XML" style="vertical-align: text-bottom" /></a>
- <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>rss.php?version=opml1.0<?php echo $cache; ?>">OPML 1.0 feed</a>
+ <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/opml.xml', 'serendipityHTTPPath') ?>"><img src="<?php echo serendipity_getTemplateFile('img/xml.gif'); ?>" <?php echo ($serendipity['XHTML11'] ? 'style="border: 0px"' : 'border="0"'); ?> alt="XML" style="vertical-align: text-bottom" /></a>
+ <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS .'/opml.xml', 'serendipityHTTPPath') ?>">OPML 1.0 feed</a>
</div>
<?php
}
Index: serendipity_xmlrpc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_xmlrpc.php,v
retrieving revision 1.16.2.1
retrieving revision 1.16.2.2
diff -u -d -r1.16.2.1 -r1.16.2.2
--- serendipity_xmlrpc.php 20 Sep 2004 14:00:39 -0000 1.16.2.1
+++ serendipity_xmlrpc.php 16 Oct 2004 17:27:13 -0000 1.16.2.2
@@ -484,8 +484,8 @@
'mt_convert_breaks' => new XML_RPC_Value('', 'string'),
'mt_keywords' => new XML_RPC_Value('', 'string'),
'title' => new XML_RPC_Value($entry['title'],'string'),
- 'permalink' => new XML_RPC_Value($serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? '/' . $serendipity['indexFile'] . '?' : '') . '/'.PATH_ARCHIVES.'/' . $postid . '_.html', 'string'),
- 'link' => new XML_RPC_Value($serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? '/' . $serendipity['indexFile'] . '?' : '') . '/'.PATH_ARCHIVES.'/' . $postid . '_.html', 'string'),
+ 'permalink' => new XML_RPC_Value(serendipity_rewriteURL(PATH_ARCHIVES.'/' . $postid . '_.html', 'baseURL'), 'string'),
+ 'link' => new XML_RPC_Value(serendipity_rewriteURL(PATH_ARCHIVES.'/' . $postid . '_.html', 'baseURL'), 'string'),
);
return array_merge($entry, $tmp);
@@ -499,4 +499,4 @@
ob_end_flush();
}
/* vim: set sts=4 ts=4 expandtab : */
-?>
\ No newline at end of file
+?>
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.419.2.51
retrieving revision 1.419.2.52
diff -u -d -r1.419.2.51 -r1.419.2.52
--- serendipity_functions.inc.php 16 Oct 2004 09:12:15 -0000 1.419.2.51
+++ serendipity_functions.inc.php 16 Oct 2004 17:27:12 -0000 1.419.2.52
@@ -371,6 +371,11 @@
$serendipity['fetchLimit'] = $limit;
}
+ /* Attempt to grab range from $serendipity, if $range is not an array or null */
+ if ( !is_array($range) && !is_null($range) && isset($serendipity['range']) ) {
+ $range = $serendipity['range'];
+ }
+
if (is_numeric($range)) {
$year = (int)substr($range, 0, 4);
$month = (int)substr($range, 4, 2);
@@ -390,13 +395,11 @@
if ($drafts) {
$cond['and'] .= " AND $drafts";
}
- }
- elseif (is_array($range) && count($range)==2) {
+ } elseif (is_array($range) && count($range)==2) {
$startts = (int)$range[0];
$endts = (int)$range[1];
$cond['and'] = " WHERE timestamp >= $startts AND timestamp <= $endts";
- }
- else {
+ } else {
if ($modified_since) {
$unix_modified = strtotime($modified_since);
if ($unix_modified != -1) {
@@ -1420,7 +1423,7 @@
$title,
$poster,
$entryURI,
- $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'unsubscribe/' . urlencode($subscriber['email']) . '/' . (int)$entry_id
+ serendipity_rewriteURL('unsubscribe/' . urlencode($subscriber['email']) . '/' . (int)$entry_id, 'baseURL')
);
} else {
$text = sprintf(
@@ -1431,7 +1434,7 @@
$title,
$poster,
$entryURI,
- $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'unsubscribe/' . urlencode($subscriber['email']) . '/' . (int)$entry_id
+ serendipity_rewriteURL('unsubscribe/' . urlencode($subscriber['email']) . '/' . (int)$entry_id, 'baseURL')
);
}
@@ -1459,8 +1462,8 @@
$entryURI = serendipity_archiveURL($id, $title, 'baseURL');
$path = ($type == 'TRACKBACK') ? 'trackback' : 'comment';
- $deleteURI = $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . PATH_DELETE . '/'. $path .'/' . $comment_id . '/'. $id .'_' . serendipity_makeFilename($title) . '.html';
- $approveURI = $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . PATH_APPROVE . '/'. $path .'/' . $comment_id . '/'. $id .'_' . serendipity_makeFilename($title) . '.html';
+ $deleteURI = serendipity_rewriteURL(PATH_DELETE . '/'. $path .'/' . $comment_id . '/'. $id .'_' . serendipity_makeFilename($title) . '.html', 'baseURL');
+ $approveURI = serenidpity_rewriteURL(PATH_APPROVE . '/'. $path .'/' . $comment_id . '/'. $id .'_' . serendipity_makeFilename($title) . '.html', 'baseURL');
if ($type == 'TRACKBACK') {
@@ -2036,22 +2039,23 @@
FAILURE;
}
-/**
- * return a fully qualified URL
- */
-function serendipity_archiveURL($id, $title, $key = 'baseURL', $checkrewrite = true) {
-global $serendipity;
- return $serendipity[$key] . ($checkrewrite && $serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . PATH_ARCHIVES . '/' . (int)$id . '-' . serendipity_makeFilename($title) . '.html';
+/* Uses logic to figure out how the URI should look, based on current rewrite rule */
+function serendipity_rewriteURL($path, $key='baseURL') {
+ global $serendipity;
+ return $serendipity[$key] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . $path;
}
-/**
- * return URL for a date archive
- */
-function serendipity_archiveDateUrl($range, $short=false, $key='baseURL') {
- global $serendipity;
+function serendipity_archiveURL($id, $title, $key = 'baseURL', $checkrewrite = true) {
+ $path = PATH_ARCHIVES . '/' . (int)$id . '-' . serendipity_makeFilename($title) . '.html';
+ if ( $checkrewrite ) {
+ $path = serendipity_rewriteURL($path, $key);
+ }
+ return $path;
+}
- return $serendipity[$key]. ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . PATH_ARCHIVES . '/' . $range . ($short ? '-short' : '') . '.html';
+function serendipity_archiveDateUrl($range, $summary=false, $key='baseURL') {
+ return serendipity_rewriteURL(PATH_ARCHIVES . '/' . $range . ($summary ? '/summary' : '') . '.html', $key);
}
/**
@@ -2614,14 +2618,14 @@
($serendipity['XHTML11'] ? 'style="display: inline; border: 0px"' : 'border="0"'),
$xmlImg,
str_repeat(' ', $level * 3),
- $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . PATH_CATEGORIES . '/' . $cat['categoryid'] . '-' . $category_id,
+ serendipity_rewriteURL(PATH_CATEGORIES . '/' . $cat['categoryid'] . '-' . $category_id, 'serendipityHTTPPath'),
htmlspecialchars($cat['category_description']),
htmlspecialchars($cat['category_name']));
} else {
$ret .= sprintf(
'%s<a href="%s" title="%s">%s</a><br />',
str_repeat(' ', $level * 3),
- $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . PATH_CATEGORIES . '/' . $cat['categoryid'] . '-' . $category_id,
+ serendipity_rewriteURL(PATH_CATEGORIES . '/' . $cat['categoryid'] . '-' . $category_id, 'serendipityHTTPPath'),
htmlspecialchars($cat['category_description']),
htmlspecialchars($cat['category_name']));
}
@@ -3370,8 +3374,8 @@
$data = array();
$data['entry_count'] = $entry_count;
- $data['link'] = serendipity_archiveDateUrl($y . sprintf('%02s', $m));
- $data['link_summary'] = serendipity_archiveDateUrl($y . sprintf('%02s', $m), true);
+ $data['link'] = serendipity_archiveDateUrl($y . '/'. sprintf('%02s', $m));
+ $data['link_summary'] = serendipity_archiveDateUrl($y . '/'. sprintf('%02s', $m), true);
$data['date'] = $s;
$output[$y]['months'][] = $data;
}
@@ -3395,22 +3399,29 @@
}
}
-function serendipity_discover_rss($name, $ext, $default = '2.0') {
- if ($name == 'atom') {
+function serendipity_discover_rss($name, $ext) {
+ static $default = '2.0';
+
+
+ /* Detect type */
+ if ( $name == 'comments' ) {
+ $type = 'comments';
+ } else {
+ $type = 'content';
+ }
+
+ /* Detect version */
+ if ( $name == 'atom' || $ext == 'atom' ) {
$ver = 'atom0.3';
+ } elseif ( $ext == 'rss' ) {
+ $ver = '0.91';
+ } elseif ( $ext == 'rss1' ) {
+ $ver = '1.0';
} else {
- switch ($ext) {
- case 'rss':
- $ver = '0.91';
- break;
- case 'rss2':
- default:
- $ver = $default;
- break;
- }
+ $ver = $default;
}
- return $ver;
+ return array($ver, $type);
}
function serendipity_load_configuration($author = null) {
Index: index.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/index.php,v
retrieving revision 1.49.2.6
retrieving revision 1.49.2.7
diff -u -d -r1.49.2.6 -r1.49.2.7
--- index.php 16 Oct 2004 09:12:15 -0000 1.49.2.6
+++ index.php 16 Oct 2004 17:27:11 -0000 1.49.2.7
@@ -52,46 +52,50 @@
if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range']) && is_numeric($serendipity['GET']['range'])) {
- if (!empty($serendipity['GET']['range'])) {
- $range = $serendipity['GET']['range'];
- } else {
- $range = $matches[1];
- }
- $_GET['serendipity']['action'] = 'read';
- $_GET['serendipity']['range'] = $range;
- if (strlen($range) == 6) {
- $date = serendipity_formatTime('%B %Y', mktime(0, 0, 0, substr($range, 4, 6), 2, substr($range, 0, 4)));
- } else {
- $date = serendipity_formatTime(DATE_FORMAT_ENTRY, strtotime($range));
- }
+ preg_match_all('@/([a-z0-9]+)@i', $matches[1], $args);
- $serendipity['smarty']->assign('head_subtitle', sprintf(ENTRIES_FOR, $date));
+ /* Attempt to locate hidden variables within the URI */
+ foreach ($args[1] as $k => $v){
+ if ( $v{0} == 'C' ) { /* category */
+ $serendipity['GET']['category'] = substr($v, 1);
+ unset($args[1][$k]);
- ob_start();
- include_once(S9Y_INCLUDE_PATH . 'serendipity_genpage.inc.php');
- $data = ob_get_contents();
- ob_end_clean();
+ } elseif ( $v{0} == 'W' ) { /* Week */
+ $week = substr($v, 1);
+ unset($args[1][$k]);
- if (isset($serendipity['pregenerate']) && $serendipity['pregenerate']) {
- $fp = fopen('./'.PATH_ARCHIVES.'/' . $matches[1], 'w');
- fwrite($fp, $data);
- fclose($fp);
+ } elseif ( $v == 'summary' ) { /* Summary */
+ $serendipity['short_archives'] = true;
+ unset($args[1][$k]);
+ }
}
- echo $data;
-} else if (preg_match(PAT_ARCHIVES_SHORT, $uri, $matches)) {
- $range = $matches[1];
- $_GET['serendipity']['action'] = 'read';
- $_GET['serendipity']['range'] = $range;
- $serendipity['short_archives'] = true;
+ /* We must always *assume* that Year, Month and Day are the first 3 arguments */
+ list($year, $month, $day) = $args[1];
- if (strlen($range) == 6) {
- $date = date('m/Y', mktime(0,0,0, substr($range, 4, 6), 2, substr($range, 0, 4)));
+ $_GET['serendipity']['action'] = 'read';
+ $_GET['serendipity']['hidefooter'] = true;
+
+ if ( $week ) {
+ $tm = strtotime('+ '. ($week-2) .' WEEKS monday', mktime(0,0,0,1,1,$year));
+ $ts = mktime(0, 0, 0, date('m', $tm), date('j', $tm), $year);
+ $te = mktime(23, 59, 59, date('m', $tm), date('j', $tm)+7, $year);
+ $date = serendipity_formatTime(WEEK .' '. $week .', %Y', $ts);
} else {
- $date = date('d/m/Y', strtotime($range));
+ if ( $day ) {
+ $ts = mktime(0, 0, 0, $month, $day, $year);
+ $te = mktime(23, 59, 59, $month, $day, $year);
+ $date = serendipity_formatTime(DATE_FORMAT_ENTRY, $ts);
+ } else {
+ $ts = mktime(0, 0, 0, $month, 1, $year);
+ $te = mktime(23, 59, 59, $month, date('t', $ts), $year);
+ $date = serendipity_formatTime('%B %Y', $ts);
+ }
}
+ $serendipity['range'] = array($ts, $te);
+
$serendipity['smarty']->assign('head_subtitle', sprintf(ENTRIES_FOR, $date));
ob_start();
@@ -100,7 +104,7 @@
ob_end_clean();
if (isset($serendipity['pregenerate']) && $serendipity['pregenerate']) {
- $fp = fopen('./archives/' . $matches[1], 'w');
+ $fp = fopen('./'.PATH_ARCHIVES.'/' . $matches[1], 'w');
fwrite($fp, $data);
fclose($fp);
}
@@ -150,32 +154,28 @@
ob_end_clean();
if (isset($serendipity['pregenerate']) && $serendipity['pregenerate']) {
- $fp = fopen('./'.PATH_ARCHIVES.'/' . $matches[1], 'w');
+ $fp = fopen($serendipity['serendipityPath'] . PATH_ARCHIVES.'/' . $id, 'w');
fwrite($fp, $data);
fclose($fp);
}
print $data;
-} else if (preg_match(PAT_FEEDS, $uri)) {
+} elseif (preg_match(PAT_FEEDS, $uri) && preg_match('@/(index|atom|rss|comments|opml)\.(rss[0-9]?|rdf|rss|xml|atom)$@', $uri, $matches)) {
header('Content-Type: text/html; charset=utf-8');
- if (preg_match('@/(index|atom|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)$@', $uri, $matches)) {
- $_GET['version'] = serendipity_discover_rss($matches[1], $matches[2]);
-
- ob_start();
- include_once(S9Y_INCLUDE_PATH . 'rss.php');
- $data = ob_get_contents();
- ob_end_clean();
-
- $data = ltrim($data);
+ list($_GET['version'], $_GET['type']) = serendipity_discover_rss($matches[1], $matches[2]);
- if ($serendipity['pregenerate']) {
- $fp = fopen('./'.PATH_FEEDS.'/index.' . $matches[1], 'w');
- fwrite($fp, $data);
- fclose($fp);
- }
+ ob_start();
+ include_once(S9Y_INCLUDE_PATH . 'rss.php');
+ $data = ob_get_contents();
+ ob_end_clean();
- print $data;
- exit;
+ if ($serendipity['pregenerate']) {
+ $fp = fopen($serendipity['serendipityPath'] . PATH_FEEDS.'/index.' . $matches[1], 'w');
+ fwrite($fp, $data);
+ fclose($fp);
}
+
+ print $data;
+ exit;
} else if (preg_match(PAT_ADMIN, $uri)) {
header("Location: {$serendipity['serendipityHTTPPath']}serendipity_admin.php");
exit;
@@ -202,7 +202,7 @@
$data = ob_get_contents();
ob_end_clean();
if (isset($serendipity['pregenerate']) && $serendipity['pregenerate']) {
- $fp = fopen('./index.html', 'w');
+ $fp = fopen($serendipity['serendipityPath'] . 'index.html', 'w');
fwrite($fp, $data);
fclose($fp);
}
Index: rss.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/rss.php,v
retrieving revision 1.28.2.2
retrieving revision 1.28.2.3
diff -u -d -r1.28.2.2 -r1.28.2.3
--- rss.php 11 Oct 2004 09:21:06 -0000 1.28.2.2
+++ rss.php 16 Oct 2004 17:27:12 -0000 1.28.2.3
@@ -3,13 +3,12 @@
include_once('serendipity_config.inc.php');
$version = strtolower($_GET['version']);
-if (empty($version)) {
- $version = serendipity_discover_rss($_GET['file'], $_GET['ext']);
-}
$description = $serendipity['blogDescription'];
$title = $serendipity['blogTitle'];
$comments = FALSE;
+
+
if (isset($_GET['category'])) {
$serendipity['GET']['category'] = $_GET['category'];
}
|