Refactor and novel18 support (added cookie support in general to AbstractScraper.cs
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-07-20 22:04:13 -04:00
parent 12a1f48fbd
commit ceb8a0db8e
59 changed files with 353 additions and 240 deletions

View File

@@ -1,11 +1,11 @@
using System.Net.Mime; using System.Net.Mime;
using System.Text; using System.Text;
using Common.Models;
using Microsoft.AspNetCore.WebUtilities; using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using Treestar.Shared.Models;
namespace Treestar.Shared.AccessLayers; namespace Common.AccessLayers;
public abstract class ApiAccessLayer public abstract class ApiAccessLayer
{ {

View File

@@ -1,4 +1,4 @@
namespace Treestar.Shared.AccessLayers; namespace Common.AccessLayers;
public interface IAccessLayerAuthenticationProvider public interface IAccessLayerAuthenticationProvider
{ {

View File

@@ -4,7 +4,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
namespace Treestar.Shared.Authentication.JwtBearer; namespace Common.Authentication.JwtBearer;
public static class JWTAuthenticationExtension public static class JWTAuthenticationExtension
{ {

View File

@@ -1,4 +1,4 @@
namespace Treestar.Shared.Authentication.JwtBearer; namespace Common.Authentication.JwtBearer;
public class JwtBearerAuthenticationOptions public class JwtBearerAuthenticationOptions
{ {

View File

@@ -7,7 +7,7 @@ using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
using WebNovelPortal.Authentication; using WebNovelPortal.Authentication;
namespace Treestar.Shared.Authentication.OIDC; namespace Common.Authentication.OIDC;
public static class AuthenticationExtension public static class AuthenticationExtension
{ {

View File

@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Treestar.Shared.Models.DBDomain namespace Common.Models.DBDomain
{ {
public class Author : BaseEntity public class Author : BaseEntity
{ {

View File

@@ -1,4 +1,4 @@
namespace Treestar.Shared.Models.DBDomain namespace Common.Models.DBDomain
{ {
public abstract class BaseEntity public abstract class BaseEntity
{ {

View File

@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace Treestar.Shared.Models.DBDomain namespace Common.Models.DBDomain
{ {
public class Chapter : BaseEntity public class Chapter : BaseEntity
{ {

View File

@@ -1,8 +1,8 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Common.Models.Enums;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Treestar.Shared.Models.Enums;
namespace Treestar.Shared.Models.DBDomain namespace Common.Models.DBDomain
{ {
[Index(nameof(Guid))] [Index(nameof(Guid))]
public class Novel : BaseEntity public class Novel : BaseEntity

View File

@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Treestar.Shared.Models.DBDomain namespace Common.Models.DBDomain
{ {
public class Tag : BaseEntity public class Tag : BaseEntity
{ {
@@ -27,5 +27,20 @@ namespace Treestar.Shared.Models.DBDomain
{ {
return TagValue.GetHashCode(); return TagValue.GetHashCode();
} }
public static Tag GetSiteTag(string siteUrl)
{
return new Tag {TagValue = $"site:{siteUrl.TrimEnd('/')}"};
}
public static Tag GetOriginalWorkTag()
{
return new Tag {TagValue = "original_work"};
}
public static Tag GetNsfwTag()
{
return new Tag {TagValue = "NSFW"};
}
} }
} }

View File

@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace Treestar.Shared.Models.DBDomain namespace Common.Models.DBDomain
{ {
[Index(nameof(Email))] [Index(nameof(Email))]
public class User : BaseEntity public class User : BaseEntity

View File

@@ -1,6 +1,6 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Treestar.Shared.Models.DBDomain namespace Common.Models.DBDomain
{ {
public class UserNovel public class UserNovel
{ {

View File

@@ -1,4 +1,4 @@
namespace Treestar.Shared.Models.DTO.Requests; namespace Common.Models.DTO.Requests;
public class ScrapeNovelRequest public class ScrapeNovelRequest
{ {

View File

@@ -1,6 +1,6 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Treestar.Shared.Models.DTO.Requests; namespace Common.Models.DTO.Requests;
public class ScrapeNovelsRequest public class ScrapeNovelsRequest
{ {

View File

@@ -1,6 +1,6 @@
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace Treestar.Shared.Models.DTO.Responses; namespace Common.Models.DTO.Responses;
public class ScrapeNovelsResponse public class ScrapeNovelsResponse
{ {

View File

@@ -1,4 +1,4 @@
namespace Treestar.Shared.Models.Enums; namespace Common.Models.Enums;
public enum NovelStatus public enum NovelStatus
{ {

View File

@@ -1,4 +1,4 @@
namespace Treestar.Shared.Models; namespace Common.Models;
public class HttpResponseWrapper<T> : HttpResponseWrapper public class HttpResponseWrapper<T> : HttpResponseWrapper
{ {

View File

@@ -3,7 +3,7 @@ using DBConnection.ModelBuilders;
using DBConnection.Seeders; using DBConnection.Seeders;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace DBConnection.Contexts; namespace DBConnection.Contexts;

View File

@@ -24,7 +24,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Treestar.Shared\Treestar.Shared.csproj" /> <ProjectReference Include="..\Common\Common.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -39,7 +39,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("NovelTag"); b.ToTable("NovelTag");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => modelBuilder.Entity("Common.Models.DBDomain.Author", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("text"); .HasColumnType("text");
@@ -59,7 +59,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Authors"); b.ToTable("Authors");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => modelBuilder.Entity("Common.Models.DBDomain.Chapter", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("text"); .HasColumnType("text");
@@ -103,7 +103,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Chapters"); b.ToTable("Chapters");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("text"); .HasColumnType("text");
@@ -140,7 +140,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Novels"); b.ToTable("Novels");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Tag", b => modelBuilder.Entity("Common.Models.DBDomain.Tag", b =>
{ {
b.Property<string>("TagValue") b.Property<string>("TagValue")
.HasColumnType("text"); .HasColumnType("text");
@@ -156,7 +156,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Tags"); b.ToTable("Tags");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => modelBuilder.Entity("Common.Models.DBDomain.User", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -179,7 +179,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Users"); b.ToTable("Users");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b =>
{ {
b.Property<string>("NovelUrl") b.Property<string>("NovelUrl")
.HasColumnType("text"); .HasColumnType("text");
@@ -199,46 +199,46 @@ namespace DBConnection.Migrations.PostgresSql
modelBuilder.Entity("NovelTag", b => modelBuilder.Entity("NovelTag", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) b.HasOne("Common.Models.DBDomain.Novel", null)
.WithMany() .WithMany()
.HasForeignKey("NovelsUrl") .HasForeignKey("NovelsUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("Treestar.Shared.Models.DBDomain.Tag", null) b.HasOne("Common.Models.DBDomain.Tag", null)
.WithMany() .WithMany()
.HasForeignKey("TagsTagValue") .HasForeignKey("TagsTagValue")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => modelBuilder.Entity("Common.Models.DBDomain.Chapter", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) b.HasOne("Common.Models.DBDomain.Novel", null)
.WithMany("Chapters") .WithMany("Chapters")
.HasForeignKey("NovelUrl") .HasForeignKey("NovelUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Author", "Author") b.HasOne("Common.Models.DBDomain.Author", "Author")
.WithMany("Novels") .WithMany("Novels")
.HasForeignKey("AuthorUrl"); .HasForeignKey("AuthorUrl");
b.Navigation("Author"); b.Navigation("Author");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") b.HasOne("Common.Models.DBDomain.Novel", "Novel")
.WithMany() .WithMany()
.HasForeignKey("NovelUrl") .HasForeignKey("NovelUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("Treestar.Shared.Models.DBDomain.User", "User") b.HasOne("Common.Models.DBDomain.User", "User")
.WithMany("WatchedNovels") .WithMany("WatchedNovels")
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@@ -249,17 +249,17 @@ namespace DBConnection.Migrations.PostgresSql
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => modelBuilder.Entity("Common.Models.DBDomain.Author", b =>
{ {
b.Navigation("Novels"); b.Navigation("Novels");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.Navigation("Chapters"); b.Navigation("Chapters");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => modelBuilder.Entity("Common.Models.DBDomain.User", b =>
{ {
b.Navigation("WatchedNovels"); b.Navigation("WatchedNovels");
}); });

View File

@@ -39,7 +39,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("NovelTag"); b.ToTable("NovelTag");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => modelBuilder.Entity("Common.Models.DBDomain.Author", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("text"); .HasColumnType("text");
@@ -59,7 +59,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Authors"); b.ToTable("Authors");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => modelBuilder.Entity("Common.Models.DBDomain.Chapter", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("text"); .HasColumnType("text");
@@ -103,7 +103,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Chapters"); b.ToTable("Chapters");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("text"); .HasColumnType("text");
@@ -142,7 +142,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Novels"); b.ToTable("Novels");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Tag", b => modelBuilder.Entity("Common.Models.DBDomain.Tag", b =>
{ {
b.Property<string>("TagValue") b.Property<string>("TagValue")
.HasColumnType("text"); .HasColumnType("text");
@@ -158,7 +158,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Tags"); b.ToTable("Tags");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => modelBuilder.Entity("Common.Models.DBDomain.User", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -181,7 +181,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Users"); b.ToTable("Users");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b =>
{ {
b.Property<string>("NovelUrl") b.Property<string>("NovelUrl")
.HasColumnType("text"); .HasColumnType("text");
@@ -201,46 +201,46 @@ namespace DBConnection.Migrations.PostgresSql
modelBuilder.Entity("NovelTag", b => modelBuilder.Entity("NovelTag", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) b.HasOne("Common.Models.DBDomain.Novel", null)
.WithMany() .WithMany()
.HasForeignKey("NovelsUrl") .HasForeignKey("NovelsUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("Treestar.Shared.Models.DBDomain.Tag", null) b.HasOne("Common.Models.DBDomain.Tag", null)
.WithMany() .WithMany()
.HasForeignKey("TagsTagValue") .HasForeignKey("TagsTagValue")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => modelBuilder.Entity("Common.Models.DBDomain.Chapter", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) b.HasOne("Common.Models.DBDomain.Novel", null)
.WithMany("Chapters") .WithMany("Chapters")
.HasForeignKey("NovelUrl") .HasForeignKey("NovelUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Author", "Author") b.HasOne("Common.Models.DBDomain.Author", "Author")
.WithMany("Novels") .WithMany("Novels")
.HasForeignKey("AuthorUrl"); .HasForeignKey("AuthorUrl");
b.Navigation("Author"); b.Navigation("Author");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") b.HasOne("Common.Models.DBDomain.Novel", "Novel")
.WithMany() .WithMany()
.HasForeignKey("NovelUrl") .HasForeignKey("NovelUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("Treestar.Shared.Models.DBDomain.User", "User") b.HasOne("Common.Models.DBDomain.User", "User")
.WithMany("WatchedNovels") .WithMany("WatchedNovels")
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@@ -251,17 +251,17 @@ namespace DBConnection.Migrations.PostgresSql
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => modelBuilder.Entity("Common.Models.DBDomain.Author", b =>
{ {
b.Navigation("Novels"); b.Navigation("Novels");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.Navigation("Chapters"); b.Navigation("Chapters");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => modelBuilder.Entity("Common.Models.DBDomain.User", b =>
{ {
b.Navigation("WatchedNovels"); b.Navigation("WatchedNovels");
}); });

View File

@@ -39,7 +39,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("NovelTag"); b.ToTable("NovelTag");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => modelBuilder.Entity("Common.Models.DBDomain.Author", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("text"); .HasColumnType("text");
@@ -59,7 +59,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Authors"); b.ToTable("Authors");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => modelBuilder.Entity("Common.Models.DBDomain.Chapter", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("text"); .HasColumnType("text");
@@ -103,7 +103,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Chapters"); b.ToTable("Chapters");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("text"); .HasColumnType("text");
@@ -142,7 +142,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Novels"); b.ToTable("Novels");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Tag", b => modelBuilder.Entity("Common.Models.DBDomain.Tag", b =>
{ {
b.Property<string>("TagValue") b.Property<string>("TagValue")
.HasColumnType("text"); .HasColumnType("text");
@@ -158,7 +158,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Tags"); b.ToTable("Tags");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => modelBuilder.Entity("Common.Models.DBDomain.User", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -183,7 +183,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Users"); b.ToTable("Users");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b =>
{ {
b.Property<string>("NovelUrl") b.Property<string>("NovelUrl")
.HasColumnType("text"); .HasColumnType("text");
@@ -203,22 +203,22 @@ namespace DBConnection.Migrations.PostgresSql
modelBuilder.Entity("NovelTag", b => modelBuilder.Entity("NovelTag", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) b.HasOne("Common.Models.DBDomain.Novel", null)
.WithMany() .WithMany()
.HasForeignKey("NovelsUrl") .HasForeignKey("NovelsUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("Treestar.Shared.Models.DBDomain.Tag", null) b.HasOne("Common.Models.DBDomain.Tag", null)
.WithMany() .WithMany()
.HasForeignKey("TagsTagValue") .HasForeignKey("TagsTagValue")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => modelBuilder.Entity("Common.Models.DBDomain.Chapter", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") b.HasOne("Common.Models.DBDomain.Novel", "Novel")
.WithMany("Chapters") .WithMany("Chapters")
.HasForeignKey("NovelUrl") .HasForeignKey("NovelUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@@ -227,24 +227,24 @@ namespace DBConnection.Migrations.PostgresSql
b.Navigation("Novel"); b.Navigation("Novel");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Author", "Author") b.HasOne("Common.Models.DBDomain.Author", "Author")
.WithMany("Novels") .WithMany("Novels")
.HasForeignKey("AuthorUrl"); .HasForeignKey("AuthorUrl");
b.Navigation("Author"); b.Navigation("Author");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") b.HasOne("Common.Models.DBDomain.Novel", "Novel")
.WithMany() .WithMany()
.HasForeignKey("NovelUrl") .HasForeignKey("NovelUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("Treestar.Shared.Models.DBDomain.User", "User") b.HasOne("Common.Models.DBDomain.User", "User")
.WithMany("WatchedNovels") .WithMany("WatchedNovels")
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@@ -255,17 +255,17 @@ namespace DBConnection.Migrations.PostgresSql
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => modelBuilder.Entity("Common.Models.DBDomain.Author", b =>
{ {
b.Navigation("Novels"); b.Navigation("Novels");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.Navigation("Chapters"); b.Navigation("Chapters");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => modelBuilder.Entity("Common.Models.DBDomain.User", b =>
{ {
b.Navigation("WatchedNovels"); b.Navigation("WatchedNovels");
}); });

View File

@@ -37,7 +37,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("NovelTag"); b.ToTable("NovelTag");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => modelBuilder.Entity("Common.Models.DBDomain.Author", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("text"); .HasColumnType("text");
@@ -57,7 +57,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Authors"); b.ToTable("Authors");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => modelBuilder.Entity("Common.Models.DBDomain.Chapter", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("text"); .HasColumnType("text");
@@ -101,7 +101,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Chapters"); b.ToTable("Chapters");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("text"); .HasColumnType("text");
@@ -140,7 +140,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Novels"); b.ToTable("Novels");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Tag", b => modelBuilder.Entity("Common.Models.DBDomain.Tag", b =>
{ {
b.Property<string>("TagValue") b.Property<string>("TagValue")
.HasColumnType("text"); .HasColumnType("text");
@@ -156,7 +156,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Tags"); b.ToTable("Tags");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => modelBuilder.Entity("Common.Models.DBDomain.User", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -181,7 +181,7 @@ namespace DBConnection.Migrations.PostgresSql
b.ToTable("Users"); b.ToTable("Users");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b =>
{ {
b.Property<string>("NovelUrl") b.Property<string>("NovelUrl")
.HasColumnType("text"); .HasColumnType("text");
@@ -201,22 +201,22 @@ namespace DBConnection.Migrations.PostgresSql
modelBuilder.Entity("NovelTag", b => modelBuilder.Entity("NovelTag", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) b.HasOne("Common.Models.DBDomain.Novel", null)
.WithMany() .WithMany()
.HasForeignKey("NovelsUrl") .HasForeignKey("NovelsUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("Treestar.Shared.Models.DBDomain.Tag", null) b.HasOne("Common.Models.DBDomain.Tag", null)
.WithMany() .WithMany()
.HasForeignKey("TagsTagValue") .HasForeignKey("TagsTagValue")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => modelBuilder.Entity("Common.Models.DBDomain.Chapter", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") b.HasOne("Common.Models.DBDomain.Novel", "Novel")
.WithMany("Chapters") .WithMany("Chapters")
.HasForeignKey("NovelUrl") .HasForeignKey("NovelUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@@ -225,24 +225,24 @@ namespace DBConnection.Migrations.PostgresSql
b.Navigation("Novel"); b.Navigation("Novel");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Author", "Author") b.HasOne("Common.Models.DBDomain.Author", "Author")
.WithMany("Novels") .WithMany("Novels")
.HasForeignKey("AuthorUrl"); .HasForeignKey("AuthorUrl");
b.Navigation("Author"); b.Navigation("Author");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") b.HasOne("Common.Models.DBDomain.Novel", "Novel")
.WithMany() .WithMany()
.HasForeignKey("NovelUrl") .HasForeignKey("NovelUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("Treestar.Shared.Models.DBDomain.User", "User") b.HasOne("Common.Models.DBDomain.User", "User")
.WithMany("WatchedNovels") .WithMany("WatchedNovels")
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@@ -253,17 +253,17 @@ namespace DBConnection.Migrations.PostgresSql
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => modelBuilder.Entity("Common.Models.DBDomain.Author", b =>
{ {
b.Navigation("Novels"); b.Navigation("Novels");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.Navigation("Chapters"); b.Navigation("Chapters");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => modelBuilder.Entity("Common.Models.DBDomain.User", b =>
{ {
b.Navigation("WatchedNovels"); b.Navigation("WatchedNovels");
}); });

View File

@@ -34,7 +34,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("NovelTag"); b.ToTable("NovelTag");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => modelBuilder.Entity("Common.Models.DBDomain.Author", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -54,7 +54,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Authors"); b.ToTable("Authors");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => modelBuilder.Entity("Common.Models.DBDomain.Chapter", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -98,7 +98,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Chapters"); b.ToTable("Chapters");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -135,7 +135,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Novels"); b.ToTable("Novels");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Tag", b => modelBuilder.Entity("Common.Models.DBDomain.Tag", b =>
{ {
b.Property<string>("TagValue") b.Property<string>("TagValue")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -151,7 +151,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Tags"); b.ToTable("Tags");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => modelBuilder.Entity("Common.Models.DBDomain.User", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -172,7 +172,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Users"); b.ToTable("Users");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b =>
{ {
b.Property<string>("NovelUrl") b.Property<string>("NovelUrl")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -192,46 +192,46 @@ namespace DBConnection.Migrations.Sqlite
modelBuilder.Entity("NovelTag", b => modelBuilder.Entity("NovelTag", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) b.HasOne("Common.Models.DBDomain.Novel", null)
.WithMany() .WithMany()
.HasForeignKey("NovelsUrl") .HasForeignKey("NovelsUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("Treestar.Shared.Models.DBDomain.Tag", null) b.HasOne("Common.Models.DBDomain.Tag", null)
.WithMany() .WithMany()
.HasForeignKey("TagsTagValue") .HasForeignKey("TagsTagValue")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => modelBuilder.Entity("Common.Models.DBDomain.Chapter", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) b.HasOne("Common.Models.DBDomain.Novel", null)
.WithMany("Chapters") .WithMany("Chapters")
.HasForeignKey("NovelUrl") .HasForeignKey("NovelUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Author", "Author") b.HasOne("Common.Models.DBDomain.Author", "Author")
.WithMany("Novels") .WithMany("Novels")
.HasForeignKey("AuthorUrl"); .HasForeignKey("AuthorUrl");
b.Navigation("Author"); b.Navigation("Author");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") b.HasOne("Common.Models.DBDomain.Novel", "Novel")
.WithMany() .WithMany()
.HasForeignKey("NovelUrl") .HasForeignKey("NovelUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("Treestar.Shared.Models.DBDomain.User", "User") b.HasOne("Common.Models.DBDomain.User", "User")
.WithMany("WatchedNovels") .WithMany("WatchedNovels")
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@@ -242,17 +242,17 @@ namespace DBConnection.Migrations.Sqlite
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => modelBuilder.Entity("Common.Models.DBDomain.Author", b =>
{ {
b.Navigation("Novels"); b.Navigation("Novels");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.Navigation("Chapters"); b.Navigation("Chapters");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => modelBuilder.Entity("Common.Models.DBDomain.User", b =>
{ {
b.Navigation("WatchedNovels"); b.Navigation("WatchedNovels");
}); });

View File

@@ -34,7 +34,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("NovelTag"); b.ToTable("NovelTag");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => modelBuilder.Entity("Common.Models.DBDomain.Author", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -54,7 +54,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Authors"); b.ToTable("Authors");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => modelBuilder.Entity("Common.Models.DBDomain.Chapter", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -98,7 +98,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Chapters"); b.ToTable("Chapters");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -137,7 +137,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Novels"); b.ToTable("Novels");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Tag", b => modelBuilder.Entity("Common.Models.DBDomain.Tag", b =>
{ {
b.Property<string>("TagValue") b.Property<string>("TagValue")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -153,7 +153,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Tags"); b.ToTable("Tags");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => modelBuilder.Entity("Common.Models.DBDomain.User", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -174,7 +174,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Users"); b.ToTable("Users");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b =>
{ {
b.Property<string>("NovelUrl") b.Property<string>("NovelUrl")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -194,46 +194,46 @@ namespace DBConnection.Migrations.Sqlite
modelBuilder.Entity("NovelTag", b => modelBuilder.Entity("NovelTag", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) b.HasOne("Common.Models.DBDomain.Novel", null)
.WithMany() .WithMany()
.HasForeignKey("NovelsUrl") .HasForeignKey("NovelsUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("Treestar.Shared.Models.DBDomain.Tag", null) b.HasOne("Common.Models.DBDomain.Tag", null)
.WithMany() .WithMany()
.HasForeignKey("TagsTagValue") .HasForeignKey("TagsTagValue")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => modelBuilder.Entity("Common.Models.DBDomain.Chapter", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) b.HasOne("Common.Models.DBDomain.Novel", null)
.WithMany("Chapters") .WithMany("Chapters")
.HasForeignKey("NovelUrl") .HasForeignKey("NovelUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Author", "Author") b.HasOne("Common.Models.DBDomain.Author", "Author")
.WithMany("Novels") .WithMany("Novels")
.HasForeignKey("AuthorUrl"); .HasForeignKey("AuthorUrl");
b.Navigation("Author"); b.Navigation("Author");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") b.HasOne("Common.Models.DBDomain.Novel", "Novel")
.WithMany() .WithMany()
.HasForeignKey("NovelUrl") .HasForeignKey("NovelUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("Treestar.Shared.Models.DBDomain.User", "User") b.HasOne("Common.Models.DBDomain.User", "User")
.WithMany("WatchedNovels") .WithMany("WatchedNovels")
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@@ -244,17 +244,17 @@ namespace DBConnection.Migrations.Sqlite
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => modelBuilder.Entity("Common.Models.DBDomain.Author", b =>
{ {
b.Navigation("Novels"); b.Navigation("Novels");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.Navigation("Chapters"); b.Navigation("Chapters");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => modelBuilder.Entity("Common.Models.DBDomain.User", b =>
{ {
b.Navigation("WatchedNovels"); b.Navigation("WatchedNovels");
}); });

View File

@@ -34,7 +34,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("NovelTag"); b.ToTable("NovelTag");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => modelBuilder.Entity("Common.Models.DBDomain.Author", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -54,7 +54,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Authors"); b.ToTable("Authors");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => modelBuilder.Entity("Common.Models.DBDomain.Chapter", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -98,7 +98,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Chapters"); b.ToTable("Chapters");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -137,7 +137,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Novels"); b.ToTable("Novels");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Tag", b => modelBuilder.Entity("Common.Models.DBDomain.Tag", b =>
{ {
b.Property<string>("TagValue") b.Property<string>("TagValue")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -153,7 +153,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Tags"); b.ToTable("Tags");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => modelBuilder.Entity("Common.Models.DBDomain.User", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -176,7 +176,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Users"); b.ToTable("Users");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b =>
{ {
b.Property<string>("NovelUrl") b.Property<string>("NovelUrl")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -196,22 +196,22 @@ namespace DBConnection.Migrations.Sqlite
modelBuilder.Entity("NovelTag", b => modelBuilder.Entity("NovelTag", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) b.HasOne("Common.Models.DBDomain.Novel", null)
.WithMany() .WithMany()
.HasForeignKey("NovelsUrl") .HasForeignKey("NovelsUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("Treestar.Shared.Models.DBDomain.Tag", null) b.HasOne("Common.Models.DBDomain.Tag", null)
.WithMany() .WithMany()
.HasForeignKey("TagsTagValue") .HasForeignKey("TagsTagValue")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => modelBuilder.Entity("Common.Models.DBDomain.Chapter", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") b.HasOne("Common.Models.DBDomain.Novel", "Novel")
.WithMany("Chapters") .WithMany("Chapters")
.HasForeignKey("NovelUrl") .HasForeignKey("NovelUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@@ -220,24 +220,24 @@ namespace DBConnection.Migrations.Sqlite
b.Navigation("Novel"); b.Navigation("Novel");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Author", "Author") b.HasOne("Common.Models.DBDomain.Author", "Author")
.WithMany("Novels") .WithMany("Novels")
.HasForeignKey("AuthorUrl"); .HasForeignKey("AuthorUrl");
b.Navigation("Author"); b.Navigation("Author");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") b.HasOne("Common.Models.DBDomain.Novel", "Novel")
.WithMany() .WithMany()
.HasForeignKey("NovelUrl") .HasForeignKey("NovelUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("Treestar.Shared.Models.DBDomain.User", "User") b.HasOne("Common.Models.DBDomain.User", "User")
.WithMany("WatchedNovels") .WithMany("WatchedNovels")
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@@ -248,17 +248,17 @@ namespace DBConnection.Migrations.Sqlite
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => modelBuilder.Entity("Common.Models.DBDomain.Author", b =>
{ {
b.Navigation("Novels"); b.Navigation("Novels");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.Navigation("Chapters"); b.Navigation("Chapters");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => modelBuilder.Entity("Common.Models.DBDomain.User", b =>
{ {
b.Navigation("WatchedNovels"); b.Navigation("WatchedNovels");
}); });

View File

@@ -32,7 +32,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("NovelTag"); b.ToTable("NovelTag");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => modelBuilder.Entity("Common.Models.DBDomain.Author", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -52,7 +52,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Authors"); b.ToTable("Authors");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => modelBuilder.Entity("Common.Models.DBDomain.Chapter", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -96,7 +96,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Chapters"); b.ToTable("Chapters");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.Property<string>("Url") b.Property<string>("Url")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -135,7 +135,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Novels"); b.ToTable("Novels");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Tag", b => modelBuilder.Entity("Common.Models.DBDomain.Tag", b =>
{ {
b.Property<string>("TagValue") b.Property<string>("TagValue")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -151,7 +151,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Tags"); b.ToTable("Tags");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => modelBuilder.Entity("Common.Models.DBDomain.User", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -174,7 +174,7 @@ namespace DBConnection.Migrations.Sqlite
b.ToTable("Users"); b.ToTable("Users");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b =>
{ {
b.Property<string>("NovelUrl") b.Property<string>("NovelUrl")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@@ -194,22 +194,22 @@ namespace DBConnection.Migrations.Sqlite
modelBuilder.Entity("NovelTag", b => modelBuilder.Entity("NovelTag", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", null) b.HasOne("Common.Models.DBDomain.Novel", null)
.WithMany() .WithMany()
.HasForeignKey("NovelsUrl") .HasForeignKey("NovelsUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("Treestar.Shared.Models.DBDomain.Tag", null) b.HasOne("Common.Models.DBDomain.Tag", null)
.WithMany() .WithMany()
.HasForeignKey("TagsTagValue") .HasForeignKey("TagsTagValue")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Chapter", b => modelBuilder.Entity("Common.Models.DBDomain.Chapter", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") b.HasOne("Common.Models.DBDomain.Novel", "Novel")
.WithMany("Chapters") .WithMany("Chapters")
.HasForeignKey("NovelUrl") .HasForeignKey("NovelUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@@ -218,24 +218,24 @@ namespace DBConnection.Migrations.Sqlite
b.Navigation("Novel"); b.Navigation("Novel");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Author", "Author") b.HasOne("Common.Models.DBDomain.Author", "Author")
.WithMany("Novels") .WithMany("Novels")
.HasForeignKey("AuthorUrl"); .HasForeignKey("AuthorUrl");
b.Navigation("Author"); b.Navigation("Author");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.UserNovel", b => modelBuilder.Entity("Common.Models.DBDomain.UserNovel", b =>
{ {
b.HasOne("Treestar.Shared.Models.DBDomain.Novel", "Novel") b.HasOne("Common.Models.DBDomain.Novel", "Novel")
.WithMany() .WithMany()
.HasForeignKey("NovelUrl") .HasForeignKey("NovelUrl")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("Treestar.Shared.Models.DBDomain.User", "User") b.HasOne("Common.Models.DBDomain.User", "User")
.WithMany("WatchedNovels") .WithMany("WatchedNovels")
.HasForeignKey("UserId") .HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
@@ -246,17 +246,17 @@ namespace DBConnection.Migrations.Sqlite
b.Navigation("User"); b.Navigation("User");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Author", b => modelBuilder.Entity("Common.Models.DBDomain.Author", b =>
{ {
b.Navigation("Novels"); b.Navigation("Novels");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.Novel", b => modelBuilder.Entity("Common.Models.DBDomain.Novel", b =>
{ {
b.Navigation("Chapters"); b.Navigation("Chapters");
}); });
modelBuilder.Entity("Treestar.Shared.Models.DBDomain.User", b => modelBuilder.Entity("Common.Models.DBDomain.User", b =>
{ {
b.Navigation("WatchedNovels"); b.Navigation("WatchedNovels");
}); });

View File

@@ -1,5 +1,5 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace DBConnection.ModelBuilders; namespace DBConnection.ModelBuilders;

View File

@@ -1,7 +1,7 @@
using DBConnection.Contexts; using DBConnection.Contexts;
using DBConnection.Repositories.Interfaces; using DBConnection.Repositories.Interfaces;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace DBConnection.Repositories; namespace DBConnection.Repositories;

View File

@@ -3,7 +3,7 @@ using DBConnection.Contexts;
using DBConnection.Repositories.Interfaces; using DBConnection.Repositories.Interfaces;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using NuGet.Configuration; using NuGet.Configuration;
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace DBConnection.Repositories; namespace DBConnection.Repositories;

View File

@@ -1,7 +1,7 @@
using DBConnection.Contexts; using DBConnection.Contexts;
using DBConnection.Repositories.Interfaces; using DBConnection.Repositories.Interfaces;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace DBConnection.Repositories; namespace DBConnection.Repositories;

View File

@@ -1,4 +1,4 @@
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace DBConnection.Repositories.Interfaces; namespace DBConnection.Repositories.Interfaces;

View File

@@ -1,4 +1,4 @@
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace DBConnection.Repositories.Interfaces; namespace DBConnection.Repositories.Interfaces;

View File

@@ -1,4 +1,4 @@
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace DBConnection.Repositories.Interfaces; namespace DBConnection.Repositories.Interfaces;

View File

@@ -1,4 +1,4 @@
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace DBConnection.Repositories.Interfaces; namespace DBConnection.Repositories.Interfaces;

View File

@@ -1,4 +1,4 @@
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace DBConnection.Repositories.Interfaces; namespace DBConnection.Repositories.Interfaces;

View File

@@ -1,4 +1,4 @@
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace DBConnection.Repositories.Interfaces; namespace DBConnection.Repositories.Interfaces;

View File

@@ -1,7 +1,7 @@
using DBConnection.Contexts; using DBConnection.Contexts;
using DBConnection.Repositories.Interfaces; using DBConnection.Repositories.Interfaces;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace DBConnection.Repositories; namespace DBConnection.Repositories;

View File

@@ -1,7 +1,7 @@
using DBConnection.Contexts; using DBConnection.Contexts;
using DBConnection.Repositories.Interfaces; using DBConnection.Repositories.Interfaces;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace DBConnection.Repositories; namespace DBConnection.Repositories;

View File

@@ -1,7 +1,7 @@
using DBConnection.Contexts; using DBConnection.Contexts;
using DBConnection.Repositories.Interfaces; using DBConnection.Repositories.Interfaces;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace DBConnection.Repositories; namespace DBConnection.Repositories;

View File

@@ -4,7 +4,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebNovelPortal", "WebNovelP
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebNovelPortalAPI", "WebNovelPortalAPI\WebNovelPortalAPI.csproj", "{D24E3BBA-EAA1-4515-9060-56E673CC7FAA}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebNovelPortalAPI", "WebNovelPortalAPI\WebNovelPortalAPI.csproj", "{D24E3BBA-EAA1-4515-9060-56E673CC7FAA}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Treestar.Shared", "Treestar.Shared\Treestar.Shared.csproj", "{639F52AF-9D62-4341-BEE6-0E9243020FC5}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{639F52AF-9D62-4341-BEE6-0E9243020FC5}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DBConnection", "DBConnection\DBConnection.csproj", "{CD895518-DA05-4886-BE14-3E04D62FA2F7}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DBConnection", "DBConnection\DBConnection.csproj", "{CD895518-DA05-4886-BE14-3E04D62FA2F7}"
EndProject EndProject

View File

@@ -1,8 +1,8 @@
using Treestar.Shared.AccessLayers; using Common.AccessLayers;
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
using Treestar.Shared.Models.DTO; using Common.Models.DTO;
using Treestar.Shared.Models.DTO.Requests; using Common.Models.DTO.Requests;
using Treestar.Shared.Models.DTO.Responses; using Common.Models.DTO.Responses;
namespace WebNovelPortal.AccessLayers; namespace WebNovelPortal.AccessLayers;

View File

@@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.IdentityModel.Protocols.OpenIdConnect; using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using Treestar.Shared.AccessLayers; using Common.AccessLayers;
namespace WebNovelPortal.Authentication; namespace WebNovelPortal.Authentication;

View File

@@ -6,7 +6,7 @@ EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src WORKDIR /src
COPY ["WebNovelPortal/WebNovelPortal.csproj", "WebNovelPortal/"] COPY ["WebNovelPortal/WebNovelPortal.csproj", "WebNovelPortal/"]
COPY ["Treestar.Shared/Treestar.Shared.csproj", "Treestar.Shared/"] COPY ["Common/Common.csproj", "Common/"]
RUN dotnet restore "WebNovelPortal/WebNovelPortal.csproj" RUN dotnet restore "WebNovelPortal/WebNovelPortal.csproj"
COPY . . COPY . .
WORKDIR "/src/WebNovelPortal" WORKDIR "/src/WebNovelPortal"

View File

@@ -2,8 +2,8 @@ using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.HttpOverrides;
using Newtonsoft.Json; using Newtonsoft.Json;
using Treestar.Shared.AccessLayers; using Common.AccessLayers;
using Treestar.Shared.Authentication.OIDC; using Common.Authentication.OIDC;
using WebNovelPortal.AccessLayers; using WebNovelPortal.AccessLayers;
using WebNovelPortal.Authentication; using WebNovelPortal.Authentication;

View File

@@ -14,7 +14,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Treestar.Shared\Treestar.Shared.csproj" /> <ProjectReference Include="..\Common\Common.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -11,4 +11,4 @@
@using WebNovelPortal.Shared.Layouts @using WebNovelPortal.Shared.Layouts
@using WebNovelPortal.Shared.Components.Layout @using WebNovelPortal.Shared.Components.Layout
@using WebNovelPortal.Shared.Components.Display @using WebNovelPortal.Shared.Components.Display
@using Treestar.Shared.Models.DBDomain @using Common.Models.DBDomain

View File

@@ -5,7 +5,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
using WebNovelPortalAPI.Middleware; using WebNovelPortalAPI.Middleware;
namespace WebNovelPortalAPI.Controllers namespace WebNovelPortalAPI.Controllers

View File

@@ -8,10 +8,10 @@ using DBConnection.Repositories.Interfaces;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
using Treestar.Shared.Models.DTO; using Common.Models.DTO;
using Treestar.Shared.Models.DTO.Requests; using Common.Models.DTO.Requests;
using Treestar.Shared.Models.DTO.Responses; using Common.Models.DTO.Responses;
using WebNovelPortalAPI.Exceptions; using WebNovelPortalAPI.Exceptions;
using WebNovelPortalAPI.Scrapers; using WebNovelPortalAPI.Scrapers;
@@ -40,7 +40,7 @@ namespace WebNovelPortalAPI.Controllers
{ {
throw new NoMatchingScraperException(url); throw new NoMatchingScraperException(url);
} }
var novel = scraper.ScrapeNovel(url); var novel = await scraper.ScrapeNovel(url);
return novel; return novel;
} }

View File

@@ -7,7 +7,7 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src WORKDIR /src
COPY ["WebNovelPortalAPI/WebNovelPortalAPI.csproj", "WebNovelPortalAPI/"] COPY ["WebNovelPortalAPI/WebNovelPortalAPI.csproj", "WebNovelPortalAPI/"]
COPY ["DBConnection/DBConnection.csproj", "DBConnection/"] COPY ["DBConnection/DBConnection.csproj", "DBConnection/"]
COPY ["Treestar.Shared/Treestar.Shared.csproj", "Treestar.Shared/"] COPY ["Common/Common.csproj", "Common/"]
RUN dotnet restore "WebNovelPortalAPI/WebNovelPortalAPI.csproj" RUN dotnet restore "WebNovelPortalAPI/WebNovelPortalAPI.csproj"
COPY . . COPY . .
WORKDIR "/src/WebNovelPortalAPI" WORKDIR "/src/WebNovelPortalAPI"

View File

@@ -1,7 +1,7 @@
using System.Security.Claims; using System.Security.Claims;
using DBConnection.Repositories.Interfaces; using DBConnection.Repositories.Interfaces;
using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Filters;
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace WebNovelPortalAPI.Middleware; namespace WebNovelPortalAPI.Middleware;

View File

@@ -4,7 +4,7 @@ using DBConnection.Extensions;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
using Newtonsoft.Json; using Newtonsoft.Json;
using Treestar.Shared.Authentication.JwtBearer; using Common.Authentication.JwtBearer;
using WebNovelPortalAPI.Extensions; using WebNovelPortalAPI.Extensions;
using WebNovelPortalAPI.Middleware; using WebNovelPortalAPI.Middleware;
using WebNovelPortalAPI.Scrapers; using WebNovelPortalAPI.Scrapers;

View File

@@ -1,11 +1,31 @@
using System.Net;
using System.Net.Http.Headers;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using HtmlAgilityPack; using HtmlAgilityPack;
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace WebNovelPortalAPI.Scrapers; namespace WebNovelPortalAPI.Scrapers;
public abstract class AbstractScraper : IScraper public abstract class AbstractScraper : IScraper
{ {
protected AbstractScraper()
{
var cookieContainer = new CookieContainer();
var handler = new HttpClientHandler
{
CookieContainer = cookieContainer
};
HttpClient client = new HttpClient(handler);
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Chrome","96.0.4664.110"));
foreach (var cookie in RequestCookies())
{
cookieContainer.Add(cookie);
}
HttpClient = client;
}
protected HttpClient HttpClient { get; }
protected abstract string UrlMatchPattern { get; } protected abstract string UrlMatchPattern { get; }
protected abstract string BaseUrlPattern { get; } protected abstract string BaseUrlPattern { get; }
protected virtual string? WorkTitlePattern { get; } protected virtual string? WorkTitlePattern { get; }
@@ -19,6 +39,14 @@ public abstract class AbstractScraper : IScraper
protected virtual string? DatePostedPattern { get; } protected virtual string? DatePostedPattern { get; }
protected virtual string? DateUpdatedPattern { get; } protected virtual string? DateUpdatedPattern { get; }
protected async Task<HtmlDocument> GetPage(string url)
{
var response = await HttpClient.GetAsync(url);
var doc = new HtmlDocument();
doc.LoadHtml(await response.Content.ReadAsStringAsync());
return doc;
}
protected virtual (DateTime? Posted, DateTime? Updated) GetDateTimeForChapter(HtmlNode linkNode, HtmlNode baseNode, protected virtual (DateTime? Posted, DateTime? Updated) GetDateTimeForChapter(HtmlNode linkNode, HtmlNode baseNode,
string baseUrl, string novelUrl) string baseUrl, string novelUrl)
{ {
@@ -87,7 +115,7 @@ public abstract class AbstractScraper : IScraper
return nodes.Select(node => new Tag return nodes.Select(node => new Tag
{ {
TagValue = node.InnerText TagValue = node.InnerText
}).ToList(); }).Union(GetMetadataTags(document, baseUrl, novelUrl)).ToList();
} }
protected virtual DateTime GetPostedDate(HtmlDocument document, string baseUrl, string novelUrl) protected virtual DateTime GetPostedDate(HtmlDocument document, string baseUrl, string novelUrl)
@@ -102,17 +130,24 @@ public abstract class AbstractScraper : IScraper
return DateTime.Parse(document.DocumentNode.SelectSingleNode(xpath).InnerText).ToUniversalTime(); return DateTime.Parse(document.DocumentNode.SelectSingleNode(xpath).InnerText).ToUniversalTime();
} }
public Novel ScrapeNovel(string url) protected virtual List<Cookie> RequestCookies()
{ {
var web = new HtmlWeb(); return new List<Cookie>();
var doc = web.Load(url); }
if (doc == null)
protected abstract IEnumerable<Tag> GetMetadataTags(HtmlDocument document, string baseUrl, string novelUrl);
public virtual async Task<Novel> ScrapeNovel(string url)
{
var baseUrl = new Regex(BaseUrlPattern).Match(url).Value;
var novelUrl = new Regex(UrlMatchPattern).Match(url).Value;
var doc = await GetPage(novelUrl);
if (string.IsNullOrEmpty(doc.Text))
{ {
throw new Exception("Error parsing document"); throw new Exception("Error parsing document");
} }
var baseUrl = new Regex(BaseUrlPattern).Match(url).Value;
var novelUrl = new Regex(UrlMatchPattern).Match(url).Value;
return new Novel return new Novel
{ {
Author = GetAuthor(doc, baseUrl, novelUrl), Author = GetAuthor(doc, baseUrl, novelUrl),
@@ -125,7 +160,7 @@ public abstract class AbstractScraper : IScraper
}; };
} }
public string? ScrapeChapterContent(string chapterUrl) public Task<string?> ScrapeChapterContent(string chapterUrl)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@@ -1,11 +1,11 @@
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
namespace WebNovelPortalAPI.Scrapers; namespace WebNovelPortalAPI.Scrapers;
public interface IScraper public interface IScraper
{ {
public bool MatchesUrl(string url); public bool MatchesUrl(string url);
public Novel ScrapeNovel(string url); public Task<Novel> ScrapeNovel(string url);
public string? ScrapeChapterContent(string chapterUrl); public Task<string?> ScrapeChapterContent(string chapterUrl);
} }

View File

@@ -1,5 +1,6 @@
using System.Reflection.Metadata; using System.Reflection.Metadata;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Common.Models.DBDomain;
using HtmlAgilityPack; using HtmlAgilityPack;
namespace WebNovelPortalAPI.Scrapers; namespace WebNovelPortalAPI.Scrapers;
@@ -34,4 +35,13 @@ public class KakuyomuScraper : AbstractScraper
var datePosted = linkNode.SelectSingleNode(ChapterPostedPattern).Attributes["datetime"].Value; var datePosted = linkNode.SelectSingleNode(ChapterPostedPattern).Attributes["datetime"].Value;
return (DateTime.Parse(datePosted).ToUniversalTime(), null); return (DateTime.Parse(datePosted).ToUniversalTime(), null);
} }
protected override IEnumerable<Tag> GetMetadataTags(HtmlDocument document, string baseUrl, string novelUrl)
{
return new List<Tag>
{
Tag.GetSiteTag(baseUrl),
Tag.GetOriginalWorkTag()
};
}
} }

View File

@@ -1,15 +1,17 @@
using System.Net;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using HtmlAgilityPack; using HtmlAgilityPack;
using Treestar.Shared.Models.DBDomain; using Common.Models.DBDomain;
using Common.Models.Enums;
namespace WebNovelPortalAPI.Scrapers; namespace WebNovelPortalAPI.Scrapers;
public class SyosetuScraper : AbstractScraper public class SyosetuScraper : AbstractScraper
{ {
protected override string UrlMatchPattern => @"https?:\/\/\w+\.syosetu\.com\/\w+\/?"; protected override string UrlMatchPattern => @"https?:\/\/(\w+)\.syosetu\.com\/\w+\/?";
protected override string BaseUrlPattern => @"https?:\/\/\w+\.syosetu\.com"; protected override string BaseUrlPattern => @"https?:\/\/(\w+)\.syosetu\.com";
protected override string? WorkTitlePattern => @"//p[@class='novel_title']"; protected override string? WorkTitlePattern => @"//p[@class='novel_title']";
@@ -29,14 +31,14 @@ public class SyosetuScraper : AbstractScraper
protected override string? DateUpdatedPattern => @"//th[contains(text(),'掲載日')]/following-sibling::td"; protected override string? DateUpdatedPattern => @"//th[contains(text(),'掲載日')]/following-sibling::td";
private HtmlDocument? GetInfoPage(string baseUrl, string novelUrl) private async Task<HtmlDocument> GetInfoPage(string baseUrl, string novelUrl)
{ {
string novelInfoBase = $"/novelview/infotop/ncode/"; string novelInfoBase = $"/novelview/infotop/ncode/";
string novelRegex = @"https?:\/\/\w+\.syosetu\.com\/(\w+)\/?"; string novelRegex = @"https?:\/\/\w+\.syosetu\.com\/(\w+)\/?";
string novelCode = new Regex(novelRegex).Match(novelUrl).Groups[1].Value; string novelCode = new Regex(novelRegex).Match(novelUrl).Groups[1].Value;
string novelInfoPage = $"{baseUrl}{novelInfoBase}{novelCode}"; string novelInfoPage = $"{baseUrl}{novelInfoBase}{novelCode}";
var web = new HtmlWeb(); return await GetPage(novelInfoPage);
return web.Load(novelInfoPage);
} }
protected override List<Chapter> GetChapters(HtmlDocument document, string baseUrl, string novelUrl) protected override List<Chapter> GetChapters(HtmlDocument document, string baseUrl, string novelUrl)
@@ -85,35 +87,86 @@ public class SyosetuScraper : AbstractScraper
protected override DateTime GetPostedDate(HtmlDocument document, string baseUrl, string novelUrl) protected override DateTime GetPostedDate(HtmlDocument document, string baseUrl, string novelUrl)
{ {
var doc = GetInfoPage(baseUrl, novelUrl); var node = document.DocumentNode.SelectSingleNode(DatePostedPattern);
if (doc == null)
{
return DateTime.MinValue;
}
var node = doc.DocumentNode.SelectSingleNode(DatePostedPattern);
return DateTime.Parse(node.InnerText).ToUniversalTime(); return DateTime.Parse(node.InnerText).ToUniversalTime();
} }
protected override DateTime GetLastUpdatedDate(HtmlDocument document, string baseUrl, string novelUrl) protected override DateTime GetLastUpdatedDate(HtmlDocument document, string baseUrl, string novelUrl)
{ {
var doc = GetInfoPage(baseUrl, novelUrl); return DateTime.Parse(document.DocumentNode.SelectNodes(DateUpdatedPattern)[1].InnerText).ToUniversalTime();
if (doc == null)
{
return DateTime.MinValue;
}
return DateTime.Parse(doc.DocumentNode.SelectNodes(DateUpdatedPattern)[1].InnerText).ToUniversalTime();
} }
protected override List<Tag> GetTags(HtmlDocument document, string baseUrl, string novelUrl) protected override List<Tag> GetTags(HtmlDocument document, string baseUrl, string novelUrl)
{ {
var doc = GetInfoPage(baseUrl, novelUrl); var tags = document.DocumentNode.SelectSingleNode(TagPattern).InnerText.Replace("\n", "").Replace("&nbsp;", " ").Split(' ');
if (doc == null) return tags.Select(i => new Tag {TagValue = i}).Union(GetMetadataTags(document, baseUrl, novelUrl)).ToList();
}
protected override List<Cookie> RequestCookies()
{
var domain = ".syosetu.com";
return new List<Cookie>
{ {
return new List<Tag>(); new Cookie
{
Domain = domain,
Name = "over18",
Value = "yes"
}
};
}
protected override IEnumerable<Tag> GetMetadataTags(HtmlDocument document, string baseUrl, string novelUrl)
{
bool nsfw = Regex.Match(baseUrl, BaseUrlPattern).Groups[1].Value == "novel18";
var tags = new List<Tag>
{
Tag.GetSiteTag(baseUrl),
Tag.GetOriginalWorkTag()
};
if (nsfw)
{
tags.Add(Tag.GetNsfwTag());
} }
var tags = doc.DocumentNode.SelectSingleNode(TagPattern).InnerText.Replace("\n", "").Replace("&nbsp;", " ").Split(' '); return tags;
return tags.Select(i => new Tag {TagValue = i}).ToList(); }
public override async Task<Novel> ScrapeNovel(string url)
{
var baseUrl = new Regex(BaseUrlPattern).Match(url).Value;
var novelUrl = new Regex(UrlMatchPattern).Match(url).Value;
HtmlDocument baseDoc;
HtmlDocument novelInfoPage;
try
{
baseDoc = await GetPage(novelUrl);
novelInfoPage = await GetInfoPage(baseUrl, novelUrl);
}
catch (Exception e)
{
throw new Exception("Error parsing document");
}
return new Novel
{
Title = GetNovelTitle(baseDoc,
baseUrl,
novelUrl),
Author = GetAuthor(baseDoc,
baseUrl,
novelUrl),
Chapters = GetChapters(baseDoc,
baseUrl,
novelUrl),
LastUpdated = GetLastUpdatedDate(novelInfoPage, baseUrl, novelUrl),
Tags = GetTags(novelInfoPage,
baseUrl,
novelUrl),
DatePosted = GetPostedDate(novelInfoPage,
baseUrl,
novelUrl),
Url = novelUrl
};
} }
} }

View File

@@ -24,7 +24,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\DBConnection\DBConnection.csproj" /> <ProjectReference Include="..\DBConnection\DBConnection.csproj" />
<ProjectReference Include="..\Treestar.Shared\Treestar.Shared.csproj" /> <ProjectReference Include="..\Common\Common.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>