Allow heading tags (h1-h6) in ContentSanitizer so news editor headings render
This commit is contained in:
@@ -132,6 +132,32 @@ class NewsController extends Controller
|
||||
] + $this->sidebarData());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Type page — /news/type/{type}
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
public function type(Request $request, string $type): View
|
||||
{
|
||||
$typeLabels = \cPad\Plugins\News\Models\NewsArticle::TYPE_LABELS;
|
||||
|
||||
abort_unless(array_key_exists($type, $typeLabels), 404);
|
||||
|
||||
$label = $typeLabels[$type];
|
||||
$perPage = config('news.articles_per_page', 12);
|
||||
|
||||
$articles = NewsArticle::with('author', 'category')
|
||||
->published()
|
||||
->where('type', $type)
|
||||
->editorialOrder()
|
||||
->paginate($perPage);
|
||||
|
||||
return view('news.type', [
|
||||
'type' => $type,
|
||||
'typeLabel' => $label,
|
||||
'articles' => $articles,
|
||||
] + $this->sidebarData());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Article page — /news/{slug}
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -173,14 +199,21 @@ class NewsController extends Controller
|
||||
return;
|
||||
}
|
||||
|
||||
NewsView::create([
|
||||
'article_id' => $article->id,
|
||||
'user_id' => $userId,
|
||||
'ip' => $ip,
|
||||
'created_at' => now(),
|
||||
]);
|
||||
try {
|
||||
NewsView::create([
|
||||
'article_id' => $article->id,
|
||||
'user_id' => $userId,
|
||||
'ip' => $ip,
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
$article->incrementViews();
|
||||
$article->incrementViews();
|
||||
} catch (\Illuminate\Database\QueryException $e) {
|
||||
// Unique constraint violation — duplicate view, skip silently.
|
||||
if (($e->errorInfo[1] ?? 0) !== 1062) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
if ($canReadSession) {
|
||||
$request->session()->put($session, true);
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\News;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use cPad\Plugins\News\Models\NewsArticle;
|
||||
|
||||
class NewsRssController extends Controller
|
||||
@@ -14,13 +15,17 @@ class NewsRssController extends Controller
|
||||
*/
|
||||
public function feed(): Response
|
||||
{
|
||||
$articles = NewsArticle::with('author', 'category')
|
||||
->published()
|
||||
->orderByDesc('published_at')
|
||||
->limit(config('news.rss_limit', 25))
|
||||
->get();
|
||||
$ttl = max(60, (int) config('news.rss_cache_ttl', 300));
|
||||
|
||||
$xml = $this->buildRss($articles);
|
||||
$xml = Cache::remember('news.rss.feed', $ttl, function (): string {
|
||||
$articles = NewsArticle::with('author', 'category')
|
||||
->published()
|
||||
->orderByDesc('published_at')
|
||||
->limit(config('news.rss_limit', 25))
|
||||
->get();
|
||||
|
||||
return $this->buildRss($articles);
|
||||
});
|
||||
|
||||
return response($xml, 200, [
|
||||
'Content-Type' => 'application/rss+xml; charset=UTF-8',
|
||||
|
||||
Reference in New Issue
Block a user