mirror of
https://github.com/NyaaStudios/nyaabooru.git
synced 2025-12-09 21:42:57 +00:00
add models, setup livewire, setup mongodb
This commit is contained in:
parent
9a47b58881
commit
c0590a3412
19 changed files with 1281 additions and 318 deletions
|
|
@ -4,7 +4,7 @@ root = true
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
indent_style = space
|
indent_style = tab
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use Laravel\Sanctum\HasApiTokens;
|
use Laravel\Sanctum\HasApiTokens;
|
||||||
use MongoDB\Laravel\Auth\User as Authenticatable;
|
use MongoDB\Laravel\Auth\User as Authenticatable;
|
||||||
|
use MongoDB\Laravel\Relations\HasMany;
|
||||||
|
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
{
|
{
|
||||||
|
|
@ -33,4 +34,9 @@ class User extends Authenticatable
|
||||||
'password' => 'hashed',
|
'password' => 'hashed',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function posts(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Post::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,11 @@
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use App\Models\PersonalAccessToken;
|
use App\Models\PersonalAccessToken;
|
||||||
|
use Illuminate\Support\Facades\Event;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Laravel\Sanctum\Sanctum;
|
use Laravel\Sanctum\Sanctum;
|
||||||
|
use SocialiteProviders\Authentik\Provider as AuthentikProvider;
|
||||||
|
use SocialiteProviders\Manager\SocialiteWasCalled;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
|
@ -22,5 +25,10 @@ class AppServiceProvider extends ServiceProvider
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
Sanctum::usePersonalAccessTokenModel(PersonalAccessToken::class);
|
Sanctum::usePersonalAccessTokenModel(PersonalAccessToken::class);
|
||||||
|
|
||||||
|
// Authentik
|
||||||
|
Event::listen(function (SocialiteWasCalled $event) {
|
||||||
|
$event->extendSocialite('authentik', AuthentikProvider::class);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Http\Controllers\AuthController;
|
||||||
use Illuminate\Foundation\Application;
|
use Illuminate\Foundation\Application;
|
||||||
use Illuminate\Foundation\Configuration\Exceptions;
|
use Illuminate\Foundation\Configuration\Exceptions;
|
||||||
use Illuminate\Foundation\Configuration\Middleware;
|
use Illuminate\Foundation\Configuration\Middleware;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
return Application::configure(basePath: dirname(__DIR__))
|
return Application::configure(basePath: dirname(__DIR__))
|
||||||
->withRouting(
|
->withRouting(
|
||||||
|
|
@ -10,6 +12,14 @@ return Application::configure(basePath: dirname(__DIR__))
|
||||||
api: __DIR__.'/../routes/api.php',
|
api: __DIR__.'/../routes/api.php',
|
||||||
commands: __DIR__.'/../routes/console.php',
|
commands: __DIR__.'/../routes/console.php',
|
||||||
health: '/up',
|
health: '/up',
|
||||||
|
then: function()
|
||||||
|
{
|
||||||
|
// Auth routing
|
||||||
|
Route::middleware('web')
|
||||||
|
->prefix('auth')
|
||||||
|
->controller(AuthController::class)
|
||||||
|
->group(base_path('routes/auth.php'));
|
||||||
|
}
|
||||||
)
|
)
|
||||||
->withMiddleware(function (Middleware $middleware) {
|
->withMiddleware(function (Middleware $middleware) {
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,5 @@
|
||||||
return [
|
return [
|
||||||
App\Providers\AppServiceProvider::class,
|
App\Providers\AppServiceProvider::class,
|
||||||
MongoDB\Laravel\MongoDBServiceProvider::class,
|
MongoDB\Laravel\MongoDBServiceProvider::class,
|
||||||
|
SocialiteProviders\Manager\ServiceProvider::class,
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,18 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.2",
|
||||||
|
"ext-gmp": "*",
|
||||||
|
"intervention/image-driver-vips": "^1.0",
|
||||||
|
"intervention/image-laravel": "^1.5",
|
||||||
"laravel/framework": "^12.0",
|
"laravel/framework": "^12.0",
|
||||||
"laravel/sanctum": "^4.0",
|
"laravel/sanctum": "^4.0",
|
||||||
"laravel/tinker": "^2.10.1",
|
"laravel/tinker": "^2.10.1",
|
||||||
"mongodb/laravel-mongodb": "^5.4"
|
"league/flysystem": "^3.29",
|
||||||
|
"league/flysystem-gridfs": "3.x-dev",
|
||||||
|
"livewire/livewire": "^3.6",
|
||||||
|
"mongodb/laravel-mongodb": "^5.4",
|
||||||
|
"predis/predis": "^3.0",
|
||||||
|
"socialiteproviders/authentik": "^5.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fakerphp/faker": "^1.23",
|
"fakerphp/faker": "^1.23",
|
||||||
|
|
|
||||||
1173
composer.lock
generated
1173
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -90,6 +90,16 @@ return [
|
||||||
'driver' => 'octane',
|
'driver' => 'octane',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'mongodb' => [
|
||||||
|
'driver' => 'mongodb',
|
||||||
|
'connection' => 'mongodb',
|
||||||
|
'collection' => 'cache',
|
||||||
|
'lock_connection' => 'mongodb',
|
||||||
|
'lock_collection' => 'cache_locks',
|
||||||
|
'lock_lottery' => [2, 100],
|
||||||
|
'lock_timeout' => 86400,
|
||||||
|
],
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,11 @@ return [
|
||||||
'report' => false,
|
'report' => false,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'gridfs' => [
|
||||||
|
'driver' => 'gridfs',
|
||||||
|
'connection' => 'mongodb',
|
||||||
|
],
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -35,4 +35,11 @@ return [
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'authentik' => [
|
||||||
|
'base_url' => env('AUTHENTIK_BASE_URL'),
|
||||||
|
'client_id' => env('AUTHENTIK_CLIENT_ID'),
|
||||||
|
'client_secret' => env('AUTHENTIK_CLIENT_SECRET'),
|
||||||
|
'redirect' => env('AUTHENTIK_REDIRECT_URI'),
|
||||||
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use MongoDB\Laravel\Schema\Blueprint;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class extends Migration
|
||||||
{
|
{
|
||||||
|
|
@ -34,6 +35,7 @@ return new class extends Migration
|
||||||
$table->text('user_agent')->nullable();
|
$table->text('user_agent')->nullable();
|
||||||
$table->longText('payload');
|
$table->longText('payload');
|
||||||
$table->integer('last_activity')->index();
|
$table->integer('last_activity')->index();
|
||||||
|
$table->expire('expires_at', 0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use MongoDB\Laravel\Schema\Blueprint;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class extends Migration
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use MongoDB\Laravel\Schema\Blueprint;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class extends Migration
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use MongoDB\Laravel\Schema\Blueprint;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class extends Migration
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,9 @@
|
||||||
"dev": "vite"
|
"dev": "vite"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/vite": "^4.0.0",
|
|
||||||
"axios": "^1.8.2",
|
"axios": "^1.8.2",
|
||||||
"concurrently": "^9.0.1",
|
"concurrently": "^9.0.1",
|
||||||
"laravel-vite-plugin": "^1.2.0",
|
"laravel-vite-plugin": "^1.2.0",
|
||||||
"tailwindcss": "^4.0.0",
|
|
||||||
"vite": "^6.2.4"
|
"vite": "^6.2.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,52 @@
|
||||||
@import 'tailwindcss';
|
@import url('https://early.webawesome.com/webawesome@3.0.0-alpha.13/dist/styles/webawesome.css');
|
||||||
|
@import url('https://early.webawesome.com/webawesome@3.0.0-alpha.13/dist/styles/utilities.css');
|
||||||
|
|
||||||
|
@import url('https://early.webawesome.com/webawesome@3.0.0-alpha.13/dist/styles/themes/tailspin.css');
|
||||||
|
@import url('https://early.webawesome.com/webawesome@3.0.0-alpha.13/dist/styles/color/bright.css');
|
||||||
|
@import url('https://early.webawesome.com/webawesome@3.0.0-alpha.13/dist/styles/brand/purple.css');
|
||||||
|
@import url('https://early.webawesome.com/webawesome@3.0.0-alpha.13/dist/styles/themes/awesome/typography.css');
|
||||||
|
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
min-height: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
:where(:root),
|
||||||
|
:host,
|
||||||
|
.wa-theme-nyaabooru {
|
||||||
|
--wa-icon-family: classic;
|
||||||
|
--wa-icon-variant: light;
|
||||||
|
--wa-border-radius-scale: 0.5;
|
||||||
|
--wa-space-scale: 1;
|
||||||
|
--wa-border-width-scale: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
wa-page {
|
||||||
|
--menu-width: 15rem;
|
||||||
|
--aside-width: 15rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
wa-page[view='desktop'] {
|
||||||
|
[slot*='navigation'] {
|
||||||
|
border-inline-end: var(--wa-border-width-s) var(--wa-border-style) var(--wa-color-surface-border);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wa-page[view='mobile'] {
|
||||||
|
--menu-width: auto;
|
||||||
|
--aside-width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
[slot='header'] {
|
||||||
|
--wa-link-decoration-default: none;
|
||||||
|
border-block-end: var(--wa-border-width-s) var(--wa-border-style) var(--wa-color-surface-border);
|
||||||
|
}
|
||||||
|
|
||||||
@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php';
|
@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php';
|
||||||
@source '../../storage/framework/views/*.php';
|
@source '../../storage/framework/views/*.php';
|
||||||
@source '../**/*.blade.php';
|
@source '../**/*.blade.php';
|
||||||
@source '../**/*.js';
|
@source '../**/*.js';
|
||||||
|
|
||||||
@theme {
|
|
||||||
--font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
|
|
||||||
'Segoe UI Symbol', 'Noto Color Emoji';
|
|
||||||
}
|
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,7 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Livewire\App\Home as AppHome;
|
||||||
|
use App\Livewire\Pages\Upload as UploadPage;
|
||||||
|
use App\Livewire\Posts\Index as PostsPage;
|
||||||
|
use App\Livewire\Posts\Edit as EditPost;
|
||||||
|
use App\Livewire\Posts\View as ViewPost;
|
||||||
|
use App\Models\Post;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
Route::get('/', function () {
|
Route::get('/', AppHome::class)->name('home');
|
||||||
return view('welcome');
|
|
||||||
|
// Authenticated routes
|
||||||
|
Route::middleware('auth')->group(function () {
|
||||||
|
Route::get('/upload', UploadPage::class)->name('upload');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Post routes
|
||||||
|
Route::middleware('auth')->prefix('posts')->group(function () {
|
||||||
|
Route::get('/', PostsPage::class)->name('posts.home');
|
||||||
|
Route::get('/{post}', ViewPost::class);
|
||||||
|
Route::get('/{post}/edit', EditPost::class);
|
||||||
|
Route::get('/{post}/download', function(Post $post) {
|
||||||
|
return Storage::download("posts/$post->id/full", config('app.name') . "_$post->id.$post->extension");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import laravel from 'laravel-vite-plugin';
|
import laravel from 'laravel-vite-plugin';
|
||||||
import tailwindcss from '@tailwindcss/vite';
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
|
|
@ -8,6 +7,5 @@ export default defineConfig({
|
||||||
input: ['resources/css/app.css', 'resources/js/app.js'],
|
input: ['resources/css/app.css', 'resources/js/app.js'],
|
||||||
refresh: true,
|
refresh: true,
|
||||||
}),
|
}),
|
||||||
tailwindcss(),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue