feat: restore sablog browse modes and clean imported HTML
Keep the public site readable after import (nbsp, highlighter, wrapping code, compact pager) and finish the admin extras already in this tree: sticky levels, preview, page cache, and live llms.txt. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -9,6 +9,18 @@
|
||||
{{ $environmentName }}
|
||||
</x-filament::badge>
|
||||
|
||||
<x-filament::button
|
||||
tag="a"
|
||||
href="{{ url('/') }}"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
size="sm"
|
||||
color="gray"
|
||||
icon="heroicon-o-globe-alt"
|
||||
>
|
||||
网站
|
||||
</x-filament::button>
|
||||
|
||||
<x-filament::button
|
||||
tag="a"
|
||||
:href="$createPostUrl"
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<x-filament-panels::page>
|
||||
<x-filament::section heading="当前语言">
|
||||
<dl class="grid gap-3 sm:grid-cols-3">
|
||||
<div>
|
||||
<dt class="text-sm text-gray-500 dark:text-gray-400">站点语言</dt>
|
||||
<dd class="mt-1 text-lg font-medium">{{ $this->info['locale'] }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-sm text-gray-500 dark:text-gray-400">回退语言</dt>
|
||||
<dd class="mt-1 text-lg font-medium">{{ $this->info['fallback'] }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-sm text-gray-500 dark:text-gray-400">假数据语言</dt>
|
||||
<dd class="mt-1 text-lg font-medium">{{ $this->info['faker'] }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<p class="mt-4 text-sm text-gray-500 dark:text-gray-400">
|
||||
改语言请编辑 <code>.env</code> 里的 <code>APP_LOCALE</code>,后台菜单文案本身是中文写死的。
|
||||
</p>
|
||||
</x-filament::section>
|
||||
|
||||
<x-filament::section heading="文章多语言" class="mt-6">
|
||||
<x-filament::badge color="warning">未开通</x-filament::badge>
|
||||
<p class="mt-3 text-sm text-gray-600 dark:text-gray-300">
|
||||
现在每篇文章只有一份正文,没有中英两个版本可以切换。这个页面先让你看到现状,以后如果做文章翻译,会在这里列出语言和对应文章。
|
||||
</p>
|
||||
</x-filament::section>
|
||||
|
||||
<div class="mt-6 grid gap-6 lg:grid-cols-2">
|
||||
<x-filament::section heading="站点语言包">
|
||||
@if(count($this->info['app_files']) === 0)
|
||||
<p class="text-sm text-gray-500 dark:text-gray-400">还没有站点自己的语言文件。</p>
|
||||
@else
|
||||
<div class="flex flex-wrap gap-2">
|
||||
@foreach($this->info['app_files'] as $locale)
|
||||
<x-filament::badge>{{ $locale }}</x-filament::badge>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
</x-filament::section>
|
||||
|
||||
<x-filament::section heading="Filament 后台语言包">
|
||||
<p class="mb-3 text-sm text-gray-500 dark:text-gray-400">
|
||||
这些是后台组件自带的翻译,不是文章内容翻译。
|
||||
</p>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
@foreach($this->info['filament_locales'] as $locale)
|
||||
<x-filament::badge color="gray">{{ $locale }}</x-filament::badge>
|
||||
@endforeach
|
||||
</div>
|
||||
</x-filament::section>
|
||||
</div>
|
||||
</x-filament-panels::page>
|
||||
@@ -0,0 +1,64 @@
|
||||
<x-filament-panels::page>
|
||||
<div class="grid gap-4 md:grid-cols-4">
|
||||
<x-filament::section>
|
||||
<div class="text-sm text-gray-500 dark:text-gray-400">当前缓存页</div>
|
||||
<div class="mt-1 text-2xl font-semibold">{{ $this->stats['count'] }} 条</div>
|
||||
</x-filament::section>
|
||||
<x-filament::section>
|
||||
<div class="text-sm text-gray-500 dark:text-gray-400">命中率</div>
|
||||
<div class="mt-1 text-2xl font-semibold">{{ $this->stats['rate'] }}%</div>
|
||||
</x-filament::section>
|
||||
<x-filament::section>
|
||||
<div class="text-sm text-gray-500 dark:text-gray-400">命中 / 未命中</div>
|
||||
<div class="mt-1 text-2xl font-semibold">{{ $this->stats['hits'] }} / {{ $this->stats['misses'] }}</div>
|
||||
</x-filament::section>
|
||||
<x-filament::section>
|
||||
<div class="text-sm text-gray-500 dark:text-gray-400">过期时间</div>
|
||||
<div class="mt-1 text-2xl font-semibold">{{ $this->stats['ttl'] }} 秒</div>
|
||||
</x-filament::section>
|
||||
</div>
|
||||
|
||||
<x-filament::section heading="已缓存的前台页面" class="mt-6">
|
||||
<p class="mb-4 text-sm text-gray-500 dark:text-gray-400">
|
||||
只缓存未登录访客打开的页面。登录后看前台不会进缓存,所以这里可能暂时是空的。
|
||||
</p>
|
||||
|
||||
@if(count($this->entries) === 0)
|
||||
<p class="text-sm text-gray-500 dark:text-gray-400">当前没有前台页面缓存。</p>
|
||||
@else
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-sm">
|
||||
<thead>
|
||||
<tr class="border-b border-gray-200 text-left dark:border-white/10">
|
||||
<th class="py-2 pr-4 font-medium">地址</th>
|
||||
<th class="py-2 pr-4 font-medium">缓存时间</th>
|
||||
<th class="py-2 font-medium">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($this->entries as $entry)
|
||||
<tr class="border-b border-gray-100 dark:border-white/5" wire:key="cache-{{ $entry['key'] }}">
|
||||
<td class="py-2 pr-4">
|
||||
<a href="{{ $entry['url'] }}" target="_blank" rel="noopener noreferrer" class="text-primary-600 hover:underline">
|
||||
{{ $entry['url'] }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="py-2 pr-4 whitespace-nowrap">{{ $entry['cached_at'] ?: '—' }}</td>
|
||||
<td class="py-2">
|
||||
<x-filament::button
|
||||
size="xs"
|
||||
color="danger"
|
||||
wire:click="forgetEntry('{{ $entry['key'] }}')"
|
||||
wire:confirm="删除这条缓存?"
|
||||
>
|
||||
删除
|
||||
</x-filament::button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endif
|
||||
</x-filament::section>
|
||||
</x-filament-panels::page>
|
||||
@@ -11,6 +11,8 @@
|
||||
<div class="alert alert-error">{{ session('error') }}</div>
|
||||
@endif
|
||||
|
||||
@include('partials.view-mode-switcher')
|
||||
|
||||
@forelse($posts as $post)
|
||||
@include('partials.post-card', ['post' => $post])
|
||||
@empty
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
@endif
|
||||
|
||||
|
||||
@include('partials.view-mode-switcher')
|
||||
|
||||
@forelse($posts as $post)
|
||||
@include('partials.post-card', ['post' => $post])
|
||||
@empty
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
@php
|
||||
$asList = $asList ?? false;
|
||||
$feedLinks = [
|
||||
['label' => 'RSS', 'url' => route('feed.rss')],
|
||||
['label' => 'Sitemap', 'url' => route('feed.sitemap')],
|
||||
['label' => 'llms.txt', 'url' => route('feed.llms')],
|
||||
];
|
||||
@endphp
|
||||
@foreach($feedLinks as $feedLink)
|
||||
@if($asList)
|
||||
<li><a href="{{ $feedLink['url'] }}" target="_blank" rel="noopener noreferrer">{{ $feedLink['label'] }}</a></li>
|
||||
@else
|
||||
@if(! $loop->first) · @endif
|
||||
<a href="{{ $feedLink['url'] }}" target="_blank" rel="noopener noreferrer">{{ $feedLink['label'] }}</a>
|
||||
@endif
|
||||
@endforeach
|
||||
@@ -7,6 +7,7 @@
|
||||
<a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener">{{ $siteIcp }}</a>
|
||||
@endif
|
||||
</p>
|
||||
<p>@include('partials.feed-links')</p>
|
||||
<p class="powered">Powered by <a href="https://laravel.com" target="_blank" rel="noopener">Laravel</a> & <a href="https://filamentphp.com" target="_blank" rel="noopener">Filament</a></p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<meta name="generator" content="LaraLog">
|
||||
<link rel="canonical" href="{{ url()->current() }}">
|
||||
<link rel="alternate" type="application/rss+xml" title="{{ $siteName }}" href="{{ route('feed.rss') }}">
|
||||
<link rel="alternate" type="text/plain" title="llms.txt" href="{{ route('feed.llms') }}">
|
||||
<link rel="stylesheet" href="{{ asset('css/blog.css') }}">
|
||||
@stack('head')
|
||||
@stack('theme:head')
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<a href="{{ route('tags') }}" class="{{ request()->routeIs('tags*') ? 'active' : '' }}">标签</a>
|
||||
<a href="{{ route('links') }}" class="{{ request()->routeIs('links') ? 'active' : '' }}">友链</a>
|
||||
<a href="{{ route('comments') }}" class="{{ request()->routeIs('comments') ? 'active' : '' }}">评论</a>
|
||||
@include('partials.feed-links')
|
||||
<form class="site-search" action="{{ route('search') }}" method="get">
|
||||
<input type="search" name="q" placeholder="搜索..." value="{{ request('q', request('keyword', '')) }}">
|
||||
</form>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
@if ($paginator->hasPages())
|
||||
<nav class="pagination-links" role="navigation">
|
||||
{{-- Previous --}}
|
||||
<nav class="pagination-links" role="navigation" aria-label="分页">
|
||||
<span class="pagination-info">第 {{ $paginator->currentPage() }} / {{ $paginator->lastPage() }} 页</span>
|
||||
|
||||
@if ($paginator->onFirstPage())
|
||||
<span class="disabled">« 上一页</span>
|
||||
<span class="disabled">«</span>
|
||||
@else
|
||||
<a href="{{ $paginator->previousPageUrl() }}" rel="prev">« 上一页</a>
|
||||
<a href="{{ $paginator->previousPageUrl() }}" rel="prev">«</a>
|
||||
@endif
|
||||
|
||||
{{-- Numbers --}}
|
||||
@foreach ($elements as $element)
|
||||
@if (is_string($element))
|
||||
<span class="disabled">{{ $element }}</span>
|
||||
@@ -23,11 +23,10 @@
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
{{-- Next --}}
|
||||
@if ($paginator->hasMorePages())
|
||||
<a href="{{ $paginator->nextPageUrl() }}" rel="next">下一页 »</a>
|
||||
<a href="{{ $paginator->nextPageUrl() }}" rel="next">»</a>
|
||||
@else
|
||||
<span class="disabled">下一页 »</span>
|
||||
<span class="disabled">»</span>
|
||||
@endif
|
||||
</nav>
|
||||
@endif
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
<article class="post-card {{ $post->is_sticky ? 'sticky' : '' }}">
|
||||
@php
|
||||
$viewMode = $homeViewMode ?? \App\Blog\Support\HomeViewMode::LIST;
|
||||
$showFull = $viewMode === \App\Blog\Support\HomeViewMode::FULL
|
||||
&& blank($post->read_password)
|
||||
&& empty(($post->meta ?? [])['members_only']);
|
||||
@endphp
|
||||
<article class="post-card {{ $post->isPinned() ? 'sticky' : '' }} post-card-{{ $viewMode }}">
|
||||
@if($url = $post->coverImageUrl())
|
||||
<a href="{{ route('posts.show', $post->id) }}" class="post-cover">
|
||||
<img src="{{ $url }}" alt="{{ $post->title }}" loading="lazy">
|
||||
</a>
|
||||
@endif
|
||||
<h2 class="post-title">
|
||||
@if($post->is_sticky)<span class="badge">置顶</span>@endif
|
||||
@if($label = $post->stickyLabel())<span class="badge">{{ $label }}</span>@endif
|
||||
<a href="{{ route('posts.show', $post->id) }}">{{ $post->title }}</a>
|
||||
</h2>
|
||||
<div class="post-meta">
|
||||
@@ -17,9 +23,15 @@
|
||||
<span>· 阅读 {{ $post->views }}</span>
|
||||
<span>· 评论 {{ $post->comment_count }}</span>
|
||||
</div>
|
||||
<div class="post-excerpt">
|
||||
{{ Str::limit(strip_tags($post->excerpt_or_fallback), 200) }}
|
||||
</div>
|
||||
@if($showFull)
|
||||
<div class="post-content">
|
||||
{!! app(\App\Blog\Services\PostContentRenderer::class)->render($post) !!}
|
||||
</div>
|
||||
@else
|
||||
<div class="post-excerpt">
|
||||
{{ \Illuminate\Support\Str::limit($post->excerpt_or_fallback, 200) }}
|
||||
</div>
|
||||
@endif
|
||||
<div class="post-footer">
|
||||
<a href="{{ route('posts.show', $post->id) }}" class="read-more">阅读全文 »</a>
|
||||
@foreach($post->tags as $tag)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
@if(! empty($isPreview))
|
||||
<div class="alert alert-warning">
|
||||
预览中:这篇文章还没发布,访客打不开。只有管理员和编辑能看到这个页面。
|
||||
</div>
|
||||
@endif
|
||||
@@ -0,0 +1,9 @@
|
||||
@php
|
||||
$viewMode = $homeViewMode ?? \App\Blog\Support\HomeViewMode::LIST;
|
||||
@endphp
|
||||
<div class="view-mode-switcher">
|
||||
浏览模式:
|
||||
<a href="{{ \App\Blog\Support\HomeViewMode::url(\App\Blog\Support\HomeViewMode::FULL) }}" class="{{ $viewMode === \App\Blog\Support\HomeViewMode::FULL ? 'active' : '' }}">标准</a>
|
||||
<span>|</span>
|
||||
<a href="{{ \App\Blog\Support\HomeViewMode::url(\App\Blog\Support\HomeViewMode::LIST) }}" class="{{ $viewMode === \App\Blog\Support\HomeViewMode::LIST ? 'active' : '' }}">列表</a>
|
||||
</div>
|
||||
@@ -10,6 +10,8 @@
|
||||
<button type="submit" class="btn">搜索</button>
|
||||
</form>
|
||||
|
||||
@include('partials.view-mode-switcher')
|
||||
|
||||
@forelse($posts as $post)
|
||||
@include('partials.post-card', ['post' => $post])
|
||||
@empty
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
@if(session('error'))
|
||||
<div class="alert alert-error">{{ session('error') }}</div>
|
||||
@endif
|
||||
@include('partials.post-preview-banner')
|
||||
|
||||
<article class="post-full">
|
||||
@if(! empty($toc))
|
||||
@@ -37,7 +38,11 @@
|
||||
@endif
|
||||
<h1 class="post-title">{{ $post->title }}</h1>
|
||||
<div class="post-meta">
|
||||
<time datetime="{{ $post->published_at->toIso8601String() }}">{{ $post->published_at->format(blog_setting('normaltime', 'Y-m-d H:i')) }}</time>
|
||||
@if($post->published_at)
|
||||
<time datetime="{{ $post->published_at->toIso8601String() }}">{{ $post->published_at->format(blog_setting('normaltime', 'Y-m-d H:i')) }}</time>
|
||||
@else
|
||||
<span>未发布</span>
|
||||
@endif
|
||||
@if($post->author)<span>· {{ $post->author->name }}</span>@endif
|
||||
@if($post->category)
|
||||
<span>· <a href="{{ route('category.show', $post->category->id) }}">{{ $post->category->name }}</a></span>
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
<main class="content">
|
||||
<h1 class="list-title">标签:{{ $tag->name }}</h1>
|
||||
|
||||
@include('partials.view-mode-switcher')
|
||||
|
||||
@forelse($posts as $post)
|
||||
@include('partials.post-card', ['post' => $post])
|
||||
@empty
|
||||
|
||||
Reference in New Issue
Block a user