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);
|
||||
|
||||
Reference in New Issue
Block a user