-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ghost
committed
Oct 3, 2023
1 parent
737b79b
commit ae8ec48
Showing
21 changed files
with
736 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,4 +50,4 @@ APP_VERSION='2.0.0' | |
APP_NAME=YGGtracker | ||
|
||
APP_LOCALE=en | ||
APP_LOCALES=en|uk | ||
APP_LOCALES=en|uk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace App\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
class DashboardController extends AbstractController | ||
{ | ||
#[Route('/')] | ||
public function indexNoLocale(): Response | ||
{ | ||
return $this->redirectToRoute( | ||
'dashboard_index', | ||
[ | ||
'_locale' => 'en' | ||
] | ||
); | ||
} | ||
|
||
#[Route( | ||
'/{_locale}', | ||
name: 'dashboard_index' | ||
)] | ||
public function index(Request $request): Response | ||
{ | ||
return $this->render( | ||
'default/dashboard/index.html.twig' | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
<?php | ||
|
||
namespace App\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
use App\Service\UserService; | ||
use App\Service\TimeService; | ||
|
||
class UserController extends AbstractController | ||
{ | ||
#[Route( | ||
'/{_locale}/profile', | ||
name: 'user_profile', | ||
defaults: [ | ||
'_locale' => '%app.locale%' | ||
], | ||
requirements: [ | ||
'_locale' => '%app.locales%', | ||
], | ||
)] | ||
public function profile( | ||
Request $request, | ||
UserService $userService, | ||
TimeService $timeService): Response | ||
{ | ||
// Init user | ||
$user = $userService->init( | ||
$request->getClientIp() | ||
); | ||
|
||
// Process post request | ||
if ($request->isMethod('post')) | ||
{ | ||
// Update locale | ||
if (in_array($request->get('locale'), explode('|', $this->getParameter('app.locales')))) | ||
{ | ||
$user->setLocale( | ||
$request->get('locale') | ||
); | ||
} | ||
|
||
// Update locales | ||
if ($request->get('locales')) | ||
{ | ||
$user->setLocales( | ||
$request->get('locales') | ||
); | ||
} | ||
|
||
// Save changes to DB | ||
$userService->save($user); | ||
} | ||
|
||
// Generate identicon | ||
$identicon = new \Jdenticon\Identicon(); | ||
|
||
$identicon->setValue($user->getAddress()); | ||
$identicon->setSize(48); | ||
$identicon->setStyle( | ||
[ | ||
'backgroundColor' => 'rgba(255, 255, 255, 0)', | ||
'padding' => 0 | ||
] | ||
); | ||
|
||
// Render template | ||
return $this->render( | ||
'default/user/profile.html.twig', | ||
[ | ||
'user' => [ | ||
'id' => $user->getId(), | ||
'address' => $request->getClientIp() == $user->getAddress() ? $user->getAddress() : false, | ||
'moderator' => $user->isModerator(), | ||
'approved' => $user->isApproved(), | ||
'status' => $user->isStatus(), | ||
'locale' => $user->getLocale(), | ||
'locales' => $user->getLocales(), | ||
'added' => $timeService->ago( | ||
$user->getAdded() | ||
), | ||
'identicon' => $identicon->getImageDataUri('webp'), | ||
], | ||
'locales' => explode('|', $this->getParameter('app.locales')) | ||
] | ||
); | ||
} | ||
|
||
#[Route( | ||
'/{_locale}/user/{id}', | ||
name: 'user_info', | ||
defaults: [ | ||
'_locale' => '%app.locale%' | ||
], | ||
requirements: [ | ||
'_locale' => '%app.locales%', | ||
], | ||
)] | ||
public function info( | ||
int $id, | ||
Request $request, | ||
UserService $userService, | ||
TimeService $timeService): Response | ||
{ | ||
// Init user | ||
if (!$user = $userService->get($id)) | ||
{ | ||
throw $this->createNotFoundException(); | ||
} | ||
|
||
// Generate identicon | ||
$identicon = new \Jdenticon\Identicon(); | ||
|
||
$identicon->setValue($user->getAddress()); | ||
$identicon->setSize(48); | ||
$identicon->setStyle( | ||
[ | ||
'backgroundColor' => 'rgba(255, 255, 255, 0)', | ||
'padding' => 0 | ||
] | ||
); | ||
|
||
// Render template | ||
return $this->render( | ||
'default/user/info.html.twig', | ||
[ | ||
'user' => [ | ||
'id' => $user->getId(), | ||
'address' => $request->getClientIp() == $user->getAddress() ? $user->getAddress() : false, | ||
'moderator' => $user->isModerator(), | ||
'approved' => $user->isApproved(), | ||
'status' => $user->isStatus(), | ||
'locale' => $user->getLocale(), | ||
'locales' => $user->getLocales(), | ||
'added' => $timeService->ago( | ||
$user->getAdded() | ||
), | ||
'identicon' => $identicon->getImageDataUri('webp'), | ||
] | ||
] | ||
); | ||
} | ||
|
||
public function module(string $route = ''): Response | ||
{ | ||
return $this->render( | ||
'default/user/module.html.twig', | ||
[ | ||
'route' => $route, | ||
'stars' => 0, | ||
'views' => 0, | ||
'comments' => 0, | ||
'downloads' => 0, | ||
'editions' => 0, | ||
] | ||
); | ||
} | ||
} |
Oops, something went wrong.