Skip to content

Commit fd0f995

Browse files
authored
Merge pull request #19 from chytanka/develop
Develop
2 parents 5771099 + 9e6afcf commit fd0f995

23 files changed

+293
-9
lines changed

src/app/app-routing.module.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export const REDDIT_PATH = `reddit`;
2424
export const READ_PATH = `read`;
2525
export const LIST_PATH = `list`;
2626
export const ZENKO_PATH = `zenko`;
27+
export const NHENTAI_PATH = `nhentai`;
28+
export const COMICK_PATH = `comick`;
2729

2830
const routes: Routes = [
2931
{
@@ -58,6 +60,14 @@ const routes: Routes = [
5860
path: ZENKO_PATH,
5961
loadChildren: () => import('./zenko/zenko.module').then(m => m.ZenkoModule)
6062
},
63+
{
64+
path: NHENTAI_PATH,
65+
loadChildren: () => import('./nhentai/nhentai.module').then(m => m.NhentaiModule)
66+
},
67+
{
68+
path: COMICK_PATH,
69+
loadChildren: () => import('./comick/comick.module').then(m => m.ComickModule)
70+
},
6171
{
6272
matcher: urlMatcher,
6373
loadChildren: () => import('./link-parser/link-parser.module').then(m => m.LinkParserModule)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { NgModule } from '@angular/core';
2+
import { RouterModule, Routes } from '@angular/router';
3+
import { ComickShellComponent } from './comick-shell/comick-shell.component';
4+
5+
const routes: Routes = [
6+
{ path: '', redirectTo: '/', pathMatch: 'full' },
7+
{
8+
path: ':id',
9+
component: ComickShellComponent
10+
}
11+
];
12+
13+
@NgModule({
14+
imports: [RouterModule.forChild(routes)],
15+
exports: [RouterModule]
16+
})
17+
export class ComickRoutingModule { }
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<app-common-read [episode$]="episode$" [error$]="error$" [loading$]="loading$" (refreshData)="refreshData()"
2+
[playlist]="playlistService.playlist()" [playlistLink]="playlistLink()" [currentPlaylistItem]="currentPlItem()">
3+
4+
<p>{{lang.ph().imagesVia}}<a href="https://nhentai.net" target="_blank" rel="noopener noreferrer">Nhentai</a>
5+
API.
6+
{{lang.ph().thanks}}<br>{{lang.ph().detalisCopy}}</p>
7+
8+
</app-common-read>

src/app/comick/comick-shell/comick-shell.component.scss

Whitespace-only changes.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Component, inject, OnDestroy } from '@angular/core';
2+
import { ComickService } from '../data-access/comick.service';
3+
import { switchMap, of } from 'rxjs';
4+
import { ReadBaseComponent } from '../../common/common-read';
5+
import { Base64 } from '../../shared/utils';
6+
import { COMICK_PATH } from '../../app-routing.module';
7+
8+
@Component({
9+
selector: 'app-comick-shell',
10+
templateUrl: './comick-shell.component.html',
11+
styleUrl: './comick-shell.component.scss'
12+
})
13+
export class ComickShellComponent extends ReadBaseComponent implements OnDestroy {
14+
comick = inject(ComickService)
15+
16+
override episode$ = this.combineParamMapAndRefresh()
17+
.pipe(this.tapStartLoading(),
18+
switchMap(([params]) => {
19+
const pathParam = params?.get('id');
20+
21+
if (!pathParam) return of(null);
22+
23+
const path = (Base64.isBase64(pathParam)) ? Base64.fromBase64(pathParam) : pathParam;
24+
25+
return (this.comick.getComposition(path)).pipe(this.catchError(), this.tapSetTitle(),
26+
this.tapSaveToHistory(COMICK_PATH, path),
27+
this.tapSaveToCurrentPlaylistItem(COMICK_PATH, path),
28+
this.finalizeLoading());
29+
})
30+
);
31+
32+
constructor() {
33+
super()
34+
}
35+
36+
ngOnDestroy(): void {
37+
this.plObserv?.unsubscribe();
38+
}
39+
}

src/app/comick/comick.module.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { NgModule } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
4+
import { ComickRoutingModule } from './comick-routing.module';
5+
import { ComickShellComponent } from './comick-shell/comick-shell.component';
6+
import { CommonReadModule } from '../common/common-read';
7+
8+
9+
@NgModule({
10+
declarations: [
11+
ComickShellComponent
12+
],
13+
imports: [
14+
CommonModule,
15+
ComickRoutingModule,
16+
CommonReadModule
17+
]
18+
})
19+
export class ComickModule { }
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { HttpClient } from '@angular/common/http';
2+
import { inject, Injectable } from '@angular/core';
3+
import { Observable, map } from 'rxjs';
4+
import { environment } from '../../../environments/environment';
5+
import { CompositionEpisode } from '../../common/common-read';
6+
import { Base64 } from '../../shared/utils';
7+
8+
@Injectable({
9+
providedIn: 'root'
10+
})
11+
export class ComickService {
12+
http: HttpClient = inject(HttpClient)
13+
14+
getComposition(id: string): Observable<CompositionEpisode> {
15+
// environment.proxy + Base64.toBase64
16+
return this.http.get<any>((environment.comickHost + id))
17+
.pipe(map((data) => { return this.map(data) }))
18+
}
19+
20+
map(data: any): CompositionEpisode {
21+
const nsfw = data.matureContent;
22+
const mappedResponse = {
23+
title: data.chapTitle,
24+
nsfw: nsfw, //['erotica', 'suggestive'].includes(data.chapter.md_comics.content_rating),
25+
images: (data.chapter.md_images.map((item: any, index: number) => {
26+
return {
27+
src: `https://meo3.comick.pictures/${item.b2key}`,
28+
height: item.h,
29+
width: item.w
30+
};
31+
})).filter((i: any) => i.src)
32+
// .map((img: any) => {
33+
// return {
34+
// src: environment.proxy + Base64.toBase64(`${img.src}`)
35+
// }
36+
// })
37+
38+
};
39+
40+
return mappedResponse;
41+
}
42+
}

src/app/link-parser/link-parser/link-parser.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { Component, Signal, ViewChild, WritableSignal, computed, effect, inject, signal } from '@angular/core';
22
import { LinkParserService } from '../data-access/link-parser.service';
3-
import {ZenkoLinkParser, ImgurLinkParser, JsonLinkParser, MangadexLinkParser, RedditLinkParser, TelegraphLinkParser } from '../utils';
3+
import {ZenkoLinkParser, ImgurLinkParser, JsonLinkParser, MangadexLinkParser, RedditLinkParser, TelegraphLinkParser, NhentaiLinkParser } from '../utils';
44
import { ActivatedRoute, Router } from '@angular/router';
55
import { LangService } from '../../shared/data-access/lang.service';
66
import { Base64 } from '../../shared/utils';
77
import { Title } from '@angular/platform-browser';
88
import { LinkParserSettingsService } from '../data-access/link-parser-settings.service';
9+
import { ComickLinkParser } from '../utils/comick-link-parser';
910

1011
@Component({
1112
selector: 'app-link-parser',
@@ -46,6 +47,8 @@ export class LinkParserComponent {
4647
this.parser.parsers.push(new TelegraphLinkParser)
4748
this.parser.parsers.push(new RedditLinkParser)
4849
this.parser.parsers.push(new ZenkoLinkParser)
50+
this.parser.parsers.push(new NhentaiLinkParser)
51+
this.parser.parsers.push(new ComickLinkParser)
4952
this.parser.parsers.push(new JsonLinkParser)
5053
}
5154

@@ -114,6 +117,8 @@ export class LinkParserComponent {
114117
imgur: '//imgur.com/favicon.ico',
115118
mangadex: '//mangadex.org/favicon.ico',
116119
telegraph: '//telegra.ph/favicon.ico',
120+
nhentai: '//nhentai.net/favicon.ico',
121+
comick: '//comick.io/favicon.ico',
117122
read: 'data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🗯️</text></svg>'
118123
}
119124

src/app/link-parser/ui/footer/footer.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const SOCIAL_LINKS: any[] = [
2525
styleUrl: './footer.component.scss'
2626
})
2727
export class FooterComponent {
28-
public readonly version: string = 'v2024.7.14'
28+
public readonly version: string = 'v2024.8.13'
2929
public lang: LangService = inject(LangService);
3030

3131
public social: any[] = SOCIAL_LINKS;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { LinkParser } from "./link-parser";
2+
3+
export class ComickLinkParser extends LinkParser {
4+
override regex = /comick\.io\/comic\/(?:[\w-]+)\/(\w+)/;
5+
override site = 'comick';
6+
};

0 commit comments

Comments
 (0)