From 605d8859178a8f34a660d7052eb1c448e91c1425 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 21 Sep 2026 11:12:20 +0100 Subject: [PATCH] Rewrite Blogspot Index view with skip/take pagination MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Renders Prev/Next pager from the Index(string id, int skip, int take) call profile, drops dead .sametitle JS, and replaces the redundant ReadPermission branch and Minutes>0 modifié check. Co-Authored-By: Claude Code --- src/Yavsc.Org/Views/Blogspot/Index.cshtml | 206 +++++++++++++++------- 1 file changed, 138 insertions(+), 68 deletions(-) diff --git a/src/Yavsc.Org/Views/Blogspot/Index.cshtml b/src/Yavsc.Org/Views/Blogspot/Index.cshtml index 1179dba53..9f29a9417 100644 --- a/src/Yavsc.Org/Views/Blogspot/Index.cshtml +++ b/src/Yavsc.Org/Views/Blogspot/Index.cshtml @@ -1,85 +1,155 @@ - @model IEnumerable @{ ViewBag.Title = "Blogs, l'index"; + + // Pagination reflects the Index(string id, int skip, int take) + // call profile. The service applies Skip/Take server-side, so + // the view only needs the current page params to build Prev/Next + // links — it does not receive a total count. + int currentSkip = Context.Request.Query.TryGetValue("skip", out var skipVal) && int.TryParse(skipVal, out var s) ? s : 0; + int currentTake = Context.Request.Query.TryGetValue("take", out var takeVal) && int.TryParse(takeVal, out var t) ? t : 25; + + var posts = Model.ToList(); + bool hasPrev = currentSkip > 0; + bool hasNext = posts.Count >= currentTake; + + int prevSkip = Math.Max(0, currentSkip - currentTake); + int nextSkip = currentSkip + currentTake; + + int maxSummaryLen = 256; } @section header { -} -@section scripts { - + .blog-index .post-meta { + font-size: .8rem; + color: var(--bs-secondary-color, #6c757d); + } + .blog-index .post-author img { + width: 1.25rem; + height: 1.25rem; + border-radius: 50%; + vertical-align: middle; + margin-right: .25rem; + } + .blog-index .actiongroup { + margin-top: .5rem; + display: flex; + gap: .5rem; + } + .blog-index .post-summary { + margin: .25rem 0; + } + .blog-index .post-summary > p:last-child { + margin-bottom: 0; + } + .blog-pager { + display: flex; + justify-content: space-between; + margin-top: 1.5rem; + } + }

@ViewBag.Title

@ViewBag.StatusMessage

-
-@{ - int maxTextLen = 75; - foreach (var post in Model) { -
- - - -
-

@post.Title

-
-
- - @post.Article - @Html.DisplayFor(m => post.Author) - - posté le @post.DateCreated.ToString("dddd d MMM yyyy à H:mm") - @if ((post.DateModified - post.DateCreated).Minutes > 0){ - @:- Modifié le @post.DateModified.ToString("dddd d MMM yyyy à H:mm") - } - -
-
- @if ((await AuthorizationService.AuthorizeAsync(User, post, new ReadPermission())).Succeeded) - { - Details - } - else - { - Details - } - @if ((await AuthorizationService.AuthorizeAsync(User, post, new EditPermission())).Succeeded) - { - Delete - - } -
-
- } +@if (!posts.Any()) +{ +

Néant

} -
+else +{ +
+ @foreach (var post in posts) + { + var canEdit = (await AuthorizationService.AuthorizeAsync(User, post, new EditPermission())).Succeeded; +
+ @if (!string.IsNullOrEmpty(post.Photo)) + { + + @post.Title + + } +
+

+ @post.Title +

+
+ + @post.Article + +
+ +
+ Details + @if (canEdit) + { + Delete + } +
+
+
+ } +
-@if(Model.Count()==0){

Néant

} + +} \ No newline at end of file