From 64babca37ba577f659a723a26f4e4bb6b494a793 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sat, 8 Apr 2023 01:39:37 +0100 Subject: [PATCH] render pages --- src/Yavsc/Helpers/AsciiDocHelpers.cs | 177 +++++++++--------- src/Yavsc/Helpers/AsciiDocTagHelper.cs | 5 +- src/Yavsc/Views/Blogspot/Title.cshtml | 2 +- src/Yavsc/Views/HairCutCommand/CGV.cshtml | 4 +- src/Yavsc/Views/Home/About.pt.cshtml | 28 +-- src/Yavsc/Views/Home/AboutAccess.cshtml | 4 +- src/Yavsc/Views/Home/AboutMarkdown.cshtml | 4 +- src/Yavsc/Views/Home/CGV.cshtml | 4 +- src/Yavsc/Views/Home/Privacy.cshtml | 4 +- src/Yavsc/Views/Home/Todo.cshtml | 8 +- .../Components/BlogIndex/Default.cshtml | 2 +- .../Shared/DisplayTemplates/Comment.cshtml | 2 +- src/Yavsc/Views/Shared/_Layout.cshtml | 2 +- src/Yavsc/Views/Test/MarkdownForms.cshtml | 4 +- 14 files changed, 126 insertions(+), 124 deletions(-) diff --git a/src/Yavsc/Helpers/AsciiDocHelpers.cs b/src/Yavsc/Helpers/AsciiDocHelpers.cs index 557a47c6..af312872 100644 --- a/src/Yavsc/Helpers/AsciiDocHelpers.cs +++ b/src/Yavsc/Helpers/AsciiDocHelpers.cs @@ -8,13 +8,13 @@ using System.Linq.Expressions; namespace Yavsc.Helpers { public static class AsciiDocHelpers -{ - static void ToHtml(this IElement elt, IHtmlContentBuilder contentbuilder) { - switch (elt.GetType().FullName) + static void ToHtml(this IElement elt, IHtmlContentBuilder contentbuilder) { - case "AsciiDocNet.Paragraph": - Paragraph p = (Paragraph) elt; + switch (elt.GetType().FullName) + { + case "AsciiDocNet.Paragraph": + Paragraph p = (Paragraph)elt; contentbuilder.AppendHtmlLine("

"); foreach (var pitem in p) { @@ -23,8 +23,8 @@ namespace Yavsc.Helpers contentbuilder.AppendHtmlLine("

"); break; case "AsciiDocNet.SectionTitle": - SectionTitle stitle = (SectionTitle) elt; - + SectionTitle stitle = (SectionTitle)elt; + contentbuilder.AppendHtmlLine($""); foreach (var titem in stitle) { @@ -33,123 +33,124 @@ namespace Yavsc.Helpers contentbuilder.AppendHtmlLine(""); break; case "AsciiDocNet.UnorderedList": - UnorderedList ul = (UnorderedList) elt; + UnorderedList ul = (UnorderedList)elt; contentbuilder.AppendHtmlLine(""); break; case "AsciiDocNet.Source": - Source source = (Source) elt ; + Source source = (Source)elt; // TODO syntact hilighting and fun js modules contentbuilder.AppendHtmlLine("
");
                     contentbuilder.Append(source.Text);
                     contentbuilder.AppendHtmlLine("
"); break; - default: - string unsupportedType = elt.GetType().FullName; - throw new InvalidProgramException(unsupportedType); + default: + string unsupportedType = elt.GetType().FullName; + throw new InvalidProgramException(unsupportedType); + } } - } - static void ToHtml(this IInlineElement elt, IHtmlContentBuilder sb) - { - switch (elt.GetType().FullName) + static void ToHtml(this IInlineElement elt, IHtmlContentBuilder sb) { - case "AsciiDocNet.Link": - Link link = (Link) elt; - sb.AppendFormat("{1} ",link.Href, link.Text); - break; - - case "AsciiDocNet.TextLiteral": - sb.Append(elt.ToString()); - break; - - case "AsciiDocNet.Emphasis": - sb.AppendHtml(""); - AsciiDocNet.Emphasis em = (Emphasis) elt; - sb.Append(em.Text); - sb.AppendHtml(""); - break; - - case "AsciiDocNet.Strong": - sb.AppendHtml(""); - AsciiDocNet.Strong str = (Strong) elt; - foreach (var stritem in str) - { - stritem.ToHtml(sb); - } - sb.AppendHtml(""); - break; + switch (elt.GetType().FullName) + { + case "AsciiDocNet.Link": + Link link = (Link)elt; + sb.AppendFormat("{1} ", link.Href, link.Text); + break; - default: - string unsupportedType = elt.GetType().FullName; - throw new InvalidProgramException(unsupportedType); + case "AsciiDocNet.TextLiteral": + sb.Append(elt.ToString()); + break; + + case "AsciiDocNet.Emphasis": + sb.AppendHtml(""); + AsciiDocNet.Emphasis em = (Emphasis)elt; + sb.Append(em.Text); + sb.AppendHtml(""); + break; + + case "AsciiDocNet.Strong": + sb.AppendHtml(""); + AsciiDocNet.Strong str = (Strong)elt; + foreach (var stritem in str) + { + stritem.ToHtml(sb); + } + sb.AppendHtml(""); + break; + + default: + string unsupportedType = elt.GetType().FullName; + throw new InvalidProgramException(unsupportedType); + } } - } - public static IHtmlContent ToHtml(this Document doc, int doclevel = 4) - { - var contentbuilder = new HtmlContentBuilder(); - if (doc.Title != null) + public static IHtmlContent ToHtml(this Document doc, int doclevel = 4) { - if (!string.IsNullOrWhiteSpace(doc.Title.Title)) + var contentbuilder = new HtmlContentBuilder(); + if (doc.Title != null) { - contentbuilder.AppendHtmlLine($"{doc.Title.Title}"); - if (!string.IsNullOrWhiteSpace(doc.Title.Subtitle)) + if (!string.IsNullOrWhiteSpace(doc.Title.Title)) { - contentbuilder.AppendHtmlLine($"{doc.Title.Title}
"); + contentbuilder.AppendHtmlLine($"{doc.Title.Title}"); + if (!string.IsNullOrWhiteSpace(doc.Title.Subtitle)) + { + contentbuilder.AppendHtmlLine($"{doc.Title.Title}
"); + } } } + foreach (var item in doc) + { + item.ToHtml(contentbuilder); + } + return contentbuilder; } - foreach (var item in doc) - { - item.ToHtml(contentbuilder); - } - return contentbuilder; - } - public static IHtmlContent AsciiDocFor(this IHtmlHelper html, - Expression> expression) - { - string ascii = html.ValueFor(expression, "{0}"); - Document document = Document.Parse(ascii); - var htmlDoc = document.ToHtml(); - - var span = new TagBuilder("p") { TagRenderMode = TagRenderMode.SelfClosing }; - span.InnerHtml.AppendHtml(htmlDoc); - return span.RenderBody(); - } + public static IHtmlContent AsciiDocFor(this IHtmlHelper html, + Expression> expression) + { + string ascii = html.ValueFor(expression, "{0}"); + if (string.IsNullOrWhiteSpace(ascii)) + return new HtmlString(string.Empty); + Document document = Document.Parse(ascii); + var htmlDoc = document.ToHtml(); + var span = new TagBuilder("p") { TagRenderMode = TagRenderMode.SelfClosing }; + span.InnerHtml.AppendHtml(htmlDoc); + return span.RenderBody(); + } - public static string AsciiDoc(IHtmlHelper htmlHelper, string text) - { - return AsciiDoc(htmlHelper, text, null); - } + public static string AsciiDoc(IHtmlHelper htmlHelper, string text) + { + return AsciiDoc(htmlHelper, text, null); + } - private static string AsciiDoc(IHtmlHelper htmlHelper, string text, object htmlAttributes) - { - // Create tag builder - var builder = new TagBuilder("div"); - var document = Document.Parse(text); + private static string AsciiDoc(IHtmlHelper htmlHelper, string text, object htmlAttributes) + { + // Create tag builder + var builder = new TagBuilder("div"); + var document = Document.Parse(text); - // builder.InnerHtml = . + // builder.InnerHtml = . - // Add attributes - builder.MergeAttribute("class", "ascii"); - builder.MergeAttributes(new RouteValueDictionary(htmlAttributes)); + // Add attributes + builder.MergeAttribute("class", "ascii"); + builder.MergeAttributes(new RouteValueDictionary(htmlAttributes)); - // Render tag - return builder.ToString(); + // Render tag + return builder.ToString(); + } } } -} diff --git a/src/Yavsc/Helpers/AsciiDocTagHelper.cs b/src/Yavsc/Helpers/AsciiDocTagHelper.cs index 98a13218..f001c584 100644 --- a/src/Yavsc/Helpers/AsciiDocTagHelper.cs +++ b/src/Yavsc/Helpers/AsciiDocTagHelper.cs @@ -9,8 +9,9 @@ namespace Yavsc.Helpers public override async Task ProcessAsync (TagHelperContext context, TagHelperOutput output) { var content = await output.GetChildContentAsync(); - - Document document = Document.Parse(content.GetContent()); + string text = content.GetContent(); + if (string.IsNullOrWhiteSpace(text)) return; + Document document = Document.Parse(text); var html = document.ToHtml(4); using var stringWriter = new StringWriter(); html.WriteTo(stringWriter, HtmlEncoder.Default); diff --git a/src/Yavsc/Views/Blogspot/Title.cshtml b/src/Yavsc/Views/Blogspot/Title.cshtml index 7f07299e..6e2b27d5 100644 --- a/src/Yavsc/Views/Blogspot/Title.cshtml +++ b/src/Yavsc/Views/Blogspot/Title.cshtml @@ -30,7 +30,7 @@ - @((item.Content?.Length > 256) ? item.Content.Substring(0, 256) + " ..." : item.Content) + @((item.Content?.Length > 256) ? item.Content.Substring(0, 256) + " ..." : item.Content) (@item.Author.UserName , posté le @item.DateCreated.ToString("dddd d MMM yyyy à H:mm") diff --git a/src/Yavsc/Views/HairCutCommand/CGV.cshtml b/src/Yavsc/Views/HairCutCommand/CGV.cshtml index 6ac548d7..62431d43 100644 --- a/src/Yavsc/Views/HairCutCommand/CGV.cshtml +++ b/src/Yavsc/Views/HairCutCommand/CGV.cshtml @@ -2,7 +2,7 @@ ViewData["Title"] = "Conditions Générales de Vente"; }

@ViewData["Title"]

- + Le paiement intervient à la commande, quelque soit la date d'intervention. Vous pouvez annuler votre commande depuis la [liste de vos commande en cours](/HairCutCommand/), @@ -10,4 +10,4 @@ Vous pouvez annuler votre commande depuis la [liste de vos commande en cours](/H Vous pouvez demander le remboursement d'un paiement, dans le cadre d'une réclamation sur l'execution de votre commande, en nous contactant via courrier éléctronique ou postal, [que vour retrouverez sur la page de contact](/Home/Contact), votre demande sera rapidement traitée. - \ No newline at end of file + diff --git a/src/Yavsc/Views/Home/About.pt.cshtml b/src/Yavsc/Views/Home/About.pt.cshtml index 26e1495c..6d02607e 100755 --- a/src/Yavsc/Views/Home/About.pt.cshtml +++ b/src/Yavsc/Views/Home/About.pt.cshtml @@ -4,7 +4,7 @@

@ViewData["Title"]

- + ## O objetivo Esta aplicação é construída para conectar artistas @@ -86,36 +86,36 @@ que imediatamente desativa as publicações associadas às suas informações, e planeia a eliminação completa desta informação no prazo de quinze dias do aplicativo, a menos que seja um pedido contraditório. A operação é anulável até duas semanas após a sua programação. - + -Este é o meu site perso, uma configuração de _Yavsc_ (outro negócio muito pequeno). +Este é o meu site perso, uma configuração de _Yavsc_ (outro negócio muito pequeno). * [README](https://github.com/pazof/yavsc/blob/vnext/README.md) * [licença: GNU GPL v3](https://github.com/pazof/yavsc/blob/vnext/LICENSE) Outras instalações: - - + + * [Coiffure](http://coiffure.pschneider.fr) * [ZicMoove](http://linkmuse.pschneider.fr) * [Yavsc](http://yavsc.pschneider.fr) - + - + Yet Another Very Small Company ... * [README](https://github.com/pazof/yavsc/blob/vnext/README.md) * [license: GNU FPL v3](https://github.com/pazof/yavsc/blob/vnext/LICENSE) - + - + ## Yet Another Very Small Company : * [README](https://github.com/pazof/yavsc/blob/vnext/README.md) * [license: GNU FPL v3](https://github.com/pazof/yavsc/blob/vnext/LICENSE) @@ -125,12 +125,12 @@ En production: * [Lua](https://lua.pschneider.fr) * [Yavsc](https://yavsc.pschneider.fr) - + - + Você está no site da ordem em cabeleireiro em casa de Soraya Boudjouraf, um ás de cabeleireiro, que trabalha na região de Paris. @@ -138,11 +138,11 @@ Ao validar um formulário de pedido aqui, é para ela que você notifica sua sol Você pode [Deixe-lhe o seu número de telefone] (/ HairCutCommand / HairCut? ActivityCode = Brush & performerId = 1bd841ab-c305-4971-940d-7ddca818310c) e / ou detalhes sobre o seu pedido, -ela vai ligar de volta. +ela vai ligar de volta. - + ## Este é um site de desenvolvimento. Este recurso só diz respeito ao desenvolvimento do software que o implementa. @@ -155,7 +155,7 @@ A "pré-produção" exibe os seguintes sites: * [Yavsc](https://yavsc.pschneider.fr) * [Lua](https://lua.pschneider.fr) - +

diff --git a/src/Yavsc/Views/Home/AboutAccess.cshtml b/src/Yavsc/Views/Home/AboutAccess.cshtml index 663d3cf7..a7ae8fa2 100644 --- a/src/Yavsc/Views/Home/AboutAccess.cshtml +++ b/src/Yavsc/Views/Home/AboutAccess.cshtml @@ -3,7 +3,7 @@ }

@ViewData["Title"]

- + # Blog et fichiers utilisateurs @@ -35,4 +35,4 @@ Et ils possèdent une addresse permanente de la forme : - \ No newline at end of file + diff --git a/src/Yavsc/Views/Home/AboutMarkdown.cshtml b/src/Yavsc/Views/Home/AboutMarkdown.cshtml index c75ed05c..cb22f162 100644 --- a/src/Yavsc/Views/Home/AboutMarkdown.cshtml +++ b/src/Yavsc/Views/Home/AboutMarkdown.cshtml @@ -3,7 +3,7 @@ }

@ViewData["Title"]

- + Quelques extensions à un Markdown de base : * les video et audio: `![video: Ep. 28 - La France en commun - Une invitation à écrire un nouveau projet d'émancipation humaine](/images/testVideo.mp4)` @@ -16,4 +16,4 @@ Quelques extensions à un Markdown de base : * le tag "Titre d'article": "#1_great_title" * le tag "User" = "@@(John Doe)" ou "@@jdoe" - + diff --git a/src/Yavsc/Views/Home/CGV.cshtml b/src/Yavsc/Views/Home/CGV.cshtml index 6ac548d7..62431d43 100644 --- a/src/Yavsc/Views/Home/CGV.cshtml +++ b/src/Yavsc/Views/Home/CGV.cshtml @@ -2,7 +2,7 @@ ViewData["Title"] = "Conditions Générales de Vente"; }

@ViewData["Title"]

- + Le paiement intervient à la commande, quelque soit la date d'intervention. Vous pouvez annuler votre commande depuis la [liste de vos commande en cours](/HairCutCommand/), @@ -10,4 +10,4 @@ Vous pouvez annuler votre commande depuis la [liste de vos commande en cours](/H Vous pouvez demander le remboursement d'un paiement, dans le cadre d'une réclamation sur l'execution de votre commande, en nous contactant via courrier éléctronique ou postal, [que vour retrouverez sur la page de contact](/Home/Contact), votre demande sera rapidement traitée. - \ No newline at end of file + diff --git a/src/Yavsc/Views/Home/Privacy.cshtml b/src/Yavsc/Views/Home/Privacy.cshtml index d5b6c578..216e01d1 100644 --- a/src/Yavsc/Views/Home/Privacy.cshtml +++ b/src/Yavsc/Views/Home/Privacy.cshtml @@ -3,7 +3,7 @@ }

@ViewData["Title"]

- + ## La confidentialité À aucun moment, aucune adresse postale, aucune adresse e-mail ni aucun numéro de téléphone @@ -11,4 +11,4 @@ ne sont transmis à personne. Seul le système et son [possesseur](/Home/Contact De plus, le droit de retrait est permanent et sa mise en oeuvre [immédiate](/Account/Delete). - \ No newline at end of file + diff --git a/src/Yavsc/Views/Home/Todo.cshtml b/src/Yavsc/Views/Home/Todo.cshtml index f3336893..6ff89f13 100755 --- a/src/Yavsc/Views/Home/Todo.cshtml +++ b/src/Yavsc/Views/Home/Todo.cshtml @@ -4,14 +4,14 @@

@ViewData["Title"]

Linkmuse(trox) - + Les tags. La librairie, les lives. - + @{ ViewData["Title"] = @SR["TODO"]; }

@ViewData["Title"]

Faster, stronger, shorter - - + + diff --git a/src/Yavsc/Views/Shared/Components/BlogIndex/Default.cshtml b/src/Yavsc/Views/Shared/Components/BlogIndex/Default.cshtml index 20ee31e4..92f81b83 100644 --- a/src/Yavsc/Views/Shared/Components/BlogIndex/Default.cshtml +++ b/src/Yavsc/Views/Shared/Components/BlogIndex/Default.cshtml @@ -32,7 +32,7 @@ - @item.Content + @item.Content @if (trunked) { ... } (@item.Author.UserName , diff --git a/src/Yavsc/Views/Shared/DisplayTemplates/Comment.cshtml b/src/Yavsc/Views/Shared/DisplayTemplates/Comment.cshtml index f6e45739..6f217fae 100644 --- a/src/Yavsc/Views/Shared/DisplayTemplates/Comment.cshtml +++ b/src/Yavsc/Views/Shared/DisplayTemplates/Comment.cshtml @@ -1,7 +1,7 @@ @model Comment
- @Model.Content + @Model.Content
@if (Model.Children!=null && Model.Children.Count>0) { foreach (var comment in Model.Children) { diff --git a/src/Yavsc/Views/Shared/_Layout.cshtml b/src/Yavsc/Views/Shared/_Layout.cshtml index 3269344b..f0c7faea 100644 --- a/src/Yavsc/Views/Shared/_Layout.cshtml +++ b/src/Yavsc/Views/Shared/_Layout.cshtml @@ -64,7 +64,7 @@ } } diff --git a/src/Yavsc/Views/Test/MarkdownForms.cshtml b/src/Yavsc/Views/Test/MarkdownForms.cshtml index 95c1fc07..968e6dfd 100644 --- a/src/Yavsc/Views/Test/MarkdownForms.cshtml +++ b/src/Yavsc/Views/Test/MarkdownForms.cshtml @@ -1,4 +1,4 @@ - + # Title @@ -20,4 +20,4 @@ Or else, ![input:textarea:yours](enter you life here :-)) - \ No newline at end of file +