diff options
author | emkael <emkael@tlen.pl> | 2017-01-16 18:06:09 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2017-01-16 18:06:09 +0100 |
commit | bcc5a4c29ec9178d7515c8b29d186f31bac4065b (patch) | |
tree | 9124ab2ffff01c1fa083038b8f0c26b95e3c6730 | |
parent | 68f5ac77ee0ca7788c7c48681ad2067de2af427b (diff) |
* cosmetic changes to the feed standard layout
-rw-r--r-- | http/index.php | 2 | ||||
-rw-r--r-- | providers/Provider.php | 6 | ||||
-rw-r--r-- | providers/Twitter.php | 10 | ||||
-rw-r--r-- | templates/atom.tpl | 4 | ||||
-rw-r--r-- | templates/rss.tpl | 6 |
5 files changed, 20 insertions, 8 deletions
diff --git a/http/index.php b/http/index.php index 0c7ad7a..17613e9 100644 --- a/http/index.php +++ b/http/index.php @@ -34,6 +34,8 @@ $smarty->setCacheDir('../cache/smarty'); $smarty->setCompileDir('../cache/smarty/compile'); $smarty->setTemplateDir('../templates'); +$smarty->assign('feedID', 'http://rss.emkael.info'.$_SERVER['REQUEST_URI']); +$smarty->assign('feedTitle', $provider->title()); $smarty->assign('cacheTime', $provider->cacheTime()); $smarty->assign('user', $feed); $smarty->assign('content', $provider->get()); diff --git a/providers/Provider.php b/providers/Provider.php index 0c3f344..02031ad 100644 --- a/providers/Provider.php +++ b/providers/Provider.php @@ -24,6 +24,8 @@ abstract class Provider { abstract protected function _spamFilter($items); + abstract protected function _sortContent($content); + protected function _getItems() { $cacheFile = sprintf($this->_getCachePath(), $this->_feed); $this->_cacheTime = file_exists($cacheFile) ? filemtime($cacheFile) : 0; @@ -42,13 +44,15 @@ abstract class Provider { if (isset($this->_options['spamfilter'])) { $items = $this->_spamFilter($items); } - return $items; + return $this->_sortContent($items); } public function cacheTime() { return $this->_cacheTime; } + abstract public function title(); + } ?> diff --git a/providers/Twitter.php b/providers/Twitter.php index 868bb28..e9b98e1 100644 --- a/providers/Twitter.php +++ b/providers/Twitter.php @@ -97,7 +97,6 @@ class Twitter extends \Providers\Provider { } } } - usort($filteredContent, function($c1, $c2) { return strcmp($c1->id_str, $c2->id_str); }); $content = $filteredContent; if ($spamHashes) { foreach ($spamHashes as $hash) { @@ -112,6 +111,15 @@ class Twitter extends \Providers\Provider { return $content; } + protected function _sortContent($content) { + usort($content, function($c1, $c2) { return strcmp($c2->id_str, $c1->id_str); }); + return $content; + } + + public function title() { + return sprintf("%s's timeline", $this->_feed); + } + } ?> diff --git a/templates/atom.tpl b/templates/atom.tpl index e7e28f5..df4a762 100644 --- a/templates/atom.tpl +++ b/templates/atom.tpl @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> - <title>{$user}'s timeline</title> + <title>{$feedTitle}</title> <link href="https://twitter.com/{$user}" /> - <id>http://emkael.info/tulz/twitterRSS/{$user}</id> + <id>{$feedID}</id> <updated>{$cacheTime|date_format:"c"}</updated> {foreach from=$content item=item} <entry> diff --git a/templates/rss.tpl b/templates/rss.tpl index f95a462..03ea30b 100644 --- a/templates/rss.tpl +++ b/templates/rss.tpl @@ -1,16 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> <rss version="2.0"> <channel> - <title>{$user}'s timeline</title> + <title>{$feedTitle}</title> <link>https://twitter.com/{$user}</link> <lastBuildDate>{$cacheTime|date_format:"D, d M Y H:i:s O"}</lastBuildDate> {foreach from=$content item=item} <item> <title>{$item->text|escape}</title> <link>https://twitter.com/{$user}/status/{$item->id_str}</link> - {if isset($item->user)} - <guid>http://emkael.info/tulz/twitterRSS/{$item->user->id_str}/{$item->id_str}</guid> - {/if} + <guid>{$feedID}/{$item->id_str}</guid> <description><![CDATA[ {$item->text|escape} ]]></description> <pubDate>{$item->created_at|date_format:"D, d M Y H:i:s O"}</pubDate> </item> |