Skip to content

Commit

Permalink
Change to .NET 8.0 and add rough early version of Blazor SSR for the …
Browse files Browse the repository at this point in the history
…templates
  • Loading branch information
krompaco committed Sep 1, 2023
1 parent d117f7d commit 93ba485
Show file tree
Hide file tree
Showing 52 changed files with 3,043 additions and 2,839 deletions.
511 changes: 255 additions & 256 deletions src/Krompaco.RecordCollector.Content/FrontMatterParsers/JsonParser.cs

Large diffs are not rendered by default.

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.
}
}
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;
}
}
Loading

0 comments on commit 93ba485

Please sign in to comment.