Skip to content

Commit 21f35a6

Browse files
feat(alpha): Provide a new "sources" page to replace "feeds"
1 parent f3c1c51 commit 21f35a6

21 files changed

Lines changed: 918 additions & 145 deletions

File tree

locales/fr_FR/LC_MESSAGES/main.mo

1.96 KB
Binary file not shown.

locales/fr_FR/LC_MESSAGES/main.po

Lines changed: 196 additions & 78 deletions
Large diffs are not rendered by default.

public/static/icons.svg

Lines changed: 1 addition & 1 deletion
Loading

src/Router.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ public static function load(): \Minz\Router
226226

227227
$router->addRoute('GET', '/feeds.xsl', 'Feeds#xsl', 'feeds xsl');
228228

229+
// Sources
230+
$router->addRoute('GET', '/sources', 'Sources#index', 'sources');
231+
229232
// Streams
230233
$router->addRoute('GET', '/streams/new', 'Streams#new', 'new stream');
231234
$router->addRoute('POST', '/streams/new', 'Streams#create', 'create stream');

src/assets/stylesheets/components/filters.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
padding: var(--space-medium);
99
}
1010

11+
.details__header + .filters__section,
1112
.filters__section + .filters__section {
1213
border-top: 1px solid var(--color-grey-line);
1314
}

src/controllers/Feeds.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ public function index(Request $request): Response
2929
{
3030
$user = auth\CurrentUser::require();
3131

32+
if ($user->isAlphaEnabled()) {
33+
// The page only displays a notice pointing to the Sources page to
34+
// these users: there is nothing to list here.
35+
return Response::ok('feeds/index.html.twig');
36+
}
37+
3238
$groups = models\Group::listBy(['user_id' => $user->id]);
3339
$groups = utils\Sorter::localeSort($groups, 'name');
3440

src/controllers/Sources.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace App\controllers;
4+
5+
use App\auth;
6+
use App\models;
7+
use Minz\Request;
8+
use Minz\Response;
9+
10+
/**
11+
* @author Marien Fressinaud <dev@marienfressinaud.fr>
12+
* @license http://www.gnu.org/licenses/agpl-3.0.en.html AGPL
13+
*/
14+
class Sources extends BaseController
15+
{
16+
/**
17+
* List the sources followed by the current user.
18+
*
19+
* @response 302 /feeds
20+
* If the user has not the alpha feature enabled.
21+
* @response 200
22+
* On success.
23+
*
24+
* @throws auth\MissingCurrentUserError
25+
* If the user is not connected.
26+
*/
27+
public function index(Request $request): Response
28+
{
29+
$user = auth\CurrentUser::require();
30+
31+
if (!$user->isAlphaEnabled()) {
32+
return Response::redirect('feeds');
33+
}
34+
35+
$sources = $user->followedSources();
36+
37+
models\collections\Preloader::for($sources)
38+
->publishers()
39+
->countStreamsFor($user)
40+
->timeFiltersFor($user);
41+
42+
return Response::ok('sources/index.html.twig', [
43+
'sources' => $sources,
44+
]);
45+
}
46+
}

src/models/Collection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,8 @@ public function syncPublicationFrequencyPerYear(): void
641641
*/
642642
public function suggestedTimeFilter(): string
643643
{
644-
if ($this->publication_frequency_per_year >= 5 * 365) {
645-
// At least five links per day.
644+
if ($this->publication_frequency_per_year >= 3 * 365) {
645+
// At least three links per day.
646646
return 'none';
647647
}
648648

src/navigations/ReadingNavigation.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public function elements(): array
2121
{
2222
$current_user = auth\CurrentUser::require();
2323

24+
$is_alpha_enabled = $current_user->isAlphaEnabled();
25+
2426
$elements = [
2527
new Item(
2628
label: TwigExtension::translate('News'),
@@ -44,6 +46,15 @@ public function elements(): array
4446
),
4547
];
4648

49+
if ($is_alpha_enabled) {
50+
$elements[] = new Item(
51+
label: TwigExtension::translate('Sources'),
52+
key: 'sources',
53+
url: \Minz\Url::for('sources'),
54+
icon: 'feed',
55+
);
56+
}
57+
4758
if ($current_user->isBetaEnabled()) {
4859
$elements[] = new Item(
4960
label: TwigExtension::translate('Explore'),
@@ -53,7 +64,7 @@ public function elements(): array
5364
);
5465
}
5566

56-
if ($current_user->isAlphaEnabled()) {
67+
if ($is_alpha_enabled) {
5768
$new_stream_action = new ItemAction(
5869
label: TwigExtension::translate('New stream'),
5970
url: \Minz\Url::for('new stream'),

src/views/collections/show.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
{% if collection.isFeed %}
1818
{% set feed_url = collection.feed_url %}
1919
{% set opengraph_description = t('A feed from %s, on %s.', [collection.feedWebsiteHost, app.brand]) %}
20-
{% set current_tab = 'feeds' %}
20+
{% set current_tab = is_alpha ? 'reading' : 'feeds' %}
2121
{% else %}
2222
{% set feed_url = url_full('collection feed', { id: collection.id }) %}
2323
{% set opengraph_description = t('A collection created by %s on %s.', [owner.username, app.brand]) %}

0 commit comments

Comments
 (0)