diff --git a/components/Posting/Posting.php b/components/Posting/Posting.php index 587ad95978..1c6c9a5ca7 100644 --- a/components/Posting/Posting.php +++ b/components/Posting/Posting.php @@ -103,7 +103,7 @@ class Posting extends Component $form_params[] = ['visibility', ChoiceType::class, ['label' => _m('Visibility:'), 'multiple' => false, 'expanded' => false, 'data' => 'public', 'choices' => [_m('Public') => 'public', _m('Instance') => 'instance', _m('Private') => 'private']]]; $form_params[] = ['content', TextareaType::class, ['label' => _m('Content:'), 'data' => $initial_content, 'attr' => ['placeholder' => _m($placeholder)], 'constraints' => [new Length(['max' => Common::config('site', 'text_limit')])]]]; $form_params[] = ['attachments', FileType::class, ['label' => _m('Attachments:'), 'multiple' => true, 'required' => false, 'invalid_message' => _m('Attachment not valid.')]]; - $form_params[] = FormFields::language($actor, $context_actor, label: _m('Note language:'), help: _m('The selected language will be federated and added as a lang attribute, preferred language can be set up in settings')); + $form_params[] = FormFields::language($actor, $context_actor, label: _m('Note language'), help: _m('The selected language will be federated and added as a lang attribute, preferred language can be set up in settings')); if (\count($available_content_types) > 1) { $form_params[] = ['content_type', ChoiceType::class, diff --git a/plugins/AttachmentCollections/AttachmentCollections.php b/plugins/AttachmentCollections/AttachmentCollections.php index 12f06934f2..eb7f12d32a 100644 --- a/plugins/AttachmentCollections/AttachmentCollections.php +++ b/plugins/AttachmentCollections/AttachmentCollections.php @@ -23,6 +23,7 @@ declare(strict_types = 1); * * @package GNUsocial * @category Plugin + * * @author Phablulo * @copyright 2018-2019, 2021 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later @@ -30,25 +31,25 @@ declare(strict_types = 1); namespace Plugin\AttachmentCollections; -use App\Core\Form; -use App\Core\Event; use App\Core\DB\DB; -use App\Util\Common; -use App\Entity\Feed; -use App\Util\Nickname; -use App\Util\Formatting; -use App\Entity\LocalUser; -use App\Core\Router\Router; -use App\Core\Modules\Plugin; +use App\Core\Event; +use App\Core\Form; use function App\Core\I18n\_m; +use App\Core\Modules\Plugin; use App\Core\Router\RouteLoader; -use Symfony\Component\HttpFoundation\Request; +use App\Core\Router\Router; +use App\Entity\Feed; +use App\Entity\LocalUser; +use App\Util\Common; +use App\Util\Formatting; +use App\Util\Nickname; use Plugin\AttachmentCollections\Controller as C; use Plugin\AttachmentCollections\Entity\Collection; use Plugin\AttachmentCollections\Entity\CollectionEntry; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\HttpFoundation\Request; class AttachmentCollections extends Plugin { @@ -56,21 +57,25 @@ class AttachmentCollections extends Plugin { // View all collections by actor id and nickname $r->connect( - id: 'collections_view_by_actor_id', uri_path: '/actor/{id<\d+>}/collections', - target: [C\Controller::class, 'collectionsViewByActorId'] + id: 'collections_view_by_actor_id', + uri_path: '/actor/{id<\d+>}/collections', + target: [C\Controller::class, 'collectionsViewByActorId'], ); $r->connect( - id: 'collections_view_by_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/collections', - target: [C\Controller::class, 'collectionsByActorNickname'] + id: 'collections_view_by_nickname', + uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/collections', + target: [C\Controller::class, 'collectionsByActorNickname'], ); // View notes from a collection by actor id and nickname $r->connect( - id: 'collection_notes_view_by_actor_id', uri_path: '/actor/{id<\d+>}/collections/{cid<\d+>}', - target: [C\Controller::class, 'collectionNotesViewByActorId'] + id: 'collection_notes_view_by_actor_id', + uri_path: '/actor/{id<\d+>}/collections/{cid<\d+>}', + target: [C\Controller::class, 'collectionNotesViewByActorId'], ); $r->connect( - id: 'collection_notes_view_by_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/collections/{cid<\d+>}', - target: [C\Controller::class, 'collectionNotesByNickname'] + id: 'collection_notes_view_by_nickname', + uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/collections/{cid<\d+>}', + target: [C\Controller::class, 'collectionNotesByNickname'], ); return Event::next; } @@ -78,9 +83,9 @@ class AttachmentCollections extends Plugin { DB::persist(Feed::create([ 'actor_id' => $actor_id, - 'url' => Router::url($route = 'collections_view_by_nickname', ['nickname' => $user->getNickname()]), - 'route' => $route, - 'title' => _m('Attachment Collections'), + 'url' => Router::url($route = 'collections_view_by_nickname', ['nickname' => $user->getNickname()]), + 'route' => $route, + 'title' => _m('Attachment Collections'), 'ordering' => $ordering++, ])); return Event::next; @@ -92,18 +97,22 @@ class AttachmentCollections extends Plugin */ public function onAppendRightPanelBlock($vars, Request $request, &$res): bool { - if ($vars['path'] !== 'attachment_show') return Event::next; + if ($vars['path'] !== 'attachment_show') { + return Event::next; + } $user = Common::user(); - if (\is_null($user)) return Event::next; + if (\is_null($user)) { + return Event::next; + } $colls = DB::dql( 'select coll from Plugin\AttachmentCollections\Entity\Collection coll where coll.actor_id = :id', - ['id' => $user->getId()] + ['id' => $user->getId()], ); - + // add to collection form $attachment_id = $vars['vars']['attachment_id']; - $choices = []; + $choices = []; foreach ($colls as $col) { $choices[$col->getName()] = $col->getId(); } @@ -112,35 +121,34 @@ class AttachmentCollections extends Plugin . 'inner join attachment_collection collection ' . 'with collection.id = entry.collection_id ' . 'where entry.attachment_id = :aid and collection.actor_id = :id', - ['aid' => $attachment_id, 'id' => $user->getId()] + ['aid' => $attachment_id, 'id' => $user->getId()], ); - $already_selected = \array_map(fn ($x) => $x['collection_id'], $already_selected); - $add_form = Form::create([ + $already_selected = array_map(fn ($x) => $x['collection_id'], $already_selected); + $add_form = Form::create([ ['collections', ChoiceType::class, [ - 'choices' => $choices, - 'multiple' => true, - 'required' => false, + 'choices' => $choices, + 'multiple' => true, + 'required' => false, 'choice_attr' => function ($id) use ($already_selected) { if (\in_array($id, $already_selected)) { return ['selected' => 'selected']; } return []; - } + }, ]], ['add', SubmitType::class, [ 'label' => _m('Add to collections'), - 'attr' => [ + 'attr' => [ 'title' => _m('Add to collection'), ], ]], ]); - $add_form->handleRequest($request); if ($add_form->isSubmitted() && $add_form->isValid()) { $collections = $add_form->getData()['collections']; - $removed = \array_filter($already_selected, fn ($x) => !\in_array($x, $collections)); - $added = \array_filter($collections, fn ($x) => !\in_array($x, $already_selected)); + $removed = array_filter($already_selected, fn ($x) => !\in_array($x, $collections)); + $added = array_filter($collections, fn ($x) => !\in_array($x, $already_selected)); if (\count($removed)) { DB::dql( 'delete from Plugin\AttachmentCollections\Entity\CollectionEntry entry ' @@ -150,10 +158,10 @@ class AttachmentCollections extends Plugin // prevent user from deleting something (s)he doesn't own: . 'and collection.actor_id = :id' . ')', - ['aid' => $attachment_id, 'id' => $user->getId(), 'ids' => $removed] + ['aid' => $attachment_id, 'id' => $user->getId(), 'ids' => $removed], ); } - $collection_ids = \array_map(fn ($x) => $x->getId(), $colls); + $collection_ids = array_map(fn ($x) => $x->getId(), $colls); foreach ($added as $cid) { // prevent user from putting something in a collection (s)he doesn't own: if (\in_array($cid, $collection_ids)) { @@ -168,16 +176,16 @@ class AttachmentCollections extends Plugin // add to new collection form $create_form = Form::create([ ['name', TextType::class, [ - 'label' => _m('Collection name'), - 'attr' => [ - 'placeholder' => _m('Name'), - 'required' => 'required' + 'label' => _m('Add to a new collection'), + 'attr' => [ + 'placeholder' => _m('New collection name'), + 'required' => 'required', ], 'data' => '', ]], ['create', SubmitType::class, [ 'label' => _m('Create a new collection'), - 'attr' => [ + 'attr' => [ 'title' => _m('Create a new collection'), ], ]], @@ -186,7 +194,7 @@ class AttachmentCollections extends Plugin if ($create_form->isSubmitted() && $create_form->isValid()) { $name = $create_form->getData()['name']; $coll = Collection::create([ - 'name' => $name, + 'name' => $name, 'actor_id' => $user->getId(), ]); DB::persist($coll); @@ -198,14 +206,13 @@ class AttachmentCollections extends Plugin DB::flush(); } - $res[] = Formatting::twigRenderFile( 'AttachmentCollections/widget.html.twig', [ - 'colls' => $colls, - 'add_form' => $add_form->createView(), + 'colls' => $colls, + 'add_form' => $add_form->createView(), 'create_form' => $create_form->createView(), - ] + ], ); return Event::next; } diff --git a/plugins/AttachmentCollections/templates/AttachmentCollections/widget.html.twig b/plugins/AttachmentCollections/templates/AttachmentCollections/widget.html.twig index 21ce61803a..cbd3f1c93d 100644 --- a/plugins/AttachmentCollections/templates/AttachmentCollections/widget.html.twig +++ b/plugins/AttachmentCollections/templates/AttachmentCollections/widget.html.twig @@ -1,17 +1,21 @@ -
+

{% trans %}Add to collection{% endtrans %}

{{ icon('arrow-down', 'icon icon-details-open') | raw }}
- {{ form(add_form) }} -
-
+
+ {{ form(add_form) }} +
+ +
-

{% trans %}More options{% endtrans %}

+ {% trans %}Other options{% endtrans %} {{ icon('arrow-down', 'icon icon-details-close') | raw }}
- {{ form(create_form) }} +
+ {{ form(create_form) }} +
diff --git a/plugins/AttachmentShowRelated/templates/attachmentShowRelated/attachmentRelatedNotes.html.twig b/plugins/AttachmentShowRelated/templates/attachmentShowRelated/attachmentRelatedNotes.html.twig index 4147f1d77d..b7ed4059e8 100644 --- a/plugins/AttachmentShowRelated/templates/attachmentShowRelated/attachmentRelatedNotes.html.twig +++ b/plugins/AttachmentShowRelated/templates/attachmentShowRelated/attachmentRelatedNotes.html.twig @@ -2,7 +2,9 @@
- {{ 'Notes related' | trans }} +

+ {{ 'Notes related' | trans }} +

{% for note in related_notes %} diff --git a/plugins/AttachmentShowRelated/templates/attachmentShowRelated/attachmentRelatedTags.html.twig b/plugins/AttachmentShowRelated/templates/attachmentShowRelated/attachmentRelatedTags.html.twig index f0f8dc453c..5e7d465977 100644 --- a/plugins/AttachmentShowRelated/templates/attachmentShowRelated/attachmentRelatedTags.html.twig +++ b/plugins/AttachmentShowRelated/templates/attachmentShowRelated/attachmentRelatedTags.html.twig @@ -1,6 +1,8 @@ -
+
- {{ 'Tags for this attachment' | trans }} +

+ {{ 'Attachment tags' | trans }} +

{% for tag in related_tags %} diff --git a/public/assets/default_theme/css/base.css b/public/assets/default_theme/css/base.css index caedaed417..35af31eee4 100644 --- a/public/assets/default_theme/css/base.css +++ b/public/assets/default_theme/css/base.css @@ -4,6 +4,9 @@ @import url("widgets/buttons.css"); @import url("widgets/sections.css"); +html { + scroll-margin-top: var(--xxl); +} @media(prefers-color-scheme:dark) { select:not([multiple]) { @@ -53,8 +56,8 @@ top: var(--s); left: var(--s); } -html { - scroll-margin-top: var(--xxl); +.heading-no-margin { + margin-bottom: initial; } .page-header { z-index: 1; diff --git a/public/assets/default_theme/css/widgets/buttons.css b/public/assets/default_theme/css/widgets/buttons.css index da15f14e97..02500b1f8f 100644 --- a/public/assets/default_theme/css/widgets/buttons.css +++ b/public/assets/default_theme/css/widgets/buttons.css @@ -109,7 +109,7 @@ textarea { padding: 6px 8px !important; border-radius: var(--s); border: 2px solid var(--border) !important; - width: inherit; + width: auto; max-width: border-box !important; } button, diff --git a/public/assets/default_theme/css/widgets/sections.css b/public/assets/default_theme/css/widgets/sections.css index 68280673ea..22346ef5a6 100644 --- a/public/assets/default_theme/css/widgets/sections.css +++ b/public/assets/default_theme/css/widgets/sections.css @@ -42,6 +42,9 @@ margin-right: 5px; border-radius: 2px; } +.section-title { + font-weight: 700; +} .section-widget { display: flex; flex-direction: column; @@ -66,32 +69,34 @@ margin-left: unset; } .section-widget-button-like { - border-radius: var(--s); - padding: 6px 10px; - margin-top: 6px; - cursor: pointer; - float: right; - align-self: end; - font-family: 'Open Sans',sans-serif; + font-family: 'Poppins', sans-serif; font-weight: 700; + display: block; + width: max-content; + align-self: end; + background: var(--gradient); + padding: 6px 8px; + border-radius: var(--s); + border: 2px solid var(--border); } -.section-widget-subtitle-details :not(summary,svg,strong) { +.section-widget-title-details summary{ + padding: 6px 12px; +} +.section-widget-subtitle-details summary { + padding: 2px 8px; +} +.section-widget-subtitle-summary + * { border-radius: var(--s); background: var(--gradient); - padding: 6px 10px; -} -.section-widget-title-details summary { - font-weight: 700; + padding: 2px 8px; } .section-widget-subtitle-details summary { border: 2px solid var(--border); - margin-bottom: var(--s); } .section-widget-title-details summary, .section-widget-subtitle-details summary { align-items: center; border-radius: var(--s); - padding: 6px 10px; background: var(--gradient) !important; } .section-widget-subtitle-details[open] svg, @@ -108,6 +113,9 @@ .section-title-summary { display: flex; } +.section-subtitle-summary ~ [class|="form-row"] { + padding: var(--s); +} .section-subtitle-summary strong, .section-title-summary h2 { margin-right: auto; @@ -133,12 +141,17 @@ font-weight: bold; } .form-row { + display: flex; + flex-direction: column; margin-bottom: var(--s); } .form-row-widget { display: block; width: 100%; } +.form-row-help { + margin-bottom: unset; +} textarea.form-row-widget { height: 7rem; resize: vertical;