mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
parent
859011d073
commit
953dc06c00
9 changed files with 127 additions and 86 deletions
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"Language": [
|
||||
"Languages": [
|
||||
{
|
||||
"Iso6391": "ab",
|
||||
"Iso6392": "abk",
|
||||
|
|
@ -1,21 +1,11 @@
|
|||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace FilterLists.Data.Entities
|
||||
{
|
||||
public abstract class BaseEntity
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[JsonIgnore]
|
||||
public long Id { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public DateTime CreatedDateUtc { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public DateTime? ModifiedDateUtc { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,71 +1,19 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace FilterLists.Data.Entities
|
||||
{
|
||||
public class FilterList : BaseEntity
|
||||
{
|
||||
public List<Language> Languages { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Maintainer Maintainer { get; set; }
|
||||
|
||||
[Description(
|
||||
@"A brief description of the list's functionality. Preferably, this is quoted (if non-English, translate to English via translator or Google Translate for consistency) from the list's documentation or composed by a maintainer of the list. If neither are available, a generic description should be composed by the FilterLists contributor.")]
|
||||
[MaxLength(1022)]
|
||||
public string Description { get; set; }
|
||||
|
||||
[Description(@"The URL to the list's documentation page from which the description was quoted if applicable.")]
|
||||
[Url]
|
||||
[MaxLength(2083)]
|
||||
[MinLength(6)]
|
||||
public string DescriptionSourceUrl { get; set; }
|
||||
|
||||
[Description(
|
||||
@"The URL to the list's donation page. This could be a custom PayPal or similar link, or a link to a web page discussing various donation options. Pull requests that include changes to this link will undergo further verification to prevent fraud.")]
|
||||
[Url]
|
||||
[MaxLength(2083)]
|
||||
[MinLength(6)]
|
||||
public string DonateUrl { get; set; }
|
||||
|
||||
[Description(@"The email address of the list's maintainer(s) if publicly available.")]
|
||||
[EmailAddress]
|
||||
[MaxLength(126)]
|
||||
[MinLength(7)]
|
||||
public string Email { get; set; }
|
||||
|
||||
[Description(@"The URL to the list's forum where issues, change requests, etc. are discussed.")]
|
||||
[Url]
|
||||
[MaxLength(2083)]
|
||||
[MinLength(6)]
|
||||
public string EmailAddress { get; set; }
|
||||
public string ForumUrl { get; set; }
|
||||
|
||||
[Description(
|
||||
@"The URL to the list's home page. Preferably, this is stated in the header of the list. Alternatively, it could be a custom domain, GitHub page, blog post, forum post, etc. that serves as a primary source of information for the list.")]
|
||||
[Url]
|
||||
[MaxLength(2083)]
|
||||
[MinLength(6)]
|
||||
public string HomeUrl { get; set; }
|
||||
|
||||
[Description(@"The URL to the list's GitHub Issues.")]
|
||||
[Url]
|
||||
[MaxLength(2083)]
|
||||
[MinLength(6)]
|
||||
public string IssuesUrl { get; set; }
|
||||
|
||||
[Description(@"The name of the list as stated by the list maintainer(s) in title case.")]
|
||||
[Required]
|
||||
[MaxLength(126)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Description(
|
||||
@"The URL to the list in raw text format. zip files and other formats are acceptable if no text format is available.")]
|
||||
[Required]
|
||||
[Url]
|
||||
[MaxLength(2083)]
|
||||
[MinLength(6)]
|
||||
public string ViewUrl { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,32 +1,13 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace FilterLists.Data.Entities
|
||||
{
|
||||
public class Maintainer : BaseEntity
|
||||
{
|
||||
public List<FilterList> FilterLists { get; set; }
|
||||
|
||||
[Description(@"The email address of the list maintainer.")]
|
||||
[EmailAddress]
|
||||
[MaxLength(126)]
|
||||
[MinLength(7)]
|
||||
public string Email { get; set; }
|
||||
|
||||
[Description(@"The URL to the list maintainer's home page.")]
|
||||
[Url]
|
||||
[MaxLength(2083)]
|
||||
[MinLength(6)]
|
||||
public string HomeUrl { get; set; }
|
||||
|
||||
[Description(@"The name of the list maintainer.")]
|
||||
[Required]
|
||||
[MaxLength(126)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Description(@"The Twitter handle of the list maintainer.")]
|
||||
[MaxLength(126)]
|
||||
public string TwitterHandle { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
using FilterLists.Data.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace FilterLists.Data.EntityTypeConfigurations
|
||||
{
|
||||
|
|
@ -8,7 +9,21 @@ public class BaseEntityTypeConfiguration<TBase> : IEntityTypeConfiguration<TBase
|
|||
{
|
||||
public virtual void Configure(EntityTypeBuilder<TBase> entityTypeBuilder)
|
||||
{
|
||||
entityTypeBuilder.Property(b => b.CreatedDateUtc).HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||
entityTypeBuilder.HasKey(b => b.Id);
|
||||
|
||||
entityTypeBuilder.Property(b => b.Id)
|
||||
.HasAnnotation("JsonIgnore", new JsonIgnoreAttribute())
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
entityTypeBuilder.Property(b => b.CreatedDateUtc)
|
||||
.HasAnnotation("JsonIgnore", new JsonIgnoreAttribute())
|
||||
.HasColumnType("TIMESTAMP")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
entityTypeBuilder.Property(b => b.ModifiedDateUtc)
|
||||
.HasAnnotation("JsonIgnore", new JsonIgnoreAttribute())
|
||||
.HasColumnType("TIMESTAMP")
|
||||
.ValueGeneratedOnUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
using FilterLists.Data.Entities;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using FilterLists.Data.Entities;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace FilterLists.Data.EntityTypeConfigurations
|
||||
{
|
||||
|
|
@ -7,6 +10,68 @@ public class FilterListTypeConfiguration : BaseEntityTypeConfiguration<FilterLis
|
|||
{
|
||||
public override void Configure(EntityTypeBuilder<FilterList> entityTypeBuilder)
|
||||
{
|
||||
entityTypeBuilder.Property(b => b.Maintainer)
|
||||
.HasAnnotation("JsonIgnore", new JsonIgnoreAttribute());
|
||||
|
||||
entityTypeBuilder.Property(b => b.Description)
|
||||
.HasAnnotation("Description",
|
||||
new DescriptionAttribute(
|
||||
"A brief description of the list's functionality. Preferably, this is quoted (if non-English, translate to English via translator or Google Translate for consistency) from the list's documentation or composed by a maintainer of the list. If neither are available, a generic description should be composed by the FilterLists contributor."))
|
||||
.HasMaxLength(1022);
|
||||
|
||||
entityTypeBuilder.Property(b => b.DescriptionSourceUrl)
|
||||
.HasAnnotation("Description",
|
||||
new DescriptionAttribute(
|
||||
"The URL to the list's documentation page from which the description was quoted if applicable."))
|
||||
.HasAnnotation("Url", new UrlAttribute())
|
||||
.HasMaxLength(2083);
|
||||
|
||||
entityTypeBuilder.Property(b => b.DonateUrl)
|
||||
.HasAnnotation("Description",
|
||||
new DescriptionAttribute(
|
||||
"The URL to the list's donation page. This could be a custom PayPal or similar link, or a link to a web page discussing various donation options. Pull requests that include changes to this link will undergo further verification to prevent fraud."))
|
||||
.HasAnnotation("Url", new UrlAttribute())
|
||||
.HasMaxLength(2083);
|
||||
|
||||
entityTypeBuilder.Property(b => b.EmailAddress)
|
||||
.HasAnnotation("Description",
|
||||
new DescriptionAttribute("The email address for communicating issues or comments about the list."))
|
||||
.HasAnnotation("EmailAddress", new EmailAddressAttribute())
|
||||
.HasMaxLength(126);
|
||||
|
||||
entityTypeBuilder.Property(b => b.ForumUrl)
|
||||
.HasAnnotation("Description",
|
||||
new DescriptionAttribute(
|
||||
"The URL to the list's forum where issues, change requests, etc. are discussed."))
|
||||
.HasAnnotation("Url", new UrlAttribute())
|
||||
.HasMaxLength(2083);
|
||||
|
||||
entityTypeBuilder.Property(b => b.HomeUrl)
|
||||
.HasAnnotation("Description",
|
||||
new DescriptionAttribute(
|
||||
"The URL to the list's home page. Preferably, this is stated in the header of the list. Alternatively, it could be a custom domain, GitHub page, blog post, forum post, etc. that serves as a primary source of information for the list."))
|
||||
.HasAnnotation("Url", new UrlAttribute())
|
||||
.HasMaxLength(2083);
|
||||
|
||||
entityTypeBuilder.Property(b => b.IssuesUrl)
|
||||
.HasAnnotation("Description", new DescriptionAttribute("The URL to the list's GitHub Issues."))
|
||||
.HasAnnotation("Url", new UrlAttribute())
|
||||
.HasMaxLength(2083);
|
||||
|
||||
entityTypeBuilder.Property(b => b.Name)
|
||||
.HasAnnotation("Description",
|
||||
new DescriptionAttribute("The name of the list as stated by the list maintainer(s) in title case."))
|
||||
.IsRequired()
|
||||
.HasMaxLength(126);
|
||||
|
||||
entityTypeBuilder.Property(b => b.IssuesUrl)
|
||||
.HasAnnotation("Description",
|
||||
new DescriptionAttribute(
|
||||
"The URL to the list in raw text format. zip files and other formats are acceptable if no text format is available."))
|
||||
.IsRequired()
|
||||
.HasAnnotation("Url", new UrlAttribute())
|
||||
.HasMaxLength(2083);
|
||||
|
||||
base.Configure(entityTypeBuilder);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,27 @@ public class LanguageTypeConfiguration : BaseEntityTypeConfiguration<Language>
|
|||
{
|
||||
public override void Configure(EntityTypeBuilder<Language> entityTypeBuilder)
|
||||
{
|
||||
entityTypeBuilder.Property(b => b.Iso6391)
|
||||
.HasMaxLength(2);
|
||||
|
||||
entityTypeBuilder.Property(b => b.Iso6392)
|
||||
.HasMaxLength(3);
|
||||
|
||||
entityTypeBuilder.Property(b => b.Iso6392B)
|
||||
.HasMaxLength(3);
|
||||
|
||||
entityTypeBuilder.Property(b => b.Iso6392T)
|
||||
.HasMaxLength(3);
|
||||
|
||||
entityTypeBuilder.Property(b => b.Iso6393)
|
||||
.HasMaxLength(3);
|
||||
|
||||
entityTypeBuilder.Property(b => b.LocalName)
|
||||
.HasMaxLength(126);
|
||||
|
||||
entityTypeBuilder.Property(b => b.Name)
|
||||
.HasMaxLength(126);
|
||||
|
||||
base.Configure(entityTypeBuilder);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using FilterLists.Data.Entities;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using FilterLists.Data.Entities;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Data.EntityTypeConfigurations
|
||||
|
|
@ -7,6 +9,25 @@ public class MaintainerTypeConfiguration : BaseEntityTypeConfiguration<Maintaine
|
|||
{
|
||||
public override void Configure(EntityTypeBuilder<Maintainer> entityTypeBuilder)
|
||||
{
|
||||
entityTypeBuilder.Property(b => b.Email)
|
||||
.HasAnnotation("Description", new DescriptionAttribute("The email address of the list maintainer."))
|
||||
.HasAnnotation("EmailAddress", new EmailAddressAttribute())
|
||||
.HasMaxLength(126);
|
||||
|
||||
entityTypeBuilder.Property(b => b.HomeUrl)
|
||||
.HasAnnotation("Description", new DescriptionAttribute("The URL to the list maintainer's home page."))
|
||||
.HasAnnotation("Url", new UrlAttribute())
|
||||
.HasMaxLength(2083);
|
||||
|
||||
entityTypeBuilder.Property(b => b.Name)
|
||||
.HasAnnotation("Description", new DescriptionAttribute("The name of the list maintainer."))
|
||||
.IsRequired()
|
||||
.HasMaxLength(126);
|
||||
|
||||
entityTypeBuilder.Property(b => b.TwitterHandle)
|
||||
.HasAnnotation("Description", new DescriptionAttribute("The Twitter handle of the list maintainer."))
|
||||
.HasMaxLength(126);
|
||||
|
||||
base.Configure(entityTypeBuilder);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue