[UI][PLUGIN][Reply][Favourite][ENTITY][Feed] Remove replies and favourite links from navigation/view.html.twig and add them to the feeds section
This commit is contained in:
parent
36613a826d
commit
0b57b20d38
|
@ -25,17 +25,18 @@ namespace Plugin\Favourite;
|
|||
|
||||
use App\Core\DB\DB;
|
||||
use App\Core\Event;
|
||||
use function App\Core\I18n\_m;
|
||||
use App\Core\Modules\NoteHandlerPlugin;
|
||||
use App\Core\Router\RouteLoader;
|
||||
use App\Core\Router\Router;
|
||||
use App\Entity\Actor;
|
||||
use App\Entity\Feed;
|
||||
use App\Entity\LocalUser;
|
||||
use App\Entity\Note;
|
||||
use App\Util\Common;
|
||||
use App\Util\Exception\InvalidFormException;
|
||||
use App\Util\Exception\NoSuchNoteException;
|
||||
use App\Util\Exception\NotFoundException;
|
||||
use App\Util\Exception\RedirectException;
|
||||
use App\Util\Formatting;
|
||||
use App\Util\Nickname;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
|
@ -83,17 +84,11 @@ class Favourite extends NoteHandlerPlugin
|
|||
return Event::next;
|
||||
}
|
||||
|
||||
public function onAddProfileNavigationItem(array $vars, array &$res): bool
|
||||
public function onAppendCardNote(array $vars, array &$result)
|
||||
{
|
||||
$res[] = ['title' => 'Favourites', 'path' => Router::url('favourites_view_by_nickname', ['nickname' => $vars['nickname']]), 'path_id' => 'favourites_view_by_nickname'];
|
||||
$res[] = ['title' => 'Reverse Favourites', 'path' => Router::url('favourites_reverse_view_by_nickname', ['nickname' => $vars['nickname']]), 'path_id' => 'favourites_view_by_nickname'];
|
||||
return Event::next;
|
||||
}
|
||||
|
||||
public function onAppendCardNote(array $vars, array &$result) {
|
||||
// if note is the original, append on end "user favourited this"
|
||||
$actor = $vars['actor'];
|
||||
$note = $vars['note'];
|
||||
$note = $vars['note'];
|
||||
|
||||
return Event::next;
|
||||
}
|
||||
|
@ -113,4 +108,23 @@ class Favourite extends NoteHandlerPlugin
|
|||
$r->connect(id: 'favourites_reverse_view_by_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/reverse_favourites', target: [Controller\Favourite::class, 'reverseFavouritesByActorNickname']);
|
||||
return Event::next;
|
||||
}
|
||||
|
||||
public function onCreateDefaultFeeds(int $actor_id, LocalUser $user, int &$ordering)
|
||||
{
|
||||
DB::persist(Feed::create([
|
||||
'actor_id' => $actor_id,
|
||||
'url' => Router::url($route = 'favourites_view_by_nickname', ['nickname' => $user->getNickname()]),
|
||||
'route' => $route,
|
||||
'title' => _m('Favourites'),
|
||||
'ordering' => $ordering++,
|
||||
]));
|
||||
DB::persist(Feed::create([
|
||||
'actor_id' => $actor_id,
|
||||
'url' => Router::url($route = 'favourites_reverse_view_by_nickname', ['nickname' => $user->getNickname()]),
|
||||
'route' => $route,
|
||||
'title' => _m('Reverse favourites'),
|
||||
'ordering' => $ordering++,
|
||||
]));
|
||||
return Event::next;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,11 +23,14 @@ declare(strict_types = 1);
|
|||
|
||||
namespace Plugin\Reply;
|
||||
|
||||
use App\Core\DB\DB;
|
||||
use App\Core\Event;
|
||||
use function App\Core\I18n\_m;
|
||||
use App\Core\Modules\NoteHandlerPlugin;
|
||||
use App\Core\Router\Router;
|
||||
use App\Entity\Actor;
|
||||
use App\Entity\Feed;
|
||||
use App\Entity\LocalUser;
|
||||
use App\Entity\Note;
|
||||
use App\Util\Common;
|
||||
use App\Util\Exception\InvalidFormException;
|
||||
|
@ -35,6 +38,7 @@ use App\Util\Exception\NoSuchNoteException;
|
|||
use App\Util\Exception\RedirectException;
|
||||
use App\Util\Exception\ServerException;
|
||||
use App\Util\Formatting;
|
||||
use App\Util\Nickname;
|
||||
use Plugin\Reply\Controller\Reply as ReplyController;
|
||||
use Plugin\Reply\Entity\NoteReply;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
@ -139,6 +143,15 @@ class Reply extends NoteHandlerPlugin
|
|||
return Event::next;
|
||||
}
|
||||
|
||||
public function onCreateDefaultFeeds(int $actor_id, LocalUser $user, int &$ordering)
|
||||
{
|
||||
DB::persist(Feed::create([
|
||||
'actor_id' => $actor_id,
|
||||
'url' => Router::url($route = 'replies', ['nickname' => $user->getNickname()]),
|
||||
'route' => $route,
|
||||
'title' => _m('Replies'),
|
||||
'ordering' => $ordering++,
|
||||
]));
|
||||
return Event::next;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,9 @@ namespace App\Entity;
|
|||
use App\Core\Cache;
|
||||
use App\Core\DB\DB;
|
||||
use App\Core\Entity;
|
||||
use App\Core\Event;
|
||||
use function App\Core\I18n\_m;
|
||||
use App\Core\Router\Router;
|
||||
use DateTimeInterface;
|
||||
|
||||
/**
|
||||
|
@ -149,12 +151,11 @@ class Feed extends Entity
|
|||
*/
|
||||
public static function createDefaultFeeds(int $actor_id, LocalUser $user): void
|
||||
{
|
||||
DB::persist(self::create(['actor_id' => $actor_id, 'url' => '/main/public',
|
||||
'route' => 'main_public', 'title' => _m('Public'), 'ordering' => 1, ]));
|
||||
DB::persist(self::create(['actor_id' => $actor_id, 'url' => '/main/all',
|
||||
'route' => 'main_all', 'title' => _m('Network'), 'ordering' => 2, ]));
|
||||
DB::persist(self::create(['actor_id' => $actor_id, 'url' => '/@' . $user->getNickname() . '/all',
|
||||
'route' => 'home_all', 'title' => _m('Home'), 'ordering' => 3, ]));
|
||||
$ordering = 1;
|
||||
DB::persist(self::create(['actor_id' => $actor_id, 'url' => Router::url($route = 'main_public'), 'route' => $route, 'title' => _m('Public'), 'ordering' => $ordering++]));
|
||||
DB::persist(self::create(['actor_id' => $actor_id, 'url' => Router::url($route = 'main_all'), 'route' => $route, 'title' => _m('Network'), 'ordering' => $ordering++]));
|
||||
DB::persist(self::create(['actor_id' => $actor_id, 'url' => Router::url($route = 'home_all', ['nickname' => $user->getNickname()]), 'route' => $route, 'title' => _m('Home'), 'ordering' => $ordering++]));
|
||||
Event::handle('CreateDefaultFeeds', [$actor_id, $user, &$ordering]);
|
||||
}
|
||||
|
||||
public static function schemaDef(): array
|
||||
|
|
|
@ -58,8 +58,6 @@ abstract class Main
|
|||
$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, 'edit_feeds']);
|
||||
|
||||
$r->connect('panel', '/panel', [C\AdminPanel::class, 'site']);
|
||||
$r->connect('panel_site', '/panel/site', [C\AdminPanel::class, 'site']);
|
||||
|
|
|
@ -36,16 +36,6 @@
|
|||
{% block profile_current_actor %}
|
||||
<nav tabindex="0" class="profile-navigation" title="{{ 'Navigate through account related pages.' | trans }}">
|
||||
|
||||
<a title='{{ 'Replies to your notes.' | trans }}' href="{{ path('replies', {'nickname' : current_actor.getNickname()}) }}" class='{{ active("replies") }}'>
|
||||
Replies
|
||||
</a>
|
||||
|
||||
{% for tab in handle_event('AddProfileNavigationItem', {'nickname': current_actor.getNickname()}) %}
|
||||
<a href="{{ tab['path'] }}" class='{{ active(tab['path_id']) }}'>
|
||||
{{ tab['title'] }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
||||
<a title='{{ 'Access your account settings.' | trans }}' href="{{ path('settings') }}" class='{{ active('settings') }}'>
|
||||
Settings
|
||||
</a>
|
||||
|
|
Loading…
Reference in New Issue
Block a user