Skip to content

Commit

Permalink
Issue 42: create atom.php at root, delete old 'atom10' template, upda…
Browse files Browse the repository at this point in the history
…te 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
  • Loading branch information
pascalchevrel committed May 5, 2012
1 parent 2d5084e commit 2c494ce
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 17 deletions.
38 changes: 37 additions & 1 deletion custom/views/atom10/index.tpl.php → 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;

Expand All @@ -8,7 +44,7 @@
<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>
Expand Down
13 changes: 1 addition & 12 deletions 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' => '',
Expand All @@ -21,4 +10,4 @@
'prolog' => '',
'template' => dirname(__FILE__).'/views/default/index.tpl.php'
)
);
);
2 changes: 1 addition & 1 deletion custom/views/archive/head.tpl.php
Expand Up @@ -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" />
2 changes: 1 addition & 1 deletion custom/views/archive/sidebar.tpl.php
Expand Up @@ -21,7 +21,7 @@
<div>
<h2><?=_g('Syndicate')?></h2>
<ul>
<li><img src="custom/img/feed.png" alt="<?=_g('Feed')?>" height="12" width="12" />&nbsp;<a href="?type=atom10"><?=_g('Feed (ATOM)')?></a></li>
<li><img src="custom/img/feed.png" alt="<?=_g('Feed')?>" height="12" width="12" />&nbsp;<a href="atom.php"><?=_g('Feed (ATOM)')?></a></li>
</ul>
</div>

Expand Down
2 changes: 1 addition & 1 deletion 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" />
2 changes: 1 addition & 1 deletion custom/views/default/sidebar.tpl.php
Expand Up @@ -21,7 +21,7 @@
<div class="section">
<h2><?=_g('Syndicate')?></h2>
<ul>
<li><img src="custom/img/feed.png" alt="<?=_g('Feed')?>" height="12" width="12" />&nbsp;<a href="?type=atom10"><?=_g('Feed (ATOM)')?></a></li>
<li><img src="custom/img/feed.png" alt="<?=_g('Feed')?>" height="12" width="12" />&nbsp;<a href="atom.php"><?=_g('Feed (ATOM)')?></a></li>
</ul>
</div>

Expand Down
10 changes: 10 additions & 0 deletions index.php
Expand Up @@ -23,6 +23,16 @@

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') ||
Expand Down

0 comments on commit 2c494ce

Please sign in to comment.