Skip to content

Commit 00a3e18

Browse files
committed
Add AllManga standalone source
1 parent 81762d6 commit 00a3e18

5 files changed

Lines changed: 737 additions & 0 deletions

File tree

src/AllManga/forms.ts

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import { AdvancedSearchForm, Section, SelectRow, type JSONObject } from "@paperback/types";
2+
3+
export interface AllMangaSearchMeta extends JSONObject {
4+
sort: string[];
5+
country: string[];
6+
includeGenres: string[];
7+
excludeGenres: string[];
8+
}
9+
10+
export const SORT_OPTIONS = [
11+
{ id: "", title: "Update" },
12+
{ id: "Name_ASC", title: "Name Ascending" },
13+
{ id: "Name_DESC", title: "Name Descending" },
14+
];
15+
16+
export const COUNTRY_OPTIONS = [
17+
{ id: "ALL", title: "All" },
18+
{ id: "JP", title: "Japan" },
19+
{ id: "CN", title: "China" },
20+
{ id: "KR", title: "Korea" },
21+
];
22+
23+
const GENRE_NAMES = [
24+
"4 Koma", "Action", "Adult", "Adventure", "Cars", "Comedy", "Cooking",
25+
"Crossdressing", "Dementia", "Demons", "Doujinshi", "Drama", "Ecchi",
26+
"Fantasy", "Game", "Gender Bender", "Gyaru", "Harem", "Historical", "Horror",
27+
"Isekai", "Josei", "Kids", "Loli", "Magic", "Manhua", "Manhwa",
28+
"Martial Arts", "Mature", "Mecha", "Medical", "Military", "Monster Girls",
29+
"Music", "Mystery", "One Shot", "Parody", "Police", "Post Apocalyptic",
30+
"Psychological", "Reincarnation", "Reverse Harem", "Romance", "Samurai",
31+
"School", "Sci-Fi", "Seinen", "Shota", "Shoujo", "Shoujo Ai", "Shounen",
32+
"Shounen Ai", "Slice of Life", "Smut", "Space", "Sports", "Super Power",
33+
"Supernatural", "Suspense", "Thriller", "Tragedy", "Unknown", "Vampire",
34+
"Webtoons", "Yaoi", "Youkai", "Yuri", "Zombies",
35+
];
36+
37+
export const GENRE_OPTIONS = GENRE_NAMES.map((name) => ({ id: name, title: name }));
38+
39+
export class AllMangaSearchForm extends AdvancedSearchForm {
40+
private sort: string[];
41+
private country: string[];
42+
private includeGenres: string[];
43+
private excludeGenres: string[];
44+
45+
constructor(initialMeta?: AllMangaSearchMeta) {
46+
super();
47+
this.sort = initialMeta?.sort ?? [];
48+
this.country = initialMeta?.country ?? [];
49+
this.includeGenres = initialMeta?.includeGenres ?? [];
50+
this.excludeGenres = initialMeta?.excludeGenres ?? [];
51+
}
52+
53+
async updateSort(value: string[]): Promise<void> {
54+
this.sort = value;
55+
this.reloadForm();
56+
}
57+
58+
async updateCountry(value: string[]): Promise<void> {
59+
this.country = value;
60+
this.reloadForm();
61+
}
62+
63+
async updateIncludeGenres(value: string[]): Promise<void> {
64+
this.includeGenres = value;
65+
this.reloadForm();
66+
}
67+
68+
async updateExcludeGenres(value: string[]): Promise<void> {
69+
this.excludeGenres = value;
70+
this.reloadForm();
71+
}
72+
73+
getSearchQueryMetadata(): JSONObject {
74+
return {
75+
searchMeta: {
76+
sort: this.sort,
77+
country: this.country,
78+
includeGenres: this.includeGenres,
79+
excludeGenres: this.excludeGenres,
80+
} satisfies AllMangaSearchMeta,
81+
};
82+
}
83+
84+
override getSections() {
85+
return [
86+
Section("filters", [
87+
SelectRow("sort", {
88+
title: "Sort By",
89+
value: this.sort,
90+
options: SORT_OPTIONS,
91+
minItemCount: 0,
92+
maxItemCount: 1,
93+
onValueChange: Application.Selector(this as AllMangaSearchForm, "updateSort"),
94+
}),
95+
SelectRow("country", {
96+
title: "Country of Origin",
97+
value: this.country,
98+
options: COUNTRY_OPTIONS,
99+
minItemCount: 0,
100+
maxItemCount: 1,
101+
onValueChange: Application.Selector(this as AllMangaSearchForm, "updateCountry"),
102+
}),
103+
SelectRow("include_genres", {
104+
title: "Include Genres",
105+
value: this.includeGenres,
106+
options: GENRE_OPTIONS,
107+
minItemCount: 0,
108+
maxItemCount: GENRE_OPTIONS.length,
109+
onValueChange: Application.Selector(this as AllMangaSearchForm, "updateIncludeGenres"),
110+
}),
111+
SelectRow("exclude_genres", {
112+
title: "Exclude Genres",
113+
value: this.excludeGenres,
114+
options: GENRE_OPTIONS,
115+
minItemCount: 0,
116+
maxItemCount: GENRE_OPTIONS.length,
117+
onValueChange: Application.Selector(this as AllMangaSearchForm, "updateExcludeGenres"),
118+
}),
119+
]),
120+
];
121+
}
122+
}

0 commit comments

Comments
 (0)