diff --git a/components/Collection/templates/collection/actors.html.twig b/components/Collection/templates/collection/actors.html.twig index 3ecff78a5b..483b608a69 100644 --- a/components/Collection/templates/collection/actors.html.twig +++ b/components/Collection/templates/collection/actors.html.twig @@ -3,9 +3,14 @@ {% block title %}{{ title }}{% endblock %} {% block body %} -
+

{{ title }}

+ {% set prepend_actors_collection = handle_event('PrependActorsCollection', request) %} + {% for widget in prepend_actors_collection %} + {{ widget | raw }} + {% endfor %} +
@@ -56,5 +61,5 @@

{{ empty_message }}

{% endif %}
-
+ {% endblock body %} diff --git a/components/Group/Controller/Group.php b/components/Group/Controller/Group.php index 7535d0b3d3..0452295ed5 100644 --- a/components/Group/Controller/Group.php +++ b/components/Group/Controller/Group.php @@ -48,6 +48,7 @@ use Component\Group\Entity\LocalGroup; use Component\Subscription\Entity\ActorSubscription; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; class Group extends FeedController @@ -130,6 +131,53 @@ class Group extends FeedController throw new RedirectException('security_login'); } + $create_form = self::getGroupCreateForm($request, $actor); + + return [ + '_template' => 'group/create.html.twig', + 'create_form' => $create_form->createView(), + ]; + } + + /** + * Settings page for the group with the provided nickname, checks if the current actor can administrate given group + * + * @throws ClientException + * @throws NicknameEmptyException + * @throws NicknameInvalidException + * @throws NicknameNotAllowedException + * @throws NicknameTakenException + * @throws NicknameTooLongException + * @throws NoLoggedInUser + * @throws ServerException + * + * @return array + */ + public function groupSettings(Request $request, string $nickname) + { + $local_group = LocalGroup::getByNickname($nickname); + $group_actor = $local_group->getActor(); + $actor = Common::actor(); + if (!\is_null($group_actor) && $actor->canAdmin($group_actor)) { + return [ + '_template' => 'group/settings.html.twig', + 'group' => $group_actor, + 'personal_info_form' => ActorForms::personalInfo($request, $actor, $local_group)->createView(), + 'open_details_query' => $this->string('open'), + ]; + } else { + throw new ClientException(_m('You do not have permission to edit settings for the group "{group}"', ['{group}' => $nickname]), code: 404); + } + } + + /** + * Create a new Group FormInterface getter + * + * @throws RedirectException + * @throws ServerException + */ + public static function getGroupCreateForm(Request $request, E\Actor $actor): FormInterface + { $create_form = Form::create([ ['group_nickname', TextType::class, ['label' => _m('Group nickname')]], ['group_create', SubmitType::class, ['label' => _m('Create this group!')]], @@ -172,41 +220,6 @@ class Group extends FeedController throw new RedirectException(); } - - return [ - '_template' => 'group/create.html.twig', - 'create_form' => $create_form->createView(), - ]; - } - - /** - * Settings page for the group with the provided nickname, checks if the current actor can administrate given group - * - * @throws ClientException - * @throws NicknameEmptyException - * @throws NicknameInvalidException - * @throws NicknameNotAllowedException - * @throws NicknameTakenException - * @throws NicknameTooLongException - * @throws NoLoggedInUser - * @throws ServerException - * - * @return array - */ - public function groupSettings(Request $request, string $nickname) - { - $local_group = LocalGroup::getByNickname($nickname); - $group_actor = $local_group->getActor(); - $actor = Common::actor(); - if (!\is_null($group_actor) && $actor->canAdmin($group_actor)) { - return [ - '_template' => 'group/settings.html.twig', - 'group' => $group_actor, - 'personal_info_form' => ActorForms::personalInfo($request, $actor, $local_group)->createView(), - 'open_details_query' => $this->string('open'), - ]; - } else { - throw new ClientException(_m('You do not have permission to edit settings for the group "{group}"', ['{group}' => $nickname]), code: 404); - } + return $create_form; } } diff --git a/components/Group/templates/cards/group/create_widget.html.twig b/components/Group/templates/cards/group/create_widget.html.twig new file mode 100644 index 0000000000..3cf183b7e7 --- /dev/null +++ b/components/Group/templates/cards/group/create_widget.html.twig @@ -0,0 +1,10 @@ +
+ + + {% trans %}Create a group{% endtrans %} + + +
+ {{ form(create_form) }} +
+
\ No newline at end of file diff --git a/components/LeftPanel/LeftPanel.php b/components/LeftPanel/LeftPanel.php index f1c2d06015..51806a6bb7 100644 --- a/components/LeftPanel/LeftPanel.php +++ b/components/LeftPanel/LeftPanel.php @@ -67,17 +67,4 @@ class LeftPanel extends Component return Event::stop; } } - - /** - * Output our dedicated stylesheet - * - * @param array $styles stylesheets path - * - * @return bool hook value; true means continue processing, false means stop - */ - public function onEndShowStyles(array &$styles, string $route): bool - { - $styles[] = 'components/LeftPanel/assets/css/view.css'; - return Event::next; - } } diff --git a/components/RightPanel/RightPanel.php b/components/RightPanel/RightPanel.php deleted file mode 100644 index 94cef52048..0000000000 --- a/components/RightPanel/RightPanel.php +++ /dev/null @@ -1,41 +0,0 @@ -. -// }}} - -namespace Component\RightPanel; - -use App\Core\Event; -use App\Core\Modules\Component; - -class RightPanel extends Component -{ - /** - * Output our dedicated stylesheet - * - * @param array $styles stylesheets path - * - * @return bool hook value; true means continue processing, false means stop - */ - public function onEndShowStyles(array &$styles, string $route): bool - { - $styles[] = 'components/RightPanel/assets/css/view.css'; - return Event::next; - } -} diff --git a/plugins/Directory/Directory.php b/plugins/Directory/Directory.php index 00a5150e1e..62dbd13299 100644 --- a/plugins/Directory/Directory.php +++ b/plugins/Directory/Directory.php @@ -27,6 +27,12 @@ use App\Core\Event; use App\Core\Modules\Plugin; use App\Core\Router\RouteLoader; use App\Core\Router\Router; +use App\Util\Common; +use App\Util\Exception\RedirectException; +use App\Util\Exception\ServerException; +use App\Util\Formatting; +use Component\Group\Controller as ComponentGroupController; +use Symfony\Component\HttpFoundation\Request; class Directory extends Plugin { @@ -54,4 +60,28 @@ class Directory extends Plugin $res[] = ['title' => 'Groups', 'path' => Router::url($path_id = 'directory_groups', []), 'path_id' => $path_id]; return Event::next; } + + /** + * Prepend various widgets to Actors Collection template + * + * @param $elements array of widgets to be prepended + * + * @throws RedirectException + * @throws ServerException + * + * @return bool EventHook + */ + public function onPrependActorsCollection(Request $request, array &$elements): bool + { + if (\is_null($actor = Common::actor())) { + return Event::next; + } + + if ($request->get('_route') === 'directory_groups') { + $elements[] = Formatting::twigRenderFile('cards/group/create_widget.html.twig', context: [ + 'create_form' => ComponentGroupController\Group::getGroupCreateForm($request, $actor)->createView(), + ]); + } + return Event::next; + } } diff --git a/public/assets/default_theme/css/base.css b/public/assets/default_theme/css/base.css index dafd2e27ee..04c5a67fa3 100644 --- a/public/assets/default_theme/css/base.css +++ b/public/assets/default_theme/css/base.css @@ -1,3 +1,8 @@ +@import url(root.css); +@import url(reset.css); +@import url(widgets/buttons.css); +@import url(widgets/sections.css); + html { font-family: 'Open Sans', sans-serif; scroll-margin-top: var(--xxl); diff --git a/public/assets/default_theme/css/reset.css b/public/assets/default_theme/css/reset.css index 5ae902f386..b67d4cbdc0 100644 --- a/public/assets/default_theme/css/reset.css +++ b/public/assets/default_theme/css/reset.css @@ -48,10 +48,6 @@ fieldset { all: unset; } -section { - all: unset; -} - :link img, :visited img, a img { border: 0; } diff --git a/templates/base.html.twig b/templates/base.html.twig index e29d03b3dd..698f794181 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -15,19 +15,12 @@ {% block stylesheets %} - + + + - - - - - - - {% for stylesheet in show_stylesheets(app.request.get('_route')) %}