Browse Source

Display list of groups for each subscription

master
Frederic Guillot 6 years ago
parent
commit
c01619d835
  1. 10
      app/controllers/feed.php
  2. 6
      app/helpers/template.php
  3. 3
      app/models/feed.php
  4. 11
      app/templates/feeds.php
  5. 23
      assets/css/app.css
  6. 2
      assets/css/app.min.css
  7. 2
      tests/unit/FeedModelTest.php

10
app/controllers/feed.php

@ -127,20 +127,20 @@ Router\get_action('feeds', function () {
$user_id = SessionStorage::getInstance()->getUserId();
$nothing_to_read = Request\int_param('nothing_to_read');
$nb_unread_items = Model\Item\count_by_status($user_id, 'unread');
$feeds = Model\Feed\get_feeds_with_items_count($user_id);
$feeds = Model\Feed\get_feeds_with_items_count_and_groups($user_id);
if ($nothing_to_read === 1 && $nb_unread_items > 0) {
Response\redirect('?action=unread');
}
Response\html(Template\layout('feeds', array(
'favicons' => Model\Favicon\get_feeds_favicons($feeds),
'feeds' => $feeds,
'favicons' => Model\Favicon\get_feeds_favicons($feeds),
'feeds' => $feeds,
'nothing_to_read' => $nothing_to_read,
'nb_unread_items' => $nb_unread_items,
'nb_failed_feeds' => Model\Feed\count_failed_feeds($user_id),
'menu' => 'feeds',
'title' => t('Subscriptions')
'menu' => 'feeds',
'title' => t('Subscriptions'),
)));
});

6
app/helpers/template.php

@ -120,3 +120,9 @@ function relative_time($timestamp, $fallback_date_format = '%e %B %Y %k:%M')
return \dt($fallback_date_format, $timestamp);
}
function link($label, $action, array $params = array())
{
$params['action'] = $action;
return sprintf('<a href="?%s">%s</a>', http_build_query($params, '', '&amp;'), escape($label));
}

3
app/models/feed.php

@ -55,7 +55,7 @@ function get_feeds($user_id)
->findAll();
}
function get_feeds_with_items_count($user_id)
function get_feeds_with_items_count_and_groups($user_id)
{
$feeds_count = array();
$feeds = get_feeds($user_id);
@ -82,6 +82,7 @@ function get_feeds_with_items_count($user_id)
foreach ($feeds as &$feed) {
$feed['items_unread'] = isset($feeds_count[$feed['id']]) ? $feeds_count[$feed['id']]['unread'] : 0;
$feed['items_total'] = isset($feeds_count[$feed['id']]) ? $feeds_count[$feed['id']]['total'] : 0;
$feed['groups'] = Group\get_feed_groups($feed['id']);
}
return $feeds;

11
app/templates/feeds.php

@ -51,6 +51,17 @@
<?php echo t('An error occurred during the last check: "%s".', $feed['parsing_error_message']) ?>
</span>
</h2>
<?php if (! empty($feed['groups'])): ?>
<ul class="feed-groups">
<?php foreach ($feed['groups'] as $group): ?>
<li>
<?php echo Miniflux\Helper\link($group['title'], 'unread', array('group_id' => $group['id'])) ?>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
<ul class="item-menu">
<li>
<a href="<?php echo $feed['site_url'] ?>" rel="noreferrer" target="_blank"><?php echo Miniflux\Helper\get_host_from_url($feed['site_url']) ?></a>

23
assets/css/app.css

@ -514,6 +514,29 @@ nav .active a {
visibility: hidden;
}
.feed-groups li {
display: inline;
margin-left: 0;
}
.feed-groups li a:after {
content: ', ';
}
.feed-groups li:last-child a:after {
content: '';
}
.feed-groups a {
color: #333;
}
.items .feed-groups a:focus,
.items .feed-groups a:hover {
color: #777;
text-decoration: none;
}
/* items listing */
.items article[data-feed-error] .feed-parsing-error {
visibility: visible;

2
assets/css/app.min.css vendored

File diff suppressed because one or more lines are too long

2
tests/unit/FeedModelTest.php

@ -104,7 +104,7 @@ class FeedModelTest extends BaseTest
$feed->setSiteUrl('site url');
$this->assertEquals(2, Model\Feed\create(1, $feed, 'etag', 'last modified'));
$feeds = Model\Feed\get_feeds_with_items_count(1);
$feeds = Model\Feed\get_feeds_with_items_count_and_groups(1);
$this->assertCount(2, $feeds);
$this->assertEquals(1, $feeds[0]['items_unread']);

Loading…
Cancel
Save