[CORE][CONTROLLER][Network] Refactor term 'network' into 'feeds'

This commit is contained in:
Hugo Sales 2021-11-26 20:37:17 +00:00
parent 0ab8febab3
commit 42f40f9ebe
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
8 changed files with 53 additions and 93 deletions

View File

@ -178,7 +178,7 @@ class Favourite extends Controller
Event::handle('FormatNoteList', [$notes, &$notes_out]);
return [
'_template' => 'network/feed.html.twig',
'_template' => 'feeds/feed.html.twig',
'notes' => $notes_out,
'page_title' => 'Favourites feed.',
];
@ -212,7 +212,7 @@ class Favourite extends Controller
Event::handle('FormatNoteList', [$notes, &$notes_out]);
return [
'_template' => 'network/feed.html.twig',
'_template' => 'feeds/feed.html.twig',
'notes' => $notes,
'page_title' => 'Reverse favourites feed.',
];

View File

@ -8,11 +8,11 @@
{% block stylesheets %}
{{ parent() }}
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/network/public.css') }}"
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/feeds/public.css') }}"
media="screen and (min-width: 1300px)">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/network/public_mid.css') }}"
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/feeds/public_mid.css') }}"
media="screen and (max-width: 1300px)">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/network/public_small.css') }}"
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/feeds/public_small.css') }}"
media="screen and (max-width: 750px)">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/poll/poll.css') }}"
media="screen">
@ -40,4 +40,4 @@
</div>
{% endblock body %}
{% block javascripts %}{% endblock %}
{% block javascripts %}{% endblock %}

View File

@ -9,11 +9,11 @@
{% block stylesheets %}
{{ parent() }}
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/poll/poll.css') }}">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/network/public.css') }}"
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/feeds/public.css') }}"
media="screen and (min-width: 1300px)">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/network/public_mid.css') }}"
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/feeds/public_mid.css') }}"
media="screen and (max-width: 1300px)">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/network/public_small.css') }}"
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/feeds/public_small.css') }}"
media="screen and (max-width: 750px)">
{% endblock %}
@ -41,4 +41,4 @@
</div>
{% endblock body %}
{% block javascripts %}{% endblock %}
{% block javascripts %}{% endblock %}

View File

@ -47,7 +47,7 @@ use App\Util\Exception\NotFoundException;
use App\Util\Exception\NotImplementedException;
use Symfony\Component\HttpFoundation\Request;
class Network extends Controller
class Feeds extends Controller
{
// Can't have constants inside herestring
private $public_scope = VisibilityScope::PUBLIC;
@ -63,7 +63,7 @@ class Network extends Controller
Event::handle('FormatNoteList', [$notes, &$notes_out]);
return [
'_template' => 'network/feed.html.twig',
'_template' => 'feeds/feed.html.twig',
'notes' => $notes_out,
'page_title' => 'Public feed',
];
@ -108,7 +108,7 @@ class Network extends Controller
Event::handle('FormatNoteList', [$notes, &$notes_out]);
return [
'_template' => 'network/feed.html.twig',
'_template' => 'feeds/feed.html.twig',
'notes' => $notes_out,
'page_title' => 'Home feed',
];
@ -122,7 +122,7 @@ class Network extends Controller
Event::handle('FormatNoteList', [$notes, &$notes_out]);
return [
'_template' => 'network/feed.html.twig',
'_template' => 'feeds/feed.html.twig',
'notes' => $notes_out,
'page_title' => 'Network feed',
];
@ -141,7 +141,7 @@ class Network extends Controller
Event::handle('FormatNoteList', [$notes, &$notes_out]);
return [
'_template' => 'network/feed.html.twig',
'_template' => 'feeds/feed.html.twig',
'notes' => $notes_out,
'page_title' => 'Replies feed',
];

View File

@ -55,10 +55,11 @@ abstract class Main
$r->connect('security_recover_password_token', '/main/recover-password/{token?}', [C\ResetPassword::class, 'reset']);
$r->connect('root', '/', RedirectController::class, ['defaults' => ['route' => 'main_all']]);
$r->connect('main_public', '/main/public', [C\Network::class, 'public']);
$r->connect('main_all', '/main/all', [C\Network::class, 'network']);
$r->connect('home_all', '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/all', [C\Network::class, 'home']);
$r->connect('replies', '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/replies', [C\Network::class, 'replies']);
$r->connect('main_public', '/main/public', [C\Feeds::class, 'public']);
$r->connect('main_all', '/main/all', [C\Feeds::class, 'network']);
$r->connect('home_all', '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/all', [C\Feeds::class, 'home']);
$r->connect('replies', '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/replies', [C\Feeds::class, 'replies']);
$r->connect('edit_feeds', '/edit-feeds', [C\Feeds::class, 'replies']);
$r->connect('panel', '/panel', [C\AdminPanel::class, 'site']);
$r->connect('panel_site', '/panel/site', [C\AdminPanel::class, 'site']);

View File

@ -1,77 +1,36 @@
{% block feeds %}
<section class="section-widget section-widget-padded">
<h2 class="section-title">{{ icon('logo', 'icon icon-logo') | raw }} {{ 'Feeds' | trans }} </h2>
<section class="section-widget section-widget-padded">
<h2 class="section-title">{{ icon('logo', 'icon icon-logo') | raw }} {{ 'Feeds' | trans }}</h2>
<nav class='sec-nav' tabindex="0" title="{{ 'Navigate through each feed.' | trans }}">
{% if not app.user %} {# Default feeds #}
<ul>
<li>
<a href="{{ path('main_public') }}" class='{{ active('main_public') }}'>
Public
</a>
</li>
<li>
{% if app.user %}
<a href="{{ path("home_all", {'nickname' : current_actor.getNickname()}) }}" class='{{ active("home_all") }}'>
Home
</a>
{% endif %}
</li>
<li>
<a href="{{ path('main_all') }}" class='hover-effect {{ active('main_all') }}'>
Network
</a>
</li>
{% if app.user %}
{% for link in handle_event('AddMainNavigationItem', {'nickname': current_actor.getNickname()}) %}
<li>
<a href="{{ link['path'] }}" class='{{ active(link['path_id']) }}'>
{{ link['title'] }}
</a>
</li>
{% endfor %}
{% endif %}
<li>
<a href="{{ path('main_public') }}" class='{{ active('main_public') }}'>
Public
</a>
</li>
<li>
<a href="{{ path('main_all') }}" class='hover-effect {{ active('main_all') }}'>
Network
</a>
</li>
</ul>
{% else %} {# User custom feeds #}
<a href="{{ path('edit_feeds') }}">{{ icon('edit', 'icon') }}</a>
<ul>
{% for link in handle_event('GetLeftNavigationFeeds', {'actor': current_actor}) %}
<li>
<a href="{{ link['path'] }}" class='{{ active(link['path_id']) }}'>
{{ link['title'] }}
</a>
</li>
{% endfor %}
</ul>
{% endif %}
</nav>
</section>
</section>
{% endblock feeds %}
{% block group %}
<section class="section-widget section-widget-padded">
<h2 class="section-title">{{ icon('logo', 'icon icon-logo') | raw }} Group</h2>
<nav class='sec-nav' tabindex="0" title="{{ 'Navigate through each feed.' | trans }}">
<ul>
<li>
<a href="{{ path('main_public') }}" class='{{ active('main_public') }}'>
Public
</a>
</li>
<li>
{% if app.user %}
<a href="{{ path("home_all", {'nickname' : current_actor.getNickname()}) }}" class='{{ active("home_all") }}'>
Home
</a>
{% endif %}
</li>
<li>
<a href="{{ path('main_all') }}" class='hover-effect {{ active('main_all') }}'>
Network
</a>
</li>
{% if app.user %}
{% for link in handle_event('AddMainNavigationItem', {'nickname': current_actor.getNickname()}) %}
<li>
<a href="{{ link['path'] }}" class='{{ active(link['path_id']) }}'>
{{ link['title'] }}
</a>
</li>
{% endfor %}
{% endif %}
</ul>
</nav>
</section>
{% endblock group %}
{% block profile_current_actor %}
<nav tabindex="0" class="profile-navigation" title="{{ 'Navigate through account related pages.' | trans }}">

View File

@ -23,7 +23,7 @@ declare(strict_types = 1);
namespace App\Tests\Controller;
use App\Controller\Network;
use App\Controller\Feeds;
use App\Core\DB\DB;
use App\Core\Security;
use App\Core\VisibilityScope;
@ -36,7 +36,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Security as SSecurity;
class NetworkTest extends GNUsocialTestCase
class FeedsTest extends GNUsocialTestCase
{
use AssertThrows;
@ -50,7 +50,7 @@ class NetworkTest extends GNUsocialTestCase
$this->testRoute('home', fn ($vis) => !$vis->message, ['taken_user']);
}
public function testNetwork()
public function testFeeds()
{
$this->testRoute('network', fn ($vis) => $vis->public);
}
@ -74,12 +74,12 @@ class NetworkTest extends GNUsocialTestCase
}
$req = $this->createMock(Request::class);
$req_stack = $this->createMock(RequestStack::class);
$network = new Network($req_stack);
$feeds = new Feeds($req_stack);
if ($route == 'home') {
static::assertThrows(ClientException::class, fn () => $network->home($req, 'username_not_taken'));
static::assertThrows(ClientException::class, fn () => $feeds->home($req, 'username_not_taken'));
}
$result = $network->{$route}($req, ...$extra_args);
static::assertSame($result['_template'], 'network/feed.html.twig');
$result = $feeds->{$route}($req, ...$extra_args);
static::assertSame($result['_template'], 'feeds/feed.html.twig');
foreach ($result['notes'] as $n) {
static::assertIsArray($n['replies']);
}