Compare commits
11 Commits
laravel
...
fix-replie
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24c16ed0dd | ||
|
|
f9de433545 | ||
|
|
fd29b928d8 | ||
|
|
98094459e3 | ||
|
|
3bb2946656 | ||
|
|
bbbf8eb6c1 | ||
|
|
c8d2bd508e | ||
| eef3262a53 | |||
| fe1015bff1 | |||
|
|
8604cdf95d | ||
| f83748cc76 |
2
.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
*.log
|
*.log
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
._*
|
||||||
.env
|
.env
|
||||||
.env.backup
|
.env.backup
|
||||||
.env.production
|
.env.production
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
/public/storage
|
/public/storage
|
||||||
/storage/*.key
|
/storage/*.key
|
||||||
/storage/pail
|
/storage/pail
|
||||||
|
/storage/framework/views/*.php
|
||||||
/vendor
|
/vendor
|
||||||
Homestead.json
|
Homestead.json
|
||||||
Homestead.yaml
|
Homestead.yaml
|
||||||
|
|||||||
70
CHANGELOG.md
@@ -1,5 +1,62 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-01-12
|
||||||
|
- Switched main SPA layouts to fluid containers to reduce wasted space.
|
||||||
|
- Added username-or-email login with case-insensitive unique usernames.
|
||||||
|
- Added SPA-friendly verification and password reset/update endpoints.
|
||||||
|
- Added user avatars (upload + display) and a basic profile page/API.
|
||||||
|
- Seeded a Micha test user with verified email.
|
||||||
|
- Added rank management with badge text/image options and ACP UI controls.
|
||||||
|
- Added user edit modal (name/email/rank) and rank assignment controls in ACP.
|
||||||
|
- Added ACP users search and improved sorting indicators.
|
||||||
|
- Added thread sidebar fields for posts count, registration date, and topic header.
|
||||||
|
- Linked header logo to the portal and fixed ACP breadcrumbs.
|
||||||
|
- Added profile location field with UCP editing and post sidebar display.
|
||||||
|
- Added per-thread replies and views counts, including view tracking.
|
||||||
|
- Added per-forum topics/views counts plus last-post details in board listings.
|
||||||
|
- Added portal summary API to load forums, stats, and recent posts in one request.
|
||||||
|
- Unified portal and forum thread list row styling with shared component.
|
||||||
|
|
||||||
|
## 2026-01-11
|
||||||
|
- Restyled the thread view to mimic phpBB: compact toolbar, title row, and post layout.
|
||||||
|
- Added phpBB-style post action buttons and post author info for replies.
|
||||||
|
|
||||||
|
## 2026-01-02
|
||||||
|
- Added ACP general settings for forum name, theme, accents, and logo (no reload required).
|
||||||
|
- Added admin-only upload endpoints and ACP UI for logos and favicons.
|
||||||
|
- Applied forum branding, theme defaults, accents, logos, and favicon links in the SPA header.
|
||||||
|
|
||||||
|
## 2025-12-30
|
||||||
|
- Added soft deletes with audit metadata (deleted_at/deleted_by) for forums, threads, and posts.
|
||||||
|
- Ensured API listings and ACP forum tree omit soft-deleted records by default.
|
||||||
|
- Added thread seeding for forum test data.
|
||||||
|
- Enforced category-only roots for forums (API validation, UI, and database constraint).
|
||||||
|
- Added portal header with phpBB-style breadcrumb + quick links, plus notifications/messages + user menu.
|
||||||
|
- Replaced the home page with a portal-style layout and latest posts list.
|
||||||
|
- Added a dedicated board index page with phpBB-like sections and per-category collapse toggles.
|
||||||
|
- Persisted board index collapse state per user via user_settings (DB + API + client cache).
|
||||||
|
- Added category view rendering for subcategories in ForumView.
|
||||||
|
- Updated thread list UI (icons, spacing) and New topic button styling in ForumView.
|
||||||
|
- Added ACP per-category quick-create buttons for child categories and forums.
|
||||||
|
- Removed the legacy navbar and cleaned up related styling.
|
||||||
|
|
||||||
|
## 2025-12-29
|
||||||
|
- Merged the React app into the Laravel codebase under `resources/js`.
|
||||||
|
- Moved the Laravel app to the repo root and removed the separate `api/` and `frontend/` folders.
|
||||||
|
- Serve the SPA shell via Blade with Vite-managed React assets.
|
||||||
|
- Dropped Tailwind tooling to keep the frontend Bootstrap-only.
|
||||||
|
- Replaced the default Laravel README with a forum placeholder.
|
||||||
|
- Updated ACP forum tools with accent-tinted buttons and larger action spacing.
|
||||||
|
- Defaulted the ACP forum tree to collapsed on page load.
|
||||||
|
- Improved ACP create/edit dialog copy based on forum vs category and hid type selection during creation.
|
||||||
|
|
||||||
|
## 2025-12-26
|
||||||
|
- Replaced the Symfony backend with a fresh Laravel app in `api/`.
|
||||||
|
- Added Fortify + Sanctum, API routes, and controllers for forums/threads/posts/settings/version.
|
||||||
|
- Added Laravel migrations for forums, threads, posts, and settings (seeded with version/build/accent).
|
||||||
|
- Added Laravel i18n endpoint backed by JSON translation files.
|
||||||
|
- Updated frontend auth/register flow to work with Laravel tokens.
|
||||||
|
|
||||||
## 2025-12-24
|
## 2025-12-24
|
||||||
- Reworked the domain model into a single forum tree (category/forum types) with parent/child hierarchy and threads restricted to forum nodes.
|
- Reworked the domain model into a single forum tree (category/forum types) with parent/child hierarchy and threads restricted to forum nodes.
|
||||||
- Updated API Platform resources, filters, migrations, and JSON format support.
|
- Updated API Platform resources, filters, migrations, and JSON format support.
|
||||||
@@ -22,16 +79,3 @@
|
|||||||
- Improved ACP drag-and-drop hover reordering and visual drop target feedback.
|
- Improved ACP drag-and-drop hover reordering and visual drop target feedback.
|
||||||
- Hardened ACP access so admin tools require authentication.
|
- Hardened ACP access so admin tools require authentication.
|
||||||
- Updated the home page to render the forum tree with ACP-style rows and icons.
|
- Updated the home page to render the forum tree with ACP-style rows and icons.
|
||||||
|
|
||||||
## 2025-12-26
|
|
||||||
- Replaced the Symfony backend with a fresh Laravel app in `api/`.
|
|
||||||
- Added Fortify + Sanctum, API routes, and controllers for forums/threads/posts/settings/version.
|
|
||||||
- Added Laravel migrations for forums, threads, posts, and settings (seeded with version/build/accent).
|
|
||||||
- Added Laravel i18n endpoint backed by JSON translation files.
|
|
||||||
- Updated frontend auth/register flow to work with Laravel tokens.
|
|
||||||
|
|
||||||
## 2025-12-29
|
|
||||||
- Merged the React app into the Laravel codebase under `resources/js`.
|
|
||||||
- Moved the Laravel app to the repo root and removed the separate `api/` and `frontend/` folders.
|
|
||||||
- Serve the SPA shell via Blade with Vite-managed React assets.
|
|
||||||
- Dropped Tailwind tooling to keep the frontend Bootstrap-only.
|
|
||||||
|
|||||||
60
README.md
@@ -1,59 +1,7 @@
|
|||||||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
|
# SpeedBB Forum
|
||||||
|
|
||||||
<p align="center">
|
Placeholder README for the forum application.
|
||||||
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
|
|
||||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
|
||||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
|
||||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
## About Laravel
|
## Status
|
||||||
|
|
||||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
Work in progress.
|
||||||
|
|
||||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
|
||||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
|
||||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
|
||||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
|
||||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
|
||||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
|
||||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
|
||||||
|
|
||||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
|
||||||
|
|
||||||
## Learning Laravel
|
|
||||||
|
|
||||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. You can also check out [Laravel Learn](https://laravel.com/learn), where you will be guided through building a modern Laravel application.
|
|
||||||
|
|
||||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
|
||||||
|
|
||||||
## Laravel Sponsors
|
|
||||||
|
|
||||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
|
|
||||||
|
|
||||||
### Premium Partners
|
|
||||||
|
|
||||||
- **[Vehikl](https://vehikl.com)**
|
|
||||||
- **[Tighten Co.](https://tighten.co)**
|
|
||||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
|
||||||
- **[64 Robots](https://64robots.com)**
|
|
||||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
|
|
||||||
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
|
|
||||||
- **[Redberry](https://redberry.international/laravel-development)**
|
|
||||||
- **[Active Logic](https://activelogic.com)**
|
|
||||||
|
|
||||||
## Contributing
|
|
||||||
|
|
||||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
|
||||||
|
|
||||||
## Code of Conduct
|
|
||||||
|
|
||||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
|
||||||
|
|
||||||
## Security Vulnerabilities
|
|
||||||
|
|
||||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Actions\Fortify;
|
namespace App\Actions\Fortify;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
@@ -19,22 +20,31 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
*/
|
*/
|
||||||
public function create(array $input): User
|
public function create(array $input): User
|
||||||
{
|
{
|
||||||
Validator::make($input, [
|
$input['name_canonical'] = Str::lower(trim($input['name'] ?? ''));
|
||||||
|
|
||||||
|
Validator::make(data: $input, rules: [
|
||||||
'name' => ['required', 'string', 'max:255'],
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'name_canonical' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
Rule::unique(table: User::class, column: 'name_canonical'),
|
||||||
|
],
|
||||||
'email' => [
|
'email' => [
|
||||||
'required',
|
'required',
|
||||||
'string',
|
'string',
|
||||||
'email',
|
'email',
|
||||||
'max:255',
|
'max:255',
|
||||||
Rule::unique(User::class),
|
Rule::unique(table: User::class),
|
||||||
],
|
],
|
||||||
'password' => $this->passwordRules(),
|
'password' => $this->passwordRules(),
|
||||||
])->validate();
|
])->validate();
|
||||||
|
|
||||||
return User::create([
|
return User::create(attributes: [
|
||||||
'name' => $input['name'],
|
'name' => $input['name'],
|
||||||
|
'name_canonical' => $input['name_canonical'],
|
||||||
'email' => $input['email'],
|
'email' => $input['email'],
|
||||||
'password' => Hash::make($input['password']),
|
'password' => Hash::make(value: $input['password']),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Actions\Fortify;
|
namespace App\Actions\Fortify;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Validation\Rules\Password;
|
use Illuminate\Validation\Rules\Password;
|
||||||
|
|
||||||
trait PasswordValidationRules
|
trait PasswordValidationRules
|
||||||
@@ -9,7 +10,7 @@ trait PasswordValidationRules
|
|||||||
/**
|
/**
|
||||||
* Get the validation rules used to validate passwords.
|
* Get the validation rules used to validate passwords.
|
||||||
*
|
*
|
||||||
* @return array<int, \Illuminate\Contracts\Validation\Rule|array<mixed>|string>
|
* @return array<int, ValidationRule|array<mixed>|string>
|
||||||
*/
|
*/
|
||||||
protected function passwordRules(): array
|
protected function passwordRules(): array
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Actions\Fortify;
|
|||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
|
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
|
||||||
@@ -17,8 +18,16 @@ class UpdateUserProfileInformation implements UpdatesUserProfileInformation
|
|||||||
*/
|
*/
|
||||||
public function update(User $user, array $input): void
|
public function update(User $user, array $input): void
|
||||||
{
|
{
|
||||||
|
$input['name_canonical'] = Str::lower(trim($input['name'] ?? ''));
|
||||||
|
|
||||||
Validator::make($input, [
|
Validator::make($input, [
|
||||||
'name' => ['required', 'string', 'max:255'],
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'name_canonical' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
Rule::unique('users', 'name_canonical')->ignore($user->id),
|
||||||
|
],
|
||||||
|
|
||||||
'email' => [
|
'email' => [
|
||||||
'required',
|
'required',
|
||||||
@@ -29,12 +38,12 @@ class UpdateUserProfileInformation implements UpdatesUserProfileInformation
|
|||||||
],
|
],
|
||||||
])->validateWithBag('updateProfileInformation');
|
])->validateWithBag('updateProfileInformation');
|
||||||
|
|
||||||
if ($input['email'] !== $user->email &&
|
if ($input['email'] !== $user->email && $user instanceof MustVerifyEmail) {
|
||||||
$user instanceof MustVerifyEmail) {
|
|
||||||
$this->updateVerifiedUser($user, $input);
|
$this->updateVerifiedUser($user, $input);
|
||||||
} else {
|
} else {
|
||||||
$user->forceFill([
|
$user->forceFill([
|
||||||
'name' => $input['name'],
|
'name' => $input['name'],
|
||||||
|
'name_canonical' => $input['name_canonical'],
|
||||||
'email' => $input['email'],
|
'email' => $input['email'],
|
||||||
])->save();
|
])->save();
|
||||||
}
|
}
|
||||||
@@ -49,6 +58,7 @@ class UpdateUserProfileInformation implements UpdatesUserProfileInformation
|
|||||||
{
|
{
|
||||||
$user->forceFill([
|
$user->forceFill([
|
||||||
'name' => $input['name'],
|
'name' => $input['name'],
|
||||||
|
'name_canonical' => $input['name_canonical'],
|
||||||
'email' => $input['email'],
|
'email' => $input['email'],
|
||||||
'email_verified_at' => null,
|
'email_verified_at' => null,
|
||||||
])->save();
|
])->save();
|
||||||
|
|||||||
@@ -3,14 +3,22 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Actions\Fortify\CreateNewUser;
|
use App\Actions\Fortify\CreateNewUser;
|
||||||
|
use App\Actions\Fortify\PasswordValidationRules;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Illuminate\Auth\Events\Verified;
|
||||||
|
use Illuminate\Auth\Events\PasswordReset;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Password;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
class AuthController extends Controller
|
class AuthController extends Controller
|
||||||
{
|
{
|
||||||
|
use PasswordValidationRules;
|
||||||
|
|
||||||
public function register(Request $request, CreateNewUser $creator): JsonResponse
|
public function register(Request $request, CreateNewUser $creator): JsonResponse
|
||||||
{
|
{
|
||||||
$input = [
|
$input = [
|
||||||
@@ -33,16 +41,30 @@ class AuthController extends Controller
|
|||||||
|
|
||||||
public function login(Request $request): JsonResponse
|
public function login(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
$request->merge([
|
||||||
|
'login' => $request->input('login', $request->input('email')),
|
||||||
|
]);
|
||||||
|
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'email' => ['required', 'email'],
|
'login' => ['required', 'string'],
|
||||||
'password' => ['required', 'string'],
|
'password' => ['required', 'string'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$user = User::where('email', $request->input('email'))->first();
|
$login = trim((string) $request->input('login'));
|
||||||
|
$loginNormalized = Str::lower($login);
|
||||||
|
$userQuery = User::query();
|
||||||
|
|
||||||
|
if (filter_var($login, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$userQuery->whereRaw('lower(email) = ?', [$loginNormalized]);
|
||||||
|
} else {
|
||||||
|
$userQuery->where('name_canonical', $loginNormalized);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $userQuery->first();
|
||||||
|
|
||||||
if (!$user || !Hash::check($request->input('password'), $user->password)) {
|
if (!$user || !Hash::check($request->input('password'), $user->password)) {
|
||||||
throw ValidationException::withMessages([
|
throw ValidationException::withMessages([
|
||||||
'email' => ['Invalid credentials.'],
|
'login' => ['Invalid credentials.'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,6 +84,93 @@ class AuthController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function verifyEmail(Request $request, string $id, string $hash): RedirectResponse
|
||||||
|
{
|
||||||
|
$user = User::findOrFail($id);
|
||||||
|
|
||||||
|
if (!hash_equals($hash, sha1($user->getEmailForVerification()))) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$user->hasVerifiedEmail()) {
|
||||||
|
$user->markEmailAsVerified();
|
||||||
|
event(new Verified($user));
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect('/login');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function forgotPassword(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'email' => ['required', 'email'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$status = Password::sendResetLink(
|
||||||
|
$request->only('email')
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($status !== Password::RESET_LINK_SENT) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'email' => [__($status)],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['message' => __($status)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resetPassword(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'token' => ['required'],
|
||||||
|
'email' => ['required', 'email'],
|
||||||
|
'password' => $this->passwordRules(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$status = Password::reset(
|
||||||
|
$request->only('email', 'password', 'password_confirmation', 'token'),
|
||||||
|
function (User $user, string $password) {
|
||||||
|
$user->forceFill([
|
||||||
|
'password' => Hash::make($password),
|
||||||
|
'remember_token' => Str::random(60),
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
event(new PasswordReset($user));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($status !== Password::PASSWORD_RESET) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'email' => [__($status)],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['message' => __($status)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatePassword(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'current_password' => ['required'],
|
||||||
|
'password' => $this->passwordRules(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = $request->user();
|
||||||
|
|
||||||
|
if (!$user || !Hash::check($request->input('current_password'), $user->password)) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'current_password' => ['Invalid current password.'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->forceFill([
|
||||||
|
'password' => Hash::make($request->input('password')),
|
||||||
|
'remember_token' => Str::random(60),
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
return response()->json(['message' => 'Password updated.']);
|
||||||
|
}
|
||||||
|
|
||||||
public function logout(Request $request): JsonResponse
|
public function logout(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$request->user()?->currentAccessToken()?->delete();
|
$request->user()?->currentAccessToken()?->delete();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\Forum;
|
use App\Models\Forum;
|
||||||
|
use App\Models\Post;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
@@ -11,7 +12,10 @@ class ForumController extends Controller
|
|||||||
{
|
{
|
||||||
public function index(Request $request): JsonResponse
|
public function index(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$query = Forum::query();
|
$query = Forum::query()
|
||||||
|
->withoutTrashed()
|
||||||
|
->withCount(['threads', 'posts'])
|
||||||
|
->withSum('threads', 'views_count');
|
||||||
|
|
||||||
$parentParam = $request->query('parent');
|
$parentParam = $request->query('parent');
|
||||||
if (is_array($parentParam) && array_key_exists('exists', $parentParam)) {
|
if (is_array($parentParam) && array_key_exists('exists', $parentParam)) {
|
||||||
@@ -35,15 +39,24 @@ class ForumController extends Controller
|
|||||||
$forums = $query
|
$forums = $query
|
||||||
->orderBy('position')
|
->orderBy('position')
|
||||||
->orderBy('name')
|
->orderBy('name')
|
||||||
->get()
|
->get();
|
||||||
->map(fn (Forum $forum) => $this->serializeForum($forum));
|
|
||||||
|
|
||||||
return response()->json($forums);
|
$forumIds = $forums->pluck('id')->all();
|
||||||
|
$lastPostByForum = $this->loadLastPostsByForum($forumIds);
|
||||||
|
|
||||||
|
$payload = $forums->map(
|
||||||
|
fn (Forum $forum) => $this->serializeForum($forum, $lastPostByForum[$forum->id] ?? null)
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json($payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show(Forum $forum): JsonResponse
|
public function show(Forum $forum): JsonResponse
|
||||||
{
|
{
|
||||||
return response()->json($this->serializeForum($forum));
|
$forum->loadCount(['threads', 'posts'])
|
||||||
|
->loadSum('threads', 'views_count');
|
||||||
|
$lastPost = $this->loadLastPostForForum($forum->id);
|
||||||
|
return response()->json($this->serializeForum($forum, $lastPost));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request): JsonResponse
|
public function store(Request $request): JsonResponse
|
||||||
@@ -57,6 +70,10 @@ class ForumController extends Controller
|
|||||||
|
|
||||||
$parentId = $this->parseIriId($data['parent'] ?? null);
|
$parentId = $this->parseIriId($data['parent'] ?? null);
|
||||||
|
|
||||||
|
if ($data['type'] === 'forum' && !$parentId) {
|
||||||
|
return response()->json(['message' => 'Forums must belong to a category.'], 422);
|
||||||
|
}
|
||||||
|
|
||||||
if ($parentId) {
|
if ($parentId) {
|
||||||
$parent = Forum::findOrFail($parentId);
|
$parent = Forum::findOrFail($parentId);
|
||||||
if ($parent->type !== 'category') {
|
if ($parent->type !== 'category') {
|
||||||
@@ -64,7 +81,12 @@ class ForumController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($parentId === null) {
|
||||||
|
Forum::whereNull('parent_id')->increment('position');
|
||||||
|
$position = 0;
|
||||||
|
} else {
|
||||||
$position = Forum::where('parent_id', $parentId)->max('position');
|
$position = Forum::where('parent_id', $parentId)->max('position');
|
||||||
|
}
|
||||||
|
|
||||||
$forum = Forum::create([
|
$forum = Forum::create([
|
||||||
'name' => $data['name'],
|
'name' => $data['name'],
|
||||||
@@ -74,7 +96,11 @@ class ForumController extends Controller
|
|||||||
'position' => ($position ?? 0) + 1,
|
'position' => ($position ?? 0) + 1,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return response()->json($this->serializeForum($forum), 201);
|
$forum->loadCount(['threads', 'posts'])
|
||||||
|
->loadSum('threads', 'views_count');
|
||||||
|
$lastPost = $this->loadLastPostForForum($forum->id);
|
||||||
|
|
||||||
|
return response()->json($this->serializeForum($forum, $lastPost), 201);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Request $request, Forum $forum): JsonResponse
|
public function update(Request $request, Forum $forum): JsonResponse
|
||||||
@@ -87,6 +113,12 @@ class ForumController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$parentId = $this->parseIriId($data['parent'] ?? null);
|
$parentId = $this->parseIriId($data['parent'] ?? null);
|
||||||
|
$nextType = $data['type'] ?? $forum->type;
|
||||||
|
$nextParentId = array_key_exists('parent', $data) ? $parentId : $forum->parent_id;
|
||||||
|
|
||||||
|
if ($nextType === 'forum' && !$nextParentId) {
|
||||||
|
return response()->json(['message' => 'Forums must belong to a category.'], 422);
|
||||||
|
}
|
||||||
|
|
||||||
if (array_key_exists('parent', $data)) {
|
if (array_key_exists('parent', $data)) {
|
||||||
if ($parentId) {
|
if ($parentId) {
|
||||||
@@ -112,11 +144,17 @@ class ForumController extends Controller
|
|||||||
|
|
||||||
$forum->save();
|
$forum->save();
|
||||||
|
|
||||||
return response()->json($this->serializeForum($forum));
|
$forum->loadCount(['threads', 'posts'])
|
||||||
|
->loadSum('threads', 'views_count');
|
||||||
|
$lastPost = $this->loadLastPostForForum($forum->id);
|
||||||
|
|
||||||
|
return response()->json($this->serializeForum($forum, $lastPost));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy(Forum $forum): JsonResponse
|
public function destroy(Request $request, Forum $forum): JsonResponse
|
||||||
{
|
{
|
||||||
|
$forum->deleted_by = $request->user()?->id;
|
||||||
|
$forum->save();
|
||||||
$forum->delete();
|
$forum->delete();
|
||||||
|
|
||||||
return response()->json(null, 204);
|
return response()->json(null, 204);
|
||||||
@@ -163,7 +201,7 @@ class ForumController extends Controller
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function serializeForum(Forum $forum): array
|
private function serializeForum(Forum $forum, ?Post $lastPost): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $forum->id,
|
'id' => $forum->id,
|
||||||
@@ -172,8 +210,54 @@ class ForumController extends Controller
|
|||||||
'type' => $forum->type,
|
'type' => $forum->type,
|
||||||
'parent' => $forum->parent_id ? "/api/forums/{$forum->parent_id}" : null,
|
'parent' => $forum->parent_id ? "/api/forums/{$forum->parent_id}" : null,
|
||||||
'position' => $forum->position,
|
'position' => $forum->position,
|
||||||
|
'threads_count' => $forum->threads_count ?? 0,
|
||||||
|
'posts_count' => $forum->posts_count ?? 0,
|
||||||
|
'views_count' => (int) ($forum->threads_sum_views_count ?? 0),
|
||||||
|
'last_post_at' => $lastPost?->created_at?->toIso8601String(),
|
||||||
|
'last_post_user_id' => $lastPost?->user_id,
|
||||||
|
'last_post_user_name' => $lastPost?->user?->name,
|
||||||
'created_at' => $forum->created_at?->toIso8601String(),
|
'created_at' => $forum->created_at?->toIso8601String(),
|
||||||
'updated_at' => $forum->updated_at?->toIso8601String(),
|
'updated_at' => $forum->updated_at?->toIso8601String(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function loadLastPostsByForum(array $forumIds): array
|
||||||
|
{
|
||||||
|
if (empty($forumIds)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$posts = Post::query()
|
||||||
|
->select('posts.*', 'threads.forum_id as forum_id')
|
||||||
|
->join('threads', 'posts.thread_id', '=', 'threads.id')
|
||||||
|
->whereIn('threads.forum_id', $forumIds)
|
||||||
|
->whereNull('posts.deleted_at')
|
||||||
|
->whereNull('threads.deleted_at')
|
||||||
|
->orderByDesc('posts.created_at')
|
||||||
|
->with('user')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$byForum = [];
|
||||||
|
foreach ($posts as $post) {
|
||||||
|
$forumId = (int) ($post->forum_id ?? 0);
|
||||||
|
if ($forumId && !array_key_exists($forumId, $byForum)) {
|
||||||
|
$byForum[$forumId] = $post;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $byForum;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function loadLastPostForForum(int $forumId): ?Post
|
||||||
|
{
|
||||||
|
return Post::query()
|
||||||
|
->select('posts.*')
|
||||||
|
->join('threads', 'posts.thread_id', '=', 'threads.id')
|
||||||
|
->where('threads.forum_id', $forumId)
|
||||||
|
->whereNull('posts.deleted_at')
|
||||||
|
->whereNull('threads.deleted_at')
|
||||||
|
->orderByDesc('posts.created_at')
|
||||||
|
->with('user')
|
||||||
|
->first();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
149
app/Http/Controllers/PortalController.php
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Forum;
|
||||||
|
use App\Models\Post;
|
||||||
|
use App\Models\Thread;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class PortalController extends Controller
|
||||||
|
{
|
||||||
|
public function __invoke(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$forums = Forum::query()
|
||||||
|
->withoutTrashed()
|
||||||
|
->withCount(['threads', 'posts'])
|
||||||
|
->withSum('threads', 'views_count')
|
||||||
|
->orderBy('position')
|
||||||
|
->orderBy('name')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$forumIds = $forums->pluck('id')->all();
|
||||||
|
$lastPostByForum = $this->loadLastPostsByForum($forumIds);
|
||||||
|
|
||||||
|
$forumPayload = $forums->map(
|
||||||
|
fn (Forum $forum) => $this->serializeForum($forum, $lastPostByForum[$forum->id] ?? null)
|
||||||
|
);
|
||||||
|
|
||||||
|
$threads = Thread::query()
|
||||||
|
->withoutTrashed()
|
||||||
|
->withCount('posts')
|
||||||
|
->with([
|
||||||
|
'user' => fn ($query) => $query->withCount('posts')->with('rank'),
|
||||||
|
'latestPost.user',
|
||||||
|
])
|
||||||
|
->latest('created_at')
|
||||||
|
->limit(12)
|
||||||
|
->get()
|
||||||
|
->map(fn (Thread $thread) => $this->serializeThread($thread));
|
||||||
|
|
||||||
|
$stats = [
|
||||||
|
'threads' => Thread::query()->withoutTrashed()->count(),
|
||||||
|
'posts' => Post::query()->withoutTrashed()->count(),
|
||||||
|
'users' => User::query()->count(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$user = auth('sanctum')->user();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'forums' => $forumPayload,
|
||||||
|
'threads' => $threads,
|
||||||
|
'stats' => $stats,
|
||||||
|
'profile' => $user ? [
|
||||||
|
'id' => $user->id,
|
||||||
|
'name' => $user->name,
|
||||||
|
'email' => $user->email,
|
||||||
|
'avatar_url' => $user->avatar_path ? Storage::url($user->avatar_path) : null,
|
||||||
|
'location' => $user->location,
|
||||||
|
'rank' => $user->rank ? [
|
||||||
|
'id' => $user->rank->id,
|
||||||
|
'name' => $user->rank->name,
|
||||||
|
] : null,
|
||||||
|
] : null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function serializeForum(Forum $forum, ?Post $lastPost): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $forum->id,
|
||||||
|
'name' => $forum->name,
|
||||||
|
'description' => $forum->description,
|
||||||
|
'type' => $forum->type,
|
||||||
|
'parent' => $forum->parent_id ? "/api/forums/{$forum->parent_id}" : null,
|
||||||
|
'position' => $forum->position,
|
||||||
|
'threads_count' => $forum->threads_count ?? 0,
|
||||||
|
'posts_count' => $forum->posts_count ?? 0,
|
||||||
|
'views_count' => (int) ($forum->threads_sum_views_count ?? 0),
|
||||||
|
'last_post_at' => $lastPost?->created_at?->toIso8601String(),
|
||||||
|
'last_post_user_id' => $lastPost?->user_id,
|
||||||
|
'last_post_user_name' => $lastPost?->user?->name,
|
||||||
|
'created_at' => $forum->created_at?->toIso8601String(),
|
||||||
|
'updated_at' => $forum->updated_at?->toIso8601String(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function serializeThread(Thread $thread): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $thread->id,
|
||||||
|
'title' => $thread->title,
|
||||||
|
'body' => $thread->body,
|
||||||
|
'forum' => "/api/forums/{$thread->forum_id}",
|
||||||
|
'user_id' => $thread->user_id,
|
||||||
|
'posts_count' => $thread->posts_count ?? 0,
|
||||||
|
'views_count' => $thread->views_count ?? 0,
|
||||||
|
'user_name' => $thread->user?->name,
|
||||||
|
'user_avatar_url' => $thread->user?->avatar_path
|
||||||
|
? Storage::url($thread->user->avatar_path)
|
||||||
|
: null,
|
||||||
|
'user_posts_count' => $thread->user?->posts_count,
|
||||||
|
'user_created_at' => $thread->user?->created_at?->toIso8601String(),
|
||||||
|
'user_rank_name' => $thread->user?->rank?->name,
|
||||||
|
'user_rank_badge_type' => $thread->user?->rank?->badge_type,
|
||||||
|
'user_rank_badge_text' => $thread->user?->rank?->badge_text,
|
||||||
|
'user_rank_badge_url' => $thread->user?->rank?->badge_image_path
|
||||||
|
? Storage::url($thread->user->rank->badge_image_path)
|
||||||
|
: null,
|
||||||
|
'last_post_at' => $thread->latestPost?->created_at?->toIso8601String()
|
||||||
|
?? $thread->created_at?->toIso8601String(),
|
||||||
|
'last_post_id' => $thread->latestPost?->id,
|
||||||
|
'last_post_user_id' => $thread->latestPost?->user_id ?? $thread->user_id,
|
||||||
|
'last_post_user_name' => $thread->latestPost?->user?->name
|
||||||
|
?? $thread->user?->name,
|
||||||
|
'created_at' => $thread->created_at?->toIso8601String(),
|
||||||
|
'updated_at' => $thread->updated_at?->toIso8601String(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function loadLastPostsByForum(array $forumIds): array
|
||||||
|
{
|
||||||
|
if (empty($forumIds)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$posts = Post::query()
|
||||||
|
->select('posts.*', 'threads.forum_id as forum_id')
|
||||||
|
->join('threads', 'posts.thread_id', '=', 'threads.id')
|
||||||
|
->whereIn('threads.forum_id', $forumIds)
|
||||||
|
->whereNull('posts.deleted_at')
|
||||||
|
->whereNull('threads.deleted_at')
|
||||||
|
->orderByDesc('posts.created_at')
|
||||||
|
->with('user')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$byForum = [];
|
||||||
|
foreach ($posts as $post) {
|
||||||
|
$forumId = (int) ($post->forum_id ?? 0);
|
||||||
|
if ($forumId && !array_key_exists($forumId, $byForum)) {
|
||||||
|
$byForum[$forumId] = $post;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $byForum;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,12 +6,15 @@ use App\Models\Post;
|
|||||||
use App\Models\Thread;
|
use App\Models\Thread;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class PostController extends Controller
|
class PostController extends Controller
|
||||||
{
|
{
|
||||||
public function index(Request $request): JsonResponse
|
public function index(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$query = Post::query();
|
$query = Post::query()->withoutTrashed()->with([
|
||||||
|
'user' => fn ($query) => $query->withCount('posts')->with('rank'),
|
||||||
|
]);
|
||||||
|
|
||||||
$threadParam = $request->query('thread');
|
$threadParam = $request->query('thread');
|
||||||
if (is_string($threadParam)) {
|
if (is_string($threadParam)) {
|
||||||
@@ -45,11 +48,17 @@ class PostController extends Controller
|
|||||||
'body' => $data['body'],
|
'body' => $data['body'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$post->loadMissing([
|
||||||
|
'user' => fn ($query) => $query->withCount('posts')->with('rank'),
|
||||||
|
]);
|
||||||
|
|
||||||
return response()->json($this->serializePost($post), 201);
|
return response()->json($this->serializePost($post), 201);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy(Post $post): JsonResponse
|
public function destroy(Request $request, Post $post): JsonResponse
|
||||||
{
|
{
|
||||||
|
$post->deleted_by = $request->user()?->id;
|
||||||
|
$post->save();
|
||||||
$post->delete();
|
$post->delete();
|
||||||
|
|
||||||
return response()->json(null, 204);
|
return response()->json(null, 204);
|
||||||
@@ -79,6 +88,19 @@ class PostController extends Controller
|
|||||||
'body' => $post->body,
|
'body' => $post->body,
|
||||||
'thread' => "/api/threads/{$post->thread_id}",
|
'thread' => "/api/threads/{$post->thread_id}",
|
||||||
'user_id' => $post->user_id,
|
'user_id' => $post->user_id,
|
||||||
|
'user_name' => $post->user?->name,
|
||||||
|
'user_avatar_url' => $post->user?->avatar_path
|
||||||
|
? Storage::url($post->user->avatar_path)
|
||||||
|
: null,
|
||||||
|
'user_posts_count' => $post->user?->posts_count,
|
||||||
|
'user_created_at' => $post->user?->created_at?->toIso8601String(),
|
||||||
|
'user_location' => $post->user?->location,
|
||||||
|
'user_rank_name' => $post->user?->rank?->name,
|
||||||
|
'user_rank_badge_type' => $post->user?->rank?->badge_type,
|
||||||
|
'user_rank_badge_text' => $post->user?->rank?->badge_text,
|
||||||
|
'user_rank_badge_url' => $post->user?->rank?->badge_image_path
|
||||||
|
? Storage::url($post->user->rank->badge_image_path)
|
||||||
|
: null,
|
||||||
'created_at' => $post->created_at?->toIso8601String(),
|
'created_at' => $post->created_at?->toIso8601String(),
|
||||||
'updated_at' => $post->updated_at?->toIso8601String(),
|
'updated_at' => $post->updated_at?->toIso8601String(),
|
||||||
];
|
];
|
||||||
|
|||||||
153
app/Http/Controllers/RankController.php
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Rank;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class RankController extends Controller
|
||||||
|
{
|
||||||
|
private function ensureAdmin(Request $request): ?JsonResponse
|
||||||
|
{
|
||||||
|
$user = $request->user();
|
||||||
|
if (!$user || !$user->roles()->where('name', 'ROLE_ADMIN')->exists()) {
|
||||||
|
return response()->json(['message' => 'Forbidden'], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$ranks = Rank::query()
|
||||||
|
->orderBy('name')
|
||||||
|
->get()
|
||||||
|
->map(fn (Rank $rank) => [
|
||||||
|
'id' => $rank->id,
|
||||||
|
'name' => $rank->name,
|
||||||
|
'badge_type' => $rank->badge_type,
|
||||||
|
'badge_text' => $rank->badge_text,
|
||||||
|
'badge_image_url' => $rank->badge_image_path
|
||||||
|
? Storage::url($rank->badge_image_path)
|
||||||
|
: null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json($ranks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
if ($error = $this->ensureAdmin($request)) {
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->validate([
|
||||||
|
'name' => ['required', 'string', 'max:100', 'unique:ranks,name'],
|
||||||
|
'badge_type' => ['nullable', 'in:text,image'],
|
||||||
|
'badge_text' => ['nullable', 'string', 'max:40'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$badgeType = $data['badge_type'] ?? 'text';
|
||||||
|
$badgeText = $badgeType === 'text'
|
||||||
|
? ($data['badge_text'] ?? $data['name'])
|
||||||
|
: null;
|
||||||
|
|
||||||
|
$rank = Rank::create([
|
||||||
|
'name' => $data['name'],
|
||||||
|
'badge_type' => $badgeType,
|
||||||
|
'badge_text' => $badgeText,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'id' => $rank->id,
|
||||||
|
'name' => $rank->name,
|
||||||
|
'badge_type' => $rank->badge_type,
|
||||||
|
'badge_text' => $rank->badge_text,
|
||||||
|
'badge_image_url' => null,
|
||||||
|
], 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, Rank $rank): JsonResponse
|
||||||
|
{
|
||||||
|
if ($error = $this->ensureAdmin($request)) {
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->validate([
|
||||||
|
'name' => ['required', 'string', 'max:100', "unique:ranks,name,{$rank->id}"],
|
||||||
|
'badge_type' => ['nullable', 'in:text,image'],
|
||||||
|
'badge_text' => ['nullable', 'string', 'max:40'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$badgeType = $data['badge_type'] ?? $rank->badge_type ?? 'text';
|
||||||
|
$badgeText = $badgeType === 'text'
|
||||||
|
? ($data['badge_text'] ?? $rank->badge_text ?? $data['name'])
|
||||||
|
: null;
|
||||||
|
|
||||||
|
if ($badgeType === 'text' && $rank->badge_image_path) {
|
||||||
|
Storage::disk('public')->delete($rank->badge_image_path);
|
||||||
|
$rank->badge_image_path = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rank->update([
|
||||||
|
'name' => $data['name'],
|
||||||
|
'badge_type' => $badgeType,
|
||||||
|
'badge_text' => $badgeText,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'id' => $rank->id,
|
||||||
|
'name' => $rank->name,
|
||||||
|
'badge_type' => $rank->badge_type,
|
||||||
|
'badge_text' => $rank->badge_text,
|
||||||
|
'badge_image_url' => $rank->badge_image_path
|
||||||
|
? Storage::url($rank->badge_image_path)
|
||||||
|
: null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Request $request, Rank $rank): JsonResponse
|
||||||
|
{
|
||||||
|
if ($error = $this->ensureAdmin($request)) {
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($rank->badge_image_path) {
|
||||||
|
Storage::disk('public')->delete($rank->badge_image_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$rank->delete();
|
||||||
|
|
||||||
|
return response()->json(null, 204);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function uploadBadgeImage(Request $request, Rank $rank): JsonResponse
|
||||||
|
{
|
||||||
|
if ($error = $this->ensureAdmin($request)) {
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->validate([
|
||||||
|
'file' => ['required', 'image', 'mimes:jpg,jpeg,png,gif,webp', 'max:2048'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($rank->badge_image_path) {
|
||||||
|
Storage::disk('public')->delete($rank->badge_image_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $data['file']->store('rank-badges', 'public');
|
||||||
|
$rank->badge_type = 'image';
|
||||||
|
$rank->badge_text = null;
|
||||||
|
$rank->badge_image_path = $path;
|
||||||
|
$rank->save();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'id' => $rank->id,
|
||||||
|
'badge_type' => $rank->badge_type,
|
||||||
|
'badge_text' => $rank->badge_text,
|
||||||
|
'badge_image_url' => Storage::url($path),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,4 +24,60 @@ class SettingController extends Controller
|
|||||||
|
|
||||||
return response()->json($settings);
|
return response()->json($settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function store(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$user = $request->user();
|
||||||
|
if (!$user || !$user->roles()->where('name', 'ROLE_ADMIN')->exists()) {
|
||||||
|
return response()->json(['message' => 'Forbidden'], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->validate([
|
||||||
|
'key' => ['required', 'string', 'max:191'],
|
||||||
|
'value' => ['nullable', 'string'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$value = $data['value'] ?? '';
|
||||||
|
|
||||||
|
$setting = Setting::updateOrCreate(
|
||||||
|
['key' => $data['key']],
|
||||||
|
['value' => $value]
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'id' => $setting->id,
|
||||||
|
'key' => $setting->key,
|
||||||
|
'value' => $setting->value,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function bulkStore(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$user = $request->user();
|
||||||
|
if (!$user || !$user->roles()->where('name', 'ROLE_ADMIN')->exists()) {
|
||||||
|
return response()->json(['message' => 'Forbidden'], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->validate([
|
||||||
|
'settings' => ['required', 'array'],
|
||||||
|
'settings.*.key' => ['required', 'string', 'max:191'],
|
||||||
|
'settings.*.value' => ['nullable', 'string'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$updated = [];
|
||||||
|
|
||||||
|
foreach ($data['settings'] as $entry) {
|
||||||
|
$setting = Setting::updateOrCreate(
|
||||||
|
['key' => $entry['key']],
|
||||||
|
['value' => $entry['value'] ?? '']
|
||||||
|
);
|
||||||
|
$updated[] = [
|
||||||
|
'id' => $setting->id,
|
||||||
|
'key' => $setting->key,
|
||||||
|
'value' => $setting->value,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($updated);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
20
app/Http/Controllers/StatsController.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Post;
|
||||||
|
use App\Models\Thread;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
class StatsController extends Controller
|
||||||
|
{
|
||||||
|
public function __invoke(): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json([
|
||||||
|
'threads' => Thread::query()->withoutTrashed()->count(),
|
||||||
|
'posts' => Post::query()->withoutTrashed()->count(),
|
||||||
|
'users' => User::query()->count(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,12 +6,19 @@ use App\Models\Forum;
|
|||||||
use App\Models\Thread;
|
use App\Models\Thread;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class ThreadController extends Controller
|
class ThreadController extends Controller
|
||||||
{
|
{
|
||||||
public function index(Request $request): JsonResponse
|
public function index(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$query = Thread::query();
|
$query = Thread::query()
|
||||||
|
->withoutTrashed()
|
||||||
|
->withCount('posts')
|
||||||
|
->with([
|
||||||
|
'user' => fn ($query) => $query->withCount('posts')->with('rank'),
|
||||||
|
'latestPost.user',
|
||||||
|
]);
|
||||||
|
|
||||||
$forumParam = $request->query('forum');
|
$forumParam = $request->query('forum');
|
||||||
if (is_string($forumParam)) {
|
if (is_string($forumParam)) {
|
||||||
@@ -31,6 +38,12 @@ class ThreadController extends Controller
|
|||||||
|
|
||||||
public function show(Thread $thread): JsonResponse
|
public function show(Thread $thread): JsonResponse
|
||||||
{
|
{
|
||||||
|
$thread->increment('views_count');
|
||||||
|
$thread->refresh();
|
||||||
|
$thread->loadMissing([
|
||||||
|
'user' => fn ($query) => $query->withCount('posts')->with('rank'),
|
||||||
|
'latestPost.user',
|
||||||
|
])->loadCount('posts');
|
||||||
return response()->json($this->serializeThread($thread));
|
return response()->json($this->serializeThread($thread));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,11 +69,18 @@ class ThreadController extends Controller
|
|||||||
'body' => $data['body'],
|
'body' => $data['body'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$thread->loadMissing([
|
||||||
|
'user' => fn ($query) => $query->withCount('posts')->with('rank'),
|
||||||
|
'latestPost.user',
|
||||||
|
])->loadCount('posts');
|
||||||
|
|
||||||
return response()->json($this->serializeThread($thread), 201);
|
return response()->json($this->serializeThread($thread), 201);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy(Thread $thread): JsonResponse
|
public function destroy(Request $request, Thread $thread): JsonResponse
|
||||||
{
|
{
|
||||||
|
$thread->deleted_by = $request->user()?->id;
|
||||||
|
$thread->save();
|
||||||
$thread->delete();
|
$thread->delete();
|
||||||
|
|
||||||
return response()->json(null, 204);
|
return response()->json(null, 204);
|
||||||
@@ -91,6 +111,27 @@ class ThreadController extends Controller
|
|||||||
'body' => $thread->body,
|
'body' => $thread->body,
|
||||||
'forum' => "/api/forums/{$thread->forum_id}",
|
'forum' => "/api/forums/{$thread->forum_id}",
|
||||||
'user_id' => $thread->user_id,
|
'user_id' => $thread->user_id,
|
||||||
|
'posts_count' => $thread->posts_count ?? 0,
|
||||||
|
'views_count' => $thread->views_count ?? 0,
|
||||||
|
'user_name' => $thread->user?->name,
|
||||||
|
'user_avatar_url' => $thread->user?->avatar_path
|
||||||
|
? Storage::url($thread->user->avatar_path)
|
||||||
|
: null,
|
||||||
|
'user_posts_count' => $thread->user?->posts_count,
|
||||||
|
'user_created_at' => $thread->user?->created_at?->toIso8601String(),
|
||||||
|
'user_location' => $thread->user?->location,
|
||||||
|
'user_rank_name' => $thread->user?->rank?->name,
|
||||||
|
'user_rank_badge_type' => $thread->user?->rank?->badge_type,
|
||||||
|
'user_rank_badge_text' => $thread->user?->rank?->badge_text,
|
||||||
|
'user_rank_badge_url' => $thread->user?->rank?->badge_image_path
|
||||||
|
? Storage::url($thread->user->rank->badge_image_path)
|
||||||
|
: null,
|
||||||
|
'last_post_at' => $thread->latestPost?->created_at?->toIso8601String()
|
||||||
|
?? $thread->created_at?->toIso8601String(),
|
||||||
|
'last_post_id' => $thread->latestPost?->id,
|
||||||
|
'last_post_user_id' => $thread->latestPost?->user_id ?? $thread->user_id,
|
||||||
|
'last_post_user_name' => $thread->latestPost?->user?->name
|
||||||
|
?? $thread->user?->name,
|
||||||
'created_at' => $thread->created_at?->toIso8601String(),
|
'created_at' => $thread->created_at?->toIso8601String(),
|
||||||
'updated_at' => $thread->updated_at?->toIso8601String(),
|
'updated_at' => $thread->updated_at?->toIso8601String(),
|
||||||
];
|
];
|
||||||
|
|||||||
79
app/Http/Controllers/UploadController.php
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class UploadController extends Controller
|
||||||
|
{
|
||||||
|
public function storeAvatar(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$user = $request->user();
|
||||||
|
if (!$user) {
|
||||||
|
return response()->json(['message' => 'Unauthorized'], 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->validate([
|
||||||
|
'file' => [
|
||||||
|
'required',
|
||||||
|
'image',
|
||||||
|
'mimes:jpg,jpeg,png,gif,webp',
|
||||||
|
'max:2048',
|
||||||
|
'dimensions:max_width=150,max_height=150',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($user->avatar_path) {
|
||||||
|
Storage::disk('public')->delete($user->avatar_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $data['file']->store('avatars', 'public');
|
||||||
|
$user->avatar_path = $path;
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'path' => $path,
|
||||||
|
'url' => Storage::url($path),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeLogo(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$user = $request->user();
|
||||||
|
if (!$user || !$user->roles()->where('name', 'ROLE_ADMIN')->exists()) {
|
||||||
|
return response()->json(['message' => 'Forbidden'], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->validate([
|
||||||
|
'file' => ['required', 'file', 'mimes:jpg,jpeg,png,gif,webp,svg,ico', 'max:5120'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$path = $data['file']->store('logos', 'public');
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'path' => $path,
|
||||||
|
'url' => Storage::url($path),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeFavicon(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$user = $request->user();
|
||||||
|
if (!$user || !$user->roles()->where('name', 'ROLE_ADMIN')->exists()) {
|
||||||
|
return response()->json(['message' => 'Forbidden'], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->validate([
|
||||||
|
'file' => ['required', 'file', 'mimes:png,ico', 'max:2048'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$path = $data['file']->store('favicons', 'public');
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'path' => $path,
|
||||||
|
'url' => Storage::url($path),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,22 +4,194 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
{
|
{
|
||||||
public function index(): JsonResponse
|
public function index(): JsonResponse
|
||||||
{
|
{
|
||||||
$users = User::query()
|
$users = User::query()
|
||||||
->with('roles')
|
->with(['roles', 'rank'])
|
||||||
->orderBy('id')
|
->orderBy('id')
|
||||||
->get()
|
->get()
|
||||||
->map(fn (User $user) => [
|
->map(fn (User $user) => [
|
||||||
'id' => $user->id,
|
'id' => $user->id,
|
||||||
'name' => $user->name,
|
'name' => $user->name,
|
||||||
'email' => $user->email,
|
'email' => $user->email,
|
||||||
|
'avatar_url' => $this->resolveAvatarUrl($user),
|
||||||
|
'location' => $user->location,
|
||||||
|
'rank' => $user->rank ? [
|
||||||
|
'id' => $user->rank->id,
|
||||||
|
'name' => $user->rank->name,
|
||||||
|
] : null,
|
||||||
'roles' => $user->roles->pluck('name')->values(),
|
'roles' => $user->roles->pluck('name')->values(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return response()->json($users);
|
return response()->json($users);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function me(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$user = $request->user();
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
return response()->json(['message' => 'Unauthenticated.'], 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'id' => $user->id,
|
||||||
|
'name' => $user->name,
|
||||||
|
'email' => $user->email,
|
||||||
|
'avatar_url' => $this->resolveAvatarUrl($user),
|
||||||
|
'location' => $user->location,
|
||||||
|
'rank' => $user->rank ? [
|
||||||
|
'id' => $user->rank->id,
|
||||||
|
'name' => $user->rank->name,
|
||||||
|
] : null,
|
||||||
|
'roles' => $user->roles()->pluck('name')->values(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function profile(User $user): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json([
|
||||||
|
'id' => $user->id,
|
||||||
|
'name' => $user->name,
|
||||||
|
'avatar_url' => $this->resolveAvatarUrl($user),
|
||||||
|
'location' => $user->location,
|
||||||
|
'rank' => $user->rank ? [
|
||||||
|
'id' => $user->rank->id,
|
||||||
|
'name' => $user->rank->name,
|
||||||
|
] : null,
|
||||||
|
'created_at' => $user->created_at?->toIso8601String(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateMe(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$user = $request->user();
|
||||||
|
if (!$user) {
|
||||||
|
return response()->json(['message' => 'Unauthenticated.'], 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->validate([
|
||||||
|
'location' => ['nullable', 'string', 'max:255'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$location = isset($data['location']) ? trim($data['location']) : null;
|
||||||
|
if ($location === '') {
|
||||||
|
$location = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->forceFill([
|
||||||
|
'location' => $location,
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
$user->loadMissing('rank');
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'id' => $user->id,
|
||||||
|
'name' => $user->name,
|
||||||
|
'email' => $user->email,
|
||||||
|
'avatar_url' => $this->resolveAvatarUrl($user),
|
||||||
|
'location' => $user->location,
|
||||||
|
'rank' => $user->rank ? [
|
||||||
|
'id' => $user->rank->id,
|
||||||
|
'name' => $user->rank->name,
|
||||||
|
] : null,
|
||||||
|
'roles' => $user->roles()->pluck('name')->values(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateRank(Request $request, User $user): JsonResponse
|
||||||
|
{
|
||||||
|
$actor = $request->user();
|
||||||
|
if (!$actor || !$actor->roles()->where('name', 'ROLE_ADMIN')->exists()) {
|
||||||
|
return response()->json(['message' => 'Forbidden'], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->validate([
|
||||||
|
'rank_id' => ['nullable', 'exists:ranks,id'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user->rank_id = $data['rank_id'] ?? null;
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
$user->loadMissing('rank');
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'id' => $user->id,
|
||||||
|
'rank' => $user->rank ? [
|
||||||
|
'id' => $user->rank->id,
|
||||||
|
'name' => $user->rank->name,
|
||||||
|
] : null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, User $user): JsonResponse
|
||||||
|
{
|
||||||
|
$actor = $request->user();
|
||||||
|
if (!$actor || !$actor->roles()->where('name', 'ROLE_ADMIN')->exists()) {
|
||||||
|
return response()->json(['message' => 'Forbidden'], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->validate([
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'email' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'email',
|
||||||
|
'max:255',
|
||||||
|
Rule::unique('users', 'email')->ignore($user->id),
|
||||||
|
],
|
||||||
|
'rank_id' => ['nullable', 'exists:ranks,id'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$nameCanonical = Str::lower(trim($data['name']));
|
||||||
|
$nameConflict = User::query()
|
||||||
|
->where('id', '!=', $user->id)
|
||||||
|
->where('name_canonical', $nameCanonical)
|
||||||
|
->exists();
|
||||||
|
|
||||||
|
if ($nameConflict) {
|
||||||
|
return response()->json(['message' => 'Name already exists.'], 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($data['email'] !== $user->email) {
|
||||||
|
$user->email_verified_at = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->forceFill([
|
||||||
|
'name' => $data['name'],
|
||||||
|
'name_canonical' => $nameCanonical,
|
||||||
|
'email' => $data['email'],
|
||||||
|
'rank_id' => $data['rank_id'] ?? null,
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
$user->loadMissing('rank');
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'id' => $user->id,
|
||||||
|
'name' => $user->name,
|
||||||
|
'email' => $user->email,
|
||||||
|
'avatar_url' => $this->resolveAvatarUrl($user),
|
||||||
|
'rank' => $user->rank ? [
|
||||||
|
'id' => $user->rank->id,
|
||||||
|
'name' => $user->rank->name,
|
||||||
|
] : null,
|
||||||
|
'roles' => $user->roles()->pluck('name')->values(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function resolveAvatarUrl(User $user): ?string
|
||||||
|
{
|
||||||
|
if (!$user->avatar_path) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Storage::url($user->avatar_path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
47
app/Http/Controllers/UserSettingController.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\UserSetting;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class UserSettingController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$user = $request->user();
|
||||||
|
$query = UserSetting::query()->where('user_id', $user->id);
|
||||||
|
|
||||||
|
if ($request->filled('key')) {
|
||||||
|
$query->where('key', $request->query('key'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$settings = $query->get()->map(fn (UserSetting $setting) => [
|
||||||
|
'id' => $setting->id,
|
||||||
|
'key' => $setting->key,
|
||||||
|
'value' => $setting->value,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json($settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'key' => ['required', 'string', 'max:191'],
|
||||||
|
'value' => ['nullable', 'array'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$setting = UserSetting::updateOrCreate(
|
||||||
|
['user_id' => $request->user()->id, 'key' => $data['key']],
|
||||||
|
['value' => $data['value'] ?? []]
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'id' => $setting->id,
|
||||||
|
'key' => $setting->key,
|
||||||
|
'value' => $setting->value,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,11 @@ namespace App\Models;
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasOneThrough;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@@ -35,6 +39,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
*/
|
*/
|
||||||
class Forum extends Model
|
class Forum extends Model
|
||||||
{
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
'description',
|
'description',
|
||||||
@@ -57,4 +63,20 @@ class Forum extends Model
|
|||||||
{
|
{
|
||||||
return $this->hasMany(Thread::class);
|
return $this->hasMany(Thread::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function posts(): HasManyThrough
|
||||||
|
{
|
||||||
|
return $this->hasManyThrough(Post::class, Thread::class, 'forum_id', 'thread_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function latestThread(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(Thread::class)->latestOfMany();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function latestPost(): HasOneThrough
|
||||||
|
{
|
||||||
|
return $this->hasOneThrough(Post::class, Thread::class, 'forum_id', 'thread_id')
|
||||||
|
->latestOfMany();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@@ -27,6 +28,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
*/
|
*/
|
||||||
class Post extends Model
|
class Post extends Model
|
||||||
{
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'thread_id',
|
'thread_id',
|
||||||
'user_id',
|
'user_id',
|
||||||
|
|||||||
28
app/Models/Rank.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property string $name
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, User> $users
|
||||||
|
*/
|
||||||
|
class Rank extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'badge_type',
|
||||||
|
'badge_text',
|
||||||
|
'badge_image_path',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function users(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(User::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,9 @@ namespace App\Models;
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $id
|
* @property int $id
|
||||||
@@ -32,6 +34,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
*/
|
*/
|
||||||
class Thread extends Model
|
class Thread extends Model
|
||||||
{
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'forum_id',
|
'forum_id',
|
||||||
'user_id',
|
'user_id',
|
||||||
@@ -53,4 +57,9 @@ class Thread extends Model
|
|||||||
{
|
{
|
||||||
return $this->hasMany(Post::class);
|
return $this->hasMany(Post::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function latestPost(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(Post::class)->latestOfMany();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,32 +2,39 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Database\Factories\UserFactory;
|
||||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
use Illuminate\Notifications\DatabaseNotification;
|
||||||
|
use Illuminate\Notifications\DatabaseNotificationCollection;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
use Laravel\Sanctum\HasApiTokens;
|
use Laravel\Sanctum\HasApiTokens;
|
||||||
|
use Laravel\Sanctum\PersonalAccessToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property string $name
|
* @property string $name
|
||||||
* @property string $email
|
* @property string $email
|
||||||
* @property \Illuminate\Support\Carbon|null $email_verified_at
|
* @property Carbon|null $email_verified_at
|
||||||
* @property string $password
|
* @property string $password
|
||||||
* @property string|null $two_factor_secret
|
* @property string|null $two_factor_secret
|
||||||
* @property string|null $two_factor_recovery_codes
|
* @property string|null $two_factor_recovery_codes
|
||||||
* @property string|null $two_factor_confirmed_at
|
* @property string|null $two_factor_confirmed_at
|
||||||
* @property string|null $remember_token
|
* @property string|null $remember_token
|
||||||
* @property \Illuminate\Support\Carbon|null $created_at
|
* @property Carbon|null $created_at
|
||||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
* @property Carbon|null $updated_at
|
||||||
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection<int, \Illuminate\Notifications\DatabaseNotification> $notifications
|
* @property-read DatabaseNotificationCollection<int, DatabaseNotification> $notifications
|
||||||
* @property-read int|null $notifications_count
|
* @property-read int|null $notifications_count
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Role> $roles
|
* @property-read Collection<int, Role> $roles
|
||||||
* @property-read int|null $roles_count
|
* @property-read int|null $roles_count
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Laravel\Sanctum\PersonalAccessToken> $tokens
|
* @property-read Collection<int, PersonalAccessToken> $tokens
|
||||||
* @property-read int|null $tokens_count
|
* @property-read int|null $tokens_count
|
||||||
* @method static \Database\Factories\UserFactory factory($count = null, $state = [])
|
* @method static UserFactory factory($count = null, $state = [])
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|User newModelQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|User newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User newQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|User query()
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User query()
|
||||||
@@ -46,8 +53,10 @@ use Laravel\Sanctum\HasApiTokens;
|
|||||||
*/
|
*/
|
||||||
class User extends Authenticatable implements MustVerifyEmail
|
class User extends Authenticatable implements MustVerifyEmail
|
||||||
{
|
{
|
||||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
/** @use HasFactory<UserFactory> */
|
||||||
use HasApiTokens, HasFactory, Notifiable;
|
use HasApiTokens;
|
||||||
|
use HasFactory;
|
||||||
|
use Notifiable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
@@ -56,6 +65,10 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
*/
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
|
'name_canonical',
|
||||||
|
'avatar_path',
|
||||||
|
'location',
|
||||||
|
'rank_id',
|
||||||
'email',
|
'email',
|
||||||
'password',
|
'password',
|
||||||
];
|
];
|
||||||
@@ -87,4 +100,14 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
{
|
{
|
||||||
return $this->belongsToMany(Role::class);
|
return $this->belongsToMany(Role::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function posts(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Post::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rank()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Rank::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
app/Models/UserSetting.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class UserSetting extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'user_id',
|
||||||
|
'key',
|
||||||
|
'value',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'value' => 'array',
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
@@ -19,6 +20,6 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
//
|
Model::preventLazyLoading(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class FortifyServiceProvider extends ServiceProvider
|
|||||||
Fortify::redirectUserForTwoFactorAuthenticationUsing(RedirectIfTwoFactorAuthenticatable::class);
|
Fortify::redirectUserForTwoFactorAuthenticationUsing(RedirectIfTwoFactorAuthenticatable::class);
|
||||||
|
|
||||||
RateLimiter::for('login', function (Request $request) {
|
RateLimiter::for('login', function (Request $request) {
|
||||||
$throttleKey = Str::transliterate(Str::lower($request->input(Fortify::username())).'|'.$request->ip());
|
$throttleKey = Str::transliterate(Str::lower($request->input(Fortify::username())) . '|' . $request->ip());
|
||||||
|
|
||||||
return Limit::perMinute(5)->by($throttleKey);
|
return Limit::perMinute(5)->by($throttleKey);
|
||||||
});
|
});
|
||||||
|
|||||||
4
artisan
@@ -4,7 +4,7 @@
|
|||||||
use Illuminate\Foundation\Application;
|
use Illuminate\Foundation\Application;
|
||||||
use Symfony\Component\Console\Input\ArgvInput;
|
use Symfony\Component\Console\Input\ArgvInput;
|
||||||
|
|
||||||
define('LARAVEL_START', microtime(true));
|
define(constant_name: 'LARAVEL_START', value: microtime(as_float: true));
|
||||||
|
|
||||||
// Register the Composer autoloader...
|
// Register the Composer autoloader...
|
||||||
require __DIR__.'/vendor/autoload.php';
|
require __DIR__.'/vendor/autoload.php';
|
||||||
@@ -13,6 +13,6 @@ require __DIR__.'/vendor/autoload.php';
|
|||||||
/** @var Application $app */
|
/** @var Application $app */
|
||||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||||
|
|
||||||
$status = $app->handleCommand(new ArgvInput);
|
$status = $app->handleCommand(input: new ArgvInput);
|
||||||
|
|
||||||
exit($status);
|
exit($status);
|
||||||
|
|||||||
@@ -6,11 +6,12 @@
|
|||||||
"keywords": ["laravel", "framework"],
|
"keywords": ["laravel", "framework"],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.4",
|
||||||
"laravel/fortify": "*",
|
"laravel/fortify": "*",
|
||||||
"laravel/framework": "^12.0",
|
"laravel/framework": "^12.0",
|
||||||
"laravel/sanctum": "*",
|
"laravel/sanctum": "*",
|
||||||
"laravel/tinker": "^2.10.1"
|
"laravel/tinker": "^2.10.1",
|
||||||
|
"ext-pdo": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"barryvdh/laravel-ide-helper": "^3.6",
|
"barryvdh/laravel-ide-helper": "^3.6",
|
||||||
@@ -20,7 +21,8 @@
|
|||||||
"laravel/sail": "^1.41",
|
"laravel/sail": "^1.41",
|
||||||
"mockery/mockery": "^1.6",
|
"mockery/mockery": "^1.6",
|
||||||
"nunomaduro/collision": "^8.6",
|
"nunomaduro/collision": "^8.6",
|
||||||
"phpunit/phpunit": "^11.5.3"
|
"phpunit/phpunit": "^11.5.3",
|
||||||
|
"squizlabs/php_codesniffer": "^4.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
@@ -35,6 +37,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"phpcs": "phpcs",
|
||||||
"setup": [
|
"setup": [
|
||||||
"composer install",
|
"composer install",
|
||||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
|
||||||
|
|||||||
81
composer.lock
generated
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "5b4bf74d07107b744033916f34a83be1",
|
"content-hash": "8e91d3287080a532070e38f61106f41c",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "bacon/bacon-qr-code",
|
"name": "bacon/bacon-qr-code",
|
||||||
@@ -8827,6 +8827,85 @@
|
|||||||
],
|
],
|
||||||
"time": "2024-10-09T05:16:32+00:00"
|
"time": "2024-10-09T05:16:32+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "squizlabs/php_codesniffer",
|
||||||
|
"version": "4.0.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git",
|
||||||
|
"reference": "0525c73950de35ded110cffafb9892946d7771b5"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/0525c73950de35ded110cffafb9892946d7771b5",
|
||||||
|
"reference": "0525c73950de35ded110cffafb9892946d7771b5",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-simplexml": "*",
|
||||||
|
"ext-tokenizer": "*",
|
||||||
|
"ext-xmlwriter": "*",
|
||||||
|
"php": ">=7.2.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^8.4.0 || ^9.3.4 || ^10.5.32 || 11.3.3 - 11.5.28 || ^11.5.31"
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"bin/phpcbf",
|
||||||
|
"bin/phpcs"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Greg Sherwood",
|
||||||
|
"role": "Former lead"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Juliette Reinders Folmer",
|
||||||
|
"role": "Current lead"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Contributors",
|
||||||
|
"homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.",
|
||||||
|
"homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
|
||||||
|
"keywords": [
|
||||||
|
"phpcs",
|
||||||
|
"standards",
|
||||||
|
"static analysis"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues",
|
||||||
|
"security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy",
|
||||||
|
"source": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
|
||||||
|
"wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/PHPCSStandards",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/jrfnl",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://opencollective.com/php_codesniffer",
|
||||||
|
"type": "open_collective"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://thanks.dev/u/gh/phpcsstandards",
|
||||||
|
"type": "thanks_dev"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2025-11-10T16:43:36+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "staabm/side-effects-detector",
|
"name": "staabm/side-effects-detector",
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
|
|||||||
@@ -112,6 +112,6 @@ return [
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
|
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')) . '-cache-'),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ return [
|
|||||||
'strict' => true,
|
'strict' => true,
|
||||||
'engine' => null,
|
'engine' => null,
|
||||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||||
(PHP_VERSION_ID >= 80500 ? \Pdo\Mysql::ATTR_SSL_CA : \PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
(PHP_VERSION_ID >= 80500 ?
|
||||||
|
\Pdo\Mysql::ATTR_SSL_CA :
|
||||||
|
\PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
||||||
]) : [],
|
]) : [],
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -79,7 +81,9 @@ return [
|
|||||||
'strict' => true,
|
'strict' => true,
|
||||||
'engine' => null,
|
'engine' => null,
|
||||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||||
(PHP_VERSION_ID >= 80500 ? \Pdo\Mysql::ATTR_SSL_CA : \PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
(PHP_VERSION_ID >= 80500 ?
|
||||||
|
\Pdo\Mysql::ATTR_SSL_CA :
|
||||||
|
\PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
||||||
]) : [],
|
]) : [],
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -148,7 +152,7 @@ return [
|
|||||||
|
|
||||||
'options' => [
|
'options' => [
|
||||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||||
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
|
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')) . '-database-'),
|
||||||
'persistent' => env('REDIS_PERSISTENT', false),
|
'persistent' => env('REDIS_PERSISTENT', false),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ return [
|
|||||||
|
|
|
|
||||||
| Here you may specify the default filesystem disk that should be used
|
| Here you may specify the default filesystem disk that should be used
|
||||||
| by the framework. The "local" disk, as well as a variety of cloud
|
| by the framework. The "local" disk, as well as a variety of cloud
|
||||||
| based disks are available to your application for file storage.
|
| based disks, are available to your application for file storage.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ return [
|
|||||||
'public' => [
|
'public' => [
|
||||||
'driver' => 'local',
|
'driver' => 'local',
|
||||||
'root' => storage_path('app/public'),
|
'root' => storage_path('app/public'),
|
||||||
'url' => env('APP_URL').'/storage',
|
'url' => env('APP_URL') . '/storage',
|
||||||
'visibility' => 'public',
|
'visibility' => 'public',
|
||||||
'throw' => false,
|
'throw' => false,
|
||||||
'report' => false,
|
'report' => false,
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ return [
|
|||||||
'handler_with' => [
|
'handler_with' => [
|
||||||
'host' => env('PAPERTRAIL_URL'),
|
'host' => env('PAPERTRAIL_URL'),
|
||||||
'port' => env('PAPERTRAIL_PORT'),
|
'port' => env('PAPERTRAIL_PORT'),
|
||||||
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'),
|
||||||
],
|
],
|
||||||
'processors' => [PsrLogMessageProcessor::class],
|
'processors' => [PsrLogMessageProcessor::class],
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -46,7 +46,10 @@ return [
|
|||||||
'username' => env('MAIL_USERNAME'),
|
'username' => env('MAIL_USERNAME'),
|
||||||
'password' => env('MAIL_PASSWORD'),
|
'password' => env('MAIL_PASSWORD'),
|
||||||
'timeout' => null,
|
'timeout' => null,
|
||||||
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
'local_domain' => env(
|
||||||
|
'MAIL_EHLO_DOMAIN',
|
||||||
|
parse_url(url: (string) env('APP_URL', 'http://localhost'), component: PHP_URL_HOST)
|
||||||
|
),
|
||||||
],
|
],
|
||||||
|
|
||||||
'ses' => [
|
'ses' => [
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ return [
|
|||||||
|
|
||||||
'cookie' => env(
|
'cookie' => env(
|
||||||
'SESSION_COOKIE',
|
'SESSION_COOKIE',
|
||||||
Str::slug((string) env('APP_NAME', 'laravel')).'-session'
|
Str::slug((string) env('APP_NAME', 'laravel')) . '-session'
|
||||||
),
|
),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -23,8 +23,11 @@ class UserFactory extends Factory
|
|||||||
*/
|
*/
|
||||||
public function definition(): array
|
public function definition(): array
|
||||||
{
|
{
|
||||||
|
$name = fake()->unique()->userName();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'name' => fake()->name(),
|
'name' => $name,
|
||||||
|
'name_canonical' => Str::lower($name),
|
||||||
'email' => fake()->unique()->safeEmail(),
|
'email' => fake()->unique()->safeEmail(),
|
||||||
'email_verified_at' => now(),
|
'email_verified_at' => now(),
|
||||||
'password' => static::$password ??= Hash::make('password'),
|
'password' => static::$password ??= Hash::make('password'),
|
||||||
|
|||||||
@@ -36,12 +36,6 @@ return new class extends Migration
|
|||||||
'created_at' => now(),
|
'created_at' => now(),
|
||||||
'updated_at' => now(),
|
'updated_at' => now(),
|
||||||
],
|
],
|
||||||
[
|
|
||||||
'key' => 'accent_color',
|
|
||||||
'value' => '#f29b3f',
|
|
||||||
'created_at' => now(),
|
|
||||||
'updated_at' => now(),
|
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('forums', function (Blueprint $table) {
|
||||||
|
$table->softDeletes();
|
||||||
|
$table->foreignId('deleted_by')->nullable()->constrained('users')->nullOnDelete();
|
||||||
|
$table->index(['deleted_at', 'deleted_by'], 'idx_forums_deleted_meta');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('threads', function (Blueprint $table) {
|
||||||
|
$table->softDeletes();
|
||||||
|
$table->foreignId('deleted_by')->nullable()->constrained('users')->nullOnDelete();
|
||||||
|
$table->index(['deleted_at', 'deleted_by'], 'idx_threads_deleted_meta');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('posts', function (Blueprint $table) {
|
||||||
|
$table->softDeletes();
|
||||||
|
$table->foreignId('deleted_by')->nullable()->constrained('users')->nullOnDelete();
|
||||||
|
$table->index(['deleted_at', 'deleted_by'], 'idx_posts_deleted_meta');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('forums', function (Blueprint $table) {
|
||||||
|
$table->dropIndex('idx_forums_deleted_meta');
|
||||||
|
$table->dropConstrainedForeignId('deleted_by');
|
||||||
|
$table->dropSoftDeletes();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('threads', function (Blueprint $table) {
|
||||||
|
$table->dropIndex('idx_threads_deleted_meta');
|
||||||
|
$table->dropConstrainedForeignId('deleted_by');
|
||||||
|
$table->dropSoftDeletes();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('posts', function (Blueprint $table) {
|
||||||
|
$table->dropIndex('idx_posts_deleted_meta');
|
||||||
|
$table->dropConstrainedForeignId('deleted_by');
|
||||||
|
$table->dropSoftDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
DB::table('forums')
|
||||||
|
->where('type', 'forum')
|
||||||
|
->whereNull('parent_id')
|
||||||
|
->update(['type' => 'category']);
|
||||||
|
|
||||||
|
$driver = Schema::getConnection()->getDriverName();
|
||||||
|
if ($driver === 'mysql') {
|
||||||
|
DB::statement('DROP TRIGGER IF EXISTS trg_forums_parent_insert');
|
||||||
|
DB::statement('DROP TRIGGER IF EXISTS trg_forums_parent_update');
|
||||||
|
DB::statement(<<<'SQL'
|
||||||
|
CREATE TRIGGER trg_forums_parent_insert
|
||||||
|
BEFORE INSERT ON forums
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
IF NEW.type = 'forum' AND NEW.parent_id IS NULL THEN
|
||||||
|
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Forums must belong to a category.';
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
SQL);
|
||||||
|
DB::statement(<<<'SQL'
|
||||||
|
CREATE TRIGGER trg_forums_parent_update
|
||||||
|
BEFORE UPDATE ON forums
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
IF NEW.type = 'forum' AND NEW.parent_id IS NULL THEN
|
||||||
|
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Forums must belong to a category.';
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
$driver = Schema::getConnection()->getDriverName();
|
||||||
|
if ($driver === 'mysql') {
|
||||||
|
DB::statement('DROP TRIGGER IF EXISTS trg_forums_parent_insert');
|
||||||
|
DB::statement('DROP TRIGGER IF EXISTS trg_forums_parent_update');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('user_settings', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->string('key');
|
||||||
|
$table->json('value');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->unique(['user_id', 'key'], 'uniq_user_settings_user_key');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('user_settings');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->string('name_canonical')->nullable()->after('name');
|
||||||
|
});
|
||||||
|
|
||||||
|
DB::table('users')
|
||||||
|
->whereNull('name_canonical')
|
||||||
|
->update(['name_canonical' => DB::raw('lower(name)')]);
|
||||||
|
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->unique('name_canonical');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropUnique(['name_canonical']);
|
||||||
|
$table->dropColumn('name_canonical');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->string('avatar_path')->nullable()->after('name_canonical');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('avatar_path');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
28
database/migrations/2026_01_05_020000_create_ranks_table.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('ranks', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name')->unique();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('ranks');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->foreignId('rank_id')->nullable()->after('avatar_path')->constrained('ranks')->nullOnDelete();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropConstrainedForeignId('rank_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('ranks', function (Blueprint $table) {
|
||||||
|
$table->string('badge_type')->default('text')->after('name');
|
||||||
|
$table->string('badge_text')->nullable()->after('badge_type');
|
||||||
|
$table->string('badge_image_path')->nullable()->after('badge_text');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('ranks', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['badge_type', 'badge_text', 'badge_image_path']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->string('location')->nullable()->after('avatar_path');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('location');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('threads', function (Blueprint $table) {
|
||||||
|
$table->unsignedInteger('views_count')->default(0)->after('body');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('threads', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('views_count');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -16,8 +16,10 @@ class DatabaseSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
$this->call([
|
$this->call([
|
||||||
RoleSeeder::class,
|
RoleSeeder::class,
|
||||||
|
RankSeeder::class,
|
||||||
UserSeeder::class,
|
UserSeeder::class,
|
||||||
ForumSeeder::class,
|
ForumSeeder::class,
|
||||||
|
ThreadSeeder::class,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
41
database/seeders/RankSeeder.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Rank;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class RankSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$member = Rank::firstOrCreate(
|
||||||
|
['name' => 'Member'],
|
||||||
|
['badge_type' => 'text', 'badge_text' => 'Member']
|
||||||
|
);
|
||||||
|
$operator = Rank::firstOrCreate(
|
||||||
|
['name' => 'Operator'],
|
||||||
|
['badge_type' => 'text', 'badge_text' => 'Operator']
|
||||||
|
);
|
||||||
|
$moderator = Rank::firstOrCreate(
|
||||||
|
['name' => 'Moderator'],
|
||||||
|
['badge_type' => 'text', 'badge_text' => 'Moderator']
|
||||||
|
);
|
||||||
|
|
||||||
|
User::query()
|
||||||
|
->whereNull('rank_id')
|
||||||
|
->update(['rank_id' => $member->id]);
|
||||||
|
|
||||||
|
User::query()
|
||||||
|
->whereHas('roles', fn ($query) => $query->where('name', 'ROLE_ADMIN'))
|
||||||
|
->update(['rank_id' => $operator->id]);
|
||||||
|
|
||||||
|
User::query()
|
||||||
|
->whereHas('roles', fn ($query) => $query->where('name', 'ROLE_MODERATOR'))
|
||||||
|
->update(['rank_id' => $moderator->id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
36
database/seeders/ThreadSeeder.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Forum;
|
||||||
|
use App\Models\Thread;
|
||||||
|
use App\Models\User;
|
||||||
|
use Faker\Factory as FakerFactory;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class ThreadSeeder extends Seeder
|
||||||
|
{
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$faker = FakerFactory::create();
|
||||||
|
$users = User::all();
|
||||||
|
$forums = Forum::where('type', 'forum')->get();
|
||||||
|
|
||||||
|
if ($users->isEmpty() || $forums->isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($forums as $forum) {
|
||||||
|
$threadCount = $faker->numberBetween(2, 8);
|
||||||
|
for ($i = 0; $i < $threadCount; $i += 1) {
|
||||||
|
$author = $users->random();
|
||||||
|
Thread::create([
|
||||||
|
'forum_id' => $forum->id,
|
||||||
|
'user_id' => $author->id,
|
||||||
|
'title' => ucfirst($faker->words($faker->numberBetween(3, 6), true)),
|
||||||
|
'body' => $faker->paragraphs($faker->numberBetween(2, 4), true),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ namespace Database\Seeders;
|
|||||||
|
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use App\Models\Rank;
|
||||||
use App\Models\Role;
|
use App\Models\Role;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
@@ -14,14 +16,29 @@ class UserSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
$adminRole = Role::where('name', 'ROLE_ADMIN')->first();
|
$adminRole = Role::where(column: 'name', operator: 'ROLE_ADMIN')->first();
|
||||||
$userRole = Role::where('name', 'ROLE_USER')->first();
|
$userRole = Role::where(column: 'name', operator: 'ROLE_USER')->first();
|
||||||
|
$operatorRank = Rank::where('name', 'Operator')->first();
|
||||||
|
$memberRank = Rank::where('name', 'Member')->first();
|
||||||
|
|
||||||
$admin = User::firstOrCreate(
|
$admin = User::updateOrCreate(
|
||||||
['email' => 'tracer@24unix.net'],
|
attributes: ['email' => 'tracer@24unix.net'],
|
||||||
[
|
values : [
|
||||||
'name' => 'tracer',
|
'name' => 'tracer',
|
||||||
'password' => Hash::make('password'),
|
'name_canonical' => Str::lower('tracer'),
|
||||||
|
'rank_id' => $operatorRank?->id ?? $memberRank?->id,
|
||||||
|
'password' => Hash::make(value: 'password'),
|
||||||
|
'email_verified_at' => now(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$micha = User::updateOrCreate(
|
||||||
|
attributes: ['email' => 'micha@24unix.net'],
|
||||||
|
values : [
|
||||||
|
'name' => 'Micha',
|
||||||
|
'name_canonical' => Str::lower('Micha'),
|
||||||
|
'rank_id' => $memberRank?->id,
|
||||||
|
'password' => Hash::make(value: 'password'),
|
||||||
'email_verified_at' => now(),
|
'email_verified_at' => now(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
@@ -34,6 +51,10 @@ class UserSeeder extends Seeder
|
|||||||
$admin->roles()->syncWithoutDetaching([$userRole->id]);
|
$admin->roles()->syncWithoutDetaching([$userRole->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($userRole) {
|
||||||
|
$micha->roles()->syncWithoutDetaching([$userRole->id]);
|
||||||
|
}
|
||||||
|
|
||||||
$users = User::factory()->count(100)->create([
|
$users = User::factory()->count(100)->create([
|
||||||
'email_verified_at' => now(),
|
'email_verified_at' => now(),
|
||||||
]);
|
]);
|
||||||
|
|||||||
39
package-lock.json
generated
@@ -13,6 +13,7 @@
|
|||||||
"react-bootstrap": "^2.10.10",
|
"react-bootstrap": "^2.10.10",
|
||||||
"react-data-table-component": "^7.7.0",
|
"react-data-table-component": "^7.7.0",
|
||||||
"react-dom": "^19.2.0",
|
"react-dom": "^19.2.0",
|
||||||
|
"react-dropzone": "^14.3.8",
|
||||||
"react-i18next": "^16.5.0",
|
"react-i18next": "^16.5.0",
|
||||||
"react-router-dom": "^7.11.0"
|
"react-router-dom": "^7.11.0"
|
||||||
},
|
},
|
||||||
@@ -1657,6 +1658,15 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/attr-accept": {
|
||||||
|
"version": "2.2.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/attr-accept/-/attr-accept-2.2.5.tgz",
|
||||||
|
"integrity": "sha512-0bDNnY/u6pPwHDMoF0FieU354oBi0a8rD9FcsLwzcGWbc8KS8KPIi7y+s13OlVY+gMWc/9xEMUgNE6Qm8ZllYQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/axios": {
|
"node_modules/axios": {
|
||||||
"version": "1.13.2",
|
"version": "1.13.2",
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.13.2.tgz",
|
"resolved": "https://registry.npmjs.org/axios/-/axios-1.13.2.tgz",
|
||||||
@@ -2463,6 +2473,18 @@
|
|||||||
"node": ">=16.0.0"
|
"node": ">=16.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/file-selector": {
|
||||||
|
"version": "2.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/file-selector/-/file-selector-2.1.2.tgz",
|
||||||
|
"integrity": "sha512-QgXo+mXTe8ljeqUFaX3QVHc5osSItJ/Km+xpocx0aSqWGMSCf6qYs/VnzZgS864Pjn5iceMRFigeAV7AfTlaig==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "^2.7.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/find-up": {
|
"node_modules/find-up": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
|
||||||
@@ -3680,6 +3702,23 @@
|
|||||||
"react": "^19.2.3"
|
"react": "^19.2.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/react-dropzone": {
|
||||||
|
"version": "14.3.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-dropzone/-/react-dropzone-14.3.8.tgz",
|
||||||
|
"integrity": "sha512-sBgODnq+lcA4P296DY4wacOZz3JFpD99fp+hb//iBO2HHnyeZU3FwWyXJ6salNpqQdsZrgMrotuko/BdJMV8Ug==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"attr-accept": "^2.2.4",
|
||||||
|
"file-selector": "^2.1.0",
|
||||||
|
"prop-types": "^15.8.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 10.13"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">= 16.8 || 18.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/react-i18next": {
|
"node_modules/react-i18next": {
|
||||||
"version": "16.5.0",
|
"version": "16.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-16.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-16.5.0.tgz",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
"react-bootstrap": "^2.10.10",
|
"react-bootstrap": "^2.10.10",
|
||||||
"react-data-table-component": "^7.7.0",
|
"react-data-table-component": "^7.7.0",
|
||||||
"react-dom": "^19.2.0",
|
"react-dom": "^19.2.0",
|
||||||
|
"react-dropzone": "^14.3.8",
|
||||||
"react-i18next": "^16.5.0",
|
"react-i18next": "^16.5.0",
|
||||||
"react-router-dom": "^7.11.0"
|
"react-router-dom": "^7.11.0"
|
||||||
},
|
},
|
||||||
|
|||||||
18
phpcs.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset name="speedBB">
|
||||||
|
<description>Project coding standard based on PSR-12.</description>
|
||||||
|
|
||||||
|
<rule ref="PSR12"/>
|
||||||
|
|
||||||
|
<file>app</file>
|
||||||
|
<file>config</file>
|
||||||
|
<file>database</file>
|
||||||
|
<file>routes</file>
|
||||||
|
<file>tests</file>
|
||||||
|
|
||||||
|
<exclude-pattern>bootstrap/cache/*</exclude-pattern>
|
||||||
|
<exclude-pattern>node_modules/*</exclude-pattern>
|
||||||
|
<exclude-pattern>public/build/*</exclude-pattern>
|
||||||
|
<exclude-pattern>storage/*</exclude-pattern>
|
||||||
|
<exclude-pattern>vendor/*</exclude-pattern>
|
||||||
|
</ruleset>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { BrowserRouter, Link, Route, Routes } from 'react-router-dom'
|
import { BrowserRouter, Link, Route, Routes, useLocation } from 'react-router-dom'
|
||||||
import { Container, Nav, Navbar, NavDropdown } from 'react-bootstrap'
|
import { Container, NavDropdown } from 'react-bootstrap'
|
||||||
import { AuthProvider, useAuth } from './context/AuthContext'
|
import { AuthProvider, useAuth } from './context/AuthContext'
|
||||||
import Home from './pages/Home'
|
import Home from './pages/Home'
|
||||||
import ForumView from './pages/ForumView'
|
import ForumView from './pages/ForumView'
|
||||||
@@ -8,96 +8,262 @@ import ThreadView from './pages/ThreadView'
|
|||||||
import Login from './pages/Login'
|
import Login from './pages/Login'
|
||||||
import Register from './pages/Register'
|
import Register from './pages/Register'
|
||||||
import Acp from './pages/Acp'
|
import Acp from './pages/Acp'
|
||||||
|
import BoardIndex from './pages/BoardIndex'
|
||||||
|
import Ucp from './pages/Ucp'
|
||||||
|
import Profile from './pages/Profile'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { fetchSetting, fetchVersion } from './api/client'
|
import { fetchSettings, fetchVersion, getForum, getThread } from './api/client'
|
||||||
|
|
||||||
function Navigation({ theme, onThemeChange }) {
|
function PortalHeader({
|
||||||
const { token, email, logout, isAdmin } = useAuth()
|
userMenu,
|
||||||
const { t, i18n } = useTranslation()
|
isAuthenticated,
|
||||||
|
forumName,
|
||||||
|
logoUrl,
|
||||||
|
showHeaderName,
|
||||||
|
canAccessAcp,
|
||||||
|
canAccessMcp,
|
||||||
|
}) {
|
||||||
|
const { t } = useTranslation()
|
||||||
|
const location = useLocation()
|
||||||
|
const [crumbs, setCrumbs] = useState([])
|
||||||
|
|
||||||
const handleLanguageChange = (locale) => {
|
useEffect(() => {
|
||||||
i18n.changeLanguage(locale)
|
let active = true
|
||||||
localStorage.setItem('speedbb_lang', locale)
|
|
||||||
|
const parseForumId = (parent) => {
|
||||||
|
if (!parent) return null
|
||||||
|
if (typeof parent === 'string') {
|
||||||
|
const parts = parent.split('/')
|
||||||
|
return parts[parts.length - 1] || null
|
||||||
|
}
|
||||||
|
if (typeof parent === 'object' && parent.id) {
|
||||||
|
return parent.id
|
||||||
|
}
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleThemeChange = (value) => {
|
const buildForumChain = async (forum) => {
|
||||||
onThemeChange(value)
|
const chain = []
|
||||||
localStorage.setItem('speedbb_theme', value)
|
let cursor = forum
|
||||||
|
|
||||||
|
while (cursor) {
|
||||||
|
chain.unshift({ label: cursor.name, to: `/forum/${cursor.id}` })
|
||||||
|
const parentId = parseForumId(cursor.parent)
|
||||||
|
if (!parentId) break
|
||||||
|
cursor = await getForum(parentId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return chain
|
||||||
|
}
|
||||||
|
|
||||||
|
const buildCrumbs = async () => {
|
||||||
|
const base = [
|
||||||
|
{ label: t('portal.portal'), to: '/' },
|
||||||
|
{ label: t('portal.board_index'), to: '/forums' },
|
||||||
|
]
|
||||||
|
|
||||||
|
if (location.pathname === '/') {
|
||||||
|
setCrumbs([{ ...base[0], current: true }, { ...base[1] }])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.pathname === '/forums') {
|
||||||
|
setCrumbs([{ ...base[0] }, { ...base[1], current: true }])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.pathname.startsWith('/forum/')) {
|
||||||
|
const forumId = location.pathname.split('/')[2]
|
||||||
|
if (forumId) {
|
||||||
|
const forum = await getForum(forumId)
|
||||||
|
const chain = await buildForumChain(forum)
|
||||||
|
if (!active) return
|
||||||
|
setCrumbs([...base, ...chain.map((crumb, idx) => ({
|
||||||
|
...crumb,
|
||||||
|
current: idx === chain.length - 1,
|
||||||
|
}))])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.pathname.startsWith('/thread/')) {
|
||||||
|
const threadId = location.pathname.split('/')[2]
|
||||||
|
if (threadId) {
|
||||||
|
const thread = await getThread(threadId)
|
||||||
|
const forumId = thread?.forum?.split('/').pop()
|
||||||
|
if (forumId) {
|
||||||
|
const forum = await getForum(forumId)
|
||||||
|
const chain = await buildForumChain(forum)
|
||||||
|
if (!active) return
|
||||||
|
const chainWithCurrent = chain.map((crumb, index) => ({
|
||||||
|
...crumb,
|
||||||
|
current: index === chain.length - 1,
|
||||||
|
}))
|
||||||
|
setCrumbs([...base, ...chainWithCurrent])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.pathname.startsWith('/acp')) {
|
||||||
|
setCrumbs([
|
||||||
|
{ ...base[0] },
|
||||||
|
{ ...base[1] },
|
||||||
|
{ label: t('portal.link_acp'), to: '/acp', current: true },
|
||||||
|
])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.pathname.startsWith('/ucp')) {
|
||||||
|
setCrumbs([
|
||||||
|
{ ...base[0] },
|
||||||
|
{ ...base[1] },
|
||||||
|
{ label: t('portal.user_control_panel'), to: '/ucp', current: true },
|
||||||
|
])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.pathname.startsWith('/profile/')) {
|
||||||
|
setCrumbs([
|
||||||
|
{ ...base[0] },
|
||||||
|
{ ...base[1] },
|
||||||
|
{ label: t('portal.user_profile'), to: location.pathname, current: true },
|
||||||
|
])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
setCrumbs([{ ...base[0] }, { ...base[1], current: true }])
|
||||||
|
}
|
||||||
|
|
||||||
|
buildCrumbs()
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
active = false
|
||||||
|
}
|
||||||
|
}, [location.pathname, t])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Navbar expand="lg" className="bb-nav">
|
<Container fluid className="pt-2 pb-2 bb-portal-shell">
|
||||||
<Container>
|
<div className="bb-portal-banner">
|
||||||
<Navbar.Brand as={Link} to="/" className="fw-semibold">
|
<div className="bb-portal-brand">
|
||||||
{t('app.brand')}
|
<Link to="/" className="bb-portal-logo-link" aria-label={forumName || '24unix.net'}>
|
||||||
</Navbar.Brand>
|
{logoUrl && (
|
||||||
{isAdmin && (
|
<img src={logoUrl} alt={forumName || 'Forum'} className="bb-portal-logo-image" />
|
||||||
<Nav className="me-auto">
|
|
||||||
<Nav.Link as={Link} to="/acp">
|
|
||||||
{t('nav.acp')}
|
|
||||||
</Nav.Link>
|
|
||||||
</Nav>
|
|
||||||
)}
|
)}
|
||||||
<Navbar.Toggle aria-controls="bb-nav" />
|
{(showHeaderName || !logoUrl) && (
|
||||||
<Navbar.Collapse id="bb-nav">
|
<div className="bb-portal-logo">{forumName || '24unix.net'}</div>
|
||||||
<Nav className="ms-auto align-items-lg-center gap-2">
|
)}
|
||||||
{!token && (
|
</Link>
|
||||||
|
</div>
|
||||||
|
<div className="bb-portal-search">
|
||||||
|
<input type="text" placeholder={t('portal.search_placeholder')} disabled />
|
||||||
|
<span className="bb-portal-search-icon">
|
||||||
|
<i className="bi bi-search" aria-hidden="true" />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="bb-portal-bars">
|
||||||
|
<div className="bb-portal-bar bb-portal-bar--top">
|
||||||
|
<div className="bb-portal-bar-left">
|
||||||
|
<span className="bb-portal-bar-title">
|
||||||
|
<i className="bi bi-list" aria-hidden="true" /> {t('portal.quick_links')}
|
||||||
|
</span>
|
||||||
|
<div className="bb-portal-bar-links">
|
||||||
|
<span>
|
||||||
|
<i className="bi bi-question-circle-fill" aria-hidden="true" /> {t('portal.link_faq')}
|
||||||
|
</span>
|
||||||
|
{isAuthenticated && canAccessAcp && (
|
||||||
<>
|
<>
|
||||||
<Nav.Link as={Link} to="/login">
|
<Link to="/acp" className="bb-portal-link">
|
||||||
{t('nav.login')}
|
<i className="bi bi-gear-fill" aria-hidden="true" /> {t('portal.link_acp')}
|
||||||
</Nav.Link>
|
</Link>
|
||||||
<Nav.Link as={Link} to="/register">
|
|
||||||
{t('nav.register')}
|
|
||||||
</Nav.Link>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{token && (
|
{isAuthenticated && canAccessMcp && (
|
||||||
|
<span>
|
||||||
|
<i className="bi bi-hammer" aria-hidden="true" /> {t('portal.link_mcp')}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className={`bb-portal-user-links${isAuthenticated ? '' : ' bb-portal-user-links--guest'}`}
|
||||||
|
>
|
||||||
|
{isAuthenticated ? (
|
||||||
<>
|
<>
|
||||||
<span className="bb-chip">{email}</span>
|
<span>
|
||||||
<Nav.Link onClick={logout}>{t('nav.logout')}</Nav.Link>
|
<i className="bi bi-bell-fill" aria-hidden="true" /> {t('portal.notifications')}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<i className="bi bi-envelope-fill" aria-hidden="true" /> {t('portal.messages')}
|
||||||
|
</span>
|
||||||
|
{userMenu}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Link to="/register" className="bb-portal-user-link">
|
||||||
|
<i className="bi bi-pencil-square" aria-hidden="true" /> {t('nav.register')}
|
||||||
|
</Link>
|
||||||
|
<Link to="/login" className="bb-portal-user-link">
|
||||||
|
<i className="bi bi-power" aria-hidden="true" /> {t('nav.login')}
|
||||||
|
</Link>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<NavDropdown title={t('nav.language')} align="end">
|
</div>
|
||||||
<NavDropdown.Item onClick={() => handleLanguageChange('en')}>
|
</div>
|
||||||
English
|
<div className="bb-portal-bar bb-portal-bar--bottom">
|
||||||
</NavDropdown.Item>
|
<div className="bb-portal-breadcrumb">
|
||||||
<NavDropdown.Item onClick={() => handleLanguageChange('de')}>
|
{crumbs.map((crumb, index) => (
|
||||||
Deutsch
|
<span key={`${crumb.to}-${index}`} className="bb-portal-crumb">
|
||||||
</NavDropdown.Item>
|
{index > 0 && <span className="bb-portal-sep">›</span>}
|
||||||
</NavDropdown>
|
{crumb.current ? (
|
||||||
<NavDropdown title={t('nav.theme')} align="end">
|
<span className="bb-portal-current">
|
||||||
<NavDropdown.Item onClick={() => handleThemeChange('auto')} active={theme === 'auto'}>
|
{index === 0 && <i className="bi bi-house-door-fill" aria-hidden="true" />}
|
||||||
{t('nav.theme_auto')}
|
{index === 1 && <i className="bi bi-chat-left-text" aria-hidden="true" />}
|
||||||
</NavDropdown.Item>
|
{crumb.label}
|
||||||
<NavDropdown.Item onClick={() => handleThemeChange('light')} active={theme === 'light'}>
|
</span>
|
||||||
{t('nav.theme_light')}
|
) : (
|
||||||
</NavDropdown.Item>
|
<Link to={crumb.to} className="bb-portal-link">
|
||||||
<NavDropdown.Item onClick={() => handleThemeChange('dark')} active={theme === 'dark'}>
|
{index === 0 && <i className="bi bi-house-door-fill" aria-hidden="true" />}
|
||||||
{t('nav.theme_dark')}
|
{index === 1 && <i className="bi bi-chat-left-text" aria-hidden="true" />}
|
||||||
</NavDropdown.Item>
|
{crumb.label}
|
||||||
</NavDropdown>
|
</Link>
|
||||||
</Nav>
|
)}
|
||||||
</Navbar.Collapse>
|
</span>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</Container>
|
</Container>
|
||||||
</Navbar>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function AppShell() {
|
function AppShell() {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { isAdmin } = useAuth()
|
const { token, email, userId, logout, isAdmin, isModerator } = useAuth()
|
||||||
const [loadMs, setLoadMs] = useState(null)
|
|
||||||
const [versionInfo, setVersionInfo] = useState(null)
|
const [versionInfo, setVersionInfo] = useState(null)
|
||||||
const [theme, setTheme] = useState(() => localStorage.getItem('speedbb_theme') || 'auto')
|
const [theme, setTheme] = useState('auto')
|
||||||
|
const [resolvedTheme, setResolvedTheme] = useState('light')
|
||||||
useEffect(() => {
|
const [accentOverride, setAccentOverride] = useState(
|
||||||
const [entry] = performance.getEntriesByType('navigation')
|
() => localStorage.getItem('speedbb_accent') || ''
|
||||||
if (entry?.duration) {
|
)
|
||||||
setLoadMs(Math.round(entry.duration))
|
const [settings, setSettings] = useState({
|
||||||
return
|
forumName: '',
|
||||||
}
|
defaultTheme: 'auto',
|
||||||
setLoadMs(Math.round(performance.now()))
|
accentDark: '',
|
||||||
}, [])
|
accentLight: '',
|
||||||
|
logoDark: '',
|
||||||
|
logoLight: '',
|
||||||
|
showHeaderName: true,
|
||||||
|
faviconIco: '',
|
||||||
|
favicon16: '',
|
||||||
|
favicon32: '',
|
||||||
|
favicon48: '',
|
||||||
|
favicon64: '',
|
||||||
|
favicon128: '',
|
||||||
|
favicon256: '',
|
||||||
|
})
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchVersion()
|
fetchVersion()
|
||||||
@@ -106,24 +272,78 @@ function AppShell() {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchSetting('accent_color')
|
let active = true
|
||||||
.then((setting) => {
|
const loadSettings = async () => {
|
||||||
if (setting?.value) {
|
try {
|
||||||
document.documentElement.style.setProperty('--bb-accent', setting.value)
|
const allSettings = await fetchSettings()
|
||||||
|
const settingsMap = new Map(allSettings.map((setting) => [setting.key, setting.value]))
|
||||||
|
if (!active) return
|
||||||
|
const next = {
|
||||||
|
forumName: settingsMap.get('forum_name') || '',
|
||||||
|
defaultTheme: settingsMap.get('default_theme') || 'auto',
|
||||||
|
accentDark: settingsMap.get('accent_color_dark') || '',
|
||||||
|
accentLight: settingsMap.get('accent_color_light') || '',
|
||||||
|
logoDark: settingsMap.get('logo_dark') || '',
|
||||||
|
logoLight: settingsMap.get('logo_light') || '',
|
||||||
|
showHeaderName: settingsMap.get('show_header_name') !== 'false',
|
||||||
|
faviconIco: settingsMap.get('favicon_ico') || '',
|
||||||
|
favicon16: settingsMap.get('favicon_16') || '',
|
||||||
|
favicon32: settingsMap.get('favicon_32') || '',
|
||||||
|
favicon48: settingsMap.get('favicon_48') || '',
|
||||||
|
favicon64: settingsMap.get('favicon_64') || '',
|
||||||
|
favicon128: settingsMap.get('favicon_128') || '',
|
||||||
|
favicon256: settingsMap.get('favicon_256') || '',
|
||||||
|
}
|
||||||
|
setSettings(next)
|
||||||
|
} catch {
|
||||||
|
// keep defaults
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loadSettings()
|
||||||
|
return () => {
|
||||||
|
active = false
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.catch(() => {})
|
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const stored = token ? localStorage.getItem('speedbb_theme') : null
|
||||||
|
const nextTheme = stored || settings.defaultTheme || 'auto'
|
||||||
|
setTheme(nextTheme)
|
||||||
|
}, [token, settings.defaultTheme])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleSettingsUpdate = (event) => {
|
||||||
|
const next = event.detail
|
||||||
|
if (!next) return
|
||||||
|
setSettings((prev) => ({ ...prev, ...next }))
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('speedbb-settings-updated', handleSettingsUpdate)
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('speedbb-settings-updated', handleSettingsUpdate)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (accentOverride) {
|
||||||
|
localStorage.setItem('speedbb_accent', accentOverride)
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem('speedbb_accent')
|
||||||
|
}
|
||||||
|
}, [accentOverride])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const root = document.documentElement
|
const root = document.documentElement
|
||||||
const media = window.matchMedia('(prefers-color-scheme: dark)')
|
const media = window.matchMedia('(prefers-color-scheme: dark)')
|
||||||
|
|
||||||
const applyTheme = (mode) => {
|
const applyTheme = (mode) => {
|
||||||
if (mode === 'auto') {
|
if (mode === 'auto') {
|
||||||
root.setAttribute('data-bs-theme', media.matches ? 'dark' : 'light')
|
const next = media.matches ? 'dark' : 'light'
|
||||||
|
root.setAttribute('data-bs-theme', next)
|
||||||
|
setResolvedTheme(next)
|
||||||
} else {
|
} else {
|
||||||
root.setAttribute('data-bs-theme', mode)
|
root.setAttribute('data-bs-theme', mode)
|
||||||
|
setResolvedTheme(mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,16 +362,124 @@ function AppShell() {
|
|||||||
}
|
}
|
||||||
}, [theme])
|
}, [theme])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const accent =
|
||||||
|
accentOverride ||
|
||||||
|
(resolvedTheme === 'dark' ? settings.accentDark : settings.accentLight) ||
|
||||||
|
settings.accentDark ||
|
||||||
|
settings.accentLight
|
||||||
|
if (accent) {
|
||||||
|
document.documentElement.style.setProperty('--bb-accent', accent)
|
||||||
|
}
|
||||||
|
}, [accentOverride, resolvedTheme, settings])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (settings.forumName) {
|
||||||
|
document.title = settings.forumName
|
||||||
|
}
|
||||||
|
}, [settings.forumName])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const upsertIcon = (id, rel, href, sizes, type) => {
|
||||||
|
if (!href) {
|
||||||
|
const existing = document.getElementById(id)
|
||||||
|
if (existing) {
|
||||||
|
existing.remove()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let link = document.getElementById(id)
|
||||||
|
if (!link) {
|
||||||
|
link = document.createElement('link')
|
||||||
|
link.id = id
|
||||||
|
document.head.appendChild(link)
|
||||||
|
}
|
||||||
|
link.setAttribute('rel', rel)
|
||||||
|
link.setAttribute('href', href)
|
||||||
|
if (sizes) {
|
||||||
|
link.setAttribute('sizes', sizes)
|
||||||
|
} else {
|
||||||
|
link.removeAttribute('sizes')
|
||||||
|
}
|
||||||
|
if (type) {
|
||||||
|
link.setAttribute('type', type)
|
||||||
|
} else {
|
||||||
|
link.removeAttribute('type')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
upsertIcon('favicon-ico', 'icon', settings.faviconIco, null, 'image/x-icon')
|
||||||
|
upsertIcon('favicon-16', 'icon', settings.favicon16, '16x16', 'image/png')
|
||||||
|
upsertIcon('favicon-32', 'icon', settings.favicon32, '32x32', 'image/png')
|
||||||
|
upsertIcon('favicon-48', 'icon', settings.favicon48, '48x48', 'image/png')
|
||||||
|
upsertIcon('favicon-64', 'icon', settings.favicon64, '64x64', 'image/png')
|
||||||
|
upsertIcon('favicon-128', 'icon', settings.favicon128, '128x128', 'image/png')
|
||||||
|
upsertIcon('favicon-256', 'icon', settings.favicon256, '256x256', 'image/png')
|
||||||
|
}, [
|
||||||
|
settings.faviconIco,
|
||||||
|
settings.favicon16,
|
||||||
|
settings.favicon32,
|
||||||
|
settings.favicon48,
|
||||||
|
settings.favicon64,
|
||||||
|
settings.favicon128,
|
||||||
|
settings.favicon256,
|
||||||
|
])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bb-shell">
|
<div className="bb-shell">
|
||||||
<Navigation theme={theme} onThemeChange={setTheme} />
|
<PortalHeader
|
||||||
|
isAuthenticated={!!token}
|
||||||
|
forumName={settings.forumName}
|
||||||
|
logoUrl={resolvedTheme === 'dark' ? settings.logoDark : settings.logoLight}
|
||||||
|
showHeaderName={settings.showHeaderName}
|
||||||
|
userMenu={
|
||||||
|
token ? (
|
||||||
|
<NavDropdown
|
||||||
|
title={
|
||||||
|
<span className="bb-user-menu">
|
||||||
|
<span className="bb-user-menu__name">{email}</span>
|
||||||
|
<i className="bi bi-caret-down-fill" aria-hidden="true" />
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
align="end"
|
||||||
|
className="bb-user-menu__dropdown"
|
||||||
|
>
|
||||||
|
<NavDropdown.Item as={Link} to="/ucp">
|
||||||
|
<i className="bi bi-sliders" aria-hidden="true" /> {t('portal.user_control_panel')}
|
||||||
|
</NavDropdown.Item>
|
||||||
|
<NavDropdown.Item as={Link} to={`/profile/${userId ?? ''}`}>
|
||||||
|
<i className="bi bi-person" aria-hidden="true" /> {t('portal.user_profile')}
|
||||||
|
</NavDropdown.Item>
|
||||||
|
<NavDropdown.Divider />
|
||||||
|
<NavDropdown.Item onClick={logout}>
|
||||||
|
<i className="bi bi-power" aria-hidden="true" /> {t('portal.user_logout')}
|
||||||
|
</NavDropdown.Item>
|
||||||
|
</NavDropdown>
|
||||||
|
) : null
|
||||||
|
}
|
||||||
|
canAccessAcp={isAdmin}
|
||||||
|
canAccessMcp={isModerator}
|
||||||
|
/>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<Home />} />
|
<Route path="/" element={<Home />} />
|
||||||
|
<Route path="/forums" element={<BoardIndex />} />
|
||||||
<Route path="/forum/:id" element={<ForumView />} />
|
<Route path="/forum/:id" element={<ForumView />} />
|
||||||
<Route path="/thread/:id" element={<ThreadView />} />
|
<Route path="/thread/:id" element={<ThreadView />} />
|
||||||
<Route path="/login" element={<Login />} />
|
<Route path="/login" element={<Login />} />
|
||||||
<Route path="/register" element={<Register />} />
|
<Route path="/register" element={<Register />} />
|
||||||
|
<Route path="/profile/:id" element={<Profile />} />
|
||||||
<Route path="/acp/*" element={<Acp isAdmin={isAdmin} />} />
|
<Route path="/acp/*" element={<Acp isAdmin={isAdmin} />} />
|
||||||
|
<Route
|
||||||
|
path="/ucp"
|
||||||
|
element={
|
||||||
|
<Ucp
|
||||||
|
theme={theme}
|
||||||
|
setTheme={setTheme}
|
||||||
|
accentOverride={accentOverride}
|
||||||
|
setAccentOverride={setAccentOverride}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
</Routes>
|
</Routes>
|
||||||
<footer className="bb-footer">
|
<footer className="bb-footer">
|
||||||
<div className="ms-3 d-flex align-items-center gap-3">
|
<div className="ms-3 d-flex align-items-center gap-3">
|
||||||
@@ -165,12 +493,6 @@ function AppShell() {
|
|||||||
<span className="bb-version-label">)</span>
|
<span className="bb-version-label">)</span>
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{loadMs !== null && (
|
|
||||||
<span className="bb-load-time">
|
|
||||||
<span className="bb-load-label">Page load time</span>{' '}
|
|
||||||
<span className="bb-load-value">{loadMs}ms</span>
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ export async function getCollection(path) {
|
|||||||
return data?.['hydra:member'] || []
|
return data?.['hydra:member'] || []
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function login(email, password) {
|
export async function login(login, password) {
|
||||||
return apiFetch('/login', {
|
return apiFetch('/login', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ email, password }),
|
body: JSON.stringify({ login, password }),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,13 +70,109 @@ export async function listAllForums() {
|
|||||||
return getCollection('/forums?pagination=false')
|
return getCollection('/forums?pagination=false')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getCurrentUser() {
|
||||||
|
return apiFetch('/user/me')
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateCurrentUser(payload) {
|
||||||
|
return apiFetch('/user/me', {
|
||||||
|
method: 'PATCH',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/merge-patch+json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify(payload),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function uploadAvatar(file) {
|
||||||
|
const body = new FormData()
|
||||||
|
body.append('file', file)
|
||||||
|
return apiFetch('/user/avatar', {
|
||||||
|
method: 'POST',
|
||||||
|
body,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getUserProfile(id) {
|
||||||
|
return apiFetch(`/user/profile/${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
export async function fetchVersion() {
|
export async function fetchVersion() {
|
||||||
return apiFetch('/version')
|
return apiFetch('/version')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function fetchStats() {
|
||||||
|
return apiFetch('/stats')
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchPortalSummary() {
|
||||||
|
return apiFetch('/portal/summary')
|
||||||
|
}
|
||||||
|
|
||||||
export async function fetchSetting(key) {
|
export async function fetchSetting(key) {
|
||||||
const data = await getCollection(`/settings?key=${encodeURIComponent(key)}&pagination=false`)
|
// TODO: Prefer fetchSettings() when multiple settings are needed.
|
||||||
|
const cacheBust = Date.now()
|
||||||
|
const data = await apiFetch(
|
||||||
|
`/settings?key=${encodeURIComponent(key)}&pagination=false&_=${cacheBust}`,
|
||||||
|
{ cache: 'no-store' }
|
||||||
|
)
|
||||||
|
if (Array.isArray(data)) {
|
||||||
return data[0] || null
|
return data[0] || null
|
||||||
|
}
|
||||||
|
return data?.['hydra:member']?.[0] || null
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchSettings() {
|
||||||
|
const cacheBust = Date.now()
|
||||||
|
const data = await apiFetch(`/settings?pagination=false&_=${cacheBust}`, { cache: 'no-store' })
|
||||||
|
if (Array.isArray(data)) {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
return data?.['hydra:member'] || []
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function saveSetting(key, value) {
|
||||||
|
return apiFetch('/settings', {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({ key, value }),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function saveSettings(settings) {
|
||||||
|
return apiFetch('/settings/bulk', {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({ settings }),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function uploadLogo(file) {
|
||||||
|
const body = new FormData()
|
||||||
|
body.append('file', file)
|
||||||
|
return apiFetch('/uploads/logo', {
|
||||||
|
method: 'POST',
|
||||||
|
body,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function uploadFavicon(file) {
|
||||||
|
const body = new FormData()
|
||||||
|
body.append('file', file)
|
||||||
|
return apiFetch('/uploads/favicon', {
|
||||||
|
method: 'POST',
|
||||||
|
body,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchUserSetting(key) {
|
||||||
|
const data = await getCollection(`/user-settings?key=${encodeURIComponent(key)}&pagination=false`)
|
||||||
|
return data[0] || null
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function saveUserSetting(key, value) {
|
||||||
|
return apiFetch('/user-settings', {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({ key, value }),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function listForumsByParent(parentId) {
|
export async function listForumsByParent(parentId) {
|
||||||
@@ -134,6 +230,10 @@ export async function listThreadsByForum(forumId) {
|
|||||||
return getCollection(`/threads?forum=/api/forums/${forumId}`)
|
return getCollection(`/threads?forum=/api/forums/${forumId}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function listThreads() {
|
||||||
|
return getCollection('/threads')
|
||||||
|
}
|
||||||
|
|
||||||
export async function getThread(id) {
|
export async function getThread(id) {
|
||||||
return apiFetch(`/threads/${id}`)
|
return apiFetch(`/threads/${id}`)
|
||||||
}
|
}
|
||||||
@@ -146,6 +246,53 @@ export async function listUsers() {
|
|||||||
return getCollection('/users')
|
return getCollection('/users')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function listRanks() {
|
||||||
|
return getCollection('/ranks')
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateUserRank(userId, rankId) {
|
||||||
|
return apiFetch(`/users/${userId}/rank`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
body: JSON.stringify({ rank_id: rankId }),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createRank(payload) {
|
||||||
|
return apiFetch('/ranks', {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify(payload),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateRank(rankId, payload) {
|
||||||
|
return apiFetch(`/ranks/${rankId}`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
body: JSON.stringify(payload),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteRank(rankId) {
|
||||||
|
return apiFetch(`/ranks/${rankId}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function uploadRankBadgeImage(rankId, file) {
|
||||||
|
const body = new FormData()
|
||||||
|
body.append('file', file)
|
||||||
|
return apiFetch(`/ranks/${rankId}/badge-image`, {
|
||||||
|
method: 'POST',
|
||||||
|
body,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateUser(userId, payload) {
|
||||||
|
return apiFetch(`/users/${userId}`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
body: JSON.stringify(payload),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export async function createThread({ title, body, forumId }) {
|
export async function createThread({ title, body, forumId }) {
|
||||||
return apiFetch('/threads', {
|
return apiFetch('/threads', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
91
resources/js/components/PortalTopicRow.jsx
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
import { Link } from 'react-router-dom'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
|
export default function PortalTopicRow({ thread, forumName, forumId, showForum = true }) {
|
||||||
|
const { t } = useTranslation()
|
||||||
|
const authorName = thread.user_name || t('thread.anonymous')
|
||||||
|
const lastAuthorName = thread.last_post_user_name || authorName
|
||||||
|
const lastPostAnchor = thread.last_post_id ? `#post-${thread.last_post_id}` : ''
|
||||||
|
|
||||||
|
const formatDateTime = (value) => {
|
||||||
|
if (!value) return '—'
|
||||||
|
const date = new Date(value)
|
||||||
|
if (Number.isNaN(date.getTime())) return '—'
|
||||||
|
const day = String(date.getDate()).padStart(2, '0')
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||||
|
const year = String(date.getFullYear())
|
||||||
|
const hours = String(date.getHours()).padStart(2, '0')
|
||||||
|
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||||
|
const seconds = String(date.getSeconds()).padStart(2, '0')
|
||||||
|
return `${day}.${month}.${year} ${hours}:${minutes}:${seconds}`
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="bb-portal-topic-row">
|
||||||
|
<div className="bb-portal-topic-main">
|
||||||
|
<span className="bb-portal-topic-icon" aria-hidden="true">
|
||||||
|
<i className="bi bi-chat-left-text" />
|
||||||
|
</span>
|
||||||
|
<div>
|
||||||
|
<Link to={`/thread/${thread.id}`} className="bb-portal-topic-title">
|
||||||
|
{thread.title}
|
||||||
|
</Link>
|
||||||
|
<div className="bb-portal-topic-meta">
|
||||||
|
<div className="bb-portal-topic-meta-line">
|
||||||
|
<span className="bb-portal-topic-meta-label">{t('portal.posted_by')}</span>
|
||||||
|
{thread.user_id ? (
|
||||||
|
<Link to={`/profile/${thread.user_id}`} className="bb-portal-topic-author">
|
||||||
|
{authorName}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<span className="bb-portal-topic-author">{authorName}</span>
|
||||||
|
)}
|
||||||
|
<span className="bb-portal-topic-meta-sep">»</span>
|
||||||
|
<span className="bb-portal-topic-meta-date">{formatDateTime(thread.created_at)}</span>
|
||||||
|
</div>
|
||||||
|
{showForum && (
|
||||||
|
<div className="bb-portal-topic-meta-line">
|
||||||
|
<span className="bb-portal-topic-meta-label">{t('portal.forum_label')}</span>
|
||||||
|
<span className="bb-portal-topic-forum">
|
||||||
|
{forumId ? (
|
||||||
|
<Link to={`/forum/${forumId}`} className="bb-portal-topic-forum-link">
|
||||||
|
{forumName}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
forumName
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="bb-portal-topic-cell">{thread.posts_count ?? 0}</div>
|
||||||
|
<div className="bb-portal-topic-cell">{thread.views_count ?? 0}</div>
|
||||||
|
<div className="bb-portal-topic-cell bb-portal-topic-cell--last">
|
||||||
|
<div className="bb-portal-last">
|
||||||
|
<span className="bb-portal-last-by">
|
||||||
|
{t('thread.by')}{' '}
|
||||||
|
{thread.last_post_user_id ? (
|
||||||
|
<Link to={`/profile/${thread.last_post_user_id}`} className="bb-portal-last-user">
|
||||||
|
{lastAuthorName}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<span className="bb-portal-last-user">{lastAuthorName}</span>
|
||||||
|
)}
|
||||||
|
<Link
|
||||||
|
to={`/thread/${thread.id}${lastPostAnchor}`}
|
||||||
|
className="bb-portal-last-jump ms-2"
|
||||||
|
aria-label={t('thread.view')}
|
||||||
|
>
|
||||||
|
<i className="bi bi-eye" aria-hidden="true" />
|
||||||
|
</Link>
|
||||||
|
</span>
|
||||||
|
<span className="bb-portal-last-date">
|
||||||
|
{formatDateTime(thread.last_post_at || thread.created_at)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -27,10 +27,11 @@ export function AuthProvider({ children }) {
|
|||||||
userId: effectiveUserId,
|
userId: effectiveUserId,
|
||||||
roles: effectiveRoles,
|
roles: effectiveRoles,
|
||||||
isAdmin: effectiveRoles.includes('ROLE_ADMIN'),
|
isAdmin: effectiveRoles.includes('ROLE_ADMIN'),
|
||||||
async login(emailInput, password) {
|
isModerator: effectiveRoles.includes('ROLE_MODERATOR') || effectiveRoles.includes('ROLE_ADMIN'),
|
||||||
const data = await apiLogin(emailInput, password)
|
async login(loginInput, password) {
|
||||||
|
const data = await apiLogin(loginInput, password)
|
||||||
localStorage.setItem('speedbb_token', data.token)
|
localStorage.setItem('speedbb_token', data.token)
|
||||||
localStorage.setItem('speedbb_email', data.email || emailInput)
|
localStorage.setItem('speedbb_email', data.email || loginInput)
|
||||||
if (data.user_id) {
|
if (data.user_id) {
|
||||||
localStorage.setItem('speedbb_user_id', String(data.user_id))
|
localStorage.setItem('speedbb_user_id', String(data.user_id))
|
||||||
setUserId(String(data.user_id))
|
setUserId(String(data.user_id))
|
||||||
@@ -43,7 +44,7 @@ export function AuthProvider({ children }) {
|
|||||||
setRoles([])
|
setRoles([])
|
||||||
}
|
}
|
||||||
setToken(data.token)
|
setToken(data.token)
|
||||||
setEmail(data.email || emailInput)
|
setEmail(data.email || loginInput)
|
||||||
},
|
},
|
||||||
logout() {
|
logout() {
|
||||||
localStorage.removeItem('speedbb_token')
|
localStorage.removeItem('speedbb_token')
|
||||||
@@ -77,6 +78,7 @@ export function AuthProvider({ children }) {
|
|||||||
userId: effectiveUserId,
|
userId: effectiveUserId,
|
||||||
roles: effectiveRoles,
|
roles: effectiveRoles,
|
||||||
isAdmin: effectiveRoles.includes('ROLE_ADMIN'),
|
isAdmin: effectiveRoles.includes('ROLE_ADMIN'),
|
||||||
|
isModerator: effectiveRoles.includes('ROLE_MODERATOR') || effectiveRoles.includes('ROLE_ADMIN'),
|
||||||
hasToken: Boolean(token),
|
hasToken: Boolean(token),
|
||||||
})
|
})
|
||||||
}, [email, effectiveUserId, effectiveRoles, token])
|
}, [email, effectiveUserId, effectiveRoles, token])
|
||||||
|
|||||||
230
resources/js/pages/BoardIndex.jsx
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||||
|
import { Container } from 'react-bootstrap'
|
||||||
|
import { Link } from 'react-router-dom'
|
||||||
|
import { fetchUserSetting, listAllForums, saveUserSetting } from '../api/client'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { useAuth } from '../context/AuthContext'
|
||||||
|
|
||||||
|
export default function BoardIndex() {
|
||||||
|
const [forums, setForums] = useState([])
|
||||||
|
const [error, setError] = useState('')
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
const [collapsed, setCollapsed] = useState({})
|
||||||
|
const { t } = useTranslation()
|
||||||
|
const { token } = useAuth()
|
||||||
|
const collapsedKey = 'board_index.collapsed_categories'
|
||||||
|
const storageKey = `speedbb_user_setting_${collapsedKey}`
|
||||||
|
const saveTimer = useRef(null)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
listAllForums()
|
||||||
|
.then(setForums)
|
||||||
|
.catch((err) => setError(err.message))
|
||||||
|
.finally(() => setLoading(false))
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!token) return
|
||||||
|
let active = true
|
||||||
|
|
||||||
|
const cached = localStorage.getItem(storageKey)
|
||||||
|
if (cached) {
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(cached)
|
||||||
|
if (Array.isArray(parsed)) {
|
||||||
|
const next = {}
|
||||||
|
parsed.forEach((id) => {
|
||||||
|
next[String(id)] = true
|
||||||
|
})
|
||||||
|
setCollapsed(next)
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
localStorage.removeItem(storageKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchUserSetting(collapsedKey)
|
||||||
|
.then((setting) => {
|
||||||
|
if (!active) return
|
||||||
|
const next = {}
|
||||||
|
if (Array.isArray(setting?.value)) {
|
||||||
|
setting.value.forEach((id) => {
|
||||||
|
next[String(id)] = true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
setCollapsed(next)
|
||||||
|
localStorage.setItem(storageKey, JSON.stringify(setting?.value || []))
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
active = false
|
||||||
|
}
|
||||||
|
}, [token])
|
||||||
|
|
||||||
|
const getParentId = (forum) => {
|
||||||
|
if (!forum.parent) return null
|
||||||
|
if (typeof forum.parent === 'string') {
|
||||||
|
return forum.parent.split('/').pop()
|
||||||
|
}
|
||||||
|
return forum.parent.id ?? null
|
||||||
|
}
|
||||||
|
|
||||||
|
const forumTree = useMemo(() => {
|
||||||
|
const map = new Map()
|
||||||
|
const roots = []
|
||||||
|
|
||||||
|
forums.forEach((forum) => {
|
||||||
|
map.set(String(forum.id), { ...forum, children: [] })
|
||||||
|
})
|
||||||
|
|
||||||
|
forums.forEach((forum) => {
|
||||||
|
const parentId = getParentId(forum)
|
||||||
|
const node = map.get(String(forum.id))
|
||||||
|
if (parentId && map.has(String(parentId))) {
|
||||||
|
map.get(String(parentId)).children.push(node)
|
||||||
|
} else {
|
||||||
|
roots.push(node)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const sortNodes = (nodes) => {
|
||||||
|
nodes.sort((a, b) => {
|
||||||
|
if (a.position !== b.position) return a.position - b.position
|
||||||
|
return a.name.localeCompare(b.name)
|
||||||
|
})
|
||||||
|
nodes.forEach((node) => sortNodes(node.children))
|
||||||
|
}
|
||||||
|
|
||||||
|
sortNodes(roots)
|
||||||
|
|
||||||
|
return roots
|
||||||
|
}, [forums])
|
||||||
|
|
||||||
|
const renderRows = (nodes) =>
|
||||||
|
nodes.map((node) => (
|
||||||
|
<div className="bb-board-row" key={node.id}>
|
||||||
|
<div className="bb-board-cell bb-board-cell--title">
|
||||||
|
<div className="bb-board-title">
|
||||||
|
<span className="bb-board-icon" aria-hidden="true">
|
||||||
|
<i className={`bi ${node.type === 'category' ? 'bi-folder2' : 'bi-chat-left-text'}`} />
|
||||||
|
</span>
|
||||||
|
<div>
|
||||||
|
<Link to={`/forum/${node.id}`} className="bb-board-link">
|
||||||
|
{node.name}
|
||||||
|
</Link>
|
||||||
|
<div className="bb-board-desc">{node.description || ''}</div>
|
||||||
|
{node.children?.length > 0 && (
|
||||||
|
<div className="bb-board-subforums">
|
||||||
|
{t('forum.children')}:{' '}
|
||||||
|
{node.children.map((child, index) => (
|
||||||
|
<span key={child.id}>
|
||||||
|
<Link to={`/forum/${child.id}`} className="bb-board-subforum-link">
|
||||||
|
{child.name}
|
||||||
|
</Link>
|
||||||
|
{index < node.children.length - 1 ? ', ' : ''}
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="bb-board-cell bb-board-cell--topics">{node.threads_count ?? 0}</div>
|
||||||
|
<div className="bb-board-cell bb-board-cell--posts">{node.views_count ?? 0}</div>
|
||||||
|
<div className="bb-board-cell bb-board-cell--last">
|
||||||
|
{node.last_post_at ? (
|
||||||
|
<div className="bb-board-last">
|
||||||
|
<span className="bb-board-last-by">
|
||||||
|
{t('thread.by')}{' '}
|
||||||
|
{node.last_post_user_id ? (
|
||||||
|
<Link to={`/profile/${node.last_post_user_id}`} className="bb-board-last-link">
|
||||||
|
{node.last_post_user_name || t('thread.anonymous')}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<span>{node.last_post_user_name || t('thread.anonymous')}</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
<span className="bb-board-last-date">
|
||||||
|
{node.last_post_at.slice(0, 10)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<span className="bb-muted">{t('thread.no_replies')}</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container fluid className="py-4 bb-portal-shell">
|
||||||
|
{loading && <p className="bb-muted">{t('home.loading')}</p>}
|
||||||
|
{error && <p className="text-danger">{error}</p>}
|
||||||
|
{!loading && forumTree.length === 0 && (
|
||||||
|
<p className="bb-muted">{t('home.empty')}</p>
|
||||||
|
)}
|
||||||
|
{forumTree.length > 0 && (
|
||||||
|
<div className="bb-board-index">
|
||||||
|
{forumTree.map((category) => (
|
||||||
|
<section className="bb-board-section" key={category.id}>
|
||||||
|
<header className="bb-board-section__header">
|
||||||
|
<span className="bb-board-section__title">{category.name}</span>
|
||||||
|
<div className="bb-board-section__controls">
|
||||||
|
<div className="bb-board-section__cols">
|
||||||
|
<span>{t('portal.topic')}</span>
|
||||||
|
<span>{t('thread.views')}</span>
|
||||||
|
<span>{t('thread.last_post')}</span>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="bb-board-toggle"
|
||||||
|
onClick={() =>
|
||||||
|
setCollapsed((prev) => {
|
||||||
|
const next = {
|
||||||
|
...prev,
|
||||||
|
[category.id]: !prev[category.id],
|
||||||
|
}
|
||||||
|
const collapsedIds = Object.keys(next).filter((key) => next[key])
|
||||||
|
localStorage.setItem(storageKey, JSON.stringify(collapsedIds))
|
||||||
|
if (token) {
|
||||||
|
if (saveTimer.current) {
|
||||||
|
clearTimeout(saveTimer.current)
|
||||||
|
}
|
||||||
|
saveTimer.current = setTimeout(() => {
|
||||||
|
saveUserSetting(collapsedKey, collapsedIds).catch(() => {})
|
||||||
|
}, 400)
|
||||||
|
}
|
||||||
|
return next
|
||||||
|
})
|
||||||
|
}
|
||||||
|
aria-label={
|
||||||
|
collapsed[category.id]
|
||||||
|
? t('forum.expand_category')
|
||||||
|
: t('forum.collapse_category')
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
className={`bi ${
|
||||||
|
collapsed[category.id] ? 'bi-plus-square' : 'bi-dash-square'
|
||||||
|
}`}
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
{!collapsed[category.id] && (
|
||||||
|
<div className="bb-board-section__body">
|
||||||
|
{category.children?.length > 0 ? (
|
||||||
|
renderRows(category.children)
|
||||||
|
) : (
|
||||||
|
<div className="bb-board-empty">{t('forum.empty_children')}</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Container>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { Button, Card, Col, Container, Form, Row } from 'react-bootstrap'
|
import { Button, Badge, Card, Col, Container, Form, Modal, Row } from 'react-bootstrap'
|
||||||
import { Link, useParams } from 'react-router-dom'
|
import { Link, useParams } from 'react-router-dom'
|
||||||
import { createThread, getForum, listForumsByParent, listThreadsByForum } from '../api/client'
|
import { createThread, getForum, listForumsByParent, listThreadsByForum } from '../api/client'
|
||||||
|
import PortalTopicRow from '../components/PortalTopicRow'
|
||||||
import { useAuth } from '../context/AuthContext'
|
import { useAuth } from '../context/AuthContext'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
@@ -13,11 +14,52 @@ export default function ForumView() {
|
|||||||
const [threads, setThreads] = useState([])
|
const [threads, setThreads] = useState([])
|
||||||
const [error, setError] = useState('')
|
const [error, setError] = useState('')
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
|
const [showModal, setShowModal] = useState(false)
|
||||||
const [title, setTitle] = useState('')
|
const [title, setTitle] = useState('')
|
||||||
const [body, setBody] = useState('')
|
const [body, setBody] = useState('')
|
||||||
const [saving, setSaving] = useState(false)
|
const [saving, setSaving] = useState(false)
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
|
const renderChildRows = (nodes) =>
|
||||||
|
nodes.map((node) => (
|
||||||
|
<div className="bb-board-row" key={node.id}>
|
||||||
|
<div className="bb-board-cell bb-board-cell--title">
|
||||||
|
<div className="bb-board-title">
|
||||||
|
<span className="bb-board-icon" aria-hidden="true">
|
||||||
|
<i className={`bi ${node.type === 'category' ? 'bi-folder2' : 'bi-chat-left-text'}`} />
|
||||||
|
</span>
|
||||||
|
<div>
|
||||||
|
<Link to={`/forum/${node.id}`} className="bb-board-link">
|
||||||
|
{node.name}
|
||||||
|
</Link>
|
||||||
|
<div className="bb-board-desc">{node.description || ''}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="bb-board-cell bb-board-cell--topics">{node.threads_count ?? 0}</div>
|
||||||
|
<div className="bb-board-cell bb-board-cell--posts">{node.views_count ?? 0}</div>
|
||||||
|
<div className="bb-board-cell bb-board-cell--last">
|
||||||
|
{node.last_post_at ? (
|
||||||
|
<div className="bb-board-last">
|
||||||
|
<span className="bb-board-last-by">
|
||||||
|
{t('thread.by')}{' '}
|
||||||
|
{node.last_post_user_id ? (
|
||||||
|
<Link to={`/profile/${node.last_post_user_id}`} className="bb-board-last-link">
|
||||||
|
{node.last_post_user_name || t('thread.anonymous')}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<span>{node.last_post_user_name || t('thread.anonymous')}</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
<span className="bb-board-last-date">{node.last_post_at.slice(0, 10)}</span>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<span className="bb-muted">{t('thread.no_replies')}</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let active = true
|
let active = true
|
||||||
|
|
||||||
@@ -62,6 +104,7 @@ export default function ForumView() {
|
|||||||
setBody('')
|
setBody('')
|
||||||
const updated = await listThreadsByForum(id)
|
const updated = await listThreadsByForum(id)
|
||||||
setThreads(updated)
|
setThreads(updated)
|
||||||
|
setShowModal(false)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err.message)
|
setError(err.message)
|
||||||
} finally {
|
} finally {
|
||||||
@@ -70,74 +113,99 @@ export default function ForumView() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container className="py-5">
|
<Container fluid className="py-5 bb-shell-container">
|
||||||
{loading && <p className="bb-muted">{t('forum.loading')}</p>}
|
{loading && <p className="bb-muted">{t('forum.loading')}</p>}
|
||||||
{error && <p className="text-danger">{error}</p>}
|
{error && <p className="text-danger">{error}</p>}
|
||||||
{forum && (
|
{forum && (
|
||||||
<>
|
<>
|
||||||
<div className="bb-hero mb-4">
|
|
||||||
<p className="bb-chip">
|
|
||||||
{forum.type === 'forum' ? t('forum.type_forum') : t('forum.type_category')}
|
|
||||||
</p>
|
|
||||||
<h2 className="mt-3">{forum.name}</h2>
|
|
||||||
<p className="bb-muted mb-0">
|
|
||||||
{forum.description || t('forum.no_description')}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Row className="g-4">
|
<Row className="g-4">
|
||||||
<Col lg={7}>
|
<Col lg={12}>
|
||||||
<h4 className="bb-section-title mb-3">{t('forum.children')}</h4>
|
{forum.type !== 'forum' && (
|
||||||
{children.length === 0 && (
|
<div className="bb-board-index">
|
||||||
<p className="bb-muted">{t('forum.empty_children')}</p>
|
<section className="bb-board-section">
|
||||||
|
<header className="bb-board-section__header">
|
||||||
|
<span className="bb-board-section__title">{forum.name}</span>
|
||||||
|
<div className="bb-board-section__cols">
|
||||||
|
<span>{t('portal.topic')}</span>
|
||||||
|
<span>{t('thread.views')}</span>
|
||||||
|
<span>{t('thread.last_post')}</span>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div className="bb-board-section__body">
|
||||||
|
{children.length > 0 ? (
|
||||||
|
renderChildRows(children)
|
||||||
|
) : (
|
||||||
|
<div className="bb-board-empty">{t('forum.empty_children')}</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
{children.map((child) => (
|
|
||||||
<Card className="bb-card mb-3" key={child.id}>
|
|
||||||
<Card.Body>
|
|
||||||
<Card.Title>{child.name}</Card.Title>
|
|
||||||
<Card.Text className="bb-muted">
|
|
||||||
{child.description || t('forum.no_description')}
|
|
||||||
</Card.Text>
|
|
||||||
<Link to={`/forum/${child.id}`} className="stretched-link">
|
|
||||||
{t('forum.open')}
|
|
||||||
</Link>
|
|
||||||
</Card.Body>
|
|
||||||
</Card>
|
|
||||||
))}
|
|
||||||
|
|
||||||
{forum.type === 'forum' && (
|
{forum.type === 'forum' && (
|
||||||
<>
|
<>
|
||||||
<h4 className="bb-section-title mb-3 mt-4">{t('forum.threads')}</h4>
|
<div className="bb-topic-toolbar mt-4 mb-2">
|
||||||
|
<div className="bb-topic-toolbar__left">
|
||||||
|
<Button
|
||||||
|
variant="dark"
|
||||||
|
className="bb-topic-action bb-accent-button"
|
||||||
|
onClick={() => setShowModal(true)}
|
||||||
|
disabled={!token || saving}
|
||||||
|
>
|
||||||
|
<i className="bi bi-pencil me-2" aria-hidden="true" />
|
||||||
|
{t('forum.start_thread')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className="bb-topic-toolbar__right">
|
||||||
|
<span className="bb-topic-count">
|
||||||
|
{threads.length} {t('forum.threads').toLowerCase()}
|
||||||
|
</span>
|
||||||
|
<div className="bb-topic-pagination">
|
||||||
|
<Button size="sm" variant="outline-secondary" disabled>
|
||||||
|
‹
|
||||||
|
</Button>
|
||||||
|
<Button size="sm" variant="outline-secondary" className="is-active" disabled>
|
||||||
|
1
|
||||||
|
</Button>
|
||||||
|
<Button size="sm" variant="outline-secondary" disabled>
|
||||||
|
›
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{!token && <p className="bb-muted mb-3">{t('forum.login_hint')}</p>}
|
||||||
|
<div className="bb-portal-topic-table">
|
||||||
|
<div className="bb-portal-topic-header">
|
||||||
|
<span>{t('portal.topic')}</span>
|
||||||
|
<span>{t('thread.replies')}</span>
|
||||||
|
<span>{t('thread.views')}</span>
|
||||||
|
<span>{t('thread.last_post')}</span>
|
||||||
|
</div>
|
||||||
{threads.length === 0 && (
|
{threads.length === 0 && (
|
||||||
<p className="bb-muted">{t('forum.empty_threads')}</p>
|
<div className="bb-topic-empty">{t('forum.empty_threads')}</div>
|
||||||
)}
|
)}
|
||||||
{threads.map((thread) => (
|
{threads.map((thread) => (
|
||||||
<Card className="bb-card mb-3" key={thread.id}>
|
<PortalTopicRow
|
||||||
<Card.Body>
|
key={thread.id}
|
||||||
<Card.Title>{thread.title}</Card.Title>
|
thread={thread}
|
||||||
<Card.Text className="bb-muted">
|
forumName={forum?.name || t('portal.unknown_forum')}
|
||||||
{thread.body.length > 160
|
forumId={forum?.id}
|
||||||
? `${thread.body.slice(0, 160)}...`
|
showForum={false}
|
||||||
: thread.body}
|
/>
|
||||||
</Card.Text>
|
|
||||||
<Link to={`/thread/${thread.id}`} className="stretched-link">
|
|
||||||
{t('thread.view')}
|
|
||||||
</Link>
|
|
||||||
</Card.Body>
|
|
||||||
</Card>
|
|
||||||
))}
|
))}
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
<Col lg={5}>
|
</Row>
|
||||||
<h4 className="bb-section-title mb-3">{t('forum.start_thread')}</h4>
|
</>
|
||||||
<div className="bb-form">
|
|
||||||
{forum.type !== 'forum' && (
|
|
||||||
<p className="bb-muted mb-3">{t('forum.only_forums')}</p>
|
|
||||||
)}
|
|
||||||
{forum.type === 'forum' && !token && (
|
|
||||||
<p className="bb-muted mb-3">{t('forum.login_hint')}</p>
|
|
||||||
)}
|
)}
|
||||||
|
{forum?.type === 'forum' && (
|
||||||
|
<Modal show={showModal} onHide={() => setShowModal(false)} centered size="lg">
|
||||||
|
<Modal.Header closeButton>
|
||||||
|
<Modal.Title>{t('forum.start_thread')}</Modal.Title>
|
||||||
|
</Modal.Header>
|
||||||
|
<Modal.Body>
|
||||||
|
{!token && <p className="bb-muted mb-3">{t('forum.login_hint')}</p>}
|
||||||
<Form onSubmit={handleSubmit}>
|
<Form onSubmit={handleSubmit}>
|
||||||
<Form.Group className="mb-3">
|
<Form.Group className="mb-3">
|
||||||
<Form.Label>{t('form.title')}</Form.Label>
|
<Form.Label>{t('form.title')}</Form.Label>
|
||||||
@@ -146,7 +214,7 @@ export default function ForumView() {
|
|||||||
placeholder={t('form.thread_title_placeholder')}
|
placeholder={t('form.thread_title_placeholder')}
|
||||||
value={title}
|
value={title}
|
||||||
onChange={(event) => setTitle(event.target.value)}
|
onChange={(event) => setTitle(event.target.value)}
|
||||||
disabled={!token || saving || forum.type !== 'forum'}
|
disabled={!token || saving}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
@@ -154,26 +222,25 @@ export default function ForumView() {
|
|||||||
<Form.Label>{t('form.body')}</Form.Label>
|
<Form.Label>{t('form.body')}</Form.Label>
|
||||||
<Form.Control
|
<Form.Control
|
||||||
as="textarea"
|
as="textarea"
|
||||||
rows={5}
|
rows={6}
|
||||||
placeholder={t('form.thread_body_placeholder')}
|
placeholder={t('form.thread_body_placeholder')}
|
||||||
value={body}
|
value={body}
|
||||||
onChange={(event) => setBody(event.target.value)}
|
onChange={(event) => setBody(event.target.value)}
|
||||||
disabled={!token || saving || forum.type !== 'forum'}
|
disabled={!token || saving}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
<Button
|
<div className="d-flex gap-2 justify-content-between">
|
||||||
type="submit"
|
<Button type="button" variant="outline-secondary" onClick={() => setShowModal(false)}>
|
||||||
variant="dark"
|
{t('acp.cancel')}
|
||||||
disabled={!token || saving || forum.type !== 'forum'}
|
</Button>
|
||||||
>
|
<Button type="submit" className="bb-accent-button" disabled={!token || saving}>
|
||||||
{saving ? t('form.posting') : t('form.create_thread')}
|
{saving ? t('form.posting') : t('form.create_thread')}
|
||||||
</Button>
|
</Button>
|
||||||
</Form>
|
|
||||||
</div>
|
</div>
|
||||||
</Col>
|
</Form>
|
||||||
</Row>
|
</Modal.Body>
|
||||||
</>
|
</Modal>
|
||||||
)}
|
)}
|
||||||
</Container>
|
</Container>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,21 +1,61 @@
|
|||||||
import { useEffect, useMemo, useState } from 'react'
|
import { useEffect, useMemo, useState } from 'react'
|
||||||
import { Container } from 'react-bootstrap'
|
import { Container } from 'react-bootstrap'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
import { listAllForums } from '../api/client'
|
import { fetchPortalSummary } from '../api/client'
|
||||||
|
import PortalTopicRow from '../components/PortalTopicRow'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { useAuth } from '../context/AuthContext'
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const [forums, setForums] = useState([])
|
const [forums, setForums] = useState([])
|
||||||
|
const [threads, setThreads] = useState([])
|
||||||
|
const [stats, setStats] = useState({ threads: 0, posts: 0, users: 0 })
|
||||||
const [error, setError] = useState('')
|
const [error, setError] = useState('')
|
||||||
const [loading, setLoading] = useState(true)
|
const [loadingForums, setLoadingForums] = useState(true)
|
||||||
|
const [loadingThreads, setLoadingThreads] = useState(true)
|
||||||
|
const [loadingStats, setLoadingStats] = useState(true)
|
||||||
|
const [profile, setProfile] = useState(null)
|
||||||
|
const { token, roles, email } = useAuth()
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
listAllForums()
|
let active = true
|
||||||
.then(setForums)
|
setLoadingForums(true)
|
||||||
.catch((err) => setError(err.message))
|
setLoadingThreads(true)
|
||||||
.finally(() => setLoading(false))
|
setLoadingStats(true)
|
||||||
}, [])
|
setError('')
|
||||||
|
|
||||||
|
fetchPortalSummary()
|
||||||
|
.then((data) => {
|
||||||
|
if (!active) return
|
||||||
|
setForums(data?.forums || [])
|
||||||
|
setThreads(data?.threads || [])
|
||||||
|
setStats({
|
||||||
|
threads: data?.stats?.threads ?? 0,
|
||||||
|
posts: data?.stats?.posts ?? 0,
|
||||||
|
users: data?.stats?.users ?? 0,
|
||||||
|
})
|
||||||
|
setProfile(data?.profile || null)
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
if (!active) return
|
||||||
|
setError(err.message)
|
||||||
|
setForums([])
|
||||||
|
setThreads([])
|
||||||
|
setStats({ threads: 0, posts: 0, users: 0 })
|
||||||
|
setProfile(null)
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
if (!active) return
|
||||||
|
setLoadingForums(false)
|
||||||
|
setLoadingThreads(false)
|
||||||
|
setLoadingStats(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
active = false
|
||||||
|
}
|
||||||
|
}, [token])
|
||||||
|
|
||||||
const getParentId = (forum) => {
|
const getParentId = (forum) => {
|
||||||
if (!forum.parent) return null
|
if (!forum.parent) return null
|
||||||
@@ -56,6 +96,40 @@ export default function Home() {
|
|||||||
return roots
|
return roots
|
||||||
}, [forums])
|
}, [forums])
|
||||||
|
|
||||||
|
const forumMap = useMemo(() => {
|
||||||
|
const map = new Map()
|
||||||
|
forums.forEach((forum) => {
|
||||||
|
map.set(String(forum.id), forum)
|
||||||
|
})
|
||||||
|
return map
|
||||||
|
}, [forums])
|
||||||
|
|
||||||
|
const recentThreads = useMemo(() => {
|
||||||
|
return [...threads]
|
||||||
|
.sort((a, b) => new Date(b.created_at) - new Date(a.created_at))
|
||||||
|
.slice(0, 12)
|
||||||
|
}, [threads])
|
||||||
|
|
||||||
|
const roleLabel = useMemo(() => {
|
||||||
|
if (!roles?.length) return t('portal.user_role_member')
|
||||||
|
if (roles.includes('ROLE_ADMIN')) return t('portal.user_role_operator')
|
||||||
|
if (roles.includes('ROLE_MODERATOR')) return t('portal.user_role_moderator')
|
||||||
|
return t('portal.user_role_member')
|
||||||
|
}, [roles, t])
|
||||||
|
|
||||||
|
const resolveForumName = (thread) => {
|
||||||
|
if (!thread?.forum) return t('portal.unknown_forum')
|
||||||
|
const parts = thread.forum.split('/')
|
||||||
|
const id = parts[parts.length - 1]
|
||||||
|
return forumMap.get(String(id))?.name || t('portal.unknown_forum')
|
||||||
|
}
|
||||||
|
|
||||||
|
const resolveForumId = (thread) => {
|
||||||
|
if (!thread?.forum) return null
|
||||||
|
const parts = thread.forum.split('/')
|
||||||
|
return parts[parts.length - 1] || null
|
||||||
|
}
|
||||||
|
|
||||||
const renderTree = (nodes, depth = 0) =>
|
const renderTree = (nodes, depth = 0) =>
|
||||||
nodes.map((node) => (
|
nodes.map((node) => (
|
||||||
<div key={node.id}>
|
<div key={node.id}>
|
||||||
@@ -71,7 +145,7 @@ export default function Home() {
|
|||||||
<Link to={`/forum/${node.id}`} className="bb-forum-link fw-semibold">
|
<Link to={`/forum/${node.id}`} className="bb-forum-link fw-semibold">
|
||||||
{node.name}
|
{node.name}
|
||||||
</Link>
|
</Link>
|
||||||
<div className="bb-muted">{node.description || t('forum.no_description')}</div>
|
<div className="bb-muted">{node.description || ''}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -82,22 +156,99 @@ export default function Home() {
|
|||||||
))
|
))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container className="py-5">
|
<Container fluid className="pb-4 bb-portal-shell">
|
||||||
<div className="bb-hero mb-4">
|
<div className="bb-portal-layout">
|
||||||
<p className="bb-chip">{t('app.brand')}</p>
|
<aside className="bb-portal-column bb-portal-column--left">
|
||||||
<h1 className="mt-3">{t('home.hero_title')}</h1>
|
<div className="bb-portal-card">
|
||||||
<p className="bb-muted mb-0">
|
<div className="bb-portal-card-title">{t('portal.menu')}</div>
|
||||||
{t('home.hero_body')}
|
<ul className="bb-portal-list">
|
||||||
</p>
|
<li>{t('portal.menu_news')}</li>
|
||||||
|
<li>{t('portal.menu_gallery')}</li>
|
||||||
|
<li>{t('portal.menu_calendar')}</li>
|
||||||
|
<li>{t('portal.menu_rules')}</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="bb-portal-card">
|
||||||
|
<div className="bb-portal-card-title">{t('portal.stats')}</div>
|
||||||
|
<div className="bb-portal-stat">
|
||||||
|
<span>{t('portal.stat_threads')}</span>
|
||||||
|
<strong>{loadingStats ? '—' : stats.threads}</strong>
|
||||||
|
</div>
|
||||||
|
<div className="bb-portal-stat">
|
||||||
|
<span>{t('portal.stat_users')}</span>
|
||||||
|
<strong>{loadingStats ? '—' : stats.users}</strong>
|
||||||
|
</div>
|
||||||
|
<div className="bb-portal-stat">
|
||||||
|
<span>{t('portal.stat_posts')}</span>
|
||||||
|
<strong>{loadingStats ? '—' : stats.posts}</strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
|
||||||
<h3 className="bb-section-title mb-3">{t('home.browse')}</h3>
|
<main className="bb-portal-column bb-portal-column--center">
|
||||||
{loading && <p className="bb-muted">{t('home.loading')}</p>}
|
<div className="bb-portal-card">
|
||||||
{error && <p className="text-danger">{error}</p>}
|
<div className="bb-portal-card-title">{t('portal.latest_posts')}</div>
|
||||||
{!loading && forumTree.length === 0 && (
|
{loadingThreads && <p className="bb-muted">{t('home.loading')}</p>}
|
||||||
<p className="bb-muted">{t('home.empty')}</p>
|
{!loadingThreads && recentThreads.length === 0 && (
|
||||||
|
<p className="bb-muted">{t('portal.empty_posts')}</p>
|
||||||
)}
|
)}
|
||||||
{forumTree.length > 0 && <div className="mt-2">{renderTree(forumTree)}</div>}
|
{!loadingThreads && recentThreads.length > 0 && (
|
||||||
|
<div className="bb-portal-topic-table">
|
||||||
|
<div className="bb-portal-topic-header">
|
||||||
|
<span>{t('portal.topic')}</span>
|
||||||
|
<span>{t('thread.replies')}</span>
|
||||||
|
<span>{t('thread.views')}</span>
|
||||||
|
<span>{t('thread.last_post')}</span>
|
||||||
|
</div>
|
||||||
|
{recentThreads.map((thread) => (
|
||||||
|
<PortalTopicRow
|
||||||
|
key={thread.id}
|
||||||
|
thread={thread}
|
||||||
|
forumName={resolveForumName(thread)}
|
||||||
|
forumId={resolveForumId(thread)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<aside className="bb-portal-column bb-portal-column--right">
|
||||||
|
<div className="bb-portal-card">
|
||||||
|
<div className="bb-portal-card-title">{t('portal.user_menu')}</div>
|
||||||
|
<div className="bb-portal-user-card">
|
||||||
|
<Link to="/ucp" className="bb-portal-user-avatar">
|
||||||
|
{profile?.avatar_url ? (
|
||||||
|
<img src={profile.avatar_url} alt="" />
|
||||||
|
) : (
|
||||||
|
<i className="bi bi-person" aria-hidden="true" />
|
||||||
|
)}
|
||||||
|
</Link>
|
||||||
|
<div className="bb-portal-user-name">
|
||||||
|
{profile?.id ? (
|
||||||
|
<Link to={`/profile/${profile.id}`} className="bb-portal-user-name-link">
|
||||||
|
{profile?.name || email || 'User'}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
profile?.name || email || 'User'
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="bb-portal-user-role">{roleLabel}</div>
|
||||||
|
</div>
|
||||||
|
<ul className="bb-portal-list">
|
||||||
|
<li>{t('portal.user_new_posts')}</li>
|
||||||
|
<li>{t('portal.user_unread')}</li>
|
||||||
|
<li>{t('portal.user_control_panel')}</li>
|
||||||
|
<li>{t('portal.user_logout')}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div className="bb-portal-card bb-portal-card--ad">
|
||||||
|
<div className="bb-portal-card-title">{t('portal.advertisement')}</div>
|
||||||
|
<div className="bb-portal-ad-box">example.com</div>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
</div>
|
||||||
|
{error && <p className="text-danger mt-3">{error}</p>}
|
||||||
</Container>
|
</Container>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next'
|
|||||||
export default function Login() {
|
export default function Login() {
|
||||||
const { login } = useAuth()
|
const { login } = useAuth()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const [email, setEmail] = useState('')
|
const [loginValue, setLoginValue] = useState('')
|
||||||
const [password, setPassword] = useState('')
|
const [password, setPassword] = useState('')
|
||||||
const [error, setError] = useState('')
|
const [error, setError] = useState('')
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
@@ -18,7 +18,7 @@ export default function Login() {
|
|||||||
setError('')
|
setError('')
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
try {
|
try {
|
||||||
await login(email, password)
|
await login(loginValue, password)
|
||||||
navigate('/')
|
navigate('/')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err.message)
|
setError(err.message)
|
||||||
@@ -28,7 +28,7 @@ export default function Login() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container className="py-5">
|
<Container fluid className="py-5">
|
||||||
<Card className="bb-card mx-auto" style={{ maxWidth: '480px' }}>
|
<Card className="bb-card mx-auto" style={{ maxWidth: '480px' }}>
|
||||||
<Card.Body>
|
<Card.Body>
|
||||||
<Card.Title className="mb-3">{t('auth.login_title')}</Card.Title>
|
<Card.Title className="mb-3">{t('auth.login_title')}</Card.Title>
|
||||||
@@ -36,11 +36,12 @@ export default function Login() {
|
|||||||
{error && <p className="text-danger">{error}</p>}
|
{error && <p className="text-danger">{error}</p>}
|
||||||
<Form onSubmit={handleSubmit}>
|
<Form onSubmit={handleSubmit}>
|
||||||
<Form.Group className="mb-3">
|
<Form.Group className="mb-3">
|
||||||
<Form.Label>{t('form.email')}</Form.Label>
|
<Form.Label>{t('auth.login_identifier')}</Form.Label>
|
||||||
<Form.Control
|
<Form.Control
|
||||||
type="email"
|
type="text"
|
||||||
value={email}
|
value={loginValue}
|
||||||
onChange={(event) => setEmail(event.target.value)}
|
onChange={(event) => setLoginValue(event.target.value)}
|
||||||
|
placeholder={t('auth.login_placeholder')}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
|
|||||||
65
resources/js/pages/Profile.jsx
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
import { Container } from 'react-bootstrap'
|
||||||
|
import { useParams } from 'react-router-dom'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { getUserProfile } from '../api/client'
|
||||||
|
|
||||||
|
export default function Profile() {
|
||||||
|
const { id } = useParams()
|
||||||
|
const { t } = useTranslation()
|
||||||
|
const [profile, setProfile] = useState(null)
|
||||||
|
const [error, setError] = useState('')
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let active = true
|
||||||
|
setLoading(true)
|
||||||
|
setError('')
|
||||||
|
|
||||||
|
getUserProfile(id)
|
||||||
|
.then((data) => {
|
||||||
|
if (!active) return
|
||||||
|
setProfile(data)
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
if (!active) return
|
||||||
|
setError(err.message)
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
if (active) setLoading(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
active = false
|
||||||
|
}
|
||||||
|
}, [id])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container fluid className="py-5 bb-portal-shell">
|
||||||
|
<div className="bb-portal-card">
|
||||||
|
<div className="bb-portal-card-title">{t('profile.title')}</div>
|
||||||
|
{loading && <p className="bb-muted">{t('profile.loading')}</p>}
|
||||||
|
{error && <p className="text-danger">{error}</p>}
|
||||||
|
{profile && (
|
||||||
|
<div className="bb-profile">
|
||||||
|
<div className="bb-profile-avatar">
|
||||||
|
{profile.avatar_url ? (
|
||||||
|
<img src={profile.avatar_url} alt="" />
|
||||||
|
) : (
|
||||||
|
<i className="bi bi-person" aria-hidden="true" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="bb-profile-meta">
|
||||||
|
<div className="bb-profile-name">{profile.name}</div>
|
||||||
|
{profile.created_at && (
|
||||||
|
<div className="bb-muted">
|
||||||
|
{t('profile.registered')} {profile.created_at.slice(0, 10)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</Container>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -33,7 +33,7 @@ export default function Register() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container className="py-5">
|
<Container fluid className="py-5">
|
||||||
<Card className="bb-card mx-auto" style={{ maxWidth: '520px' }}>
|
<Card className="bb-card mx-auto" style={{ maxWidth: '520px' }}>
|
||||||
<Card.Body>
|
<Card.Body>
|
||||||
<Card.Title className="mb-3">{t('auth.register_title')}</Card.Title>
|
<Card.Title className="mb-3">{t('auth.register_title')}</Card.Title>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { Button, Card, Col, Container, Form, Row } from 'react-bootstrap'
|
import { Button, Container, Form } from 'react-bootstrap'
|
||||||
import { Link, useParams } from 'react-router-dom'
|
import { Link, useParams } from 'react-router-dom'
|
||||||
import { createPost, getThread, listPostsByThread } from '../api/client'
|
import { createPost, getThread, listPostsByThread } from '../api/client'
|
||||||
import { useAuth } from '../context/AuthContext'
|
import { useAuth } from '../context/AuthContext'
|
||||||
@@ -15,6 +15,7 @@ export default function ThreadView() {
|
|||||||
const [body, setBody] = useState('')
|
const [body, setBody] = useState('')
|
||||||
const [saving, setSaving] = useState(false)
|
const [saving, setSaving] = useState(false)
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
const replyRef = useRef(null)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
@@ -27,6 +28,18 @@ export default function ThreadView() {
|
|||||||
.finally(() => setLoading(false))
|
.finally(() => setLoading(false))
|
||||||
}, [id])
|
}, [id])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!thread && posts.length === 0) return
|
||||||
|
const hash = window.location.hash
|
||||||
|
if (!hash) return
|
||||||
|
const targetId = hash.replace('#', '')
|
||||||
|
if (!targetId) return
|
||||||
|
const target = document.getElementById(targetId)
|
||||||
|
if (target) {
|
||||||
|
target.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||||||
|
}
|
||||||
|
}, [thread, posts])
|
||||||
|
|
||||||
const handleSubmit = async (event) => {
|
const handleSubmit = async (event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
setSaving(true)
|
setSaving(true)
|
||||||
@@ -43,46 +56,198 @@ export default function ThreadView() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const replyCount = posts.length
|
||||||
|
const formatDate = (value) => {
|
||||||
|
if (!value) return '—'
|
||||||
|
const date = new Date(value)
|
||||||
|
if (Number.isNaN(date.getTime())) return '—'
|
||||||
|
const day = String(date.getDate()).padStart(2, '0')
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||||
|
const year = String(date.getFullYear())
|
||||||
|
return `${day}.${month}.${year}`
|
||||||
|
}
|
||||||
|
const allPosts = useMemo(() => {
|
||||||
|
if (!thread) return posts
|
||||||
|
const rootPost = {
|
||||||
|
id: `thread-${thread.id}`,
|
||||||
|
body: thread.body,
|
||||||
|
created_at: thread.created_at,
|
||||||
|
user_name: thread.user_name,
|
||||||
|
user_avatar_url: thread.user_avatar_url,
|
||||||
|
user_posts_count: thread.user_posts_count,
|
||||||
|
user_created_at: thread.user_created_at,
|
||||||
|
user_location: thread.user_location,
|
||||||
|
user_rank_name: thread.user_rank_name,
|
||||||
|
user_rank_badge_type: thread.user_rank_badge_type,
|
||||||
|
user_rank_badge_text: thread.user_rank_badge_text,
|
||||||
|
user_rank_badge_url: thread.user_rank_badge_url,
|
||||||
|
isRoot: true,
|
||||||
|
}
|
||||||
|
return [rootPost, ...posts]
|
||||||
|
}, [posts, thread])
|
||||||
|
|
||||||
|
const handleJumpToReply = () => {
|
||||||
|
replyRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||||||
|
}
|
||||||
|
|
||||||
|
const totalPosts = allPosts.length
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container className="py-5">
|
<Container fluid className="py-4 bb-shell-container">
|
||||||
{loading && <p className="bb-muted">{t('thread.loading')}</p>}
|
{loading && <p className="bb-muted">{t('thread.loading')}</p>}
|
||||||
{error && <p className="text-danger">{error}</p>}
|
{error && <p className="text-danger">{error}</p>}
|
||||||
{thread && (
|
{thread && (
|
||||||
<>
|
<div className="bb-thread">
|
||||||
<div className="bb-hero mb-4">
|
<div className="bb-thread-titlebar">
|
||||||
<p className="bb-chip">{t('thread.label')}</p>
|
<h1 className="bb-thread-title">{thread.title}</h1>
|
||||||
<h2 className="mt-3">{thread.title}</h2>
|
<div className="bb-thread-meta">
|
||||||
<p className="bb-muted mb-2">{thread.body}</p>
|
<span>{t('thread.by')}</span>
|
||||||
{thread.forum && (
|
<span className="bb-thread-author">
|
||||||
<p className="bb-muted mb-0">
|
{thread.user_name || t('thread.anonymous')}
|
||||||
{t('thread.category')}{' '}
|
</span>
|
||||||
<Link to={`/forum/${thread.forum.id || thread.forum.split('/').pop()}`}>
|
{thread.created_at && (
|
||||||
{thread.forum.name || t('thread.back_to_category')}
|
<span className="bb-thread-date">{thread.created_at.slice(0, 10)}</span>
|
||||||
</Link>
|
|
||||||
</p>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Row className="g-4">
|
<div className="bb-thread-toolbar">
|
||||||
<Col lg={7}>
|
<div className="bb-thread-actions">
|
||||||
<h4 className="bb-section-title mb-3">{t('thread.replies')}</h4>
|
<Button className="bb-accent-button" onClick={handleJumpToReply}>
|
||||||
{posts.length === 0 && (
|
<i className="bi bi-reply-fill" aria-hidden="true" />
|
||||||
<p className="bb-muted">{t('thread.empty')}</p>
|
<span>{t('form.post_reply')}</span>
|
||||||
|
</Button>
|
||||||
|
<button type="button" className="bb-thread-icon-button" aria-label={t('thread.reply')}>
|
||||||
|
<i className="bi bi-arrow-counterclockwise" aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
<button type="button" className="bb-thread-icon-button" aria-label={t('thread.views')}>
|
||||||
|
<i className="bi bi-wrench" aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
<button type="button" className="bb-thread-icon-button" aria-label={t('thread.last_post')}>
|
||||||
|
<i className="bi bi-gear" aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="bb-thread-meta-right">
|
||||||
|
<span>{totalPosts} {totalPosts === 1 ? 'post' : 'posts'}</span>
|
||||||
|
<span>•</span>
|
||||||
|
<span>Page 1 of 1</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="bb-posts">
|
||||||
|
{allPosts.map((post, index) => {
|
||||||
|
const authorName = post.author?.username
|
||||||
|
|| post.user_name
|
||||||
|
|| post.author_name
|
||||||
|
|| t('thread.anonymous')
|
||||||
|
const topicLabel = thread?.title
|
||||||
|
? post.isRoot
|
||||||
|
? thread.title
|
||||||
|
: `${t('thread.reply_prefix')} ${thread.title}`
|
||||||
|
: ''
|
||||||
|
const postNumber = index + 1
|
||||||
|
|
||||||
|
return (
|
||||||
|
<article className="bb-post-row" key={post.id} id={`post-${post.id}`}>
|
||||||
|
<aside className="bb-post-author">
|
||||||
|
<div className="bb-post-avatar">
|
||||||
|
{post.user_avatar_url ? (
|
||||||
|
<img src={post.user_avatar_url} alt="" />
|
||||||
|
) : (
|
||||||
|
<i className="bi bi-person" aria-hidden="true" />
|
||||||
)}
|
)}
|
||||||
{posts.map((post) => (
|
</div>
|
||||||
<Card className="bb-card mb-3" key={post.id}>
|
<div className="bb-post-author-name">{authorName}</div>
|
||||||
<Card.Body>
|
<div className="bb-post-author-role">
|
||||||
<Card.Text>{post.body}</Card.Text>
|
{post.user_rank_name || ''}
|
||||||
<small className="bb-muted">
|
</div>
|
||||||
{post.author?.username || t('thread.anonymous')}
|
{(post.user_rank_badge_text || post.user_rank_badge_url) && (
|
||||||
</small>
|
<div className="bb-post-author-badge">
|
||||||
</Card.Body>
|
{post.user_rank_badge_type === 'image' && post.user_rank_badge_url ? (
|
||||||
</Card>
|
<img src={post.user_rank_badge_url} alt="" />
|
||||||
))}
|
) : (
|
||||||
</Col>
|
<span>{post.user_rank_badge_text}</span>
|
||||||
<Col lg={5}>
|
)}
|
||||||
<h4 className="bb-section-title mb-3">{t('thread.reply')}</h4>
|
</div>
|
||||||
<div className="bb-form">
|
)}
|
||||||
|
<div className="bb-post-author-meta">
|
||||||
|
<div className="bb-post-author-stat">
|
||||||
|
<span className="bb-post-author-label">{t('thread.posts')}:</span>
|
||||||
|
<span className="bb-post-author-value">
|
||||||
|
{post.user_posts_count ?? 0}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="bb-post-author-stat">
|
||||||
|
<span className="bb-post-author-label">{t('thread.registered')}:</span>
|
||||||
|
<span className="bb-post-author-value">
|
||||||
|
{formatDate(post.user_created_at)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="bb-post-author-stat">
|
||||||
|
<span className="bb-post-author-label">{t('thread.location')}:</span>
|
||||||
|
<span className="bb-post-author-value">
|
||||||
|
{post.user_location || '-'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="bb-post-author-stat">
|
||||||
|
<span className="bb-post-author-label">Thanks given:</span>
|
||||||
|
<span className="bb-post-author-value">7</span>
|
||||||
|
</div>
|
||||||
|
<div className="bb-post-author-stat">
|
||||||
|
<span className="bb-post-author-label">Thanks received:</span>
|
||||||
|
<span className="bb-post-author-value">5</span>
|
||||||
|
</div>
|
||||||
|
<div className="bb-post-author-stat bb-post-author-contact">
|
||||||
|
<span className="bb-post-author-label">Contact:</span>
|
||||||
|
<span className="bb-post-author-value">
|
||||||
|
<i className="bi bi-chat-dots" aria-hidden="true" />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
<div className="bb-post-content">
|
||||||
|
<div className="bb-post-header">
|
||||||
|
<div className="bb-post-header-meta">
|
||||||
|
{topicLabel && (
|
||||||
|
<span className="bb-post-topic">
|
||||||
|
#{postNumber} {topicLabel}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
<span>{t('thread.by')} {authorName}</span>
|
||||||
|
{post.created_at && (
|
||||||
|
<span>{post.created_at.slice(0, 10)}</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="bb-post-actions">
|
||||||
|
<button type="button" className="bb-post-action" aria-label="Edit post">
|
||||||
|
<i className="bi bi-pencil" aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
<button type="button" className="bb-post-action" aria-label="Delete post">
|
||||||
|
<i className="bi bi-x-lg" aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
<button type="button" className="bb-post-action" aria-label="Report post">
|
||||||
|
<i className="bi bi-exclamation-lg" aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
<button type="button" className="bb-post-action" aria-label="Post info">
|
||||||
|
<i className="bi bi-info-lg" aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
<button type="button" className="bb-post-action" aria-label="Quote post">
|
||||||
|
<i className="bi bi-quote" aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
<a href="/" className="bb-post-action" aria-label={t('portal.portal')}>
|
||||||
|
<i className="bi bi-house-door" aria-hidden="true" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="bb-post-body">{post.body}</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="bb-thread-reply" ref={replyRef}>
|
||||||
|
<div className="bb-thread-reply-title">{t('thread.reply')}</div>
|
||||||
{!token && (
|
{!token && (
|
||||||
<p className="bb-muted mb-3">{t('thread.login_hint')}</p>
|
<p className="bb-muted mb-3">{t('thread.login_hint')}</p>
|
||||||
)}
|
)}
|
||||||
@@ -91,7 +256,7 @@ export default function ThreadView() {
|
|||||||
<Form.Label>{t('form.message')}</Form.Label>
|
<Form.Label>{t('form.message')}</Form.Label>
|
||||||
<Form.Control
|
<Form.Control
|
||||||
as="textarea"
|
as="textarea"
|
||||||
rows={5}
|
rows={6}
|
||||||
placeholder={t('form.reply_placeholder')}
|
placeholder={t('form.reply_placeholder')}
|
||||||
value={body}
|
value={body}
|
||||||
onChange={(event) => setBody(event.target.value)}
|
onChange={(event) => setBody(event.target.value)}
|
||||||
@@ -99,14 +264,14 @@ export default function ThreadView() {
|
|||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
<Button type="submit" variant="dark" disabled={!token || saving}>
|
<div className="bb-thread-reply-actions">
|
||||||
|
<Button type="submit" className="bb-accent-button" disabled={!token || saving}>
|
||||||
{saving ? t('form.posting') : t('form.post_reply')}
|
{saving ? t('form.posting') : t('form.post_reply')}
|
||||||
</Button>
|
</Button>
|
||||||
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
</Col>
|
</div>
|
||||||
</Row>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</Container>
|
</Container>
|
||||||
)
|
)
|
||||||
|
|||||||
179
resources/js/pages/Ucp.jsx
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
import { Container, Form, Row, Col, Button } from 'react-bootstrap'
|
||||||
|
import { getCurrentUser, updateCurrentUser, uploadAvatar } from '../api/client'
|
||||||
|
import { useAuth } from '../context/AuthContext'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
|
export default function Ucp({ theme, setTheme, accentOverride, setAccentOverride }) {
|
||||||
|
const { t, i18n } = useTranslation()
|
||||||
|
const { token } = useAuth()
|
||||||
|
const accentMode = accentOverride ? 'custom' : 'system'
|
||||||
|
const [avatarError, setAvatarError] = useState('')
|
||||||
|
const [avatarUploading, setAvatarUploading] = useState(false)
|
||||||
|
const [avatarPreview, setAvatarPreview] = useState('')
|
||||||
|
const [location, setLocation] = useState('')
|
||||||
|
const [profileError, setProfileError] = useState('')
|
||||||
|
const [profileSaving, setProfileSaving] = useState(false)
|
||||||
|
const [profileSaved, setProfileSaved] = useState(false)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!token) return
|
||||||
|
let active = true
|
||||||
|
|
||||||
|
getCurrentUser()
|
||||||
|
.then((data) => {
|
||||||
|
if (!active) return
|
||||||
|
setAvatarPreview(data?.avatar_url || '')
|
||||||
|
setLocation(data?.location || '')
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
if (active) setAvatarPreview('')
|
||||||
|
})
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
active = false
|
||||||
|
}
|
||||||
|
}, [token])
|
||||||
|
|
||||||
|
const handleLanguageChange = (event) => {
|
||||||
|
const locale = event.target.value
|
||||||
|
i18n.changeLanguage(locale)
|
||||||
|
localStorage.setItem('speedbb_lang', locale)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container fluid className="py-5 bb-portal-shell">
|
||||||
|
<div className="bb-portal-card mb-4">
|
||||||
|
<div className="bb-portal-card-title">{t('ucp.profile')}</div>
|
||||||
|
<p className="bb-muted mb-4">{t('ucp.profile_hint')}</p>
|
||||||
|
<Row className="g-3 align-items-center">
|
||||||
|
<Col md="auto">
|
||||||
|
<div className="bb-avatar-preview">
|
||||||
|
{avatarPreview ? (
|
||||||
|
<img src={avatarPreview} alt="" />
|
||||||
|
) : (
|
||||||
|
<i className="bi bi-person" aria-hidden="true" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</Col>
|
||||||
|
<Col>
|
||||||
|
{avatarError && <p className="text-danger mb-2">{avatarError}</p>}
|
||||||
|
<Form.Group>
|
||||||
|
<Form.Label>{t('ucp.avatar_label')}</Form.Label>
|
||||||
|
<Form.Control
|
||||||
|
type="file"
|
||||||
|
accept="image/png,image/jpeg,image/jpg,image/gif,image/webp"
|
||||||
|
disabled={!token || avatarUploading}
|
||||||
|
onChange={async (event) => {
|
||||||
|
const file = event.target.files?.[0]
|
||||||
|
if (!file) return
|
||||||
|
setAvatarError('')
|
||||||
|
setAvatarUploading(true)
|
||||||
|
try {
|
||||||
|
const response = await uploadAvatar(file)
|
||||||
|
setAvatarPreview(response.url)
|
||||||
|
} catch (err) {
|
||||||
|
setAvatarError(err.message)
|
||||||
|
} finally {
|
||||||
|
setAvatarUploading(false)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Form.Text className="bb-muted">{t('ucp.avatar_hint')}</Form.Text>
|
||||||
|
</Form.Group>
|
||||||
|
<Form.Group className="mt-3">
|
||||||
|
<Form.Label>{t('ucp.location_label')}</Form.Label>
|
||||||
|
<Form.Control
|
||||||
|
type="text"
|
||||||
|
value={location}
|
||||||
|
disabled={!token || profileSaving}
|
||||||
|
onChange={(event) => {
|
||||||
|
setLocation(event.target.value)
|
||||||
|
setProfileSaved(false)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Form.Text className="bb-muted">{t('ucp.location_hint')}</Form.Text>
|
||||||
|
</Form.Group>
|
||||||
|
{profileError && <p className="text-danger mt-2 mb-0">{profileError}</p>}
|
||||||
|
{profileSaved && <p className="text-success mt-2 mb-0">{t('ucp.profile_saved')}</p>}
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline-light"
|
||||||
|
className="mt-3"
|
||||||
|
disabled={!token || profileSaving}
|
||||||
|
onClick={async () => {
|
||||||
|
setProfileError('')
|
||||||
|
setProfileSaved(false)
|
||||||
|
setProfileSaving(true)
|
||||||
|
try {
|
||||||
|
const response = await updateCurrentUser({ location })
|
||||||
|
setLocation(response?.location || '')
|
||||||
|
setProfileSaved(true)
|
||||||
|
} catch (err) {
|
||||||
|
setProfileError(err.message)
|
||||||
|
} finally {
|
||||||
|
setProfileSaving(false)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{profileSaving ? t('form.saving') : t('ucp.save_profile')}
|
||||||
|
</Button>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</div>
|
||||||
|
<div className="bb-portal-card">
|
||||||
|
<div className="bb-portal-card-title">{t('portal.user_control_panel')}</div>
|
||||||
|
<p className="bb-muted mb-4">{t('ucp.intro')}</p>
|
||||||
|
<Row className="g-3">
|
||||||
|
<Col xs={12}>
|
||||||
|
<Form.Group>
|
||||||
|
<Form.Label>{t('nav.language')}</Form.Label>
|
||||||
|
<Form.Select value={i18n.language} onChange={handleLanguageChange}>
|
||||||
|
<option value="en">English</option>
|
||||||
|
<option value="de">Deutsch</option>
|
||||||
|
</Form.Select>
|
||||||
|
</Form.Group>
|
||||||
|
</Col>
|
||||||
|
<Col md={6}>
|
||||||
|
<Form.Group>
|
||||||
|
<Form.Label>{t('nav.theme')}</Form.Label>
|
||||||
|
<Form.Select value={theme} onChange={(event) => setTheme(event.target.value)}>
|
||||||
|
<option value="auto">{t('ucp.system_default')}</option>
|
||||||
|
<option value="dark">{t('nav.theme_dark')}</option>
|
||||||
|
<option value="light">{t('nav.theme_light')}</option>
|
||||||
|
</Form.Select>
|
||||||
|
</Form.Group>
|
||||||
|
</Col>
|
||||||
|
<Col md={6}>
|
||||||
|
<Form.Group>
|
||||||
|
<Form.Label>{t('ucp.accent_override')}</Form.Label>
|
||||||
|
<div className="d-flex align-items-center gap-2">
|
||||||
|
<Form.Select
|
||||||
|
value={accentMode}
|
||||||
|
onChange={(event) => {
|
||||||
|
const mode = event.target.value
|
||||||
|
if (mode === 'system') {
|
||||||
|
setAccentOverride('')
|
||||||
|
} else if (!accentOverride) {
|
||||||
|
setAccentOverride('#f29b3f')
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<option value="system">{t('ucp.system_default')}</option>
|
||||||
|
<option value="custom">{t('ucp.custom_color')}</option>
|
||||||
|
</Form.Select>
|
||||||
|
<Form.Control
|
||||||
|
type="color"
|
||||||
|
value={accentOverride || '#f29b3f'}
|
||||||
|
onChange={(event) => setAccentOverride(event.target.value)}
|
||||||
|
disabled={accentMode !== 'custom'}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Form.Text className="bb-muted">{t('ucp.accent_override_hint')}</Form.Text>
|
||||||
|
</Form.Group>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</div>
|
||||||
|
</Container>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -9,14 +9,42 @@
|
|||||||
"acp.forums": "Foren",
|
"acp.forums": "Foren",
|
||||||
"acp.forums_confirm_delete": "Dieses Forum löschen? Das kann nicht rückgängig gemacht werden.",
|
"acp.forums_confirm_delete": "Dieses Forum löschen? Das kann nicht rückgängig gemacht werden.",
|
||||||
"acp.forums_create_title": "Forum oder Kategorie erstellen",
|
"acp.forums_create_title": "Forum oder Kategorie erstellen",
|
||||||
|
"acp.forums_create_category_title": "Kategorie erstellen",
|
||||||
|
"acp.forums_create_forum_title": "Forum erstellen",
|
||||||
"acp.forums_edit_title": "Forum bearbeiten",
|
"acp.forums_edit_title": "Forum bearbeiten",
|
||||||
|
"acp.forums_edit_category_title": "Kategorie bearbeiten",
|
||||||
|
"acp.forums_edit_forum_title": "Forum bearbeiten",
|
||||||
"acp.forums_empty": "Noch keine Foren vorhanden. Lege rechts das erste an.",
|
"acp.forums_empty": "Noch keine Foren vorhanden. Lege rechts das erste an.",
|
||||||
"acp.forums_form_empty_hint": "Wähle ein Forum zum Bearbeiten oder klicke auf Neue Kategorie / Neues Forum.",
|
"acp.forums_form_empty_hint": "Wähle ein Forum zum Bearbeiten oder klicke auf Neue Kategorie / Neues Forum.",
|
||||||
"acp.forums_form_empty_title": "Keine Auswahl",
|
"acp.forums_form_empty_title": "Keine Auswahl",
|
||||||
"acp.forums_form_hint": "Erstelle ein neues Forum oder bearbeite das ausgewählte. Kategorien können Foren und andere Kategorien enthalten.",
|
"acp.forums_form_hint": "Erstelle ein neues Forum oder bearbeite das ausgewählte. Kategorien können Foren und andere Kategorien enthalten.",
|
||||||
|
"acp.forums_create_category_hint": "Erstelle eine neue Kategorie. Kategorien können Foren und andere Kategorien enthalten.",
|
||||||
|
"acp.forums_create_forum_hint": "Erstelle ein neues Forum innerhalb einer Kategorie.",
|
||||||
|
"acp.forums_edit_category_hint": "Aktualisiere die Kategorie. Kategorien können Foren und andere Kategorien enthalten.",
|
||||||
|
"acp.forums_edit_forum_hint": "Aktualisiere die Forum-Details.",
|
||||||
"acp.forums_hint": "Kategorien und Foren in einer Baumansicht verwalten.",
|
"acp.forums_hint": "Kategorien und Foren in einer Baumansicht verwalten.",
|
||||||
"acp.forums_name_required": "Bitte zuerst einen Namen eingeben.",
|
"acp.forums_name_required": "Bitte zuerst einen Namen eingeben.",
|
||||||
"acp.forums_parent": "Ãbergeordnete Kategorie",
|
"acp.forums_parent": "Ãbergeordnete Kategorie",
|
||||||
|
"acp.forums_parent_required": "Foren brauchen eine übergeordnete Kategorie.",
|
||||||
|
"acp.forum_name": "Forenname",
|
||||||
|
"acp.default_theme": "Standard-Design",
|
||||||
|
"acp.accent_dark": "Akzentfarbe (dunkel)",
|
||||||
|
"acp.accent_light": "Akzentfarbe (hell)",
|
||||||
|
"acp.logo_dark": "Logo (dunkel)",
|
||||||
|
"acp.logo_light": "Logo (hell)",
|
||||||
|
"acp.logo_upload": "Logo hochladen",
|
||||||
|
"acp.favicons": "Favicons",
|
||||||
|
"acp.favicon_ico": "Favicon (ICO)",
|
||||||
|
"acp.favicon_16": "Favicon 16x16",
|
||||||
|
"acp.favicon_32": "Favicon 32x32",
|
||||||
|
"acp.favicon_48": "Favicon 48x48",
|
||||||
|
"acp.favicon_64": "Favicon 64x64",
|
||||||
|
"acp.favicon_128": "Favicon 128x128",
|
||||||
|
"acp.favicon_256": "Favicon 256x256",
|
||||||
|
"acp.show_header_name": "Forenname im Header anzeigen",
|
||||||
|
"acp.add_category": "Kategorie hinzufügen",
|
||||||
|
"acp.add_forum": "Forum hinzufügen",
|
||||||
|
"acp.ranks": "Ränge",
|
||||||
"acp.forums_parent_root": "Wurzel (kein Parent)",
|
"acp.forums_parent_root": "Wurzel (kein Parent)",
|
||||||
"acp.forums_tree": "Forenbaum",
|
"acp.forums_tree": "Forenbaum",
|
||||||
"acp.forums_type": "Typ",
|
"acp.forums_type": "Typ",
|
||||||
@@ -31,9 +59,10 @@
|
|||||||
"acp.save": "Speichern",
|
"acp.save": "Speichern",
|
||||||
"acp.title": "Administrationsbereich",
|
"acp.title": "Administrationsbereich",
|
||||||
"acp.users": "Benutzer",
|
"acp.users": "Benutzer",
|
||||||
"app.brand": "speedBB",
|
|
||||||
"auth.login_hint": "Melde dich an, um neue Threads zu starten und zu antworten.",
|
"auth.login_hint": "Melde dich an, um neue Threads zu starten und zu antworten.",
|
||||||
"auth.login_title": "Anmelden",
|
"auth.login_title": "Anmelden",
|
||||||
|
"auth.login_identifier": "E-Mail oder Benutzername",
|
||||||
|
"auth.login_placeholder": "name@example.com oder benutzername",
|
||||||
"auth.register_hint": "Registriere dich mit E-Mail und einem eindeutigen Benutzernamen.",
|
"auth.register_hint": "Registriere dich mit E-Mail und einem eindeutigen Benutzernamen.",
|
||||||
"auth.verify_notice": "Bitte bestätige deine E-Mail-Adresse, bevor du dich anmeldest.",
|
"auth.verify_notice": "Bitte bestätige deine E-Mail-Adresse, bevor du dich anmeldest.",
|
||||||
"auth.register_title": "Konto erstellen",
|
"auth.register_title": "Konto erstellen",
|
||||||
@@ -51,6 +80,7 @@
|
|||||||
"form.reply_placeholder": "Schreibe deine Antwort.",
|
"form.reply_placeholder": "Schreibe deine Antwort.",
|
||||||
"form.sign_in": "Anmelden",
|
"form.sign_in": "Anmelden",
|
||||||
"form.signing_in": "Anmeldung läuft...",
|
"form.signing_in": "Anmeldung läuft...",
|
||||||
|
"form.saving": "Speichern...",
|
||||||
"form.thread_body_placeholder": "Teile den Kontext und deine Frage.",
|
"form.thread_body_placeholder": "Teile den Kontext und deine Frage.",
|
||||||
"form.thread_title_placeholder": "Thema",
|
"form.thread_title_placeholder": "Thema",
|
||||||
"form.title": "Titel",
|
"form.title": "Titel",
|
||||||
@@ -60,16 +90,33 @@
|
|||||||
"forum.empty_threads": "Noch keine Threads vorhanden. Starte unten einen.",
|
"forum.empty_threads": "Noch keine Threads vorhanden. Starte unten einen.",
|
||||||
"forum.loading": "Forum wird geladen...",
|
"forum.loading": "Forum wird geladen...",
|
||||||
"forum.login_hint": "Melde dich an, um einen neuen Thread zu erstellen.",
|
"forum.login_hint": "Melde dich an, um einen neuen Thread zu erstellen.",
|
||||||
"forum.no_description": "Noch keine Beschreibung vorhanden.",
|
"forum.only_forums": "Threads können nur in Foren erstellt werden.",
|
||||||
"forum.only_forums": "Threads können nur in Foren erstellt werden.",
|
|
||||||
"forum.open": "Forum öffnen",
|
"forum.open": "Forum öffnen",
|
||||||
"forum.start_thread": "Thread starten",
|
"forum.collapse_category": "Kategorie einklappen",
|
||||||
|
"forum.expand_category": "Kategorie ausklappen",
|
||||||
|
"forum.start_thread": "Neues Thema",
|
||||||
"forum.threads": "Threads",
|
"forum.threads": "Threads",
|
||||||
"forum.type_category": "Kategorie",
|
"forum.type_category": "Kategorie",
|
||||||
"forum.type_forum": "Forum",
|
"forum.type_forum": "Forum",
|
||||||
"user.id": "ID",
|
"user.id": "ID",
|
||||||
"user.name": "Name",
|
"user.name": "Name",
|
||||||
"user.email": "E-Mail",
|
"user.email": "E-Mail",
|
||||||
|
"user.rank": "Rang",
|
||||||
|
"user.rank_unassigned": "Nicht zugewiesen",
|
||||||
|
"user.edit_title": "Benutzer bearbeiten",
|
||||||
|
"user.search": "Benutzer suchen...",
|
||||||
|
"rank.name": "Rangname",
|
||||||
|
"rank.name_placeholder": "z. B. Operator",
|
||||||
|
"rank.create": "Rang erstellen",
|
||||||
|
"rank.edit_title": "Rang bearbeiten",
|
||||||
|
"rank.badge_type": "Badge-Typ",
|
||||||
|
"rank.badge_text": "Text-Badge",
|
||||||
|
"rank.badge_image": "Bild-Badge",
|
||||||
|
"rank.badge_text_placeholder": "z. B. TEAM-RHF",
|
||||||
|
"rank.badge_text_required": "Badge-Text ist erforderlich.",
|
||||||
|
"rank.badge_image_required": "Badge-Bild ist erforderlich.",
|
||||||
|
"rank.delete_confirm": "Diesen Rang löschen?",
|
||||||
|
"rank.empty": "Noch keine Ränge vorhanden.",
|
||||||
"user.roles": "Rollen",
|
"user.roles": "Rollen",
|
||||||
"user.actions": "Aktionen",
|
"user.actions": "Aktionen",
|
||||||
"user.impersonate": "Imitieren",
|
"user.impersonate": "Imitieren",
|
||||||
@@ -82,16 +129,65 @@
|
|||||||
"home.hero_body": "Entdecke Diskussionen, stelle Fragen und teile Ideen in Kategorien und Foren.",
|
"home.hero_body": "Entdecke Diskussionen, stelle Fragen und teile Ideen in Kategorien und Foren.",
|
||||||
"home.hero_title": "Foren",
|
"home.hero_title": "Foren",
|
||||||
"home.loading": "Foren werden geladen...",
|
"home.loading": "Foren werden geladen...",
|
||||||
"nav.acp": "ACP",
|
|
||||||
"nav.forums": "Foren",
|
"nav.forums": "Foren",
|
||||||
"nav.language": "Sprache",
|
"nav.language": "Sprache",
|
||||||
"nav.login": "Anmelden",
|
"nav.login": "Anmelden",
|
||||||
"nav.logout": "Abmelden",
|
"nav.logout": "Abmelden",
|
||||||
"nav.register": "Registrieren",
|
"nav.register": "Registrieren",
|
||||||
"nav.theme": "Design",
|
"nav.theme": "Design",
|
||||||
"nav.theme_auto": "Auto",
|
|
||||||
"nav.theme_dark": "Dunkel",
|
"nav.theme_dark": "Dunkel",
|
||||||
"nav.theme_light": "Hell",
|
"nav.theme_light": "Hell",
|
||||||
|
"portal.portal": "Portal",
|
||||||
|
"portal.tagline": "Demo forum",
|
||||||
|
"portal.search_placeholder": "Suche...",
|
||||||
|
"portal.quick_links": "Quicklinks",
|
||||||
|
"portal.link_faq": "FAQ",
|
||||||
|
"portal.link_acp": "ACP",
|
||||||
|
"portal.link_mcp": "MCP",
|
||||||
|
"portal.board_index": "Foren-Übersicht",
|
||||||
|
"portal.notifications": "Benachrichtigungen",
|
||||||
|
"portal.messages": "Private Nachrichten",
|
||||||
|
"portal.menu": "Menü",
|
||||||
|
"portal.menu_news": "News",
|
||||||
|
"portal.menu_gallery": "Galerie",
|
||||||
|
"portal.menu_calendar": "Kalender",
|
||||||
|
"portal.menu_rules": "Forenregeln",
|
||||||
|
"portal.stats": "Statistik",
|
||||||
|
"portal.stat_threads": "Themen",
|
||||||
|
"portal.stat_users": "Benutzer",
|
||||||
|
"portal.stat_posts": "Beiträge",
|
||||||
|
"portal.latest_posts": "Aktuelle Beiträge",
|
||||||
|
"portal.empty_posts": "Noch keine Beiträge.",
|
||||||
|
"portal.topic": "Themen",
|
||||||
|
"portal.posted_by": "Verfasst von",
|
||||||
|
"portal.forum_label": "Forum:",
|
||||||
|
"portal.unknown_forum": "Unbekannt",
|
||||||
|
"portal.user_menu": "Benutzer-Menü",
|
||||||
|
"portal.user_new_posts": "Neue Beiträge",
|
||||||
|
"portal.user_unread": "Ungelesene Beiträge",
|
||||||
|
"portal.user_control_panel": "Benutzerkontrollzentrum",
|
||||||
|
"portal.user_profile": "Profil",
|
||||||
|
"portal.user_logout": "Logout",
|
||||||
|
"portal.user_role_operator": "Operator",
|
||||||
|
"portal.user_role_moderator": "Moderator",
|
||||||
|
"portal.user_role_member": "Mitglied",
|
||||||
|
"portal.advertisement": "Werbung",
|
||||||
|
"profile.title": "Profil",
|
||||||
|
"profile.loading": "Profil wird geladen...",
|
||||||
|
"profile.registered": "Registriert:",
|
||||||
|
"ucp.intro": "Verwalte deine grundlegenden Foren-Einstellungen.",
|
||||||
|
"ucp.profile": "Profil",
|
||||||
|
"ucp.profile_hint": "Aktualisiere den Avatar neben deinen Beitragen.",
|
||||||
|
"ucp.avatar_label": "Profilbild",
|
||||||
|
"ucp.avatar_hint": "Lade ein Bild hoch (max. 150x150px, Du kannst jpg, png, gif oder webp verwenden).",
|
||||||
|
"ucp.location_label": "Wohnort",
|
||||||
|
"ucp.location_hint": "Wird neben Deinen Beiträgen und im Profil angezeigt.",
|
||||||
|
"ucp.save_profile": "Profil speichern",
|
||||||
|
"ucp.profile_saved": "Profil gespeichert.",
|
||||||
|
"ucp.system_default": "Systemstandard",
|
||||||
|
"ucp.accent_override": "Akzentfarbe überschreiben",
|
||||||
|
"ucp.accent_override_hint": "Wähle eine eigene Akzentfarbe für die Oberfläche.",
|
||||||
|
"ucp.custom_color": "Eigene Farbe",
|
||||||
"thread.anonymous": "Anonym",
|
"thread.anonymous": "Anonym",
|
||||||
"thread.back_to_category": "Zurück zum Forum",
|
"thread.back_to_category": "Zurück zum Forum",
|
||||||
"thread.category": "Forum:",
|
"thread.category": "Forum:",
|
||||||
@@ -99,7 +195,15 @@
|
|||||||
"thread.label": "Thread",
|
"thread.label": "Thread",
|
||||||
"thread.loading": "Thread wird geladen...",
|
"thread.loading": "Thread wird geladen...",
|
||||||
"thread.login_hint": "Melde dich an, um auf diesen Thread zu antworten.",
|
"thread.login_hint": "Melde dich an, um auf diesen Thread zu antworten.",
|
||||||
|
"thread.posts": "Beiträge",
|
||||||
|
"thread.location": "Wohnort",
|
||||||
|
"thread.reply_prefix": "Aw:",
|
||||||
|
"thread.registered": "Registriert",
|
||||||
"thread.replies": "Antworten",
|
"thread.replies": "Antworten",
|
||||||
|
"thread.views": "Zugriffe",
|
||||||
|
"thread.last_post": "Letzter Beitrag",
|
||||||
|
"thread.by": "von",
|
||||||
|
"thread.no_replies": "Noch keine Antworten.",
|
||||||
"thread.reply": "Antworten",
|
"thread.reply": "Antworten",
|
||||||
"thread.view": "Thread ansehen"
|
"thread.view": "Thread ansehen"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,14 +9,42 @@
|
|||||||
"acp.forums": "Forums",
|
"acp.forums": "Forums",
|
||||||
"acp.forums_confirm_delete": "Delete this forum? This cannot be undone.",
|
"acp.forums_confirm_delete": "Delete this forum? This cannot be undone.",
|
||||||
"acp.forums_create_title": "Create forum or category",
|
"acp.forums_create_title": "Create forum or category",
|
||||||
|
"acp.forums_create_category_title": "Create category",
|
||||||
|
"acp.forums_create_forum_title": "Create forum",
|
||||||
"acp.forums_edit_title": "Edit forum",
|
"acp.forums_edit_title": "Edit forum",
|
||||||
|
"acp.forums_edit_category_title": "Edit category",
|
||||||
|
"acp.forums_edit_forum_title": "Edit forum",
|
||||||
"acp.forums_empty": "No forums yet. Create the first one on the right.",
|
"acp.forums_empty": "No forums yet. Create the first one on the right.",
|
||||||
"acp.forums_form_empty_hint": "Choose a forum to edit or click New category / New forum to create one.",
|
"acp.forums_form_empty_hint": "Choose a forum to edit or click New category / New forum to create one.",
|
||||||
"acp.forums_form_empty_title": "No selection",
|
"acp.forums_form_empty_title": "No selection",
|
||||||
"acp.forums_form_hint": "Create a new forum or edit the selected one. Categories can contain forums and other categories.",
|
"acp.forums_form_hint": "Create a new forum or edit the selected one. Categories can contain forums and other categories.",
|
||||||
|
"acp.forums_create_category_hint": "Create a new category. Categories can contain forums and other categories.",
|
||||||
|
"acp.forums_create_forum_hint": "Create a new forum within a category.",
|
||||||
|
"acp.forums_edit_category_hint": "Update the category details. Categories can contain forums and other categories.",
|
||||||
|
"acp.forums_edit_forum_hint": "Update the forum details.",
|
||||||
"acp.forums_hint": "Manage categories and forums from a tree view.",
|
"acp.forums_hint": "Manage categories and forums from a tree view.",
|
||||||
"acp.forums_name_required": "Please enter a name before saving.",
|
"acp.forums_name_required": "Please enter a name before saving.",
|
||||||
"acp.forums_parent": "Parent category",
|
"acp.forums_parent": "Parent category",
|
||||||
|
"acp.forums_parent_required": "Forums must have a parent category.",
|
||||||
|
"acp.forum_name": "Forum name",
|
||||||
|
"acp.default_theme": "Default theme",
|
||||||
|
"acp.accent_dark": "Accent color (dark)",
|
||||||
|
"acp.accent_light": "Accent color (light)",
|
||||||
|
"acp.logo_dark": "Logo (dark)",
|
||||||
|
"acp.logo_light": "Logo (light)",
|
||||||
|
"acp.logo_upload": "Upload logo",
|
||||||
|
"acp.favicons": "Favicons",
|
||||||
|
"acp.favicon_ico": "Favicon (ICO)",
|
||||||
|
"acp.favicon_16": "Favicon 16x16",
|
||||||
|
"acp.favicon_32": "Favicon 32x32",
|
||||||
|
"acp.favicon_48": "Favicon 48x48",
|
||||||
|
"acp.favicon_64": "Favicon 64x64",
|
||||||
|
"acp.favicon_128": "Favicon 128x128",
|
||||||
|
"acp.favicon_256": "Favicon 256x256",
|
||||||
|
"acp.show_header_name": "Display name in header",
|
||||||
|
"acp.add_category": "Add category",
|
||||||
|
"acp.add_forum": "Add forum",
|
||||||
|
"acp.ranks": "Ranks",
|
||||||
"acp.forums_parent_root": "Root (no parent)",
|
"acp.forums_parent_root": "Root (no parent)",
|
||||||
"acp.forums_tree": "Forum tree",
|
"acp.forums_tree": "Forum tree",
|
||||||
"acp.forums_type": "Type",
|
"acp.forums_type": "Type",
|
||||||
@@ -31,9 +59,10 @@
|
|||||||
"acp.save": "Save",
|
"acp.save": "Save",
|
||||||
"acp.title": "Admin control panel",
|
"acp.title": "Admin control panel",
|
||||||
"acp.users": "Users",
|
"acp.users": "Users",
|
||||||
"app.brand": "speedBB",
|
|
||||||
"auth.login_hint": "Access your account to start new threads and reply.",
|
"auth.login_hint": "Access your account to start new threads and reply.",
|
||||||
"auth.login_title": "Log in",
|
"auth.login_title": "Log in",
|
||||||
|
"auth.login_identifier": "Email or username",
|
||||||
|
"auth.login_placeholder": "name@example.com or username",
|
||||||
"auth.register_hint": "Register with an email and a unique username.",
|
"auth.register_hint": "Register with an email and a unique username.",
|
||||||
"auth.verify_notice": "Check your email to verify your account before logging in.",
|
"auth.verify_notice": "Check your email to verify your account before logging in.",
|
||||||
"auth.register_title": "Create account",
|
"auth.register_title": "Create account",
|
||||||
@@ -51,6 +80,7 @@
|
|||||||
"form.reply_placeholder": "Share your reply.",
|
"form.reply_placeholder": "Share your reply.",
|
||||||
"form.sign_in": "Sign in",
|
"form.sign_in": "Sign in",
|
||||||
"form.signing_in": "Signing in...",
|
"form.signing_in": "Signing in...",
|
||||||
|
"form.saving": "Saving...",
|
||||||
"form.thread_body_placeholder": "Share the context and your question.",
|
"form.thread_body_placeholder": "Share the context and your question.",
|
||||||
"form.thread_title_placeholder": "Topic headline",
|
"form.thread_title_placeholder": "Topic headline",
|
||||||
"form.title": "Title",
|
"form.title": "Title",
|
||||||
@@ -60,16 +90,33 @@
|
|||||||
"forum.empty_threads": "No threads here yet. Start one below.",
|
"forum.empty_threads": "No threads here yet. Start one below.",
|
||||||
"forum.loading": "Loading forum...",
|
"forum.loading": "Loading forum...",
|
||||||
"forum.login_hint": "Log in to create a new thread.",
|
"forum.login_hint": "Log in to create a new thread.",
|
||||||
"forum.no_description": "No description added yet.",
|
|
||||||
"forum.only_forums": "Threads can only be created in forums.",
|
"forum.only_forums": "Threads can only be created in forums.",
|
||||||
"forum.open": "Open forum",
|
"forum.open": "Open forum",
|
||||||
"forum.start_thread": "Start a thread",
|
"forum.collapse_category": "Collapse category",
|
||||||
|
"forum.expand_category": "Expand category",
|
||||||
|
"forum.start_thread": "New topic",
|
||||||
"forum.threads": "Threads",
|
"forum.threads": "Threads",
|
||||||
"forum.type_category": "Category",
|
"forum.type_category": "Category",
|
||||||
"forum.type_forum": "Forum",
|
"forum.type_forum": "Forum",
|
||||||
"user.id": "ID",
|
"user.id": "ID",
|
||||||
"user.name": "Name",
|
"user.name": "Name",
|
||||||
"user.email": "Email",
|
"user.email": "Email",
|
||||||
|
"user.rank": "Rank",
|
||||||
|
"user.rank_unassigned": "Unassigned",
|
||||||
|
"user.edit_title": "Edit user",
|
||||||
|
"user.search": "Search users...",
|
||||||
|
"rank.name": "Rank name",
|
||||||
|
"rank.name_placeholder": "e.g. Operator",
|
||||||
|
"rank.create": "Create rank",
|
||||||
|
"rank.edit_title": "Edit rank",
|
||||||
|
"rank.badge_type": "Badge type",
|
||||||
|
"rank.badge_text": "Text badge",
|
||||||
|
"rank.badge_image": "Image badge",
|
||||||
|
"rank.badge_text_placeholder": "e.g. TEAM-RHF",
|
||||||
|
"rank.badge_text_required": "Badge text is required.",
|
||||||
|
"rank.badge_image_required": "Badge image is required.",
|
||||||
|
"rank.delete_confirm": "Delete this rank?",
|
||||||
|
"rank.empty": "No ranks created yet.",
|
||||||
"user.roles": "Roles",
|
"user.roles": "Roles",
|
||||||
"user.actions": "Actions",
|
"user.actions": "Actions",
|
||||||
"user.impersonate": "Impersonate",
|
"user.impersonate": "Impersonate",
|
||||||
@@ -82,16 +129,65 @@
|
|||||||
"home.hero_body": "Explore conversations, ask questions, and share ideas across categories and forums.",
|
"home.hero_body": "Explore conversations, ask questions, and share ideas across categories and forums.",
|
||||||
"home.hero_title": "Forums",
|
"home.hero_title": "Forums",
|
||||||
"home.loading": "Loading forums...",
|
"home.loading": "Loading forums...",
|
||||||
"nav.acp": "ACP",
|
|
||||||
"nav.forums": "Forums",
|
"nav.forums": "Forums",
|
||||||
"nav.language": "Language",
|
"nav.language": "Language",
|
||||||
"nav.login": "Login",
|
"nav.login": "Login",
|
||||||
"nav.logout": "Logout",
|
"nav.logout": "Logout",
|
||||||
"nav.register": "Register",
|
"nav.register": "Register",
|
||||||
"nav.theme": "Theme",
|
"nav.theme": "Theme",
|
||||||
"nav.theme_auto": "Auto",
|
|
||||||
"nav.theme_dark": "Dark",
|
"nav.theme_dark": "Dark",
|
||||||
"nav.theme_light": "Light",
|
"nav.theme_light": "Light",
|
||||||
|
"portal.portal": "Portal",
|
||||||
|
"portal.tagline": "Demo forum",
|
||||||
|
"portal.search_placeholder": "Search...",
|
||||||
|
"portal.quick_links": "Quick links",
|
||||||
|
"portal.link_faq": "FAQ",
|
||||||
|
"portal.link_acp": "ACP",
|
||||||
|
"portal.link_mcp": "MCP",
|
||||||
|
"portal.board_index": "Board index",
|
||||||
|
"portal.notifications": "Notifications",
|
||||||
|
"portal.messages": "Private messages",
|
||||||
|
"portal.menu": "Menu",
|
||||||
|
"portal.menu_news": "News",
|
||||||
|
"portal.menu_gallery": "Gallery",
|
||||||
|
"portal.menu_calendar": "Calendar",
|
||||||
|
"portal.menu_rules": "Forum rules",
|
||||||
|
"portal.stats": "Statistics",
|
||||||
|
"portal.stat_threads": "Threads",
|
||||||
|
"portal.stat_users": "Users",
|
||||||
|
"portal.stat_posts": "Posts",
|
||||||
|
"portal.latest_posts": "Latest posts",
|
||||||
|
"portal.empty_posts": "No posts yet.",
|
||||||
|
"portal.topic": "Topics",
|
||||||
|
"portal.posted_by": "Posted by",
|
||||||
|
"portal.forum_label": "Forum:",
|
||||||
|
"portal.unknown_forum": "Unknown",
|
||||||
|
"portal.user_menu": "User menu",
|
||||||
|
"portal.user_new_posts": "New posts",
|
||||||
|
"portal.user_unread": "Unread posts",
|
||||||
|
"portal.user_control_panel": "User Control Panel",
|
||||||
|
"portal.user_profile": "Profile",
|
||||||
|
"portal.user_logout": "Logout",
|
||||||
|
"portal.user_role_operator": "Operator",
|
||||||
|
"portal.user_role_moderator": "Moderator",
|
||||||
|
"portal.user_role_member": "Member",
|
||||||
|
"portal.advertisement": "Advertisement",
|
||||||
|
"profile.title": "Profile",
|
||||||
|
"profile.loading": "Loading profile...",
|
||||||
|
"profile.registered": "Registered:",
|
||||||
|
"ucp.intro": "Manage your basic preferences for the forum.",
|
||||||
|
"ucp.profile": "Profile",
|
||||||
|
"ucp.profile_hint": "Update the avatar shown next to your posts.",
|
||||||
|
"ucp.avatar_label": "Profile image",
|
||||||
|
"ucp.avatar_hint": "Upload an image (max 150x150px, you can use jpg, png, gif, or webp).",
|
||||||
|
"ucp.location_label": "Location",
|
||||||
|
"ucp.location_hint": "Shown next to your posts and profile.",
|
||||||
|
"ucp.save_profile": "Save profile",
|
||||||
|
"ucp.profile_saved": "Profile saved.",
|
||||||
|
"ucp.system_default": "System default",
|
||||||
|
"ucp.accent_override": "Accent color override",
|
||||||
|
"ucp.accent_override_hint": "Choose a custom accent color for your UI.",
|
||||||
|
"ucp.custom_color": "Custom color",
|
||||||
"thread.anonymous": "Anonymous",
|
"thread.anonymous": "Anonymous",
|
||||||
"thread.back_to_category": "Back to forum",
|
"thread.back_to_category": "Back to forum",
|
||||||
"thread.category": "Forum:",
|
"thread.category": "Forum:",
|
||||||
@@ -99,7 +195,15 @@
|
|||||||
"thread.label": "Thread",
|
"thread.label": "Thread",
|
||||||
"thread.loading": "Loading thread...",
|
"thread.loading": "Loading thread...",
|
||||||
"thread.login_hint": "Log in to reply to this thread.",
|
"thread.login_hint": "Log in to reply to this thread.",
|
||||||
|
"thread.posts": "Posts",
|
||||||
|
"thread.location": "Location",
|
||||||
|
"thread.reply_prefix": "Re:",
|
||||||
|
"thread.registered": "Registered",
|
||||||
"thread.replies": "Replies",
|
"thread.replies": "Replies",
|
||||||
|
"thread.views": "Views",
|
||||||
|
"thread.last_post": "Last post",
|
||||||
|
"thread.by": "by",
|
||||||
|
"thread.no_replies": "No replies yet.",
|
||||||
"thread.reply": "Reply",
|
"thread.reply": "Reply",
|
||||||
"thread.view": "View thread"
|
"thread.view": "View thread"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,21 +3,51 @@
|
|||||||
use App\Http\Controllers\AuthController;
|
use App\Http\Controllers\AuthController;
|
||||||
use App\Http\Controllers\ForumController;
|
use App\Http\Controllers\ForumController;
|
||||||
use App\Http\Controllers\I18nController;
|
use App\Http\Controllers\I18nController;
|
||||||
|
use App\Http\Controllers\PortalController;
|
||||||
use App\Http\Controllers\PostController;
|
use App\Http\Controllers\PostController;
|
||||||
use App\Http\Controllers\SettingController;
|
use App\Http\Controllers\SettingController;
|
||||||
|
use App\Http\Controllers\StatsController;
|
||||||
use App\Http\Controllers\ThreadController;
|
use App\Http\Controllers\ThreadController;
|
||||||
|
use App\Http\Controllers\UploadController;
|
||||||
|
use App\Http\Controllers\UserSettingController;
|
||||||
use App\Http\Controllers\UserController;
|
use App\Http\Controllers\UserController;
|
||||||
use App\Http\Controllers\VersionController;
|
use App\Http\Controllers\VersionController;
|
||||||
|
use App\Http\Controllers\RankController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::post('/login', [AuthController::class, 'login']);
|
Route::post('/login', [AuthController::class, 'login']);
|
||||||
Route::post('/register', [AuthController::class, 'register']);
|
Route::post('/register', [AuthController::class, 'register']);
|
||||||
|
Route::post('/forgot-password', [AuthController::class, 'forgotPassword'])->middleware('guest');
|
||||||
|
Route::post('/reset-password', [AuthController::class, 'resetPassword'])->middleware('guest');
|
||||||
|
Route::get('/email/verify/{id}/{hash}', [AuthController::class, 'verifyEmail'])
|
||||||
|
->middleware('signed')
|
||||||
|
->name('verification.verify');
|
||||||
Route::post('/logout', [AuthController::class, 'logout'])->middleware('auth:sanctum');
|
Route::post('/logout', [AuthController::class, 'logout'])->middleware('auth:sanctum');
|
||||||
|
Route::post('/user/password', [AuthController::class, 'updatePassword'])->middleware('auth:sanctum');
|
||||||
|
|
||||||
Route::get('/version', VersionController::class);
|
Route::get('/version', VersionController::class);
|
||||||
|
Route::get('/portal/summary', PortalController::class);
|
||||||
|
Route::get('/stats', StatsController::class);
|
||||||
Route::get('/settings', [SettingController::class, 'index']);
|
Route::get('/settings', [SettingController::class, 'index']);
|
||||||
|
Route::post('/settings', [SettingController::class, 'store'])->middleware('auth:sanctum');
|
||||||
|
Route::post('/settings/bulk', [SettingController::class, 'bulkStore'])->middleware('auth:sanctum');
|
||||||
|
Route::get('/user-settings', [UserSettingController::class, 'index'])->middleware('auth:sanctum');
|
||||||
|
Route::post('/user-settings', [UserSettingController::class, 'store'])->middleware('auth:sanctum');
|
||||||
|
Route::post('/uploads/logo', [UploadController::class, 'storeLogo'])->middleware('auth:sanctum');
|
||||||
|
Route::post('/uploads/favicon', [UploadController::class, 'storeFavicon'])->middleware('auth:sanctum');
|
||||||
|
Route::post('/user/avatar', [UploadController::class, 'storeAvatar'])->middleware('auth:sanctum');
|
||||||
Route::get('/i18n/{locale}', I18nController::class);
|
Route::get('/i18n/{locale}', I18nController::class);
|
||||||
Route::get('/users', [UserController::class, 'index'])->middleware('auth:sanctum');
|
Route::get('/users', [UserController::class, 'index'])->middleware('auth:sanctum');
|
||||||
|
Route::patch('/users/{user}', [UserController::class, 'update'])->middleware('auth:sanctum');
|
||||||
|
Route::get('/user/me', [UserController::class, 'me'])->middleware('auth:sanctum');
|
||||||
|
Route::patch('/user/me', [UserController::class, 'updateMe'])->middleware('auth:sanctum');
|
||||||
|
Route::get('/user/profile/{user}', [UserController::class, 'profile'])->middleware('auth:sanctum');
|
||||||
|
Route::patch('/users/{user}/rank', [UserController::class, 'updateRank'])->middleware('auth:sanctum');
|
||||||
|
Route::get('/ranks', [RankController::class, 'index'])->middleware('auth:sanctum');
|
||||||
|
Route::post('/ranks', [RankController::class, 'store'])->middleware('auth:sanctum');
|
||||||
|
Route::patch('/ranks/{rank}', [RankController::class, 'update'])->middleware('auth:sanctum');
|
||||||
|
Route::delete('/ranks/{rank}', [RankController::class, 'destroy'])->middleware('auth:sanctum');
|
||||||
|
Route::post('/ranks/{rank}/badge-image', [RankController::class, 'uploadBadgeImage'])->middleware('auth:sanctum');
|
||||||
|
|
||||||
Route::get('/forums', [ForumController::class, 'index']);
|
Route::get('/forums', [ForumController::class, 'index']);
|
||||||
Route::get('/forums/{forum}', [ForumController::class, 'show']);
|
Route::get('/forums/{forum}', [ForumController::class, 'show']);
|
||||||
|
|||||||
@@ -3,5 +3,7 @@
|
|||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::view('/', 'app');
|
Route::view('/', 'app');
|
||||||
|
Route::view('/login', 'app')->name('login');
|
||||||
|
Route::view('/reset-password', 'app')->name('password.reset');
|
||||||
|
|
||||||
Route::view('/{any}', 'app')->where('any', '^(?!api).*$');
|
Route::view('/{any}', 'app')->where('any', '^(?!api).*$');
|
||||||
|
|||||||
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 389 B |
|
After Width: | Height: | Size: 835 B |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 6.0 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Feature;
|
|
||||||
|
|
||||||
// use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
||||||
use Tests\TestCase;
|
|
||||||
|
|
||||||
class ExampleTest extends TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* A basic test example.
|
|
||||||
*/
|
|
||||||
public function test_the_application_returns_a_successful_response(): void
|
|
||||||
{
|
|
||||||
$response = $this->get('/');
|
|
||||||
|
|
||||||
$response->assertStatus(200);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Unit;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
class ExampleTest extends TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* A basic test example.
|
|
||||||
*/
|
|
||||||
public function test_that_true_is_true(): void
|
|
||||||
{
|
|
||||||
$this->assertTrue(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||