diff --git a/src/Yavsc.Server/Services/BlogSpotService.cs b/src/Yavsc.Server/Services/BlogSpotService.cs index 99146a1a..78d6932a 100644 --- a/src/Yavsc.Server/Services/BlogSpotService.cs +++ b/src/Yavsc.Server/Services/BlogSpotService.cs @@ -113,7 +113,7 @@ public class BlogSpotService _context.SaveChanges(user.GetUserId()); } - public async Task>> IndexByTitle(ClaimsPrincipal user, string id, int skip = 0, int take = 25) + public async Task> Index(ClaimsPrincipal user, string id, int skip = 0, int take = 25) { IEnumerable posts; @@ -149,9 +149,8 @@ public class BlogSpotService .Select(p => p.BlogPost).ToArray(); } - var data = posts.OrderByDescending(p => p.DateCreated); - var grouped = data.GroupBy(p => p.Title).Skip(skip).Take(take); - return grouped; + var data = posts.OrderByDescending(p => p.DateModified); + return data; } public async Task Delete(ClaimsPrincipal user, long id) @@ -174,7 +173,7 @@ public class BlogSpotService return _context.UserPosts(posterId, readerId); } - public object? ByTitle(string title) + public object? GetTitle(string title) { return _context.BlogSpot.Include( b => b.Author @@ -190,4 +189,5 @@ public class BlogSpotService .Include(b => b.ACL) .SingleOrDefaultAsync(x => x.Id == value); } + } diff --git a/src/Yavsc/Controllers/Communicating/BlogspotController.cs b/src/Yavsc/Controllers/Communicating/BlogspotController.cs index 0c1de2e3..8ca8220f 100644 --- a/src/Yavsc/Controllers/Communicating/BlogspotController.cs +++ b/src/Yavsc/Controllers/Communicating/BlogspotController.cs @@ -47,8 +47,8 @@ namespace Yavsc.Controllers await blogSpotService.UserPosts(id, User.GetUserId(), skip, take)); } - IEnumerable> byTitle = await this.blogSpotService.IndexByTitle(User, id, skip, take); - return View(byTitle); + IEnumerable index = await this.blogSpotService.Index(User, id, skip, take); + return View(index); } [Route("~/Title/{id?}")] @@ -56,7 +56,7 @@ namespace Yavsc.Controllers public IActionResult Title(string id) { ViewData["Title"] = id; - return View("Title", blogSpotService.ByTitle(id)); + return View("Title", blogSpotService.GetTitle(id)); } private async Task> UserPosts(string userName, int pageLen = 10, int pageNum = 0) diff --git a/src/Yavsc/Helpers/AsciiDocTagHelper.cs b/src/Yavsc/Helpers/AsciiDocTagHelper.cs index 9d9d34e6..3286b1bb 100644 --- a/src/Yavsc/Helpers/AsciiDocTagHelper.cs +++ b/src/Yavsc/Helpers/AsciiDocTagHelper.cs @@ -1,5 +1,6 @@ using System.Text.Encodings.Web; using AsciiDocNet; +using Microsoft.AspNetCore.Html; using Microsoft.AspNetCore.Razor.TagHelpers; namespace Yavsc.Helpers @@ -8,17 +9,28 @@ namespace Yavsc.Helpers { public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { - if (context.AllAttributes.ContainsName("summary")) - { - var summaryLength = context.AllAttributes["summary"].Value; - } + await base.ProcessAsync(context, output); var content = await output.GetChildContentAsync(); string text = content.GetContent(); if (string.IsNullOrWhiteSpace(text)) return; + try { - + if (context.AllAttributes.ContainsName("summary")) + { + var summaryLength = context.AllAttributes["summary"].Value; + if (summaryLength is HtmlString sumLenStr) + { + if (int.TryParse(sumLenStr.Value, out var sumLen)) + { + if (text.Length > sumLen) + { + text = text.Substring(0, sumLen) + "(...)"; + } + } + } + } Document document = Document.Parse(text); var html = document.ToHtml(2); using var stringWriter = new StringWriter(); diff --git a/src/Yavsc/Views/Blogspot/Details.cshtml b/src/Yavsc/Views/Blogspot/Details.cshtml index 4d884a29..d8d46e5f 100644 --- a/src/Yavsc/Views/Blogspot/Details.cshtml +++ b/src/Yavsc/Views/Blogspot/Details.cshtml @@ -60,10 +60,14 @@ $('#commentValidation').html( } } -
-
-

@Model.Title

- + +
+
+ +
+ +

@Model.Title

+ @Html.DisplayFor(m=>m.Author) @Html.DisplayFor(m=>m.Content) @@ -98,4 +102,4 @@ $('#commentValidation').html( Edit } Back to List -
+ diff --git a/src/Yavsc/Views/Blogspot/Index.cshtml b/src/Yavsc/Views/Blogspot/Index.cshtml index 7e1a7f7d..d860624c 100644 --- a/src/Yavsc/Views/Blogspot/Index.cshtml +++ b/src/Yavsc/Views/Blogspot/Index.cshtml @@ -1,4 +1,4 @@ -@model IEnumerable> +@model IEnumerable @{ ViewData["Title"] = "Blogs, l'index"; } @@ -43,59 +43,51 @@ Create a new article

} - -
- +
+@{ + int maxTextLen = 75; + foreach (var post in Model) { +
-@foreach (var group in Model) { - var title = group.Key ?? "@"; - string secondclass=""; - var first = group.First(); - int maxTextLen = 256; -
- @foreach (var item in group) { - var trunked = item.Content?.Length > maxTextLen; - - - - - +
+ + + +
+

@post.Title

+
+ + @post.Content + @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) + { + Edit + + Delete + + } +
+ } } -
-@title
- - - @item.Content - @if (trunked) { ... } - @Html.DisplayFor(m => item.Author) - - posté le @item.DateCreated.ToString("dddd d MMM yyyy à H:mm") - @if ((item.DateModified - item.DateCreated).Minutes > 0){  - @:- Modifié le @item.DateModified.ToString("dddd d MMM yyyy à H:mm") - }) - - -
    - @if ((await AuthorizationService.AuthorizeAsync(User, item, new ReadPermission())).Succeeded) { -
  • - Details -
  • - } - else { - Details DEBUG - } - @if ((await AuthorizationService.AuthorizeAsync(User, item, new EditPermission())).Succeeded) { -
  • Edit -
  • -
  • Delete -
  • - } -
-
+
@if(Model.Count()==0){

Néant

} - -
diff --git a/src/Yavsc/Views/Blogspot/Title.cshtml b/src/Yavsc/Views/Blogspot/Title.cshtml index 811105ce..4f7f7ed9 100644 --- a/src/Yavsc/Views/Blogspot/Title.cshtml +++ b/src/Yavsc/Views/Blogspot/Title.cshtml @@ -28,7 +28,7 @@
    @if ((await AuthorizationService.AuthorizeAsync(User, item, new ReadPermission())).Succeeded) {
  • - Details + Details
  • } @if ((await AuthorizationService.AuthorizeAsync(User, item, new EditPermission())).Succeeded) { diff --git a/src/Yavsc/Views/OAuth/Authorize.cshtml b/src/Yavsc/Views/OAuth/Authorize.cshtml index f0ddbecf..f33162c4 100644 --- a/src/Yavsc/Views/OAuth/Authorize.cshtml +++ b/src/Yavsc/Views/OAuth/Authorize.cshtml @@ -20,9 +20,9 @@ }

- - - + + +

diff --git a/src/Yavsc/Views/Shared/Logout.cshtml b/src/Yavsc/Views/Shared/Logout.cshtml index edf9616d..b3fc02a7 100644 --- a/src/Yavsc/Views/Shared/Logout.cshtml +++ b/src/Yavsc/Views/Shared/Logout.cshtml @@ -14,6 +14,6 @@ } - + -
\ No newline at end of file + diff --git a/src/Yavsc/Views/Shared/SignIn.cshtml b/src/Yavsc/Views/Shared/SignIn.cshtml index 0e00c104..7fb6e56e 100644 --- a/src/Yavsc/Views/Shared/SignIn.cshtml +++ b/src/Yavsc/Views/Shared/SignIn.cshtml @@ -37,7 +37,7 @@
- +

diff --git a/src/Yavsc/wwwroot/css/site.css b/src/Yavsc/wwwroot/css/site.css index 7edc006c..633f830b 100644 --- a/src/Yavsc/wwwroot/css/site.css +++ b/src/Yavsc/wwwroot/css/site.css @@ -30,5 +30,21 @@ input[type='checkbox'] { min-height: 1em; } .container { - background-color: #000000cf; - color: #ffffff; } + background-color: #00000040; + color: #fff; + border-radius: 2em; } + +.post { + background-color: #000000dd; + color: #d1d1d1; + padding: 2.3em; + border-radius: 2em; + border: solid #441515a4 2pt; } + +div.actiongroup { + float: right; + margin: .5em; } + +div.float-left { + float: left; + margin: .5em; } diff --git a/src/Yavsc/wwwroot/css/site.scss b/src/Yavsc/wwwroot/css/site.scss index 9553b3ec..01dc5e7b 100644 --- a/src/Yavsc/wwwroot/css/site.scss +++ b/src/Yavsc/wwwroot/css/site.scss @@ -45,6 +45,27 @@ input[type='checkbox'] { } .container { - background-color: #000000cf; - color:#ffffff; + background-color: #00000040; + color: #fff; + border-radius: 2em; +} + +.post { + background-color: #000000dd; + color:#d1d1d1; + padding: 2.3em; + border-radius: 2em; + border: solid #441515a4 2pt; +} + +.actiongroup +{ + float: right; + margin:.5em; +} + +.float-left +{ + float: left; + margin:.5em; } diff --git a/src/sampleWebAsWebApiClient/Views/Home/Index.cshtml b/src/sampleWebAsWebApiClient/Views/Home/Index.cshtml index 7899726a..d68605ad 100755 --- a/src/sampleWebAsWebApiClient/Views/Home/Index.cshtml +++ b/src/sampleWebAsWebApiClient/Views/Home/Index.cshtml @@ -19,26 +19,26 @@ }

- +
- +
- +
Envoyer vers le dossier "test" - +
- Sign out + Sign out } else {

Welcome, anonymous

- Sign in + Sign in }