Updated admin page to be more streamlined and added the beginning of the blogging features

This commit is contained in:
Vincent Allen
2025-10-21 13:32:39 -04:00
parent 0e24ce2073
commit b34449808f
224 changed files with 27064 additions and 396 deletions

View File

@@ -26,10 +26,21 @@ public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options
public DbSet<ArtifactType> ArtifactTypes { get; set; }
public DbSet<ArtifactGroupingViewCount> ArtifactGroupingViewCounts { get; set; }
public DbSet<BlogPost> BlogPosts { get; set; }
public DbSet<BlogPostTag> BlogPostTags { get; set; }
/// <summary>
/// Configuration for what featured artifacts will be show on the homepage of the search page
/// </summary>
public DbSet<SearchPageSliderEntry> SearchPageSliderEntries { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ArtifactEntry>()
.HasMany(a => a.RelatedTo)
.WithMany(a => a.RelatedBy)
@@ -39,10 +50,15 @@ public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options
.HasOne(a => a.StorageLocation)
.WithMany(l => l.ArtifactEntries);
modelBuilder.Entity<ArtifactGroupingViewCount>()
.HasOne(vc => vc.Grouping)
.WithOne(g => g.ViewCount)
.HasForeignKey<ArtifactGroupingViewCount>(vc => vc.ArtifactGroupingId);
modelBuilder.Entity<ArtifactGrouping>()
.OwnsOne(p => p.IdentifierFields)
.ToJson();
modelBuilder.Entity<ArtifactGrouping>()
.HasMany(grouping => grouping.ChildArtifactEntries)
.WithOne(entry => entry.ArtifactGrouping)
@@ -69,11 +85,12 @@ public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options
sourceDictionary => new Dictionary<string, string>(sourceDictionary)
);
// Create the search vector columns for artifat groupings
modelBuilder.Entity<ArtifactGrouping>()
.HasGeneratedTsVectorColumn(
p => p.AllSearchVector,
"english",
p => p.AllSearchString
p => p.AllSearchString
)
.HasIndex(p => p.AllSearchVector)
.HasMethod("GIN");
@@ -141,6 +158,37 @@ public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options
.HasIndex(p => p.FileContentSearchVector)
.HasMethod("GIN");
// Create the search vector columns for blog posts
modelBuilder.Entity<BlogPost>()
.HasGeneratedTsVectorColumn(
p => p.ContentSearchVector,
"english",
p => p.Content)
.HasIndex(p => p.ContentSearchVector)
.HasMethod("GIN");
modelBuilder.Entity<BlogPost>()
.HasGeneratedTsVectorColumn(
p => p.TitleSearchVector,
"english",
p => p.Title)
.HasIndex(p => p.TitleSearchVector)
.HasMethod("GIN");
modelBuilder.Entity<BlogPost>()
.HasGeneratedTsVectorColumn(
p => p.TagsSearchVector,
"english",
p => p.TagsSearchString)
.HasIndex(p => p.TagsSearchVector)
.HasMethod("GIN");
modelBuilder.Entity<BlogPost>()
.HasGeneratedTsVectorColumn(
p => p.AllSearchVector,
"english",
p => p.AllSearchString)
.HasIndex(p => p.AllSearchVector)
.HasMethod("GIN");
}
}