summaries

This commit is contained in:
2020-10-10 17:46:16 +01:00
parent c907b387d7
commit f81f6617ce
2 changed files with 11 additions and 2 deletions

View File

@ -24,6 +24,7 @@ namespace Yavsc.TagHelpers
{ {
private const string MarkdownContentAttributeName = "markdown"; private const string MarkdownContentAttributeName = "markdown";
private const string MarkdownMarkAttributeName = "ismarkdown"; private const string MarkdownMarkAttributeName = "ismarkdown";
private const string SummaryMarkAttributeName = "summary";
[HtmlAttributeName("site")] [HtmlAttributeName("site")]
public SiteSettings Site { get; set; } public SiteSettings Site { get; set; }
[HtmlAttributeName("base")] [HtmlAttributeName("base")]
@ -32,6 +33,11 @@ namespace Yavsc.TagHelpers
[HtmlAttributeName(MarkdownContentAttributeName)] [HtmlAttributeName(MarkdownContentAttributeName)]
public string MarkdownContent { get; set; } public string MarkdownContent { get; set; }
[HtmlAttributeName(SummaryMarkAttributeName)]
public int Summary { get; set; }
static Regex rxExtractLanguage = new Regex("^({{(.+)}}[\r\n])", RegexOptions.Compiled); static Regex rxExtractLanguage = new Regex("^({{(.+)}}[\r\n])", RegexOptions.Compiled);
private static string FormatCodePrettyPrint(MarkdownDeep.Markdown m, string code) private static string FormatCodePrettyPrint(MarkdownDeep.Markdown m, string code)
{ {
@ -98,6 +104,8 @@ namespace Yavsc.TagHelpers
markdownTransformer.FormatCodeBlock = FormatCodePrettyPrint; markdownTransformer.FormatCodeBlock = FormatCodePrettyPrint;
markdownTransformer.ExtractHeadBlocks = true; markdownTransformer.ExtractHeadBlocks = true;
markdownTransformer.UserBreaks = true; markdownTransformer.UserBreaks = true;
markdownTransformer.SummaryLength = Summary;
// TODO markdownTransformer.DoOnlyHtmlChunk = true;
return markdownTransformer; return markdownTransformer;
} }

View File

@ -26,13 +26,14 @@
<a asp-action="Title" asp-route-id="@group.Key" >@title</a></td></tr> <a asp-action="Title" asp-route-id="@group.Key" >@title</a></td></tr>
@foreach (var item in group) { @foreach (var item in group) {
var trclass = (item.Visible)?"visiblepost":"hiddenpost"; var trclass = (item.Visible)?"visiblepost":"hiddenpost";
var trunked = item.Content?.Length > 256;
<tr class="@trclass"> <tr class="@trclass">
<td><a asp-action="Details" asp-route-id="@item.Id" class="bloglink"> <td><a asp-action="Details" asp-route-id="@item.Id" class="bloglink">
<img src="@item.Photo" class="blogphoto"></a> <img src="@item.Photo" class="blogphoto"></a>
</td> </td>
<td> <td>
<markdown>@((item.Content?.Length > 256) ? item.Content.Substring(0, 256) + " ..." : item.Content)</markdown> <markdown summary="256">@item.Content</markdown>
@if (trunked) { <a asp-action="Details" asp-route-id="@item.Id" class="bloglink">...</a> }
<span style="font-size:x-small;">(@item.Author.UserName </span>, <span style="font-size:x-small;">(@item.Author.UserName </span>,
<span style="font-size:xx-small;"> <span style="font-size:xx-small;">
posté le @item.DateCreated.ToString("dddd d MMM yyyy à H:mm") posté le @item.DateCreated.ToString("dddd d MMM yyyy à H:mm")