diff options
author | Pascal Chevrel <pascal@chevrel.org> | 2012-05-05 22:39:34 +0200 |
---|---|---|
committer | Pascal Chevrel <pascal@chevrel.org> | 2012-05-05 22:39:34 +0200 |
commit | 2c494ce0492c9b0b38c3fc989105ad7bac9c8580 (patch) | |
tree | 3cbe548c152bf19199b43f0e020161e6aecd1408 | |
parent | 2d5084e43c0263e1257f294b3a8631776d343220 (diff) | |
download | planet-2c494ce0492c9b0b38c3fc989105ad7bac9c8580.tar planet-2c494ce0492c9b0b38c3fc989105ad7bac9c8580.tar.gz planet-2c494ce0492c9b0b38c3fc989105ad7bac9c8580.tar.bz2 planet-2c494ce0492c9b0b38c3fc989105ad7bac9c8580.tar.xz planet-2c494ce0492c9b0b38c3fc989105ad7bac9c8580.zip |
Issue 42: create atom.php at root, delete old 'atom10' template, update all internal links to point to the new location, put a redirect in place so as that moonmoon installs don't loose their users upon upgrading to a newer moonmoon
-rw-r--r-- | atom.php (renamed from custom/views/atom10/index.tpl.php) | 38 | ||||
-rw-r--r-- | custom/views.php | 13 | ||||
-rw-r--r-- | custom/views/archive/head.tpl.php | 2 | ||||
-rwxr-xr-x | custom/views/archive/sidebar.tpl.php | 2 | ||||
-rw-r--r-- | custom/views/default/head.tpl.php | 2 | ||||
-rwxr-xr-x | custom/views/default/sidebar.tpl.php | 2 | ||||
-rwxr-xr-x | index.php | 10 |
7 files changed, 52 insertions, 17 deletions
diff --git a/custom/views/atom10/index.tpl.php b/atom.php index d88f17b..035d049 100644 --- a/custom/views/atom10/index.tpl.php +++ b/atom.php @@ -1,4 +1,40 @@ <?php +include_once(dirname(__FILE__).'/app/app.php'); +include_once(dirname(__FILE__).'/app/lib/Cache.php'); + +//Installed ? +if (!isset($Planet)) { + echo '<p>' . _g('You might want to <a href="install.php">install moonmoon</a>.') . '</p>'; + exit; +} + +//Load from cache +$items = Array(); +if (0 < $Planet->loadOpml(dirname(__FILE__).'/custom/people.opml')) { + $Planet->loadFeeds(); + $items = $Planet->getItems(); +} + +//Prepare output cache +Cache::$enabled = false; +$cache_key = (count($items)) ? $items[0]->get_id() : ''; +$last_modified = (count($items)) ? $items[0]->get_date() : ''; +$cache_duration = $PlanetConfig->getOutputTimeout()*60; + +Cache::setStore(dirname(__FILE__) . '/' . $conf['cachedir'] . '/'); +//Go display +if (!isset($_GET['type']) || + !is_file(dirname(__FILE__).'/custom/views/'.$_GET['type'].'/index.tpl.php') || + strpos($_GET['type'], DIRECTORY_SEPARATOR)){ + $_GET['type'] = 'default'; +} + +if (!OutputCache::Start($_GET['type'], $cache_key, $cache_duration)) { + include_once(dirname(__FILE__).'/custom/views/'.$_GET['type'].'/index.tpl.php'); + OutputCache::End(); +} + +var_dump($PlanetConfig, $Planet); $limit = $PlanetConfig->getMaxDisplay(); $count = 0; @@ -8,7 +44,7 @@ echo '<?xml version="1.0" encoding="UTF-8" ?>'; <title><?php echo htmlspecialchars($PlanetConfig->getName()); ?></title> <subtitle><?php echo htmlspecialchars($PlanetConfig->getName()); ?></subtitle> <id><?php echo $PlanetConfig->getUrl(); ?></id> - <link rel="self" type="application/atom+xml" href="<?php echo $PlanetConfig->getUrl(); ?>?type=atom10" /> + <link rel="self" type="application/atom+xml" href="<?php echo $PlanetConfig->getUrl(); ?>atom.php" /> <link rel="alternate" type="text/html" href="<?php echo $PlanetConfig->getUrl(); ?>" /> <updated><?php echo date("Y-m-d\TH:i:s\Z") ?></updated> <author><name>Author</name></author> diff --git a/custom/views.php b/custom/views.php index 6d48d59..b34013f 100644 --- a/custom/views.php +++ b/custom/views.php @@ -1,16 +1,5 @@ <?php $views = array( - 'rss10' => array( - 'header' => 'Content-Type: text/xml; charset=UTF-8', - 'prolog' => '<?xml version="1.0" encoding="UTF-8" ?>'."\n", - 'template' => dirname(__FILE__).'/views/rss10/rss10.tpl.php' - ), - 'atom10' => array( - //'header' => 'Content-Type: text/xml; charset=UTF-8', - 'header' => 'Content-Type: text/plain; charset=UTF-8', - 'prolog' => '<?xml version="1.0" encoding="UTF-8" ?>'."\n", - 'template' => dirname(__FILE__).'/views/atom10/atom10.tpl.php' - ), 'archive' => array( 'header' => 'Content-type: text/html; charset=UTF-8', 'prolog' => '', @@ -21,4 +10,4 @@ $views = array( 'prolog' => '', 'template' => dirname(__FILE__).'/views/default/index.tpl.php' ) -);
\ No newline at end of file +); diff --git a/custom/views/archive/head.tpl.php b/custom/views/archive/head.tpl.php index 03f99ae..005a75d 100644 --- a/custom/views/archive/head.tpl.php +++ b/custom/views/archive/head.tpl.php @@ -3,4 +3,4 @@ <link rel="stylesheet" media="screen" type="text/css" href="custom/style/light.css" title="Light" /> <link rel="stylesheet" media="screen" type="text/css" href="custom/style/dark.css" title="Dark" /> - <link rel="alternate" type="application/atom+xml" title="ATOM" href="?type=atom10" /> + <link rel="alternate" type="application/atom+xml" title="ATOM" href="atom.php" /> diff --git a/custom/views/archive/sidebar.tpl.php b/custom/views/archive/sidebar.tpl.php index 3f0d617..e21f377 100755 --- a/custom/views/archive/sidebar.tpl.php +++ b/custom/views/archive/sidebar.tpl.php @@ -21,7 +21,7 @@ usort($all_people, array('PlanetFeed', 'compare')); <div> <h2><?=_g('Syndicate')?></h2> <ul> - <li><img src="custom/img/feed.png" alt="<?=_g('Feed')?>" height="12" width="12" /> <a href="?type=atom10"><?=_g('Feed (ATOM)')?></a></li> + <li><img src="custom/img/feed.png" alt="<?=_g('Feed')?>" height="12" width="12" /> <a href="atom.php"><?=_g('Feed (ATOM)')?></a></li> </ul> </div> diff --git a/custom/views/default/head.tpl.php b/custom/views/default/head.tpl.php index 6e204fe..5773aa6 100644 --- a/custom/views/default/head.tpl.php +++ b/custom/views/default/head.tpl.php @@ -1,3 +1,3 @@ <link rel="stylesheet" media="screen" type="text/css" href="custom/style/default.css" title="Default" /> - <link rel="alternate" type="application/atom+xml" title="ATOM" href="?type=atom10" /> + <link rel="alternate" type="application/atom+xml" title="ATOM" href="atom.php" /> diff --git a/custom/views/default/sidebar.tpl.php b/custom/views/default/sidebar.tpl.php index 2a3a360..830f3c6 100755 --- a/custom/views/default/sidebar.tpl.php +++ b/custom/views/default/sidebar.tpl.php @@ -21,7 +21,7 @@ usort($all_people, array('PlanetFeed', 'compare')); <div class="section"> <h2><?=_g('Syndicate')?></h2> <ul> - <li><img src="custom/img/feed.png" alt="<?=_g('Feed')?>" height="12" width="12" /> <a href="?type=atom10"><?=_g('Feed (ATOM)')?></a></li> + <li><img src="custom/img/feed.png" alt="<?=_g('Feed')?>" height="12" width="12" /> <a href="atom.php"><?=_g('Feed (ATOM)')?></a></li> </ul> </div> @@ -23,6 +23,16 @@ $cache_duration = $PlanetConfig->getOutputTimeout()*60; Cache::setStore(dirname(__FILE__) . '/' . $conf['cachedir'] . '/'); +if (isset($_GET['type']) && $_GET['type'] == 'atom10') { + /* XXX: Redirect old ATOM feeds to new url to make sure our users don't + * loose subscribers upon upgrading their moonmoon installation. + * Remove this check in a more distant future. + */ + header('Status: 301 Moved Permanently', false, 301); + header('Location: atom.php'); + exit; +} + //Go display if (!isset($_GET['type']) || !is_file(dirname(__FILE__).'/custom/views/'.$_GET['type'].'/index.tpl.php') || |