Skip to content

Commit

Permalink
imp: Allow to follow a shared collection
Browse files Browse the repository at this point in the history
  • Loading branch information
marienfressinaud committed Oct 3, 2024
1 parent 5700d39 commit b22dd64
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 42 deletions.
Binary file modified locales/fr_FR/LC_MESSAGES/main.mo
Binary file not shown.
49 changes: 25 additions & 24 deletions locales/fr_FR/LC_MESSAGES/main.po
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: Flus\n"
"POT-Creation-Date: 2024-10-02 10:37+0200\n"
"PO-Revision-Date: 2024-10-02 10:37+0200\n"
"POT-Creation-Date: 2024-10-03 13:37+0200\n"
"PO-Revision-Date: 2024-10-03 13:38+0200\n"
"Last-Translator: Marien Fressinaud <[email protected]>\n"
"Language-Team: \n"
"Language: fr_FR\n"
Expand Down Expand Up @@ -409,7 +409,7 @@ msgstr "Sport"
msgid "Tech"
msgstr "Tech"

#: services/LinkFetcher.php:272
#: services/LinkFetcher.php:274
#, php-format
msgid "%s on Twitter: %s"
msgstr "%s sur Twitter : %s"
Expand Down Expand Up @@ -721,7 +721,7 @@ msgid "Place here the links you want to consult later on."
msgstr "Placez ici les liens que vous souhaitez consulter plus tard."

#: views/bookmarks/index.phtml:28 views/collections/_collection.phtml:31
#: views/collections/show.phtml:169 views/collections/show_public.phtml:226
#: views/collections/show.phtml:211 views/collections/show_public.phtml:226
#: views/links/searches/show.phtml:106 views/news/index.phtml:115
#: views/read/index.phtml:29
#, php-format
Expand All @@ -730,7 +730,7 @@ msgid_plural "%s links"
msgstr[0] "%s lien"
msgstr[1] "%s liens"

#: views/bookmarks/index.phtml:43 views/collections/show.phtml:184
#: views/bookmarks/index.phtml:43 views/collections/show.phtml:226
msgid "Add a link"
msgstr "Ajouter un lien"

Expand Down Expand Up @@ -1004,7 +1004,7 @@ msgstr ""
msgid "Share access with"
msgstr "Partagez l’accès avec"

#: views/collections/shares/index.phtml:46 views/collections/show.phtml:89
#: views/collections/shares/index.phtml:46 views/collections/show.phtml:92
msgid "Share"
msgstr "Partager"

Expand Down Expand Up @@ -1080,29 +1080,43 @@ msgstr "Publiée par %s"
msgid "Actions"
msgstr "Actions"

#: views/collections/show.phtml:104 views/groups/_group.phtml:23
#: views/collections/show.phtml:108 views/collections/show_public.phtml:127
msgid "Adjust for the news"
msgstr "Régler pour le journal"

#: views/collections/show.phtml:122 views/groups/_group.phtml:23
#: views/groups/_group.phtml:37 views/links/_link.phtml:273
#: views/links/show.phtml:141 views/profiles/show.phtml:55
msgid "Edit"
msgstr "Modifier"

#: views/collections/show.phtml:118 views/collections/show_public.phtml:140
#: views/collections/show.phtml:135 views/collections/show_public.phtml:140
msgid "Put in a group"
msgstr "Placer dans un groupe"

#: views/collections/show.phtml:132
#: views/collections/show.phtml:148
msgid "Change the illustration"
msgstr "Changer l’illustration"

#: views/collections/show.phtml:141
#: views/collections/show.phtml:160 views/collections/show_public.phtml:187
#: views/links/searches/show.phtml:121
msgid "Unfollow"
msgstr "Ne plus suivre"

#: views/collections/show.phtml:172 views/collections/show_public.phtml:198
#: views/collections/show_public.phtml:212 views/links/searches/show.phtml:130
msgid "Follow"
msgstr "Suivre"

#: views/collections/show.phtml:183
msgid ""
"Are you sure that you want to delete this collection? You may lose the links "
"that are attached only to this collection."
msgstr ""
"Êtes-vous sur·e de vouloir supprimer cette collection ? Vous pourriez perdre "
"les liens qui lui sont attachés."

#: views/collections/show.phtml:152 views/links/_link.phtml:311
#: views/collections/show.phtml:194 views/links/_link.phtml:311
#: views/links/show.phtml:158
msgid "Delete"
msgstr "Supprimer"
Expand All @@ -1126,10 +1140,6 @@ msgstr ""
"Flux issu de <a target=\"_blank\" rel=\"noopener noreferrer\" "
"href=\"%s\">%s</a>"

#: views/collections/show_public.phtml:127
msgid "Adjust for the news"
msgstr "Régler pour le journal"

#: views/collections/show_public.phtml:153
msgid "Copy the link"
msgstr "Copier le lien"
Expand All @@ -1144,15 +1154,6 @@ msgstr "Tout marquer comme lu"
msgid "Remove the links from the news"
msgstr "Retirer les liens du journal"

#: views/collections/show_public.phtml:187 views/links/searches/show.phtml:121
msgid "Unfollow"
msgstr "Ne plus suivre"

#: views/collections/show_public.phtml:198
#: views/collections/show_public.phtml:212 views/links/searches/show.phtml:130
msgid "Follow"
msgstr "Suivre"

#: views/collections/show_public.phtml:248
msgid "This collection is empty."
msgstr "Cette collection est vide."
Expand Down
4 changes: 4 additions & 0 deletions src/assets/stylesheets/components/sections.css
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@
}

.section__actions {
display: flex;

gap: var(--space-small);

flex-shrink: 0;
}

Expand Down
4 changes: 3 additions & 1 deletion src/controllers/collections/Groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ public function update(Request $request): Response
if ($can_update) {
$collection->group_id = $group_id;
$collection->save();
} else {
}

if ($is_following) {
$followed_collection = models\FollowedCollection::findBy([
'user_id' => $user->id,
'collection_id' => $collection->id,
Expand Down
10 changes: 9 additions & 1 deletion src/models/dao/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,15 @@ public static function listComputedFollowedByUserId(
WHERE fc.collection_id = c.id
AND fc.user_id = :user_id
AND c.is_public = true
AND (
c.is_public = true
OR c.user_id = :user_id
OR EXISTS (
SELECT 1 FROM collection_shares cs
WHERE cs.user_id = :user_id
AND cs.collection_id = c.id
)
)
{$type_clause}
Expand Down
5 changes: 3 additions & 2 deletions src/models/dao/links/NewsQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ public static function listFromFollowedCollections(string $user_id, int $max): a
AND lc.collection_id = c.id
AND (
(l.is_hidden = false AND c.is_public = true) OR
EXISTS (
(l.is_hidden = false AND c.is_public = true)
OR c.user_id = :user_id
OR EXISTS (
SELECT 1 FROM collection_shares cs
WHERE cs.user_id = :user_id
AND cs.collection_id = c.id
Expand Down
70 changes: 56 additions & 14 deletions src/views/collections/show.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
</span>
</summary>

<?php $is_following = $current_user->isFollowing($collection->id); ?>
<?php $is_shared = count($collection->shares()) > 0; ?>

<nav class="popup__container popup__container--left" role="menu">
<button
class="popup__item popup__item--button"
Expand All @@ -91,6 +94,21 @@

<div class="popup__separator"></div>

<?php if ($is_following): ?>
<button
class="popup__item popup__item--button"
data-controller="modal-opener"
data-action="modal-opener#fetch"
data-modal-opener-href-value="<?= url('edit collection filter', ['id' => $collection->id, 'from' => url('collection', $current_url_params)]) ?>"
aria-haspopup="dialog"
aria-controls="modal"
role="menuitem"
>
<?= icon('slider') ?>
<?= _('Adjust for the news') ?>
</button>
<?php endif; ?>

<button
class="popup__item popup__item--button"
data-controller="modal-opener"
Expand All @@ -104,20 +122,18 @@
<?= _('Edit') ?>
</button>

<?php if ($collection->user_id === $current_user->id): ?>
<button
class="popup__item popup__item--button"
data-controller="modal-opener"
data-action="modal-opener#fetch"
data-modal-opener-href-value="<?= url('edit group collection', ['id' => $collection->id, 'from' => url('collection', $current_url_params)]) ?>"
aria-haspopup="dialog"
aria-controls="modal"
role="menuitem"
>
<?= icon('directory') ?>
<?= _('Put in a group') ?>
</button>
<?php endif; ?>
<button
class="popup__item popup__item--button"
data-controller="modal-opener"
data-action="modal-opener#fetch"
data-modal-opener-href-value="<?= url('edit group collection', ['id' => $collection->id, 'from' => url('collection', $current_url_params)]) ?>"
aria-haspopup="dialog"
aria-controls="modal"
role="menuitem"
>
<?= icon('directory') ?>
<?= _('Put in a group') ?>
</button>

<button
class="popup__item popup__item--button"
Expand All @@ -132,6 +148,32 @@
<?= _('Change the illustration') ?>
</button>

<?php if ($is_following): ?>
<div class="popup__separator"></div>

<form method="post" action="<?= url('unfollow collection', ['id' => $collection->id]) ?>" role="menuitem">
<input type="hidden" name="csrf" value="<?= $csrf_token ?>" />
<input type="hidden" name="from" value="<?= url('collection', $current_url_params) ?>" />

<button class="popup__item popup__item--button">
<?= icon('feed-stop') ?>
<?= _('Unfollow') ?>
</button>
</form>
<?php elseif ($is_shared): ?>
<div class="popup__separator"></div>

<form method="post" action="<?= url('follow collection', ['id' => $collection->id]) ?>" role="menuitem">
<input type="hidden" name="csrf" value="<?= $csrf_token ?>" />
<input type="hidden" name="from" value="<?= url('collection', $current_url_params) ?>" />

<button class="popup__item popup__item--button">
<?= icon('feed') ?>
<?= _('Follow') ?>
</button>
</form>
<?php endif; ?>

<?php if ($collection->user_id === $current_user->id): ?>
<div class="popup__separator"></div>

Expand Down

0 comments on commit b22dd64

Please sign in to comment.