Add favicons on the feeds page

This commit is contained in:
Frédéric Guillot 2014-12-24 18:12:41 -05:00
parent c1d74b8332
commit feb25c7552
8 changed files with 31 additions and 12 deletions

View File

@ -128,6 +128,7 @@ Router\get_action('feeds', function() {
}
Response\html(Template\layout('feeds', array(
'favicons' => Model\Feed\get_all_favicons(),
'feeds' => Model\Feed\get_all_item_counts(),
'nothing_to_read' => Request\int_param('nothing_to_read'),
'menu' => 'feeds',

View File

@ -4,7 +4,7 @@ namespace Helper;
function favicon(array $favicons, $feed_id)
{
if (isset($favicons[$feed_id])) {
if (! empty($favicons[$feed_id])) {
return '<img src="'.$favicons[$feed_id].'" class="favicon"/>';
}

View File

@ -68,6 +68,18 @@ function get_item_favicons(array $items)
return get_favicons($feed_ids);
}
// Get all favicons
function get_all_favicons()
{
if (Config\get('favicons') == 0) {
return array();
}
return Database::get('db')
->table('favicons')
->listing('feed_id', 'icon');
}
// Update feed information
function update(array $values)
{

View File

@ -28,9 +28,11 @@
<span id="loading-feed-<?= $feed['id'] ?>" class="loading-icon"></span>
<?php endif ?>
<span id="items-count-<?= $feed['id'] ?>"><?= $feed['items_unread'] .'/' . $feed['items_total'] ?></span>
<?= Helper\favicon($favicons, $feed['id']) ?>
<a href="?action=feed-items&amp;feed_id=<?= $feed['id'] ?>" title="<?= t('Show only this subscription') ?>"><?= Helper\escape($feed['title']) ?></a>
<span id="items-count-<?= $feed['id'] ?>"><?= $feed['items_unread'] .'/' . $feed['items_total'] ?></span>
<?php if ($feed['enabled']): ?>

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInita5bf9ee28a13532106d0068a171b06ab::getLoader();
return ComposerAutoloaderInitc9ebccb0a3ac2fed704b9ca3688ea671::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInita5bf9ee28a13532106d0068a171b06ab
class ComposerAutoloaderInitc9ebccb0a3ac2fed704b9ca3688ea671
{
private static $loader;
@ -19,9 +19,9 @@ class ComposerAutoloaderInita5bf9ee28a13532106d0068a171b06ab
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInita5bf9ee28a13532106d0068a171b06ab', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitc9ebccb0a3ac2fed704b9ca3688ea671', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInita5bf9ee28a13532106d0068a171b06ab', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitc9ebccb0a3ac2fed704b9ca3688ea671', 'loadClassLoader'));
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@ -42,14 +42,14 @@ class ComposerAutoloaderInita5bf9ee28a13532106d0068a171b06ab
$includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) {
composerRequirea5bf9ee28a13532106d0068a171b06ab($file);
composerRequirec9ebccb0a3ac2fed704b9ca3688ea671($file);
}
return $loader;
}
}
function composerRequirea5bf9ee28a13532106d0068a171b06ab($file)
function composerRequirec9ebccb0a3ac2fed704b9ca3688ea671($file)
{
require $file;
}

View File

@ -162,18 +162,18 @@
"source": {
"type": "git",
"url": "https://github.com/fguillot/picoFeed.git",
"reference": "e785e62ee79a02478e9691cc0cc50e689f2bf4a4"
"reference": "9bfc660ff57569ccc89b92de806c918e934d0c93"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/e785e62ee79a02478e9691cc0cc50e689f2bf4a4",
"reference": "e785e62ee79a02478e9691cc0cc50e689f2bf4a4",
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/9bfc660ff57569ccc89b92de806c918e934d0c93",
"reference": "9bfc660ff57569ccc89b92de806c918e934d0c93",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"time": "2014-12-24 22:35:22",
"time": "2014-12-24 23:02:34",
"type": "library",
"installation-source": "dist",
"autoload": {

View File

@ -105,6 +105,10 @@ class Favicon
*/
public function getDataUri()
{
if (empty($this->content)) {
return '';
}
return sprintf(
'data:%s;base64,%s',
$this->getType(),