Skip to content

Commit 2e708a9

Browse files
committed
Update packages and convert sample to use raw string
1 parent 7924eec commit 2e708a9

File tree

4 files changed

+105
-86
lines changed

4 files changed

+105
-86
lines changed

projects/sfa/wiki/Program.cs

+74-72
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using FluentValidation;
22
using FluentValidation.AspNetCore;
3-
using Ganss.XSS;
3+
using Ganss.Xss;
44
using HtmlBuilders;
55
using LiteDB;
66
using Markdig;
@@ -272,7 +272,7 @@ static string RenderMarkdown(string str)
272272

273273
static string RenderDeletePageButton(Page page, AntiforgeryTokenSet antiForgery)
274274
{
275-
var antiForgeryField = Input.Hidden.Name(antiForgery.FormFieldName).Value(antiForgery.RequestToken);
275+
var antiForgeryField = Input.Hidden.Name(antiForgery.FormFieldName).Value(antiForgery.RequestToken!);
276276
HtmlTag id = Input.Hidden.Name("Id").Value(page.Id.ToString());
277277
var submit = Div.Style("margin-top", "20px").Append(Button.Class("uk-button uk-button-danger").Append("Delete Page"));
278278

@@ -306,7 +306,7 @@ HtmlTag CreateEditorHelper(Attachment attachment) =>
306306

307307
static HtmlTag CreateDelete(int pageId, string attachmentId, AntiforgeryTokenSet antiForgery)
308308
{
309-
var antiForgeryField = Input.Hidden.Name(antiForgery.FormFieldName).Value(antiForgery.RequestToken);
309+
var antiForgeryField = Input.Hidden.Name(antiForgery.FormFieldName).Value(antiForgery.RequestToken!);
310310
var id = Input.Hidden.Name("Id").Value(attachmentId.ToString());
311311
var name = Input.Hidden.Name("PageId").Value(pageId.ToString());
312312

@@ -353,7 +353,7 @@ static string BuildForm(PageInput input, string path, AntiforgeryTokenSet antiFo
353353
{
354354
bool IsFieldOK(string key) => modelState!.ContainsKey(key) && modelState[key]!.ValidationState == ModelValidationState.Invalid;
355355

356-
var antiForgeryField = Input.Hidden.Name(antiForgery.FormFieldName).Value(antiForgery.RequestToken);
356+
var antiForgeryField = Input.Hidden.Name(antiForgery.FormFieldName).Value(antiForgery.RequestToken!);
357357

358358
var nameField = Div
359359
.Append(Label.Class("uk-form-label").Append(nameof(input.Name)))
@@ -405,9 +405,9 @@ static string BuildForm(PageInput input, string path, AntiforgeryTokenSet antiFo
405405
.Append(contentField)
406406
.Append(attachmentField);
407407

408-
if (input.Id.HasValue)
408+
if (input.Id is object)
409409
{
410-
HtmlTag id = Input.Hidden.Name("Id").Value(input.Id.ToString());
410+
HtmlTag id = Input.Hidden.Name("Id").Value(input.Id.ToString()!);
411411
form = form.Append(id);
412412
}
413413

@@ -443,71 +443,73 @@ function copyMarkdownLink(element) {
443443
};
444444

445445
(Template head, Template body, Template layout) _templates = (
446-
head: Scriban.Template.Parse(@"
447-
<meta charset=""utf-8"">
448-
<meta name=""viewport"" content=""width=device-width, initial-scale=1"">
449-
<title>{{ title }}</title>
450-
<link rel=""stylesheet"" href=""https://cdn.jsdelivr.net/npm/[email protected]/dist/css/uikit.min.css"" />
451-
{{ header }}
452-
<style>
453-
.last-modified { font-size: small; }
454-
a:visited { color: blue; }
455-
a:link { color: red; }
456-
</style>
457-
"),
458-
body: Scriban.Template.Parse(@"
459-
<nav class=""uk-navbar-container"">
460-
<div class=""uk-container"">
461-
<div class=""uk-navbar"">
462-
<div class=""uk-navbar-left"">
463-
<ul class=""uk-navbar-nav"">
464-
<li class=""uk-active""><a href=""/""><span uk-icon=""home""></span></a></li>
465-
</ul>
466-
</div>
467-
<div class=""uk-navbar-center"">
468-
<div class=""uk-navbar-item"">
469-
<form action=""/new-page"">
470-
<input class=""uk-input uk-form-width-large"" type=""text"" name=""pageName"" placeholder=""Type desired page title here""></input>
471-
<input type=""submit"" class=""uk-button uk-button-default"" value=""Add New Page"">
472-
</form>
473-
</div>
474-
</div>
475-
</div>
476-
</div>
477-
</nav>
478-
{{ if at_side_panel != """" }}
479-
<div class=""uk-container"">
480-
<div uk-grid>
481-
<div class=""uk-width-4-5"">
482-
<h1>{{ page_name }}</h1>
483-
{{ content }}
484-
</div>
485-
<div class=""uk-width-1-5"">
486-
{{ at_side_panel }}
487-
</div>
488-
</div>
489-
</div>
490-
{{ else }}
491-
<div class=""uk-container"">
492-
<h1>{{ page_name }}</h1>
493-
{{ content }}
494-
</div>
495-
{{ end }}
496-
497-
<script src=""https://cdn.jsdelivr.net/npm/[email protected]/dist/js/uikit.min.js""></script>
498-
<script src=""https://cdn.jsdelivr.net/npm/[email protected]/dist/js/uikit-icons.min.js""></script>
499-
{{ at_foot }}
500-
"),
501-
layout: Scriban.Template.Parse(@"
502-
<!DOCTYPE html>
503-
<head>
504-
{{ head }}
505-
</head>
506-
<body>
507-
{{ body }}
508-
</body>
509-
</html>
510-
")
446+
head: Scriban.Template.Parse(
447+
"""
448+
<meta charset="utf-8">
449+
<meta name="viewport" content="width=device-width, initial-scale=1">
450+
<title>{{ title }}</title>
451+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/uikit.min.css" />
452+
{{ header }}
453+
<style>
454+
.last-modified { font-size: small; }
455+
a:visited { color: blue; }
456+
a:link { color: red; }
457+
</style>
458+
"""),
459+
body: Scriban.Template.Parse("""
460+
<nav class="uk-navbar-container">
461+
<div class="uk-container">
462+
<div class="uk-navbar">
463+
<div class="uk-navbar-left">
464+
<ul class="uk-navbar-nav">
465+
<li class="uk-active"><a href="/"><span uk-icon="home"></span></a></li>
466+
</ul>
467+
</div>
468+
<div class="uk-navbar-center">
469+
<div class="uk-navbar-item">
470+
<form action="/new-page">
471+
<input class="uk-input uk-form-width-large" type="text" name="pageName" placeholder="Type desired page title here"></input>
472+
<input type="submit" class="uk-button uk-button-default" value="Add New Page">
473+
</form>
474+
</div>
475+
</div>
476+
</div>
477+
</div>
478+
</nav>
479+
{{ if at_side_panel != "" }}
480+
<div class="uk-container">
481+
<div uk-grid>
482+
<div class="uk-width-4-5">
483+
<h1>{{ page_name }}</h1>
484+
{{ content }}
485+
</div>
486+
<div class="uk-width-1-5">
487+
{{ at_side_panel }}
488+
</div>
489+
</div>
490+
</div>
491+
{{ else }}
492+
<div class="uk-container">
493+
<h1>{{ page_name }}</h1>
494+
{{ content }}
495+
</div>
496+
{{ end }}
497+
498+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/uikit.min.js"></script>
499+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/uikit-icons.min.js"></script>
500+
{{ at_foot }}
501+
502+
"""),
503+
layout: Scriban.Template.Parse("""
504+
<!DOCTYPE html>
505+
<head>
506+
{{ head }}
507+
</head>
508+
<body>
509+
{{ body }}
510+
</body>
511+
</html>
512+
""")
511513
);
512514

513515
// Use only when the page requires editor
@@ -793,7 +795,7 @@ public static PageInput From(IFormCollection form)
793795

794796
IFormFile? file = form.Files["Attachment"];
795797

796-
return new PageInput(pageId, name, content, file);
798+
return new PageInput(pageId, name!, content!, file);
797799
}
798800
}
799801

projects/sfa/wiki/nuget.config

-8
This file was deleted.

projects/sfa/wiki/wiki.csproj

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<ImplicitUsings>true</ImplicitUsings>
66
</PropertyGroup>
77
<ItemGroup>
8-
<PackageReference Include="Scriban" Version="5.0.0" />
9-
<PackageReference Include="Markdig" Version="0.26.0" />
10-
<PackageReference Include="LiteDB" Version="5.0.11" />
11-
<PackageReference Include="HtmlBuilders" Version="6.0.1" />
12-
<PackageReference Include="HtmlSanitizer" Version="6.0.*" />
13-
<PackageReference Include="FluentValidation.AspNetCore" Version="10.3.4" />
8+
<PackageReference Include="Scriban" Version="5.10.0" />
9+
<PackageReference Include="Markdig" Version="0.37.0" />
10+
<PackageReference Include="LiteDB" Version="5.0.19" />
11+
<PackageReference Include="HtmlBuilders" Version="7.2.0" />
12+
<PackageReference Include="HtmlSanitizer" Version="8.1.860-beta" />
13+
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
1414
</ItemGroup>
1515
</Project>

projects/sfa/wiki/wiki.sln

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.002.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "wiki", "wiki.csproj", "{BD4F3D16-D4B7-4663-B4AB-72BDBEA7391B}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{BD4F3D16-D4B7-4663-B4AB-72BDBEA7391B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{BD4F3D16-D4B7-4663-B4AB-72BDBEA7391B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{BD4F3D16-D4B7-4663-B4AB-72BDBEA7391B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{BD4F3D16-D4B7-4663-B4AB-72BDBEA7391B}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {66E15924-BA6C-475F-979B-999AE50E98EE}
24+
EndGlobalSection
25+
EndGlobal

0 commit comments

Comments
 (0)