Skip to content

Commit 126fce6

Browse files
authored
Merge pull request #20 from chytanka/develop
Develop
2 parents fd0f995 + 2a73eb8 commit 126fce6

17 files changed

+170
-9
lines changed

src/app/app-routing.module.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const LIST_PATH = `list`;
2626
export const ZENKO_PATH = `zenko`;
2727
export const NHENTAI_PATH = `nhentai`;
2828
export const COMICK_PATH = `comick`;
29+
export const YANDERE_PATH = `yandere`;
2930

3031
const routes: Routes = [
3132
{
@@ -68,6 +69,10 @@ const routes: Routes = [
6869
path: COMICK_PATH,
6970
loadChildren: () => import('./comick/comick.module').then(m => m.ComickModule)
7071
},
72+
{
73+
path: YANDERE_PATH,
74+
loadChildren: () => import('./yandere/yandere.module').then(m => m.YandereModule)
75+
},
7176
{
7277
matcher: urlMatcher,
7378
loadChildren: () => import('./link-parser/link-parser.module').then(m => m.LinkParserModule)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<h1 class="logo-text">@defer{ <app-text-embracer [text]="lang.ph().shortTitle" /> }</h1>
55
<div style="display: flex; gap: 1ch;">
66
<form (submit)="onSubmit()">
7-
<input name="chtnk_url" type="url" required autofocus [placeholder]="lang.ph().enterLink"
7+
<input name="chtnk_url" type="url" required autofocus [placeholder]="lang.ph().enterLink+supportSites().join(', ')"
88
(input)="inputLink($event)" [value]="link()">
99
</form>
1010
</div>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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, NhentaiLinkParser } from '../utils';
3+
import {ZenkoLinkParser, ImgurLinkParser, JsonLinkParser, MangadexLinkParser, RedditLinkParser, TelegraphLinkParser, NhentaiLinkParser, YandereParser } from '../utils';
44
import { ActivatedRoute, Router } from '@angular/router';
55
import { LangService } from '../../shared/data-access/lang.service';
66
import { Base64 } from '../../shared/utils';
@@ -49,9 +49,12 @@ export class LinkParserComponent {
4949
this.parser.parsers.push(new ZenkoLinkParser)
5050
this.parser.parsers.push(new NhentaiLinkParser)
5151
this.parser.parsers.push(new ComickLinkParser)
52+
this.parser.parsers.push(new YandereParser)
5253
this.parser.parsers.push(new JsonLinkParser)
5354
}
5455

56+
supportSites = signal(["Imgur", "Telegra.ph", "Reddit", "MD", "Zenko","Comick", "NHentai", "Yande.re Pools"])
57+
5558
inputLink(event: Event) {
5659
const v: string = (event.target as HTMLInputElement).value;
5760

@@ -119,6 +122,7 @@ export class LinkParserComponent {
119122
telegraph: '//telegra.ph/favicon.ico',
120123
nhentai: '//nhentai.net/favicon.ico',
121124
comick: '//comick.io/favicon.ico',
125+
yandere: '//yande.re/favicon.ico',
122126
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>'
123127
}
124128

src/app/link-parser/utils/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export * from './json-link-parser';
55
export * from './telegraph-link-parser';
66
export * from './reddit-link-parser';
77
export * from './zenko-link-parser';
8-
export * from './nhentai-link-parser'
8+
export * from './nhentai-link-parser'
9+
export * from './yandere-link-parser'
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 YandereParser extends LinkParser {
4+
override regex = /yande\.re\/pool\/show\/(\d+)/;
5+
override site = 'yandere';
6+
};

src/app/list/list-shell/list-shell.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, EffectCleanupRegisterFn, WritableSignal, computed, effect, inject, signal } from '@angular/core';
22
import { LinkParserService } from '../../link-parser/data-access/link-parser.service';
3-
import { ImgurLinkParser, JsonLinkParser, LinkParser, MangadexLinkParser, NhentaiLinkParser, RedditLinkParser, TelegraphLinkParser, ZenkoLinkParser } from '../../link-parser/utils';
3+
import { ImgurLinkParser, JsonLinkParser, LinkParser, MangadexLinkParser, NhentaiLinkParser, RedditLinkParser, TelegraphLinkParser, YandereParser, ZenkoLinkParser } from '../../link-parser/utils';
44
import { DomManipulationService } from '../../shared/data-access';
55
import { LangService } from '../../shared/data-access/lang.service';
66
import { ComickLinkParser } from '../../link-parser/utils/comick-link-parser';
@@ -89,6 +89,7 @@ export class ListShellComponent {
8989
this.parser.parsers.push(new ZenkoLinkParser)
9090
this.parser.parsers.push(new NhentaiLinkParser)
9191
this.parser.parsers.push(new ComickLinkParser)
92+
this.parser.parsers.push(new YandereParser)
9293
this.parser.parsers.push(new JsonLinkParser)
9394
}
9495

src/app/shared/ui/viewer/viewer.component.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeDetectionStrategy, Component, ElementRef, HostListener, Input, Signal, ViewChild, WritableSignal, computed, effect, inject, signal } from '@angular/core';
1+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, HostListener, Input, Signal, ViewChild, WritableSignal, computed, effect, inject, signal } from '@angular/core';
22
import { CompositionEpisode } from '../../../common/common-read';
33
import { ViewerService, DomManipulationService } from '../../data-access';
44
import { ActivatedRoute, Router } from '@angular/router';
@@ -32,7 +32,23 @@ export class ViewerComponent {
3232
@Input() playlistLink: string = "";
3333
@Input() currentPlaylistItem: PlaylistItem | undefined;
3434

35+
cdr = inject(ChangeDetectorRef)
3536

37+
initListFromParrentWindow() {
38+
if (!this.embedHelper.isEmbedded()) return
39+
40+
this.embedHelper.postMessage({}, 'listrequest');
41+
42+
window.addEventListener('message', ({data}) => {
43+
if(data.event != "listresponse") return;
44+
45+
this.playlist = data.data as Playlist // !!!
46+
47+
this.cdr.detectChanges()
48+
49+
}, false);
50+
51+
}
3652

3753
getCyrrentIndex() {
3854
for (let i = 0; i < this.playlist.length; i++) {
@@ -62,6 +78,7 @@ export class ViewerComponent {
6278

6379
constructor(private el: ElementRef, public viewer: ViewerService, private dm: DomManipulationService, private router: Router, public lang: LangService) {
6480
this.initHotKeys()
81+
this.initListFromParrentWindow();
6582
}
6683

6784
toggleFullScreen = () => this.dm.toggleFullScreen(this.el.nativeElement)

src/app/shared/utils/phrases.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export class Phrases {
22
title: string = "Chytanka — read it easily and comfortably!";
33
shortTitle: string = "Chytanka";
4-
enterLink: string = "Enter link to episode on Imgur, Telegra.ph, Reddit, MD";
4+
enterLink: string = "Enter link to episode on ";
55
slogan: string = "and read it easily and comfortably!";
66
letsgo: string = "Let's go"
77
dataLoadErr: string = "Data loading error. Please try again later."
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { inject, Injectable } from '@angular/core';
2+
import { environment } from '../../../environments/environment';
3+
import { HttpClient } from '@angular/common/http';
4+
import { Observable, map } from 'rxjs';
5+
import { CompositionEpisode, CompositionPublisher } from '../../common/common-read';
6+
import { Base64 } from '../../shared/utils';
7+
8+
@Injectable({
9+
providedIn: 'root'
10+
})
11+
export class YandereService {
12+
http: HttpClient = inject(HttpClient)
13+
14+
getComposition(id: string): Observable<CompositionEpisode> {
15+
return this.http.get<any>(environment.yanderePoolsHost + id)
16+
.pipe(map((data) => { return this.map(data) }))
17+
}
18+
19+
map(data: any): CompositionEpisode {
20+
const mappedResponse = {
21+
title: data.name,
22+
23+
images: (data.posts.map((item: any) => {
24+
return {
25+
src: item.sample_url,
26+
width: item.sample_width,
27+
height: item.sample_height
28+
};
29+
})).filter((i: any) => i.src)
30+
.map((img: any) => {
31+
return {
32+
src: environment.proxy + Base64.toBase64(img.src),
33+
width: img.width,
34+
height: img.height
35+
}
36+
})
37+
38+
};
39+
40+
return mappedResponse;
41+
}
42+
}
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 { YandereShellComponent } from './yandere-shell/yandere-shell.component';
4+
5+
const routes: Routes = [
6+
{ path: '', redirectTo: '/', pathMatch: 'full' },
7+
{
8+
path: ':id',
9+
component: YandereShellComponent
10+
}
11+
];
12+
13+
@NgModule({
14+
imports: [RouterModule.forChild(routes)],
15+
exports: [RouterModule]
16+
})
17+
export class YandereRoutingModule { }

0 commit comments

Comments
 (0)