diff --git a/app/Blog/Controllers/PostController.php b/app/Blog/Controllers/PostController.php index 0aa65c9..65b94a7 100644 --- a/app/Blog/Controllers/PostController.php +++ b/app/Blog/Controllers/PostController.php @@ -29,7 +29,7 @@ class PostController extends Controller $comments = $post->comments() ->where('status', 'published') - ->latest('created_at') + ->orderBy('created_at', (int) blog_setting('comment_order', 1) === 1 ? 'asc' : 'desc') ->paginate(20); $contentHtml = $this->renderer->render($post); diff --git a/app/Filament/Pages/BlogSettings.php b/app/Filament/Pages/BlogSettings.php index e800271..01f3a27 100644 --- a/app/Filament/Pages/BlogSettings.php +++ b/app/Filament/Pages/BlogSettings.php @@ -2,18 +2,18 @@ declare(strict_types=1); - namespace App\Filament\Pages; use App\Models\Setting; use Filament\Actions\Action; -use Filament\Schemas\Components\Section; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Toggle; use Filament\Forms\Concerns\InteractsWithForms; use Filament\Notifications\Notification; use Filament\Pages\Page; +use Filament\Schemas\Components\Tabs; +use Filament\Schemas\Components\Tabs\Tab; use Filament\Schemas\Schema; class BlogSettings extends Page @@ -33,18 +33,35 @@ class BlogSettings extends Page public function mount(): void { $this->form->fill([ + // 站点 'site_name' => Setting::get('site_name', config('blog.name')), 'site_description' => Setting::get('site_description', config('blog.description')), 'site_icp' => Setting::get('site_icp', config('blog.icp')), + // 外观 'active_theme' => Setting::get('active_theme', config('themes.default')), 'per_page' => Setting::get('per_page', config('blog.per_page')), + 'list_shownum' => Setting::get('list_shownum', '50'), + 'listtime' => Setting::get('listtime', 'Y-m-d'), + 'normaltime' => Setting::get('normaltime', 'Y-m-d H:i'), + // 订阅与 SEO + 'rss_num' => Setting::get('rss_num', config('blog.rss_num')), + 'rss_ttl' => Setting::get('rss_ttl', '30'), + 'seo_default_keywords' => Setting::get('seo_default_keywords', ''), + 'seo_default_description' => Setting::get('seo_default_description', ''), + // 评论 'comment_audit' => Setting::get('comment_audit', '0'), + 'comment_order' => Setting::get('comment_order', '1'), 'comment_min_len' => Setting::get('comment_min_len', config('blog.comment_min_len')), 'comment_max_len' => Setting::get('comment_max_len', config('blog.comment_max_len')), 'comment_post_space' => Setting::get('comment_post_space', config('blog.comment_post_space')), - 'rss_num' => Setting::get('rss_num', config('blog.rss_num')), - 'seo_default_keywords' => Setting::get('seo_default_keywords', ''), - 'seo_default_description' => Setting::get('seo_default_description', ''), + 'comment_timeformat' => Setting::get('comment_timeformat', 'Y-m-d H:i'), + // 附件 + 'attachments_thumbs' => Setting::get('attachments_thumbs', '1'), + 'attachments_thumbs_size' => Setting::get('attachments_thumbs_size', '500x500'), + 'watermark' => Setting::get('watermark', '0'), + 'watermark_size' => Setting::get('watermark_size', '300x300'), + 'watermarktrans' => Setting::get('watermarktrans', '100'), + // 维护 'site_closed' => Setting::get('site_closed', '0'), 'site_closed_note' => Setting::get('site_closed_note', ''), ]); @@ -54,40 +71,59 @@ class BlogSettings extends Page { return $schema ->components([ - Section::make('站点信息') - ->schema([ - TextInput::make('site_name')->label('站点名称')->required(), - TextInput::make('site_description')->label('站点描述')->columnSpanFull(), - TextInput::make('site_icp')->label('ICP 备案号'), - ]), - Section::make('主题') - ->schema([ - Select::make('active_theme') - ->label('激活主题') - ->options(collect(app(\App\Blog\Support\ThemeManager::class)->all())->pluck('title', 'name')), - ]), - Section::make('列表与订阅') - ->schema([ - TextInput::make('per_page')->label('每页文章数')->numeric(), - TextInput::make('rss_num')->label('RSS 文章数')->numeric(), - ]), - Section::make('评论') - ->columns(2) - ->schema([ - Toggle::make('comment_audit')->label('新评论需审核')->default(false), - TextInput::make('comment_min_len')->label('评论最短字数')->numeric(), - TextInput::make('comment_max_len')->label('评论最长字数')->numeric(), - TextInput::make('comment_post_space')->label('评论间隔(秒)')->numeric(), - ]), - Section::make('SEO 默认值') - ->schema([ - TextInput::make('seo_default_keywords')->label('默认关键词'), - TextInput::make('seo_default_description')->label('默认描述')->columnSpanFull(), - ]), - Section::make('维护') - ->schema([ - Toggle::make('site_closed')->label('关闭站点')->default(false), - TextInput::make('site_closed_note')->label('关闭说明'), + Tabs::make('settings-tabs') + ->tabs([ + Tab::make('站点') + ->schema([ + TextInput::make('site_name')->label('站点名称')->required(), + TextInput::make('site_description')->label('站点描述')->columnSpanFull(), + TextInput::make('site_icp')->label('ICP 备案号'), + ]), + Tab::make('外观') + ->columns(2) + ->schema([ + Select::make('active_theme') + ->label('激活主题') + ->columnSpanFull() + ->options(collect(app(\App\Blog\Support\ThemeManager::class)->all())->pluck('title', 'name')), + TextInput::make('per_page')->label('首页每页文章数')->numeric(), + TextInput::make('list_shownum')->label('列表每页数量')->numeric()->helperText('分类/标签/搜索等列表页'), + TextInput::make('listtime')->label('列表时间格式')->placeholder('Y-m-d'), + TextInput::make('normaltime')->label('详情时间格式')->placeholder('Y-m-d H:i'), + ]), + Tab::make('订阅与 SEO') + ->columns(2) + ->schema([ + TextInput::make('rss_num')->label('RSS 文章数')->numeric(), + TextInput::make('rss_ttl')->label('RSS TTL(分钟)')->numeric(), + TextInput::make('seo_default_keywords')->label('默认关键词')->columnSpanFull(), + TextInput::make('seo_default_description')->label('默认描述')->columnSpanFull(), + ]), + Tab::make('评论') + ->columns(2) + ->schema([ + Toggle::make('comment_audit')->label('新评论需审核')->default(false), + Select::make('comment_order')->label('评论排序') + ->options(['1' => '正序(旧在前)', '0' => '倒序(新在前)']), + TextInput::make('comment_min_len')->label('最短字数')->numeric(), + TextInput::make('comment_max_len')->label('最长字数')->numeric(), + TextInput::make('comment_post_space')->label('评论间隔(秒)')->numeric(), + TextInput::make('comment_timeformat')->label('评论时间格式')->placeholder('Y-m-d H:i'), + ]), + Tab::make('附件') + ->columns(2) + ->schema([ + Toggle::make('attachments_thumbs')->label('生成缩略图')->default(true), + TextInput::make('attachments_thumbs_size')->label('缩略图尺寸')->placeholder('500x500'), + Toggle::make('watermark')->label('图片水印')->default(false), + TextInput::make('watermark_size')->label('水印触发尺寸')->placeholder('300x300'), + TextInput::make('watermarktrans')->label('水印透明度(%)')->numeric(), + ]), + Tab::make('维护') + ->schema([ + Toggle::make('site_closed')->label('关闭站点')->default(false), + TextInput::make('site_closed_note')->label('关闭说明')->columnSpanFull(), + ]), ]), ]) ->statePath('data'); diff --git a/app/Models/Post.php b/app/Models/Post.php index d039a10..31b8559 100644 --- a/app/Models/Post.php +++ b/app/Models/Post.php @@ -95,9 +95,10 @@ class Post extends Model implements HasMedia public function registerMediaConversions(?Media $media = null): void { + [$tw, $th] = array_pad(explode('x', strtolower((string) blog_setting('attachments_thumbs_size', '500x500'))), 2, '500'); $this->addMediaConversion('thumb') - ->width(500) - ->height(500) + ->width((int) $tw) + ->height((int) $th) ->performOnCollections('attachments'); } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 5f23b6e..771f664 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,9 +2,11 @@ declare(strict_types=1); - namespace App\Providers; +use Filament\Facades\Filament; +use Filament\View\PanelsRenderHook; +use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider @@ -26,5 +28,21 @@ class AppServiceProvider extends ServiceProvider foreach (glob(base_path('plugins/*/database/migrations')) ?: [] as $path) { $this->loadMigrationsFrom($path); } + + // 后台侧边栏紧凑化(更窄的菜单项) + Filament::serving(function () { + Filament::registerRenderHook( + PanelsRenderHook::STYLES_AFTER, + fn () => Blade::render(<<<'HTML' + +HTML) + ); + }); } } diff --git a/app/Providers/Filament/AdminPanelProvider.php b/app/Providers/Filament/AdminPanelProvider.php index 7736a31..47b5c99 100644 --- a/app/Providers/Filament/AdminPanelProvider.php +++ b/app/Providers/Filament/AdminPanelProvider.php @@ -42,6 +42,7 @@ class AdminPanelProvider extends PanelProvider 'primary' => Color::Sky, ]) ->brandName(config('blog.name')) + ->sidebarWidth('13rem') ->navigationGroups([ NavigationGroup::make('内容'), NavigationGroup::make('管理'), diff --git a/resources/views/archives.blade.php b/resources/views/archives.blade.php index 2c6a5cb..725c9b6 100644 --- a/resources/views/archives.blade.php +++ b/resources/views/archives.blade.php @@ -15,7 +15,7 @@ ({{ $monthPosts->count() }} 篇) diff --git a/resources/views/comments.blade.php b/resources/views/comments.blade.php index b4d2d0c..85a8e2a 100644 --- a/resources/views/comments.blade.php +++ b/resources/views/comments.blade.php @@ -11,7 +11,7 @@
{{ $comment->author_name }} · 评论于 {{ $comment->post->title }} - · {{ $comment->created_at->format('Y-m-d H:i') }} + · {{ $comment->created_at->format(blog_setting('comment_timeformat', 'Y-m-d H:i')) }}
{!! nl2br(e($comment->content)) !!}
diff --git a/resources/views/partials/post-card.blade.php b/resources/views/partials/post-card.blade.php index 0e29545..3f314f8 100644 --- a/resources/views/partials/post-card.blade.php +++ b/resources/views/partials/post-card.blade.php @@ -9,7 +9,7 @@ {{ $post->title }}
- + @if($post->category) · {{ $post->category->name }} diff --git a/resources/views/show.blade.php b/resources/views/show.blade.php index 4ac91bc..1b346d4 100644 --- a/resources/views/show.blade.php +++ b/resources/views/show.blade.php @@ -23,7 +23,7 @@ @endif

{{ $post->title }}

- + @if($post->author)· {{ $post->author->name }}@endif @if($post->category) · {{ $post->category->name }} @@ -55,7 +55,7 @@ @if($comment->author_url) · 访问主页 @endif - · {{ $comment->created_at->format('Y-m-d H:i') }} + · {{ $comment->created_at->format(blog_setting('comment_timeformat', 'Y-m-d H:i')) }}
{!! nl2br(e($comment->content)) !!}
diff --git a/storage/media-library/temp/7fA4ZpZFbEUvIR2M2PVWa4ayh92mB8Hs/WdJFvpPg3z2UFH7NChBskJ71FtRVaMEo.jpg b/storage/media-library/temp/7fA4ZpZFbEUvIR2M2PVWa4ayh92mB8Hs/WdJFvpPg3z2UFH7NChBskJ71FtRVaMEo.jpg new file mode 100644 index 0000000..7e754f4 --- /dev/null +++ b/storage/media-library/temp/7fA4ZpZFbEUvIR2M2PVWa4ayh92mB8Hs/WdJFvpPg3z2UFH7NChBskJ71FtRVaMEo.jpg @@ -0,0 +1 @@ +fake-jpg \ No newline at end of file diff --git a/storage/media-library/temp/7fA4ZpZFbEUvIR2M2PVWa4ayh92mB8Hs/esDs09nBNmWS9mMBPgQLpXTPfqIuLptPthumb.jpg b/storage/media-library/temp/7fA4ZpZFbEUvIR2M2PVWa4ayh92mB8Hs/esDs09nBNmWS9mMBPgQLpXTPfqIuLptPthumb.jpg new file mode 100644 index 0000000..7e754f4 --- /dev/null +++ b/storage/media-library/temp/7fA4ZpZFbEUvIR2M2PVWa4ayh92mB8Hs/esDs09nBNmWS9mMBPgQLpXTPfqIuLptPthumb.jpg @@ -0,0 +1 @@ +fake-jpg \ No newline at end of file diff --git a/storage/media-library/temp/HbYaJQcnIuSnuFrCIcHn0ndiXUUHqsvL/NbS5mseWautWvELHDZthYijqpRFQYvq1.jpg b/storage/media-library/temp/HbYaJQcnIuSnuFrCIcHn0ndiXUUHqsvL/NbS5mseWautWvELHDZthYijqpRFQYvq1.jpg new file mode 100644 index 0000000..7e754f4 --- /dev/null +++ b/storage/media-library/temp/HbYaJQcnIuSnuFrCIcHn0ndiXUUHqsvL/NbS5mseWautWvELHDZthYijqpRFQYvq1.jpg @@ -0,0 +1 @@ +fake-jpg \ No newline at end of file diff --git a/storage/media-library/temp/HbYaJQcnIuSnuFrCIcHn0ndiXUUHqsvL/vxZfdYJJcelC8OCKYdwJxs4DL8vA2OG2thumb.jpg b/storage/media-library/temp/HbYaJQcnIuSnuFrCIcHn0ndiXUUHqsvL/vxZfdYJJcelC8OCKYdwJxs4DL8vA2OG2thumb.jpg new file mode 100644 index 0000000..7e754f4 --- /dev/null +++ b/storage/media-library/temp/HbYaJQcnIuSnuFrCIcHn0ndiXUUHqsvL/vxZfdYJJcelC8OCKYdwJxs4DL8vA2OG2thumb.jpg @@ -0,0 +1 @@ +fake-jpg \ No newline at end of file diff --git a/storage/media-library/temp/b9gOp0GVn7ppiZs8rnFCKodYvRT6Wquf/aZOkSStz7Yse33nEjkCnAPrnL7mwvkqCthumb.jpg b/storage/media-library/temp/b9gOp0GVn7ppiZs8rnFCKodYvRT6Wquf/aZOkSStz7Yse33nEjkCnAPrnL7mwvkqCthumb.jpg new file mode 100644 index 0000000..7e754f4 --- /dev/null +++ b/storage/media-library/temp/b9gOp0GVn7ppiZs8rnFCKodYvRT6Wquf/aZOkSStz7Yse33nEjkCnAPrnL7mwvkqCthumb.jpg @@ -0,0 +1 @@ +fake-jpg \ No newline at end of file diff --git a/storage/media-library/temp/b9gOp0GVn7ppiZs8rnFCKodYvRT6Wquf/t45g2arVfS4JxC0tl25qagSO9e28E9lw.jpg b/storage/media-library/temp/b9gOp0GVn7ppiZs8rnFCKodYvRT6Wquf/t45g2arVfS4JxC0tl25qagSO9e28E9lw.jpg new file mode 100644 index 0000000..7e754f4 --- /dev/null +++ b/storage/media-library/temp/b9gOp0GVn7ppiZs8rnFCKodYvRT6Wquf/t45g2arVfS4JxC0tl25qagSO9e28E9lw.jpg @@ -0,0 +1 @@ +fake-jpg \ No newline at end of file diff --git a/storage/media-library/temp/bWCrLeUtviZtJ8GrgHeFxvffxLZc1Ubh/5Qd9L26xp7Zw3bbLgFAQOjF6tbLixigfthumb.jpg b/storage/media-library/temp/bWCrLeUtviZtJ8GrgHeFxvffxLZc1Ubh/5Qd9L26xp7Zw3bbLgFAQOjF6tbLixigfthumb.jpg new file mode 100644 index 0000000..7e754f4 --- /dev/null +++ b/storage/media-library/temp/bWCrLeUtviZtJ8GrgHeFxvffxLZc1Ubh/5Qd9L26xp7Zw3bbLgFAQOjF6tbLixigfthumb.jpg @@ -0,0 +1 @@ +fake-jpg \ No newline at end of file diff --git a/storage/media-library/temp/bWCrLeUtviZtJ8GrgHeFxvffxLZc1Ubh/U3AOp9IBOI1356FZsT41qHm6ljlnxXQd.jpg b/storage/media-library/temp/bWCrLeUtviZtJ8GrgHeFxvffxLZc1Ubh/U3AOp9IBOI1356FZsT41qHm6ljlnxXQd.jpg new file mode 100644 index 0000000..7e754f4 --- /dev/null +++ b/storage/media-library/temp/bWCrLeUtviZtJ8GrgHeFxvffxLZc1Ubh/U3AOp9IBOI1356FZsT41qHm6ljlnxXQd.jpg @@ -0,0 +1 @@ +fake-jpg \ No newline at end of file diff --git a/storage/media-library/temp/r07A9Gd6MK22ujtd5TXVa3Q9lMI8Kr62/XoW33agEcvn1QDfPjhGHfiQvx9bd002N.jpg b/storage/media-library/temp/r07A9Gd6MK22ujtd5TXVa3Q9lMI8Kr62/XoW33agEcvn1QDfPjhGHfiQvx9bd002N.jpg new file mode 100644 index 0000000..7e754f4 --- /dev/null +++ b/storage/media-library/temp/r07A9Gd6MK22ujtd5TXVa3Q9lMI8Kr62/XoW33agEcvn1QDfPjhGHfiQvx9bd002N.jpg @@ -0,0 +1 @@ +fake-jpg \ No newline at end of file diff --git a/storage/media-library/temp/r07A9Gd6MK22ujtd5TXVa3Q9lMI8Kr62/aHyKaw2alnGIkUUZWSK1NB3tHZDfxCFwthumb.jpg b/storage/media-library/temp/r07A9Gd6MK22ujtd5TXVa3Q9lMI8Kr62/aHyKaw2alnGIkUUZWSK1NB3tHZDfxCFwthumb.jpg new file mode 100644 index 0000000..7e754f4 --- /dev/null +++ b/storage/media-library/temp/r07A9Gd6MK22ujtd5TXVa3Q9lMI8Kr62/aHyKaw2alnGIkUUZWSK1NB3tHZDfxCFwthumb.jpg @@ -0,0 +1 @@ +fake-jpg \ No newline at end of file diff --git a/themes/sablog/views/show.blade.php b/themes/sablog/views/show.blade.php index 7409763..92e4f69 100644 --- a/themes/sablog/views/show.blade.php +++ b/themes/sablog/views/show.blade.php @@ -21,7 +21,7 @@ @endif

{{ $post->title }}

- + @if($post->author)· {{ $post->author->name }}@endif @if($post->category) · {{ $post->category->name }} @@ -51,7 +51,7 @@
{{ $comment->author_name }} @if($comment->author_url)· 访问主页@endif - · {{ $comment->created_at->format('Y-m-d H:i') }} + · {{ $comment->created_at->format(blog_setting('comment_timeformat', 'Y-m-d H:i')) }}
{!! nl2br(e($comment->content)) !!}