Browse Source

implement event settings

main
ghost 1 year ago
parent
commit
7aa2c03abc
  1. 2
      .env
  2. 8
      config/services.yaml
  3. 1
      public/asset/default/css/common.css
  4. 4
      public/asset/default/css/framework.css
  5. 7
      src/Controller/ArticleController.php
  6. 6
      src/Controller/SearchController.php
  7. 12
      src/Controller/TorrentController.php
  8. 67
      src/Controller/UserController.php
  9. 30
      src/Entity/User.php
  10. 345
      src/Service/ActivityService.php
  11. 10
      src/Service/UserService.php
  12. 82
      templates/default/user/info.html.twig
  13. 21
      templates/default/user/module.html.twig
  14. 149
      templates/default/user/settings.html.twig

2
.env

@ -56,6 +56,8 @@ APP_THEME=default
APP_THEMES=default APP_THEMES=default
APP_SENSITIVE=0 APP_SENSITIVE=0
APP_APPROVED=0
APP_YGGDRASIL=1
APP_TRACKERS=http://[201:23b4:991a:634d:8359:4521:5576:15b7]:2023/announce|http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/announce|http://[316:c51a:62a3:8b9::5]/announce APP_TRACKERS=http://[201:23b4:991a:634d:8359:4521:5576:15b7]:2023/announce|http://[200:1e2f:e608:eb3a:2bf:1e62:87ba:e2f7]/announce|http://[316:c51a:62a3:8b9::5]/announce

8
config/services.yaml

@ -6,12 +6,14 @@
parameters: parameters:
app.version: '%env(APP_VERSION)%' app.version: '%env(APP_VERSION)%'
app.name: '%env(APP_NAME)%' app.name: '%env(APP_NAME)%'
app.locale: '%env(APP_LOCALE)%' app.trackers: '%env(APP_TRACKERS)%'
app.locales: '%env(APP_LOCALES)%' app.locales: '%env(APP_LOCALES)%'
app.theme: '%env(APP_THEME)%'
app.themes: '%env(APP_THEMES)%' app.themes: '%env(APP_THEMES)%'
app.locale: '%env(APP_LOCALE)%'
app.theme: '%env(APP_THEME)%'
app.sensitive: '%env(APP_SENSITIVE)%' app.sensitive: '%env(APP_SENSITIVE)%'
app.trackers: '%env(APP_TRACKERS)%' app.approved: '%env(APP_APPROVED)%'
app.yggdrasil: '%env(APP_YGGDRASIL)%'
app.article.title.length.min: '%env(APP_ARTICLE_TITLE_LENGTH_MIN)%' app.article.title.length.min: '%env(APP_ARTICLE_TITLE_LENGTH_MIN)%'
app.article.title.length.max: '%env(APP_ARTICLE_TITLE_LENGTH_MAX)%' app.article.title.length.max: '%env(APP_ARTICLE_TITLE_LENGTH_MAX)%'
app.article.description.length.min: '%env(APP_ARTICLE_DESCRIPTION_LENGTH_MIN)%' app.article.description.length.min: '%env(APP_ARTICLE_DESCRIPTION_LENGTH_MIN)%'

1
public/asset/default/css/common.css

@ -111,6 +111,7 @@ textarea:hover {
td { td {
padding: 2px 0; padding: 2px 0;
vertical-align: top;
} }
header a.logo { header a.logo {

4
public/asset/default/css/framework.css

@ -367,6 +367,10 @@ a:visited.background-color-hover-night-light:hover {
margin-right: 4px; margin-right: 4px;
} }
.margin-b-4-px {
margin-bottom: 4px;
}
.margin-r-4-px { .margin-r-4-px {
margin-right: 4px; margin-right: 4px;
} }

7
src/Controller/ArticleController.php

@ -29,7 +29,6 @@ class ArticleController extends AbstractController
)] )]
public function info( public function info(
Request $request, Request $request,
TranslatorInterface $translator,
UserService $userService, UserService $userService,
ActivityService $activityService ActivityService $activityService
): Response ): Response
@ -263,7 +262,11 @@ class ArticleController extends AbstractController
time(), time(),
$this->getParameter('app.locale'), $this->getParameter('app.locale'),
explode('|', $this->getParameter('app.locales')), explode('|', $this->getParameter('app.locales')),
$this->getParameter('app.theme') $activityService->getEventCodes(),
$this->getParameter('app.theme'),
$this->getParameter('app.sensitive'),
$this->getParameter('app.yggdrasil'),
$this->getParameter('app.approved')
); );
// Add user join event // Add user join event

6
src/Controller/SearchController.php

@ -164,7 +164,11 @@ class SearchController extends AbstractController
time(), time(),
$this->getParameter('app.locale'), $this->getParameter('app.locale'),
explode('|', $this->getParameter('app.locales')), explode('|', $this->getParameter('app.locales')),
$this->getParameter('app.theme') $activityService->getEventCodes(),
$this->getParameter('app.theme'),
$this->getParameter('app.sensitive'),
$this->getParameter('app.yggdrasil'),
$this->getParameter('app.approved')
); );
// Add user join event // Add user join event

12
src/Controller/TorrentController.php

@ -1155,11 +1155,14 @@ class TorrentController extends AbstractController
); );
// Filter trackers // Filter trackers
if ($user->isYggdrasil())
{
$file->setAnnounceList( $file->setAnnounceList(
[ [
explode('|', $this->getParameter('app.trackers')) explode('|', $this->getParameter('app.trackers'))
] ]
); );
}
$data = $file->dumpToString(); $data = $file->dumpToString();
@ -1260,11 +1263,14 @@ class TorrentController extends AbstractController
); );
// Filter trackers // Filter trackers
if ($user->isYggdrasil())
{
$file->setAnnounceList( $file->setAnnounceList(
[ [
explode('|', $this->getParameter('app.trackers')) explode('|', $this->getParameter('app.trackers'))
] ]
); );
}
// Return magnet link // Return magnet link
return $this->redirect( return $this->redirect(
@ -1308,7 +1314,11 @@ class TorrentController extends AbstractController
time(), time(),
$this->getParameter('app.locale'), $this->getParameter('app.locale'),
explode('|', $this->getParameter('app.locales')), explode('|', $this->getParameter('app.locales')),
$this->getParameter('app.theme') $activityService->getEventCodes(),
$this->getParameter('app.theme'),
$this->getParameter('app.sensitive'),
$this->getParameter('app.yggdrasil'),
$this->getParameter('app.approved')
); );
// Add user join event // Add user join event

67
src/Controller/UserController.php

@ -63,8 +63,8 @@ class UserController extends AbstractController
} }
#[Route( #[Route(
'/{_locale}/profile', '/{_locale}/settings',
name: 'user_profile', name: 'user_settings',
defaults: [ defaults: [
'_locale' => '%app.locale%' '_locale' => '%app.locale%'
], ],
@ -72,7 +72,7 @@ class UserController extends AbstractController
'_locale' => '%app.locales%', '_locale' => '%app.locales%',
], ],
)] )]
public function profile( public function settings(
Request $request, Request $request,
UserService $userService, UserService $userService,
ActivityService $activityService ActivityService $activityService
@ -121,17 +121,36 @@ class UserController extends AbstractController
); );
} }
// Update events
$events = [];
foreach ((array) $request->get('events') as $event)
{
if (in_array($event, $activityService->getEventCodes()))
{
$events[] = $event;
}
}
$user->setEvents(
$events
);
// Update sensitive // Update sensitive
$user->setSensitive( $user->setSensitive(
$request->get('sensitive') === 'true' $request->get('sensitive') === 'true'
); );
// Update yggdrasil
$user->setYggdrasil(
$request->get('yggdrasil') === 'true'
);
// Save changes to DB // Save changes to DB
$userService->save($user); $userService->save($user);
// Redirect user to new locale // Redirect user to new locale
return $this->redirectToRoute( return $this->redirectToRoute(
'user_profile', 'user_settings',
[ [
'_locale' => $user->getLocale() '_locale' => $user->getLocale()
] ]
@ -140,38 +159,35 @@ class UserController extends AbstractController
// Render template // Render template
return $this->render( return $this->render(
'default/user/profile.html.twig', 'default/user/settings.html.twig',
[ [
'user' => [ 'user' => [
'id' => $user->getId(), 'id' => $user->getId(),
'address' => $request->getClientIp() == $user->getAddress() ? $user->getAddress() : false,
'moderator' => $user->isModerator(),
'approved' => $user->isApproved(),
'status' => $user->isStatus(),
'sensitive' => $user->isSensitive(), 'sensitive' => $user->isSensitive(),
'yggdrasil' => $user->isYggdrasil(),
'locale' => $user->getLocale(), 'locale' => $user->getLocale(),
'locales' => $user->getLocales(), 'locales' => $user->getLocales(),
'events' => $user->getEvents(),
'theme' => $user->getTheme(), 'theme' => $user->getTheme(),
'added' => $user->getAdded(), 'added' => $user->getAdded()
'identicon' => $userService->identicon(
$user->getAddress(),
48
),
], ],
'locales' => explode('|', $this->getParameter('app.locales')), 'locales' => explode('|', $this->getParameter('app.locales')),
'themes' => explode('|', $this->getParameter('app.themes')) 'themes' => explode('|', $this->getParameter('app.themes')),
'events' => $activityService->getEventsTree()
] ]
); );
} }
#[Route( #[Route(
'/{_locale}/user/{userId}', '/{_locale}/profile/{userId}',
name: 'user_info', name: 'user_info',
defaults: [ defaults: [
'_locale' => '%app.locale%' '_locale' => '%app.locale%',
'userId' => null
], ],
requirements: [ requirements: [
'_locale' => '%app.locales%', '_locale' => '%app.locales%',
'userId' => '\d+',
], ],
)] )]
public function info( public function info(
@ -197,7 +213,9 @@ class UserController extends AbstractController
} }
// Init target user // Init target user
if (!$userTarget = $userService->getUser($request->get('userId'))) if (!$userTarget = $userService->getUser(
$request->get('userId') ? $request->get('userId') : $user->getId()
))
{ {
throw $this->createNotFoundException(); throw $this->createNotFoundException();
} }
@ -208,13 +226,15 @@ class UserController extends AbstractController
[ [
'user' => [ 'user' => [
'id' => $userTarget->getId(), 'id' => $userTarget->getId(),
'address' => $request->getClientIp() == $userTarget->getAddress() ? $userTarget->getAddress() : false, 'address' => $userTarget->getId() === $user->getId() ? $userTarget->getAddress() : false,
'moderator' => $userTarget->isModerator(), 'moderator' => $userTarget->isModerator(),
'approved' => $userTarget->isApproved(), 'approved' => $userTarget->isApproved(),
'status' => $userTarget->isStatus(), 'status' => $userTarget->isStatus(),
'sensitive' => $userTarget->isSensitive(), 'sensitive' => $userTarget->isSensitive(),
'yggdrasil' => $userTarget->isYggdrasil(),
'locale' => $userTarget->getLocale(), 'locale' => $userTarget->getLocale(),
'locales' => $userTarget->getLocales(), 'locales' => $userTarget->getLocales(),
'events' => $userTarget->getEvents(),
'theme' => $userTarget->getTheme(), 'theme' => $userTarget->getTheme(),
'added' => $userTarget->getAdded(), 'added' => $userTarget->getAdded(),
'identicon' => $userService->identicon( 'identicon' => $userService->identicon(
@ -232,7 +252,8 @@ class UserController extends AbstractController
$userTarget->getId() $userTarget->getId()
) )
], ],
] ],
'events' => $activityService->getEventsTree()
] ]
); );
} }
@ -587,7 +608,11 @@ class UserController extends AbstractController
time(), time(),
$this->getParameter('app.locale'), $this->getParameter('app.locale'),
explode('|', $this->getParameter('app.locales')), explode('|', $this->getParameter('app.locales')),
$this->getParameter('app.theme') $activityService->getEventCodes(),
$this->getParameter('app.theme'),
$this->getParameter('app.sensitive'),
$this->getParameter('app.yggdrasil'),
$this->getParameter('app.approved')
); );
// Add user join event // Add user join event

30
src/Entity/User.php

@ -35,12 +35,18 @@ class User
#[ORM\Column(type: Types::ARRAY)] #[ORM\Column(type: Types::ARRAY)]
private array $locales = []; private array $locales = [];
#[ORM\Column(type: Types::ARRAY)]
private array $events = [];
#[ORM\Column(length: 255)] #[ORM\Column(length: 255)]
private ?string $theme = null; private ?string $theme = null;
#[ORM\Column] #[ORM\Column]
private ?bool $sensitive = null; private ?bool $sensitive = null;
#[ORM\Column]
private ?bool $yggdrasil = null;
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;
@ -137,6 +143,18 @@ class User
return $this; return $this;
} }
public function getEvents(): array
{
return $this->events;
}
public function setEvents(array $events): static
{
$this->events = $events;
return $this;
}
public function getTheme(): ?string public function getTheme(): ?string
{ {
return $this->theme; return $this->theme;
@ -160,4 +178,16 @@ class User
return $this; return $this;
} }
public function isYggdrasil(): ?bool
{
return $this->yggdrasil;
}
public function setYggdrasil(bool $yggdrasil): static
{
$this->yggdrasil = $yggdrasil;
return $this;
}
} }

345
src/Service/ActivityService.php

@ -5,16 +5,359 @@ namespace App\Service;
use App\Entity\Activity; use App\Entity\Activity;
use App\Repository\ActivityRepository; use App\Repository\ActivityRepository;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
class ActivityService class ActivityService
{ {
private EntityManagerInterface $entityManagerInterface; private EntityManagerInterface $entityManagerInterface;
private TranslatorInterface $translatorInterface;
public function __construct( public function __construct(
EntityManagerInterface $entityManagerInterface EntityManagerInterface $entityManagerInterface,
TranslatorInterface $translatorInterface
) )
{ {
$this->entityManagerInterface = $entityManagerInterface; $this->entityManagerInterface = $entityManagerInterface;
$this->translatorInterface = $translatorInterface;
}
public function getEventCodes(): array
{
return
[
// User
Activity::EVENT_USER_ADD,
Activity::EVENT_USER_APPROVE_ADD,
Activity::EVENT_USER_APPROVE_DELETE,
Activity::EVENT_USER_MODERATOR_ADD,
Activity::EVENT_USER_MODERATOR_DELETE,
Activity::EVENT_USER_STATUS_ADD,
Activity::EVENT_USER_STATUS_DELETE,
Activity::EVENT_USER_STAR_ADD,
Activity::EVENT_USER_STAR_DELETE,
// Torrents
Activity::EVENT_TORRENT_ADD,
Activity::EVENT_TORRENT_LOCALES_ADD,
Activity::EVENT_TORRENT_LOCALES_DELETE,
Activity::EVENT_TORRENT_LOCALES_APPROVE_ADD,
Activity::EVENT_TORRENT_LOCALES_APPROVE_DELETE,
Activity::EVENT_TORRENT_SENSITIVE_ADD,
Activity::EVENT_TORRENT_SENSITIVE_DELETE,
Activity::EVENT_TORRENT_SENSITIVE_APPROVE_ADD,
Activity::EVENT_TORRENT_SENSITIVE_APPROVE_DELETE,
Activity::EVENT_TORRENT_STAR_ADD,
Activity::EVENT_TORRENT_STAR_DELETE,
Activity::EVENT_TORRENT_DOWNLOAD_FILE_ADD,
Activity::EVENT_TORRENT_DOWNLOAD_MAGNET_ADD,
// Articles
Activity::EVENT_ARTICLE_ADD,
];
}
public function getEventsTree(): array
{
$events = [];
foreach ($this->getEventCodes() as $code)
{
switch ($code)
{
// User
case Activity::EVENT_USER_ADD:
$events
[
$this->translatorInterface->trans('Users')
]
[
$this->translatorInterface->trans('Joined')
] = $code;
break;
/// User approve
case Activity::EVENT_USER_APPROVE_ADD:
$events
[
$this->translatorInterface->trans('Users')
]
[
$this->translatorInterface->trans('Approved')
] = $code;
break;
case Activity::EVENT_USER_APPROVE_DELETE:
$events
[
$this->translatorInterface->trans('Users')
]
[
$this->translatorInterface->trans('Disapproved')
] = $code;
break;
/// User status
case Activity::EVENT_USER_STATUS_ADD:
$events
[
$this->translatorInterface->trans('User statuses')
]
[
$this->translatorInterface->trans('Enabled')
] = $code;
break;
case Activity::EVENT_USER_STATUS_DELETE:
$events
[
$this->translatorInterface->trans('User statuses')
]
[
$this->translatorInterface->trans('Disabled')
] = $code;
break;
/// User moderator
case Activity::EVENT_USER_MODERATOR_ADD:
$events
[
$this->translatorInterface->trans('User moderators')
]
[
$this->translatorInterface->trans('Added')
] = $code;
break;
case Activity::EVENT_USER_MODERATOR_DELETE:
$events
[
$this->translatorInterface->trans('User moderators')
]
[
$this->translatorInterface->trans('Removed')
] = $code;
break;
/// User star
case Activity::EVENT_USER_STAR_ADD:
$events
[
$this->translatorInterface->trans('User stars')
]
[
$this->translatorInterface->trans('Added')
] = $code;
break;
case Activity::EVENT_USER_STAR_DELETE:
$events
[
$this->translatorInterface->trans('User stars')
]
[
$this->translatorInterface->trans('Removed')
] = $code;
break;
// Torrent
case Activity::EVENT_TORRENT_ADD:
$events
[
$this->translatorInterface->trans('Torrents')
]
[
$this->translatorInterface->trans('Added')
] = $code;
break;
/// Torrent locales
case Activity::EVENT_TORRENT_LOCALES_ADD:
$events
[
$this->translatorInterface->trans('Torrent locales')
]
[
$this->translatorInterface->trans('Added')
] = $code;
break;
case Activity::EVENT_TORRENT_LOCALES_DELETE:
$events
[
$this->translatorInterface->trans('Torrent locales')
]
[
$this->translatorInterface->trans('Deleted')
] = $code;
break;
case Activity::EVENT_TORRENT_LOCALES_APPROVE_ADD:
$events
[
$this->translatorInterface->trans('Torrent locales')
]
[
$this->translatorInterface->trans('Approved')
] = $code;
break;
case Activity::EVENT_TORRENT_LOCALES_APPROVE_DELETE:
$events
[
$this->translatorInterface->trans('Torrent locales')
]
[
$this->translatorInterface->trans('Disapproved')
] = $code;
break;
/// Torrent sensitive
case Activity::EVENT_TORRENT_SENSITIVE_ADD:
$events
[
$this->translatorInterface->trans('Torrent sensitive')
]
[
$this->translatorInterface->trans('Added')
] = $code;
break;
case Activity::EVENT_TORRENT_SENSITIVE_DELETE:
$events
[
$this->translatorInterface->trans('Torrent sensitive')
]
[
$this->translatorInterface->trans('Deleted')
] = $code;
break;
case Activity::EVENT_TORRENT_SENSITIVE_APPROVE_ADD:
$events
[
$this->translatorInterface->trans('Torrent sensitive')
]
[
$this->translatorInterface->trans('Approved')
] = $code;
break;
case Activity::EVENT_TORRENT_SENSITIVE_APPROVE_DELETE:
$events
[
$this->translatorInterface->trans('Torrent sensitive')
]
[
$this->translatorInterface->trans('Disapproved')
] = $code;
break;
/// Torrent stars
case Activity::EVENT_TORRENT_STAR_ADD:
$events
[
$this->translatorInterface->trans('Torrent stars')
]
[
$this->translatorInterface->trans('Added')
] = $code;
break;
case Activity::EVENT_TORRENT_STAR_DELETE:
$events
[
$this->translatorInterface->trans('Torrent stars')
]
[
$this->translatorInterface->trans('Removed')
] = $code;
break;
/// Torrent downloads
case Activity::EVENT_TORRENT_DOWNLOAD_FILE_ADD:
$events
[
$this->translatorInterface->trans('Torrent downloads')
]
[
$this->translatorInterface->trans('Files')
] = $code;
break;
case Activity::EVENT_TORRENT_DOWNLOAD_MAGNET_ADD:
$events
[
$this->translatorInterface->trans('Torrent downloads')
]
[
$this->translatorInterface->trans('Magnet links')
] = $code;
break;
// Article
case Activity::EVENT_TORRENT_ADD:
$events
[
$this->translatorInterface->trans('Articles')
]
[
$this->translatorInterface->trans('Added')
] = $code;
break;
}
}
return $events;
} }
public function findLastActivities(): array public function findLastActivities(): array

10
src/Service/UserService.php

@ -28,8 +28,10 @@ class UserService
string $added, string $added,
string $locale, string $locale,
array $locales, array $locales,
array $events,
string $theme, string $theme,
bool $sensitive = true, bool $sensitive = true,
bool $yggdrasil = true,
bool $approved = false, bool $approved = false,
bool $moderator = false, bool $moderator = false,
bool $status = true bool $status = true
@ -70,10 +72,18 @@ class UserService
$theme $theme
); );
$user->setEvents(
$events
);
$user->setSensitive( $user->setSensitive(
$sensitive $sensitive
); );
$user->setYggdrasil(
$yggdrasil
);
$this->entityManagerInterface->persist($user); $this->entityManagerInterface->persist($user);
$this->entityManagerInterface->flush(); $this->entityManagerInterface->flush();

82
templates/default/user/info.html.twig

@ -33,12 +33,33 @@
<tr> <tr>
<td class="padding-y-8-px border-bottom-default text-right" colspan="2">{{ 'Common'|trans }}</td> <td class="padding-y-8-px border-bottom-default text-right" colspan="2">{{ 'Common'|trans }}</td>
</tr> </tr>
{% if user.address %}
<tr> <tr>
<td class="padding-t-16-px">{{ 'Joined'|trans }}</td> <td class="padding-t-16-px">{{ 'Address' | trans }}</td>
<td class="padding-t-16-px">
{{ user.address }}
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
<path d="M11 1a2 2 0 0 0-2 2v4a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h5V3a3 3 0 0 1 6 0v4a.5.5 0 0 1-1 0V3a2 2 0 0 0-2-2zM3 8a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V9a1 1 0 0 0-1-1H3z"/>
</svg>
<span class="opacity-0 parent-hover-opacity-09" title="{{ 'Address hidden for others'|trans }}">
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
</svg>
</span>
</td>
</tr>
<tr>
<td>{{ 'Joined' | trans }}</td>
<td>{{ user.added | format_ago }}</td>
</tr>
{% else %}
<tr>
<td class="padding-t-16-px">{{ 'Joined' | trans }}</td>
<td class="padding-t-16-px">{{ user.added | format_ago }}</td> <td class="padding-t-16-px">{{ user.added | format_ago }}</td>
</tr> </tr>
{% endif %}
<tr> <tr>
<td class="padding-y-8-px border-bottom-default text-right" colspan="2">{{ 'Access'|trans }}</td> <td class="padding-y-8-px border-bottom-default text-right" colspan="2">{{ 'Access' | trans }}</td>
</tr> </tr>
<tr> <tr>
<td class="padding-t-16-px"> <td class="padding-t-16-px">
@ -121,7 +142,7 @@
<tr> <tr>
<td class="padding-y-8-px border-bottom-default text-right" colspan="2"> <td class="padding-y-8-px border-bottom-default text-right" colspan="2">
{% if user.owner %} {% if user.owner %}
<a class="margin-r-4-px{#opacity-0 parent-hover-opacity-09#}" href="{{ path('user_profile', { userId : user.id }) }}" title="{{'Edit'|trans }}"> <a class="margin-r-4-px{#opacity-0 parent-hover-opacity-09#}" href="{{ path('user_settings', { userId : user.id }) }}" title="{{'Edit'|trans }}">
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
<path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"/> <path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"/>
</svg> </svg>
@ -132,33 +153,62 @@
</tr> </tr>
<tr> <tr>
<td class="padding-t-16-px"> <td class="padding-t-16-px">
{{ 'Interface' | trans }} {{ 'Theme' | trans }}
</td> </td>
<td class="padding-t-16-px"> <td class="padding-t-16-px">
{{ user.theme | u.title }}
</td>
</tr>
<tr>
<td>
{{ 'Interface' | trans }}
</td>
<td>
{{ user.locale | locale_name(user.locale) | u.title }} {{ user.locale | locale_name(user.locale) | u.title }}
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="width-20">{{ 'Content'|trans }}</td> <td class="width-20">
{{ 'Languages' | trans }}
</td>
<td class="width-80 line-height-20-px"> <td class="width-80 line-height-20-px">
{% for i, locale in user.locales %}{% if i > 0 %},{% endif %} {{ locale|locale_name(locale)|u.title }}{% endfor %} {% for i, locale in user.locales %}{% if i > 0 %},{% endif %} {{ locale|locale_name(locale)|u.title }}{% endfor %}
{#
{% for locale in user.locales %}
<div class="padding-y-4-px">
{{ locale|locale_name(locale)|u.title }}
</div>
{% endfor %}
#}
</td> </td>
</tr> </tr>
<tr> <tr>
<td>{{ 'Theme'|trans }}</td> <td>
<td>{{ user.theme | u.title }}</td> {{ 'Sensitive' | trans }}
</td>
<td>
{% if user.sensitive %}
{{ 'Yes' | trans }}
{% else %}
{{ 'No' | trans }}
{% endif %}
</td>
</tr> </tr>
<tr> <tr>
<td>{{ 'Sensitive'|trans }}</td>
<td> <td>
{% if user.sensitive %} {{ 'Events subscribed' | trans }}
</td>
<td>
{% for group, event in events %}
<div class="margin-b-4-px">
<span class="text-color-night">
{{ group }}:
</span>
{% set i = 0 %}
{% for key, value in event %}{% if value in user.events %}{% if i > 0 %}, {% endif %}{{ key | lower }}{% set i = i + 1 %}{% endif %}{% endfor %}
</div>
{% endfor %}
</td>
</tr>
<tr>
<td>
{{ 'Yggdrasil filter' | trans }}
</td>
<td>
{% if user.yggdrasil %}
{{ 'Yes'|trans }} {{ 'Yes'|trans }}
{% else %} {% else %}
{{ 'No'|trans }} {{ 'No'|trans }}

21
templates/default/user/module.html.twig

@ -6,25 +6,38 @@
</svg> </svg>
</span> </span>
{% else %} {% else %}
<a class="padding-8-px display-block text-color-night" href="{{ path('user_dashboard') }}" title="{{ 'Home' | trans }}"> <a rel="nofollow" class="padding-8-px display-block text-color-night" href="{{ path('user_dashboard') }}" title="{{ 'Home' | trans }}">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" viewBox="0 0 16 16">
<path d="M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z"/> <path d="M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z"/>
</svg> </svg>
</a> </a>
{% endif %} {% endif %}
{% if route == 'user_profile' %} {% if route == 'user_info' %}
<span class="padding-8-px display-block cursor-default" title="{{ 'Profile' | trans }}"> <span class="padding-8-px display-block cursor-default" title="{{ 'Profile' | trans }}">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" viewBox="0 0 16 16">
<path d="M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H3Zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/> <path d="M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H3Zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/>
</svg> </svg>
</span> </span>
{% else %} {% else %}
<a class="padding-8-px display-block text-color-night" href="{{ path('user_profile') }}" title="{{ 'Profile' | trans }}"> <a rel="nofollow" class="padding-8-px display-block text-color-night" href="{{ path('user_info') }}" title="{{ 'Profile' | trans }}">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" viewBox="0 0 16 16">
<path d="M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H3Zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/> <path d="M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H3Zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/>
</svg> </svg>
</a> </a>
{% endif %} {% endif %}
{% if route == 'user_settings' %}
<span class="padding-8-px display-block cursor-default" title="{{ 'Settings' | trans }}">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" class="bi bi-gear-fill" viewBox="0 0 16 16">
<path d="M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.686.705-1.987 1.987l.169.311c.446.82.023 1.841-.872 2.105l-.34.1c-1.4.413-1.4 2.397 0 2.81l.34.1a1.464 1.464 0 0 1 .872 2.105l-.17.31c-.698 1.283.705 2.686 1.987 1.987l.311-.169a1.464 1.464 0 0 1 2.105.872l.1.34c.413 1.4 2.397 1.4 2.81 0l.1-.34a1.464 1.464 0 0 1 2.105-.872l.31.17c1.283.698 2.686-.705 1.987-1.987l-.169-.311a1.464 1.464 0 0 1 .872-2.105l.34-.1c1.4-.413 1.4-2.397 0-2.81l-.34-.1a1.464 1.464 0 0 1-.872-2.105l.17-.31c.698-1.283-.705-2.686-1.987-1.987l-.311.169a1.464 1.464 0 0 1-2.105-.872l-.1-.34zM8 10.93a2.929 2.929 0 1 1 0-5.86 2.929 2.929 0 0 1 0 5.858z"/>
</svg>
</span>
{% else %}
<a rel="nofollow" class="padding-8-px display-block text-color-night" href="{{ path('user_settings') }}" title="{{ 'Settings' | trans }}">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" class="bi bi-gear-fill" viewBox="0 0 16 16">
<path d="M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.686.705-1.987 1.987l.169.311c.446.82.023 1.841-.872 2.105l-.34.1c-1.4.413-1.4 2.397 0 2.81l.34.1a1.464 1.464 0 0 1 .872 2.105l-.17.31c-.698 1.283.705 2.686 1.987 1.987l.311-.169a1.464 1.464 0 0 1 2.105.872l.1.34c.413 1.4 2.397 1.4 2.81 0l.1-.34a1.464 1.464 0 0 1 2.105-.872l.31.17c1.283.698 2.686-.705 1.987-1.987l-.169-.311a1.464 1.464 0 0 1 .872-2.105l.34-.1c1.4-.413 1.4-2.397 0-2.81l-.34-.1a1.464 1.464 0 0 1-.872-2.105l.17-.31c.698-1.283-.705-2.686-1.987-1.987l-.311.169a1.464 1.464 0 0 1-2.105-.872l-.1-.34zM8 10.93a2.929 2.929 0 1 1 0-5.86 2.929 2.929 0 0 1 0 5.858z"/>
</svg>
</a>
{% endif %}
{% if route == 'article_submit' or route == 'torrent_submit' %} {% if route == 'article_submit' or route == 'torrent_submit' %}
<span class="padding-8-px display-block cursor-default" title="{{ 'Submit' | trans }}"> <span class="padding-8-px display-block cursor-default" title="{{ 'Submit' | trans }}">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" viewBox="0 0 16 16">
@ -32,7 +45,7 @@
</svg> </svg>
</span> </span>
{% else %} {% else %}
<a class="padding-8-px display-block text-color-night" href="{{ path('article_submit') }}" title="{{ 'Submit' | trans }}"> <a rel="nofollow" class="padding-8-px display-block text-color-night" href="{{ path('article_submit') }}" title="{{ 'Submit' | trans }}">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" viewBox="0 0 16 16">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8.5 4.5a.5.5 0 0 0-1 0v3h-3a.5.5 0 0 0 0 1h3v3a.5.5 0 0 0 1 0v-3h3a.5.5 0 0 0 0-1h-3v-3z"/> <path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8.5 4.5a.5.5 0 0 0-1 0v3h-3a.5.5 0 0 0 0 1h3v3a.5.5 0 0 0 1 0v-3h3a.5.5 0 0 0 0-1h-3v-3z"/>
</svg> </svg>

149
templates/default/user/profile.html.twig → templates/default/user/settings.html.twig

@ -1,77 +1,38 @@
{% extends 'default/layout.html.twig' %} {% extends 'default/layout.html.twig' %}
{% block title %}{{ 'Profile'|trans }} - {{ name }}{% endblock %} {% block title %}{{ 'Settings' | trans }} - {{ name }}{% endblock %}
{% block main_content %} {% block main_content %}
<div class="padding-24-px margin-y-8-px border-radius-3-px background-color-night"> <div class="padding-24-px margin-y-8-px border-radius-3-px background-color-night">
<form name="profile" action="{{ path('user_profile') }}" method="post"> <form name="profile" action="{{ path('user_settings') }}" method="post">
<div class="text-center"> <h1>{{ 'Settings' | trans }} </h1>
<a href="{{ path('user_info', { userId : user.id }) }}">
<img class="border-radius-50 border-color-default border-width-2-px" src="{{ user.identicon }}" alt="{{ 'identicon'|trans }}" />
</a>
</div>
<h2>{{ 'Profile'|trans }}</h2>
<table class="width-100"> <table class="width-100">
<tbody> <tbody>
<tr> <tr>
<td class="padding-b-8-px border-bottom-default text-right" colspan="2">{{ 'Common'|trans }}</td> <td class="padding-b-8-px border-bottom-default text-right" colspan="2">
</tr> {{ 'Interface' | trans }}
<tr>
<td class="padding-t-16-px">{{ 'Address'|trans }}</td>
<td class="padding-t-16-px">
{{ user.address }}
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
<path d="M11 1a2 2 0 0 0-2 2v4a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h5V3a3 3 0 0 1 6 0v4a.5.5 0 0 1-1 0V3a2 2 0 0 0-2-2zM3 8a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V9a1 1 0 0 0-1-1H3z"/>
</svg>
<span class="opacity-0 parent-hover-opacity-09" title="{{ 'Address hidden for others'|trans }}">
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
</svg>
</span>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>{{ 'Joined' | trans }}</td>
<td>{{ user.added | format_ago }}</td>
</tr>
<tr>
<td class="padding-b-8-px border-bottom-default text-right" colspan="2">{{ 'Access'|trans }}</td>
</tr>
<tr>
<td class="padding-t-16-px">{{ 'Status'|trans }}</td>
<td class="padding-t-16-px"> <td class="padding-t-16-px">
{% if user.status %} {{ 'Theme' | trans }}
{{ 'Aactive' | trans }}
{% else %}
{{ 'Disabled' | trans }}
{% endif %}
</td>
</tr>
<tr>
<td>{{ 'Approved'|trans }}</td>
<td>
{% if user.approved %}
{{ 'Yes' | trans }}
{% else %}
{{ 'No' | trans }}
{% endif %}
</td> </td>
</tr> <td class="padding-t-16-px">
<tr> <select name="theme">
<td>{{ 'Moderator' | trans }}</td> {% for theme in themes %}
<td> {% if theme == user.theme %}
{% if user.moderator %} <option value="{{ theme }}" selected="selected">
{{ 'Yes' | trans }} {{ theme | u.title }}
</option>
{% else %} {% else %}
{{ 'No' | trans }} <option value="{{ theme }}">
{{ theme | u.title }}
</option>
{% endif %} {% endif %}
{% endfor %}
</select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="padding-b-8-px border-bottom-default text-right" colspan="2"> <td class="padding-t-16-px">{{ 'Language' | trans }}</td>
{{ 'Settings' | trans }}
</td>
</tr>
<tr>
<td class="padding-t-16-px">{{ 'Interface'|trans }}</td>
<td class="padding-t-16-px"> <td class="padding-t-16-px">
<select name="locale"> <select name="locale">
{% for locale in locales %} {% for locale in locales %}
@ -89,10 +50,15 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td class="padding-b-8-px border-bottom-default text-right" colspan="2">
{{ 'Content language' | trans }} {{ 'Search' | trans }}
</td> </td>
<td> </tr>
<tr>
<td class="padding-t-16-px">
{{ 'Languages' | trans }}
</td>
<td class="padding-t-16-px">
{% for locale in locales %} {% for locale in locales %}
<div class="padding-y-4-px"> <div class="padding-y-4-px">
{% if locale in user.locales %} {% if locale in user.locales %}
@ -107,38 +73,61 @@
{% endfor %} {% endfor %}
</td> </td>
</tr> </tr>
<tr>
<td class="padding-t-8-px">
{{ 'Sensitive' | trans }}
</td>
<td>
<div class="padding-t-8-px">
{% if user.sensitive %}
<input name="sensitive" type="checkbox" value="true" checked="checked" />
{% else %}
<input name="sensitive" type="checkbox" value="true" />
{% endif %}
</div>
</td>
</tr>
<tr>
<td class="padding-b-8-px border-bottom-default text-right" colspan="2">
{{ 'Events' | trans }}
</td>
</tr>
{% for group, event in events %}
<tr> <tr>
<td class="padding-t-16-px"> <td class="padding-t-16-px">
{{ 'Theme' | trans }} {{ group }}
</td> </td>
<td class="padding-t-16-px"> <td class="padding-t-16-px">
<select name="theme"> {% for key, value in event %}
{% for theme in themes %} <span class="margin-r-8-px">
{% if theme == user.theme %} {% if value in user.events %}
<option value="{{ theme }}" selected="selected"> <input name="events[]" id="event-{{ value }}" type="checkbox" value="{{ value }}" checked="checked" />
{{ theme | u.title }}
</option>
{% else %} {% else %}
<option value="{{ theme }}"> <input name="events[]" id="event-{{ value }}" type="checkbox" value="{{ value }}" />
{{ theme | u.title }}
</option>
{% endif %} {% endif %}
<label for="event-{{ value }}">
{{ key }}
</label>
</span>
{% endfor %} {% endfor %}
</select>
</td> </td>
</tr> </tr>
{% endfor %}
<tr> <tr>
<td class="padding-y-8-px"> <td class="padding-b-8-px border-bottom-default text-right" colspan="2">
{{ 'Sensitive filter'|trans }} {{ 'Downloads' | trans }}
</td> </td>
<td> </tr>
<div class="padding-y-8-px"> <tr>
{% if user.sensitive %} <td class="padding-y-16-px">
<input name="sensitive" type="checkbox" value="true" checked="checked" /> {{ 'Yggdrasil filter' | trans }}
</td>
<td class="padding-y-16-px">
{% if user.yggdrasil %}
<input name="yggdrasil" type="checkbox" value="true" checked="checked" />
{% else %} {% else %}
<input name="sensitive" type="checkbox" value="true" /> <input name="yggdrasil" type="checkbox" value="true" />
{% endif %} {% endif %}
</div>
</td> </td>
</tr> </tr>
</tbody> </tbody>
Loading…
Cancel
Save