mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
add ListSample.json
This commit is contained in:
parent
5da819f8a3
commit
524e9b5ce2
8 changed files with 151 additions and 111 deletions
15
data/ListSample.json
Normal file
15
data/ListSample.json
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"Author": "John Doe",
|
||||
"Description": "A sample list to filter out advertisements.",
|
||||
"DescriptionSourceUrl": "https://mysample.list",
|
||||
"DonateUrl": "https://mysample.list/donate/",
|
||||
"Email": "contact@mysample.list",
|
||||
"ForumUrl": "https://mysample.list/forum/",
|
||||
"HomeUrl": "https://mysample.list/",
|
||||
"IssuesUrl": "https://github.com/mysamplelist/issues",
|
||||
"Name": "My Sample List",
|
||||
"ViewUrl": "https://mysample.list/list.txt",
|
||||
"Id": 0,
|
||||
"AddedDateUtc": "0001-01-01T00:00:00",
|
||||
"ModifiedDateUtc": null
|
||||
}
|
||||
|
|
@ -1,31 +1,14 @@
|
|||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Name": {
|
||||
"description": "The name of the list as stated by the list maintainer(s) in title case.",
|
||||
"Author": {
|
||||
"description": "The author (person or group) who maintains the list.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"maxLength": 126
|
||||
},
|
||||
"ViewUrl": {
|
||||
"description": "The URL to the list in raw text format. zip files and other formats are acceptable if no text format is available.",
|
||||
"type": "string",
|
||||
"minLength": 6,
|
||||
"maxLength": 2083,
|
||||
"format": "uri"
|
||||
},
|
||||
"HomeUrl": {
|
||||
"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.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"minLength": 6,
|
||||
"maxLength": 2083,
|
||||
"format": "uri"
|
||||
},
|
||||
"Description": {
|
||||
"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.",
|
||||
"type": [
|
||||
|
|
@ -44,12 +27,23 @@
|
|||
"maxLength": 2083,
|
||||
"format": "uri"
|
||||
},
|
||||
"Author": {
|
||||
"description": "The author (person or group) who maintains the list.",
|
||||
"DonateUrl": {
|
||||
"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.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"minLength": 6,
|
||||
"maxLength": 2083,
|
||||
"format": "uri"
|
||||
},
|
||||
"Email": {
|
||||
"description": "The email address of the list's maintainer(s) if publicly available.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"minLength": 7,
|
||||
"maxLength": 126
|
||||
},
|
||||
"ForumUrl": {
|
||||
|
|
@ -62,6 +56,16 @@
|
|||
"maxLength": 2083,
|
||||
"format": "uri"
|
||||
},
|
||||
"HomeUrl": {
|
||||
"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.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"minLength": 6,
|
||||
"maxLength": 2083,
|
||||
"format": "uri"
|
||||
},
|
||||
"IssuesUrl": {
|
||||
"description": "The URL to the list's GitHub Issues.",
|
||||
"type": [
|
||||
|
|
@ -72,21 +76,17 @@
|
|||
"maxLength": 2083,
|
||||
"format": "uri"
|
||||
},
|
||||
"Email": {
|
||||
"description": "The email address of the list's maintainer(s) if publicly available.",
|
||||
"Name": {
|
||||
"description": "The name of the list as stated by the list maintainer(s) in title case.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"minLength": 7,
|
||||
"maxLength": 126
|
||||
},
|
||||
"DonateUrl": {
|
||||
"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.",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
],
|
||||
"ViewUrl": {
|
||||
"description": "The URL to the list in raw text format. zip files and other formats are acceptable if no text format is available.",
|
||||
"type": "string",
|
||||
"minLength": 6,
|
||||
"maxLength": 2083,
|
||||
"format": "uri"
|
||||
|
|
@ -108,16 +108,16 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"Name",
|
||||
"ViewUrl",
|
||||
"HomeUrl",
|
||||
"Author",
|
||||
"Description",
|
||||
"DescriptionSourceUrl",
|
||||
"Author",
|
||||
"ForumUrl",
|
||||
"IssuesUrl",
|
||||
"Email",
|
||||
"DonateUrl",
|
||||
"Email",
|
||||
"ForumUrl",
|
||||
"HomeUrl",
|
||||
"IssuesUrl",
|
||||
"Name",
|
||||
"ViewUrl",
|
||||
"Id",
|
||||
"AddedDateUtc",
|
||||
"ModifiedDateUtc"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using FilterLists.Data.Schema;
|
||||
using FilterLists.Data.Json;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
||||
|
|
@ -8,7 +8,8 @@ public class Program
|
|||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
JsonSchemaGenerator.WriteSchemaToFiles();
|
||||
JsonSchemaGenerator.WriteSchemaToFile();
|
||||
JsonSampleGenerator.WriteSampleToFile();
|
||||
BuildWebHost(args).Run();
|
||||
}
|
||||
|
||||
|
|
|
|||
29
src/FilterLists.Data/Json/JsonSampleGenerator.cs
Normal file
29
src/FilterLists.Data/Json/JsonSampleGenerator.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using FilterLists.Data.Models.Implementations;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace FilterLists.Data.Json
|
||||
{
|
||||
public static class JsonSampleGenerator
|
||||
{
|
||||
public static void WriteSampleToFile()
|
||||
{
|
||||
File.WriteAllText(
|
||||
Path.GetFullPath(Path.Combine(AppContext.BaseDirectory + @"\", @"..\..\..\..\..\data\")) +
|
||||
"ListSample.json", ((JObject) JToken.FromObject(new List
|
||||
{
|
||||
Author = "John Doe",
|
||||
Description = "A sample list to filter out advertisements.",
|
||||
DescriptionSourceUrl = "https://mysample.list",
|
||||
DonateUrl = "https://mysample.list/donate/",
|
||||
Email = "contact@mysample.list",
|
||||
ForumUrl = "https://mysample.list/forum/",
|
||||
HomeUrl = "https://mysample.list/",
|
||||
IssuesUrl = "https://github.com/mysamplelist/issues",
|
||||
Name = "My Sample List",
|
||||
ViewUrl = "https://mysample.list/list.txt"
|
||||
})).ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
17
src/FilterLists.Data/Json/JsonSchemaGenerator.cs
Normal file
17
src/FilterLists.Data/Json/JsonSchemaGenerator.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using FilterLists.Data.Models.Implementations;
|
||||
using Newtonsoft.Json.Schema.Generation;
|
||||
|
||||
namespace FilterLists.Data.Json
|
||||
{
|
||||
public static class JsonSchemaGenerator
|
||||
{
|
||||
public static void WriteSchemaToFile()
|
||||
{
|
||||
File.WriteAllText(
|
||||
Path.GetFullPath(Path.Combine(AppContext.BaseDirectory + @"\", @"..\..\..\..\..\data\")) +
|
||||
"ListSchema.json", new JSchemaGenerator().Generate(typeof(List)).ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,16 +4,16 @@ namespace FilterLists.Data.Models.Contracts
|
|||
{
|
||||
public interface IList
|
||||
{
|
||||
string Name { get; set; }
|
||||
string ViewUrl { get; set; }
|
||||
string HomeUrl { get; set; }
|
||||
string Author { get; set; }
|
||||
string Description { get; set; }
|
||||
string DescriptionSourceUrl { get; set; }
|
||||
string Author { get; set; }
|
||||
string ForumUrl { get; set; }
|
||||
string IssuesUrl { get; set; }
|
||||
string Email { get; set; }
|
||||
string DonateUrl { get; set; }
|
||||
string Email { get; set; }
|
||||
string ForumUrl { get; set; }
|
||||
string HomeUrl { get; set; }
|
||||
string IssuesUrl { get; set; }
|
||||
string Name { get; set; }
|
||||
string ViewUrl { get; set; }
|
||||
long Id { get; set; }
|
||||
DateTime AddedDateUtc { get; set; }
|
||||
DateTime? ModifiedDateUtc { get; set; }
|
||||
|
|
|
|||
|
|
@ -6,6 +6,49 @@ namespace FilterLists.Data.Models.Implementations
|
|||
{
|
||||
public class List : BaseEntity, IList
|
||||
{
|
||||
[Description(@"The author (person or group) who maintains the list.")]
|
||||
[MaxLength(126)]
|
||||
public string Author { 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.")]
|
||||
[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 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.")]
|
||||
[MaxLength(126)]
|
||||
public string Name { get; set; }
|
||||
|
|
@ -16,48 +59,5 @@ public class List : BaseEntity, IList
|
|||
[MaxLength(2083)]
|
||||
[MinLength(6)]
|
||||
public string ViewUrl { 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(@"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 author (person or group) who maintains the list.")]
|
||||
[MaxLength(126)]
|
||||
public string Author { get; set; }
|
||||
|
||||
[Description(@"The URL to the list's forum where issues, change requests, etc. are discussed.")]
|
||||
[Url]
|
||||
[MaxLength(2083)]
|
||||
[MinLength(6)]
|
||||
public string ForumUrl { get; set; }
|
||||
|
||||
[Description(@"The URL to the list's GitHub Issues.")]
|
||||
[Url]
|
||||
[MaxLength(2083)]
|
||||
[MinLength(6)]
|
||||
public string IssuesUrl { get; set; }
|
||||
|
||||
[Description(@"The email address of the list's maintainer(s) if publicly available.")]
|
||||
[MaxLength(126)]
|
||||
[MinLength(7)]
|
||||
public string Email { 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; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using FilterLists.Data.Models.Implementations;
|
||||
using Newtonsoft.Json.Schema.Generation;
|
||||
|
||||
namespace FilterLists.Data.Schema
|
||||
{
|
||||
public static class JsonSchemaGenerator
|
||||
{
|
||||
public static void WriteSchemaToFiles()
|
||||
{
|
||||
WriteSchemaToFile(typeof(List));
|
||||
}
|
||||
|
||||
private static void WriteSchemaToFile(Type type)
|
||||
{
|
||||
File.WriteAllText(
|
||||
Path.GetFullPath(Path.Combine(AppContext.BaseDirectory + @"\", @"..\..\..\..\..\data\")) + type.Name +
|
||||
"Schema.json", new JSchemaGenerator().Generate(type).ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue