Fixed something... It's 4:30 Idk...
This commit is contained in:
parent
a3d818a80a
commit
ce19f164dc
|
|
@ -18,7 +18,6 @@ public class Init : Migration
|
||||||
.WithColumn("ModifiedAt").AsDateTime()
|
.WithColumn("ModifiedAt").AsDateTime()
|
||||||
.WithColumn("Signature").AsString().Nullable()
|
.WithColumn("Signature").AsString().Nullable()
|
||||||
.WithColumn("FullWidth").AsBoolean()
|
.WithColumn("FullWidth").AsBoolean()
|
||||||
.WithColumn("Deleted").AsBoolean()
|
|
||||||
.WithColumn("Visible").AsBoolean();
|
.WithColumn("Visible").AsBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,6 @@ public static class DependencyInjection
|
||||||
ModifiedAt = DateTime.UtcNow,
|
ModifiedAt = DateTime.UtcNow,
|
||||||
SourceLocation = "welcome.md",
|
SourceLocation = "welcome.md",
|
||||||
ShowDetails = false,
|
ShowDetails = false,
|
||||||
Deleted = false,
|
|
||||||
Visible = false
|
Visible = false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,5 @@ public sealed class BlogMeta
|
||||||
public DateTime ModifiedAt { get; init; }
|
public DateTime ModifiedAt { get; init; }
|
||||||
public string? Signature { get; init; }
|
public string? Signature { get; init; }
|
||||||
public bool FullWidth { get; init; } = false;
|
public bool FullWidth { get; init; } = false;
|
||||||
public bool Deleted { get; init; } = false;
|
|
||||||
public bool Visible { get; init; } = false;
|
public bool Visible { get; init; } = false;
|
||||||
}
|
}
|
||||||
|
|
@ -22,7 +22,6 @@ public sealed class BlogMetaRepository(SqliteConnectionFactory connectionFactory
|
||||||
const string sql = """
|
const string sql = """
|
||||||
select * from Blogs
|
select * from Blogs
|
||||||
where (slug = @slug or id = cast(@slug as integer))
|
where (slug = @slug or id = cast(@slug as integer))
|
||||||
and deleted = 0
|
|
||||||
and CreatedAt <= datetime('now')
|
and CreatedAt <= datetime('now')
|
||||||
""";
|
""";
|
||||||
|
|
||||||
|
|
@ -38,7 +37,6 @@ public sealed class BlogMetaRepository(SqliteConnectionFactory connectionFactory
|
||||||
const string sql = """
|
const string sql = """
|
||||||
select * from Blogs
|
select * from Blogs
|
||||||
where id = @id
|
where id = @id
|
||||||
and deleted = 0
|
|
||||||
""";
|
""";
|
||||||
|
|
||||||
return await connection.QueryFirstOrDefaultAsync<BlogMeta>(sql, new { id });
|
return await connection.QueryFirstOrDefaultAsync<BlogMeta>(sql, new { id });
|
||||||
|
|
@ -47,8 +45,7 @@ public sealed class BlogMetaRepository(SqliteConnectionFactory connectionFactory
|
||||||
public async Task<bool> Delete(int id)
|
public async Task<bool> Delete(int id)
|
||||||
{
|
{
|
||||||
const string sql = """
|
const string sql = """
|
||||||
update Blogs
|
delete from Blogs
|
||||||
set Deleted = 1
|
|
||||||
where id = @id
|
where id = @id
|
||||||
""";
|
""";
|
||||||
|
|
||||||
|
|
@ -62,8 +59,8 @@ public sealed class BlogMetaRepository(SqliteConnectionFactory connectionFactory
|
||||||
using var connection = connectionFactory.Create();
|
using var connection = connectionFactory.Create();
|
||||||
|
|
||||||
const string sql = """
|
const string sql = """
|
||||||
insert into Blogs (Title, SourceLocation, Slug, ShowDetails, ImageUrl, CreatedAt, ModifiedAt, Signature, FullWidth, Deleted, Visible)
|
insert into Blogs (Title, SourceLocation, Slug, ShowDetails, ImageUrl, CreatedAt, ModifiedAt, Signature, FullWidth, Visible)
|
||||||
values (@Title, @SourceLocation, @Slug, @ShowDetails, @ImageUrl, @CreatedAt, @ModifiedAt, @Signature, @FullWidth, @Deleted, @Visible)
|
values (@Title, @SourceLocation, @Slug, @ShowDetails, @ImageUrl, @CreatedAt, @ModifiedAt, @Signature, @FullWidth, @Visible)
|
||||||
returning *
|
returning *
|
||||||
""";
|
""";
|
||||||
try
|
try
|
||||||
|
|
@ -85,7 +82,7 @@ public sealed class BlogMetaRepository(SqliteConnectionFactory connectionFactory
|
||||||
|
|
||||||
const string sql = """
|
const string sql = """
|
||||||
update Blogs
|
update Blogs
|
||||||
set Title = @Title, SourceLocation = @SourceLocation, Slug = @Slug, ShowDetails = @ShowDetails, ImageUrl = @ImageUrl, CreatedAt = @CreatedAt, ModifiedAt = @ModifiedAt, Signature = @Signature, FullWidth = @FullWidth, Deleted = @Deleted, Visible = @Visible
|
set Title = @Title, SourceLocation = @SourceLocation, Slug = @Slug, ShowDetails = @ShowDetails, ImageUrl = @ImageUrl, CreatedAt = @CreatedAt, ModifiedAt = @ModifiedAt, Signature = @Signature, FullWidth = @FullWidth, Visible = @Visible
|
||||||
where id = @Id
|
where id = @Id
|
||||||
returning *
|
returning *
|
||||||
""";
|
""";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
@using Ganss.Xss
|
@using Ganss.Xss
|
||||||
@using Markdig;
|
@using Markdig;
|
||||||
|
@using Markdig.Extensions.AutoIdentifiers
|
||||||
@using Pek.Markdig.HighlightJs
|
@using Pek.Markdig.HighlightJs
|
||||||
@model FastBlog.Core.Models.Blogs.Blog
|
@model FastBlog.Core.Models.Blogs.Blog
|
||||||
|
|
||||||
|
|
@ -9,10 +10,14 @@
|
||||||
.UseSmartyPants()
|
.UseSmartyPants()
|
||||||
.UseEmojiAndSmiley()
|
.UseEmojiAndSmiley()
|
||||||
.UseAlertBlocks()
|
.UseAlertBlocks()
|
||||||
.UseAdvancedExtensions()
|
.UseAdvancedExtensions();
|
||||||
.UseHighlightJs();
|
|
||||||
|
pipelineBuilder.Extensions.Remove(pipelineBuilder.Extensions.Find<AutoIdentifierExtension>()!);
|
||||||
|
pipelineBuilder.UseAutoIdentifiers(AutoIdentifierOptions.GitHub);
|
||||||
|
pipelineBuilder.UseHighlightJs();
|
||||||
var sanitizer = new HtmlSanitizer();
|
var sanitizer = new HtmlSanitizer();
|
||||||
sanitizer.AllowedAttributes.Add("class");
|
sanitizer.AllowedAttributes.Add("class");
|
||||||
|
sanitizer.AllowedAttributes.Add("id");
|
||||||
var pipeline = pipelineBuilder.Build();
|
var pipeline = pipelineBuilder.Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue