rendering html
This commit is contained in:
@ -1,9 +1,6 @@
|
|||||||
using System.Text;
|
|
||||||
using Microsoft.AspNetCore.Html;
|
using Microsoft.AspNetCore.Html;
|
||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
||||||
using AsciiDocNet;
|
using AsciiDocNet;
|
||||||
using Yavsc.Models.Blog;
|
|
||||||
using System.Linq.Expressions;
|
|
||||||
|
|
||||||
namespace Yavsc.Helpers
|
namespace Yavsc.Helpers
|
||||||
{
|
{
|
||||||
@ -51,7 +48,7 @@ namespace Yavsc.Helpers
|
|||||||
Source source = (Source)elt;
|
Source source = (Source)elt;
|
||||||
// TODO syntact hilighting and fun js modules
|
// TODO syntact hilighting and fun js modules
|
||||||
contentbuilder.AppendHtmlLine("<pre><code>");
|
contentbuilder.AppendHtmlLine("<pre><code>");
|
||||||
contentbuilder.Append(source.Text);
|
contentbuilder.AppendHtml(source.Text);
|
||||||
contentbuilder.AppendHtmlLine("</code></pre>");
|
contentbuilder.AppendHtmlLine("</code></pre>");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -95,7 +92,7 @@ namespace Yavsc.Helpers
|
|||||||
case "AsciiDocNet.Emphasis":
|
case "AsciiDocNet.Emphasis":
|
||||||
sb.AppendHtml("<i>");
|
sb.AppendHtml("<i>");
|
||||||
AsciiDocNet.Emphasis em = (Emphasis)elt;
|
AsciiDocNet.Emphasis em = (Emphasis)elt;
|
||||||
sb.Append(em.Text);
|
sb.AppendHtml(em.Text);
|
||||||
sb.AppendHtml("</i>");
|
sb.AppendHtml("</i>");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -150,9 +147,9 @@ namespace Yavsc.Helpers
|
|||||||
var tl = elt as TextLiteral;
|
var tl = elt as TextLiteral;
|
||||||
if (tl?.Attributes.Anchor != null)
|
if (tl?.Attributes.Anchor != null)
|
||||||
{
|
{
|
||||||
sb.AppendFormat("<a name=\"{0}\">{1}</a> ", tl.Attributes.Anchor.Id, tl.Attributes.Anchor.XRefLabel);
|
sb.AppendHtmlLine($"<a name=\"{tl.Attributes.Anchor.Id}\">{tl.Attributes.Anchor.XRefLabel}</a> ");
|
||||||
}
|
}
|
||||||
if (tl != null) sb.Append(tl.Text);
|
if (tl != null) sb.AppendHtml(tl.Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IHtmlContent ToHtml(this Document doc, int doclevel = 4)
|
public static IHtmlContent ToHtml(this Document doc, int doclevel = 4)
|
||||||
@ -176,7 +173,7 @@ namespace Yavsc.Helpers
|
|||||||
return contentbuilder;
|
return contentbuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public static IHtmlContent AsciiDocFor<TModel>(this IHtmlHelper<TModel> html,
|
public static IHtmlContent AsciiDocFor<TModel>(this IHtmlHelper<TModel> html,
|
||||||
Expression<Func<TModel, string>> expression)
|
Expression<Func<TModel, string>> expression)
|
||||||
{
|
{
|
||||||
@ -209,6 +206,6 @@ namespace Yavsc.Helpers
|
|||||||
|
|
||||||
// Render tag
|
// Render tag
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,10 @@ namespace Yavsc.Helpers
|
|||||||
{
|
{
|
||||||
public override async Task ProcessAsync (TagHelperContext context, TagHelperOutput output)
|
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);
|
await base.ProcessAsync(context, output);
|
||||||
var content = await output.GetChildContentAsync();
|
var content = await output.GetChildContentAsync();
|
||||||
string text = content.GetContent();
|
string text = content.GetContent();
|
||||||
|
@ -51,17 +51,18 @@
|
|||||||
var title = group.Key ?? "@";
|
var title = group.Key ?? "@";
|
||||||
string secondclass="";
|
string secondclass="";
|
||||||
var first = group.First();
|
var first = group.First();
|
||||||
|
int maxTextLen = 256;
|
||||||
|
|
||||||
<tr><td colspan="3">
|
<tr><td colspan="3">
|
||||||
<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 trunked = item.Content?.Length > 256;
|
var trunked = item.Content?.Length > maxTextLen;
|
||||||
<tr>
|
<tr>
|
||||||
<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>
|
||||||
<asciidoc summary="256">@item.Content</asciidoc>
|
<asciidoc summary="@maxTextLen">@item.Content</asciidoc>
|
||||||
@if (trunked) { <a asp-action="Details" asp-route-id="@item.Id" class="bloglink">...</a> }
|
@if (trunked) { <a asp-action="Details" asp-route-id="@item.Id" class="bloglink">...</a> }
|
||||||
<span style="font-size:x-small;">@Html.DisplayFor(m => item.Author)</span>
|
<span style="font-size:x-small;">@Html.DisplayFor(m => item.Author)</span>
|
||||||
<span style="font-size:xx-small;">
|
<span style="font-size:xx-small;">
|
||||||
|
Reference in New Issue
Block a user