-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change to .NET 8.0 and add rough early version of Blazor SSR for the …
…templates
- Loading branch information
Showing
52 changed files
with
3,043 additions
and
2,839 deletions.
There are no files selected for viewing
511 changes: 255 additions & 256 deletions
511
src/Krompaco.RecordCollector.Content/FrontMatterParsers/JsonParser.cs
Large diffs are not rendered by default.
Oops, something went wrong.
9 changes: 4 additions & 5 deletions
9
src/Krompaco.RecordCollector.Content/FrontMatterParsers/ParserBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
namespace Krompaco.RecordCollector.Content.FrontMatterParsers | ||
namespace Krompaco.RecordCollector.Content.FrontMatterParsers; | ||
|
||
public class ParserBase | ||
{ | ||
public class ParserBase | ||
{ | ||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
protected string FullName { get; set; } | ||
protected string FullName { get; set; } | ||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. | ||
} | ||
} |
119 changes: 59 additions & 60 deletions
119
src/Krompaco.RecordCollector.Content/FrontMatterParsers/SummaryExtractor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,86 @@ | ||
using System.Text; | ||
|
||
namespace Krompaco.RecordCollector.Content.FrontMatterParsers | ||
namespace Krompaco.RecordCollector.Content.FrontMatterParsers; | ||
|
||
public class SummaryExtractor | ||
{ | ||
public class SummaryExtractor | ||
private readonly StreamReader tr; | ||
|
||
public SummaryExtractor(StreamReader tr) | ||
{ | ||
private readonly StreamReader tr; | ||
this.tr = tr; | ||
} | ||
|
||
public SummaryExtractor(StreamReader tr) | ||
{ | ||
this.tr = tr; | ||
} | ||
public string? GetSummaryFromContent() | ||
{ | ||
var rowCount = 0; | ||
var frontMatterOpened = false; | ||
var frontMatterClosed = false; | ||
var sb = new StringBuilder(); | ||
|
||
public string? GetSummaryFromContent() | ||
while (this.tr.Peek() >= 0) | ||
{ | ||
var rowCount = 0; | ||
var frontMatterOpened = false; | ||
var frontMatterClosed = false; | ||
var sb = new StringBuilder(); | ||
rowCount++; | ||
var line = this.tr.ReadLine() ?? string.Empty; | ||
|
||
while (this.tr.Peek() >= 0) | ||
if (line.Trim() == "<!--more-->" || line.Trim() == "# more") | ||
{ | ||
rowCount++; | ||
var line = this.tr.ReadLine() ?? string.Empty; | ||
return this.ResetStreamAndReturn(sb.ToString()); | ||
} | ||
|
||
if (line.Trim() == "<!--more-->" || line.Trim() == "# more") | ||
{ | ||
return this.ResetStreamAndReturn(sb.ToString()); | ||
} | ||
if (frontMatterClosed) | ||
{ | ||
sb.AppendLine(line); | ||
} | ||
|
||
if (frontMatterClosed) | ||
{ | ||
sb.AppendLine(line); | ||
} | ||
if (frontMatterOpened && line.StartsWith("}", StringComparison.Ordinal)) | ||
{ | ||
frontMatterClosed = true; | ||
} | ||
|
||
if (frontMatterOpened && line.StartsWith("}", StringComparison.Ordinal)) | ||
{ | ||
frontMatterClosed = true; | ||
} | ||
if (line.StartsWith("{", StringComparison.Ordinal)) | ||
{ | ||
frontMatterOpened = true; | ||
} | ||
|
||
if (line.StartsWith("{", StringComparison.Ordinal)) | ||
if (line.Trim() == "+++") | ||
{ | ||
if (frontMatterOpened) | ||
{ | ||
frontMatterOpened = true; | ||
frontMatterClosed = true; | ||
} | ||
|
||
if (line.Trim() == "+++") | ||
{ | ||
if (frontMatterOpened) | ||
{ | ||
frontMatterClosed = true; | ||
} | ||
|
||
frontMatterOpened = true; | ||
} | ||
frontMatterOpened = true; | ||
} | ||
|
||
if (line.Trim() == "---") | ||
if (line.Trim() == "---") | ||
{ | ||
if (frontMatterOpened) | ||
{ | ||
if (frontMatterOpened) | ||
{ | ||
frontMatterClosed = true; | ||
} | ||
|
||
frontMatterOpened = true; | ||
frontMatterClosed = true; | ||
} | ||
|
||
if (line.TrimStart().StartsWith("<html", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
return this.ResetStreamAndReturn(null); | ||
} | ||
frontMatterOpened = true; | ||
} | ||
|
||
if (rowCount == 100) | ||
{ | ||
break; | ||
} | ||
if (line.TrimStart().StartsWith("<html", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
return this.ResetStreamAndReturn(null); | ||
} | ||
|
||
return this.ResetStreamAndReturn(null); | ||
if (rowCount == 100) | ||
{ | ||
break; | ||
} | ||
} | ||
|
||
private string? ResetStreamAndReturn(string? summary) | ||
{ | ||
this.tr.BaseStream.Position = 0; | ||
this.tr.DiscardBufferedData(); | ||
return summary; | ||
} | ||
return this.ResetStreamAndReturn(null); | ||
} | ||
|
||
private string? ResetStreamAndReturn(string? summary) | ||
{ | ||
this.tr.BaseStream.Position = 0; | ||
this.tr.DiscardBufferedData(); | ||
return summary; | ||
} | ||
} |
Oops, something went wrong.