Compare commits
8 Commits
2becf42487
...
feature/he
| Author | SHA1 | Date | |
|---|---|---|---|
| 16d631423c | |||
| c8168580d6 | |||
| f3a3344004 | |||
| 3713ac502c | |||
| a81c7535c5 | |||
| 8c9efd4371 | |||
| d710d6bac5 | |||
| 6b209077ef |
BIN
apps/NwaifuAnime/public/pic/Blank-profile.png
Normal file
BIN
apps/NwaifuAnime/public/pic/Blank-profile.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
@@ -7,8 +7,9 @@
|
||||
}
|
||||
}
|
||||
<app-header></app-header>
|
||||
<div class="h-10"></div>
|
||||
<main>
|
||||
<div class="h-12"></div>
|
||||
<div class="content">
|
||||
<router-outlet></router-outlet>
|
||||
</main>
|
||||
<app-footer></app-footer>
|
||||
</div>
|
||||
<app-notification></app-notification>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
main {
|
||||
.content {
|
||||
overflow-y: auto;
|
||||
height: calc(100vh - 3rem);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
import { Component } from "@angular/core";
|
||||
import { RouterModule } from "@angular/router";
|
||||
import { AppService } from "./app.service";
|
||||
import { FooterComponent } from "./components/footer/footer.component";
|
||||
import { HeaderComponent } from "./components/header/header.component";
|
||||
import { NotificationComponent } from "./components/notification/notification.component";
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [RouterModule, HeaderComponent, NotificationComponent, NotificationComponent],
|
||||
imports: [
|
||||
RouterModule,
|
||||
HeaderComponent,
|
||||
NotificationComponent,
|
||||
NotificationComponent,
|
||||
FooterComponent,
|
||||
],
|
||||
selector: "app-root",
|
||||
templateUrl: "./app.component.html",
|
||||
styleUrl: "./app.component.less",
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ApplicationConfig, isDevMode, provideZoneChangeDetection } from "@angul
|
||||
import { provideRouter } from "@angular/router";
|
||||
import { provideServiceWorker } from "@angular/service-worker";
|
||||
import { appRoutes } from "./app.routes";
|
||||
import { Parser } from "./services/parsers/parser";
|
||||
import { MangalibParserService } from "./services/parsers/rulib/mangalib.parser.service";
|
||||
import { SlashlibParserService } from "./services/parsers/rulib/slashlib.parser.service";
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
@@ -13,5 +16,7 @@ export const appConfig: ApplicationConfig = {
|
||||
registrationStrategy: "registerWhenStable:30000",
|
||||
}),
|
||||
provideHttpClient(withFetch()),
|
||||
{ provide: Parser, multi: true, useClass: MangalibParserService },
|
||||
{ provide: Parser, multi: true, useClass: SlashlibParserService },
|
||||
],
|
||||
};
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<div class="footer w-full border-t border-black bg-gray-300 pt-3">
|
||||
<p class="text-3xl ps-[5rem]">DMCA Disclaimer</p>
|
||||
<div class="footer-content h-full px-[5rem] py-6 flex flex-col gap-3">
|
||||
<div class="block">
|
||||
<p>На русском:</p>
|
||||
<p>
|
||||
Разработчики этого приложения не имеют никакого отношения к контенту, доступному в
|
||||
приложении. Оно собрано из источников, свободно доступных через любой веб-браузер.
|
||||
</p>
|
||||
</div>
|
||||
<div class="block">
|
||||
<p>English:</p>
|
||||
<p>
|
||||
The developers of this application does not have any affiliation with the content available
|
||||
in the app. It is collecting from the sources freely available through any web browser.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Component } from "@angular/core";
|
||||
|
||||
@Component({
|
||||
selector: "app-footer",
|
||||
templateUrl: "./footer.component.html",
|
||||
styleUrls: ["./footer.component.less"],
|
||||
standalone: true,
|
||||
})
|
||||
export class FooterComponent {}
|
||||
@@ -1,64 +1,6 @@
|
||||
<div
|
||||
[class]="
|
||||
'header fixed flex justify-between w-full px-2 bg-gray-700 md:h-8 items-center md:flex-row flex-col md:gap-0 gap-3 text-xl md:text-base ' +
|
||||
(menuOpened ? 'h-screen' : '')
|
||||
"
|
||||
>
|
||||
<div class="flex justify-between flex-row w-full align-middle h-8 items-center">
|
||||
<div class="flex flex-row gap-3 h-full items-center">
|
||||
<a routerLink="/" class="h-full px-2 flex justify-center items-center justify-self-center"
|
||||
><h1 class="text-white" title="Main page">NwaifuAnime</h1></a
|
||||
>
|
||||
<div class="border-l border-white h-full"></div>
|
||||
<div class="flex-row gap-3 md:flex hidden h-full items-center">
|
||||
<a
|
||||
routerLink="/auth"
|
||||
class="h-full px-2 flex justify-center items-center hover:bg-gray-600 transition ease-in-out delay-150 duration-300"
|
||||
><h2 class="text-white" title="Auth page">Auth</h2></a
|
||||
class="header fixed flex flex-row items-center px-2 justify-between top-0 left-0 h-12 bg-gray-700 w-full"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Search bar on small screens -->
|
||||
<button
|
||||
type="button"
|
||||
class="md:hidden flex justify-center items-center px-2"
|
||||
(click)="changeMenu()"
|
||||
>
|
||||
<i [class]="menuBtnClass"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex flex-col md:flex-row md:justify-end justify-center items-center gap-3 md:w-[50vw] h-full w-full"
|
||||
>
|
||||
<!-- Search bar on big screens -->
|
||||
<div [class]="searchBarClass">
|
||||
<input
|
||||
type="search"
|
||||
#searchInput
|
||||
class="outline-none ps-1 text-sm leading-6 w-full border-0 bg-transparent border-r border-gray-700"
|
||||
(keydown.enter)="search()"
|
||||
/>
|
||||
<button
|
||||
class="align-middle w-[100px] text-center border-0 flex flex-col items-center justify-center"
|
||||
type="submit"
|
||||
(click)="search()"
|
||||
>
|
||||
<span class="text-sm text-black h-full">Поиск</span>
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
[class]="
|
||||
'flex flex-col w-full justify-start items-center md:hidden overflow-hidden ' +
|
||||
(menuOpened ? 'h-auto' : 'h-0')
|
||||
"
|
||||
>
|
||||
<a
|
||||
routerLink="/auth"
|
||||
class="h-full px-2 flex justify-center items-center hover:bg-gray-600 transition ease-in-out delay-150 duration-300"
|
||||
><h2 class="text-white" title="Auth page">Auth</h2></a
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<a routerLink="/" title="Main page"><p class="text-xl text-white">NwaifuAnime</p></a>
|
||||
<app-search-field></app-search-field>
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
.header {
|
||||
transition: height 0.3s;
|
||||
}
|
||||
:host {
|
||||
z-index: 20;
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild } from "@angular/core";
|
||||
import { Component, OnDestroy } from "@angular/core";
|
||||
import { ActivatedRoute, NavigationEnd, Router, RouterLink } from "@angular/router";
|
||||
import { Subject, filter, takeUntil } from "rxjs";
|
||||
import { SearchFieldComponent } from "../search-field/search-field.component";
|
||||
|
||||
@Component({
|
||||
selector: "app-header",
|
||||
templateUrl: "./header.component.html",
|
||||
styleUrls: ["./header.component.less"],
|
||||
standalone: true,
|
||||
imports: [CommonModule, RouterLink],
|
||||
imports: [CommonModule, RouterLink, SearchFieldComponent],
|
||||
})
|
||||
export class HeaderComponent implements AfterViewInit, OnDestroy {
|
||||
@ViewChild("searchInput") searchInput: ElementRef<HTMLInputElement> | null = null;
|
||||
export class HeaderComponent implements OnDestroy {
|
||||
menuOpened = false;
|
||||
private destroy$ = new Subject<void>();
|
||||
constructor(
|
||||
@@ -19,8 +19,10 @@ export class HeaderComponent implements AfterViewInit, OnDestroy {
|
||||
private route: ActivatedRoute,
|
||||
) {
|
||||
this.router.events
|
||||
.pipe(filter((event) => event instanceof NavigationEnd))
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.pipe(
|
||||
filter((event) => event instanceof NavigationEnd),
|
||||
takeUntil(this.destroy$),
|
||||
)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
.subscribe((val: any) => {
|
||||
if (val.url.startsWith("/detail") || val.url.startsWith("/reader")) {
|
||||
@@ -28,6 +30,7 @@ export class HeaderComponent implements AfterViewInit, OnDestroy {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
changeMenu() {
|
||||
this.menuOpened = !this.menuOpened;
|
||||
}
|
||||
@@ -40,22 +43,6 @@ export class HeaderComponent implements AfterViewInit, OnDestroy {
|
||||
return `search-bar bg-slate-300 md:w-full w-full md:m-0 ms-2 me-2 md:h-6 h-10 md:flex justify-start flex-row items-center rounded-md ${this.menuOpened ? "flex" : "hidden"}`;
|
||||
}
|
||||
|
||||
search() {
|
||||
if (this.searchInput) {
|
||||
const text = this.searchInput.nativeElement.value;
|
||||
this.router.navigateByUrl(`/?search=${text}`);
|
||||
}
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
||||
const search = params["search"];
|
||||
if (search && this.searchInput) {
|
||||
this.searchInput.nativeElement.value = search;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
|
||||
@@ -1,4 +1,33 @@
|
||||
<h1>It's home component</h1>
|
||||
@if (!search) {
|
||||
@if (loading) {
|
||||
<p class="text-5xl text-center mb-16">Подождите...</p>
|
||||
} @else {
|
||||
<p class="text-5xl text-center mb-10">Популярное:</p>
|
||||
<div class="flex flex-col gap-3 items-center w-full px-4 overflow-x-hidden">
|
||||
@for (popular of popularItems; track popular[0]) {
|
||||
<p class="text-5xl text-center">{{ popular[0] }}</p>
|
||||
<div class="w-full overflow-x-auto py-3">
|
||||
<div class="flex flex-row items-center gap-4 h-[400px] w-max">
|
||||
@for (popularTitle of popular[1]; track popularTitle.id) {
|
||||
<a routerLink="/detail" [queryParams]="{ url: popularTitle.slug_url }" class="h-full">
|
||||
<div
|
||||
class="flex flex-col justify-around border-black rounded-md p-4 w-[400px] items-center border h-full flex-shrink-0"
|
||||
>
|
||||
<img
|
||||
[src]="popularTitle.cover.thumbnail"
|
||||
[alt]="popularTitle.slug"
|
||||
class="w-[200px] h-auto aspect-auto"
|
||||
/>
|
||||
<p>{{ popularTitle.rus_name }}</p>
|
||||
</div>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
} @else {
|
||||
<div class="flex flex-col items-center w-full px-3">
|
||||
@if (loading) {
|
||||
<h1>Loading...</h1>
|
||||
@@ -13,10 +42,17 @@
|
||||
title="{{ item.name }}"
|
||||
class="mb-6 max-w-[700px] w-full"
|
||||
>
|
||||
<div class="card flex flex-col items-center border-black border-2 rounded-md p-4 w-full">
|
||||
<div
|
||||
class="card flex flex-col items-center border-black border-2 rounded-md p-4 w-full h-[350px]"
|
||||
>
|
||||
<h1>{{ item.rus_name }}</h1>
|
||||
<img [src]="item.cover.thumbnail" [alt]="item.slug" class="w-[200px] h-auto aspect-auto" />
|
||||
<img
|
||||
[src]="item.cover.thumbnail"
|
||||
[alt]="item.slug"
|
||||
class="w-[200px] h-auto max-h-[300px] aspect-auto"
|
||||
/>
|
||||
</div>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component, Input, OnDestroy, OnInit } from "@angular/core";
|
||||
import { ActivatedRoute, RouterLink } from "@angular/router";
|
||||
import { Subject, takeUntil } from "rxjs";
|
||||
import { map, Subject, Subscription, takeUntil } from "rxjs";
|
||||
import { IRuLIBPopular } from "../../services/parsers/rulib/rulib.popular.dto";
|
||||
import { Datum } from "../../services/parsers/rulib/rulib.search.dto";
|
||||
import { SearchService } from "../../services/search.service";
|
||||
|
||||
@@ -16,33 +17,75 @@ export class HomeComponent implements OnDestroy, OnInit {
|
||||
@Input() items: Datum[] = [];
|
||||
loading = false;
|
||||
notFound = false;
|
||||
search: string = "";
|
||||
popularItemsMap: Map<string, IRuLIBPopular[]> = new Map<string, IRuLIBPopular[]>();
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
private popularSubscription = new Subscription();
|
||||
|
||||
constructor(
|
||||
private searchService: SearchService,
|
||||
private route: ActivatedRoute,
|
||||
) {}
|
||||
) {
|
||||
this.searchService.setMangalibParser();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
this.popularSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
private getPopular(parserName: string) {
|
||||
this.searchService
|
||||
.getPopular()
|
||||
.pipe(
|
||||
map((data) => data as IRuLIBPopular[]),
|
||||
takeUntil(this.destroy$),
|
||||
)
|
||||
.subscribe({
|
||||
next: (data) => {
|
||||
this.popularItemsMap.set(parserName, data);
|
||||
this.loading = false;
|
||||
},
|
||||
error: (error) => {
|
||||
console.error(error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private getPopularMangalib() {
|
||||
this.searchService.setMangalibParser();
|
||||
this.getPopular(this.searchService.getRuLibName());
|
||||
}
|
||||
|
||||
private getPopularSlashlib() {
|
||||
this.searchService.setSlashlibParser();
|
||||
this.getPopular(this.searchService.getRuLibName());
|
||||
}
|
||||
|
||||
get popularItems() {
|
||||
return Array.from(this.popularItemsMap.entries()).sort((a, b) => (a[0] > b[0] ? 1 : -1));
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.queryParams.subscribe((params) => {
|
||||
const search = params["search"];
|
||||
if (search) {
|
||||
this.searchService.setMangalibParser();
|
||||
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
||||
this.search = params["search"] ?? "";
|
||||
this.items = [];
|
||||
this.loading = true;
|
||||
if (this.search) {
|
||||
this.searchService.setMangalibParser();
|
||||
this.searchService
|
||||
.search(search)
|
||||
.search(this.search)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((data) => {
|
||||
this.loading = false;
|
||||
this.items = data.data;
|
||||
this.notFound = this.items.length === 0;
|
||||
});
|
||||
} else {
|
||||
this.getPopularMangalib();
|
||||
this.getPopularSlashlib();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,7 +14,11 @@
|
||||
@if (pages.length > 0 && currentPage) {
|
||||
<div [class]="imageContainerClass">
|
||||
@if (!isManhwa) {
|
||||
<app-scale-image [imageSrc]="currentPage.imageUrl"></app-scale-image>
|
||||
<app-scale-image
|
||||
[imageSrc]="currentPage.imageUrl"
|
||||
(clickLeft)="prevPage()"
|
||||
(clickRight)="nextPage()"
|
||||
></app-scale-image>
|
||||
} @else {
|
||||
@for (page of manhwaPages; track page.id) {
|
||||
<app-scale-image
|
||||
@@ -26,7 +30,7 @@
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<div class="flex items-center justify-center space-x-4 my-10">
|
||||
<div class="flex items-center justify-center space-x-4 mt-[6rem]">
|
||||
<button (click)="prevPage()" class="p-3 text-white bg-slate-600 w-[100px] rounded-lg">
|
||||
←
|
||||
</button>
|
||||
@@ -35,8 +39,10 @@
|
||||
→
|
||||
</button>
|
||||
</div>
|
||||
@if (isManhwa) {
|
||||
<div class="hidden md:block md:fixed right-10 top-[50%]">
|
||||
{{ currentPageIndex + 1 }} / {{ pages.length }}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -240,6 +240,6 @@ export class ReaderComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
get imageContainerClass() {
|
||||
return `${this.isManhwa ? "h-auto" : "h-[70vh]"} w-[95vw] md:w-[450px] flex flex-col`;
|
||||
return `${this.isManhwa ? "h-auto" : "min-h-[70vh]"} w-screen md:w-[450px] flex flex-col`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="image-container" #container>
|
||||
@if (imageSrc) {
|
||||
<img #image [src]="imageSrc" (load)="onImageLoad()" alt="Manga page" />
|
||||
<img #image [src]="imageSrc" (load)="onImageLoad()" alt="Manga page" class="cursor-pointer" />
|
||||
} @else {
|
||||
<div class="h-screen flex flex-col items-center justify-center"><h1>Loading...</h1></div>
|
||||
}
|
||||
|
||||
@@ -6,9 +6,11 @@ import {
|
||||
Input,
|
||||
OnDestroy,
|
||||
Output,
|
||||
QueryList,
|
||||
ViewChild,
|
||||
ViewChildren,
|
||||
} from "@angular/core";
|
||||
import { Subscription, debounceTime, fromEvent } from "rxjs";
|
||||
import { Subject, Subscription, debounceTime, fromEvent, map, takeUntil } from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: "app-scale-image",
|
||||
@@ -20,10 +22,16 @@ export class ScaleImageComponent implements AfterViewInit, OnDestroy {
|
||||
@Input({ required: true }) imageSrc: string = "";
|
||||
@ViewChild("container", { static: true }) containerRef: ElementRef | null = null;
|
||||
@ViewChild("image", { static: true }) imageRef: ElementRef | null = null;
|
||||
@ViewChildren("image") imageList: QueryList<ElementRef<HTMLImageElement>> = new QueryList<
|
||||
ElementRef<HTMLImageElement>
|
||||
>();
|
||||
@Output() view = new EventEmitter<void>();
|
||||
@Output() clickLeft = new EventEmitter<void>();
|
||||
@Output() clickRight = new EventEmitter<void>();
|
||||
@Input() host: ElementRef | null = null;
|
||||
@Input() hostScrollable: boolean = false;
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
private resizeSubscription: Subscription = new Subscription();
|
||||
private observer!: IntersectionObserver;
|
||||
|
||||
@@ -39,11 +47,37 @@ export class ScaleImageComponent implements AfterViewInit, OnDestroy {
|
||||
);
|
||||
if (this.containerRef) this.observer.observe(this.containerRef.nativeElement);
|
||||
}
|
||||
if (!this.host) {
|
||||
this.imageList.changes
|
||||
.pipe<QueryList<ElementRef<HTMLImageElement>>>(takeUntil(this.destroy$))
|
||||
.subscribe((imageList) => {
|
||||
fromEvent(imageList.first.nativeElement, "click")
|
||||
.pipe(
|
||||
takeUntil(this.destroy$),
|
||||
map((e) => e as MouseEvent),
|
||||
)
|
||||
.subscribe((e) => {
|
||||
const target = e.target as HTMLImageElement;
|
||||
const imageWidth = target.clientWidth;
|
||||
const clickX = e.offsetX;
|
||||
if (clickX < imageWidth / 2) this.clickLeft.emit();
|
||||
else this.clickRight.emit();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// fromEvent(this.imageRef.first.nativeElement, "click")
|
||||
// .pipe(takeUntil(this.destroy$))
|
||||
// .subscribe((e) => {
|
||||
// console.log(e);
|
||||
// });
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.resizeSubscription) this.resizeSubscription.unsubscribe();
|
||||
if (this.observer) this.observer.disconnect();
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
onImageLoad() {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<div class="flex flex-row gap-3 justify-between items-center">
|
||||
<div class="input-block max-h-0"></div>
|
||||
<div class="input-btn rounded-full w-8 h-8 bg-slate-400 flex justify-center items-center">
|
||||
<i class="lni lni-search-alt"></i>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,42 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild } from "@angular/core";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { Subject, takeUntil } from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: "app-search-field",
|
||||
standalone: true,
|
||||
imports: [CommonModule],
|
||||
templateUrl: "./search-field.component.html",
|
||||
styleUrl: "./search-field.component.less",
|
||||
})
|
||||
export class SearchFieldComponent implements AfterViewInit, OnDestroy {
|
||||
@ViewChild("searchInput") searchInput: ElementRef<HTMLInputElement> | null = null;
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
) {}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
|
||||
const search = params["search"];
|
||||
if (search && this.searchInput) {
|
||||
this.searchInput.nativeElement.value = search;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
search() {
|
||||
if (this.searchInput && this.searchInput.nativeElement.value)
|
||||
this.router.navigate(["/", "search"], {
|
||||
queryParams: { search: this.searchInput.nativeElement.value },
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export enum EParser {
|
||||
MangaLib = 0,
|
||||
SlashLib = 1,
|
||||
}
|
||||
@@ -15,4 +15,6 @@ export abstract class Parser {
|
||||
abstract getChapters(url: string): Observable<object>;
|
||||
|
||||
abstract getChapter(url: string, chapter: string, volume: string): Observable<object>;
|
||||
|
||||
abstract getPopular(): Observable<object[]>;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import { RulibAuthService } from "./rulib.auth.service";
|
||||
import { IRulibChapterResult } from "./rulib.chapter.dto";
|
||||
import { IRulibChaptersResult } from "./rulib.chapters.dto";
|
||||
import { IRulibDetailResult } from "./rulib.detail.dto";
|
||||
import { IRuLIBPopular } from "./rulib.popular.dto";
|
||||
import { IRulibSearchResult } from "./rulib.search.dto";
|
||||
|
||||
//TODO: Make abstract classes
|
||||
@Injectable({
|
||||
providedIn: "root",
|
||||
})
|
||||
@@ -98,4 +98,21 @@ export class LibSocialParserService extends Parser {
|
||||
catchError((error) => throwError(() => `Now found ${error}`)),
|
||||
);
|
||||
}
|
||||
|
||||
getPopular(): Observable<IRuLIBPopular[]> {
|
||||
return this.http
|
||||
.get<{ data: { popular: IRuLIBPopular[] } }>(`${this.url}/api/`, {
|
||||
headers: {
|
||||
Authorization: "Bearer " + this.rulibAuthService.getToken(),
|
||||
"Site-Id": this.site_id,
|
||||
},
|
||||
})
|
||||
.pipe(
|
||||
map((data) => {
|
||||
const res = data.data.popular;
|
||||
return res;
|
||||
}),
|
||||
catchError((error) => throwError(() => `Now found ${error}`)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
export interface IRuLIBPopular {
|
||||
id: number;
|
||||
name: string;
|
||||
rus_name: string;
|
||||
eng_name: string;
|
||||
slug: string;
|
||||
slug_url: string;
|
||||
cover: Cover;
|
||||
ageRestriction: AgeRestriction;
|
||||
site: number;
|
||||
type: AgeRestriction;
|
||||
rating: Rating;
|
||||
last_item_at: Date;
|
||||
metadata: Metadata;
|
||||
model: Model;
|
||||
status: AgeRestriction;
|
||||
releaseDateString: string;
|
||||
}
|
||||
|
||||
export interface AgeRestriction {
|
||||
id: number;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface Cover {
|
||||
filename: string;
|
||||
thumbnail: string;
|
||||
default: string;
|
||||
md: string;
|
||||
}
|
||||
|
||||
export interface Metadata {
|
||||
last_item: LastItem;
|
||||
}
|
||||
|
||||
export interface LastItem {
|
||||
id: number;
|
||||
number: string;
|
||||
volume: number | string;
|
||||
name: string;
|
||||
branch_id: number | null;
|
||||
status?: null;
|
||||
type?: string;
|
||||
number_secondary?: string;
|
||||
slug?: number;
|
||||
manga_id?: null;
|
||||
created_at?: Date;
|
||||
likes_count?: null;
|
||||
}
|
||||
|
||||
export enum Model {
|
||||
Manga = "manga",
|
||||
}
|
||||
|
||||
export interface Rating {
|
||||
average: string;
|
||||
averageFormated: string;
|
||||
votes: number;
|
||||
votesFormated: string;
|
||||
user: number;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { ParserDecorator } from "../decorators/parser.decorator";
|
||||
import { ESiteUrls } from "../urls";
|
||||
import { LibSocialParserService } from "./lib.social.parser.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root",
|
||||
})
|
||||
@ParserDecorator({ site_name: "Slashlib", url: ESiteUrls.LIB_SOCIAL, site_id: 2 })
|
||||
export class SlashlibParserService extends LibSocialParserService {}
|
||||
@@ -1,4 +1,5 @@
|
||||
export enum ESiteUrls {
|
||||
LIB_SOCIAL = "https://api.lib.social",
|
||||
MANGALIB = "https://api.mangalib.me",
|
||||
SLASHLIB = "https://api.slashlib.me",
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { Injectable } from "@angular/core";
|
||||
import { Inject, Injectable } from "@angular/core";
|
||||
import { Observable, map } from "rxjs";
|
||||
import { EParser } from "./parsers/enums/parser";
|
||||
import { Parser } from "./parsers/parser";
|
||||
import { MangalibParserService } from "./parsers/rulib/mangalib.parser.service";
|
||||
import { IRulibChapterResult } from "./parsers/rulib/rulib.chapter.dto";
|
||||
import { IRulibChaptersResult } from "./parsers/rulib/rulib.chapters.dto";
|
||||
import { IRulibDetailResult } from "./parsers/rulib/rulib.detail.dto";
|
||||
@@ -13,11 +13,19 @@ export class SearchService {
|
||||
private parser!: Parser;
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private mangalibParser: MangalibParserService,
|
||||
@Inject(Parser) private parsers: Parser[],
|
||||
) {}
|
||||
|
||||
setMangalibParser() {
|
||||
this.parser = this.mangalibParser;
|
||||
this.setParser(EParser.MangaLib);
|
||||
}
|
||||
|
||||
setSlashlibParser() {
|
||||
this.setParser(EParser.SlashLib);
|
||||
}
|
||||
|
||||
private setParser(parser: EParser) {
|
||||
this.parser = this.parsers[parser];
|
||||
}
|
||||
|
||||
search(query: string): Observable<IRulibSearchResult> {
|
||||
@@ -69,4 +77,13 @@ export class SearchService {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (this.parser as any).isManhwa(url);
|
||||
}
|
||||
|
||||
getPopular(): Observable<object[]> {
|
||||
return this.parser.getPopular();
|
||||
}
|
||||
|
||||
getRuLibName(): string {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (this.parser as any).site_name;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user