Skip to content

Commit

Permalink
Merge pull request #20 from chytanka/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rodzyk authored Aug 16, 2024
2 parents fd0f995 + 2a73eb8 commit 126fce6
Show file tree
Hide file tree
Showing 17 changed files with 170 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const LIST_PATH = `list`;
export const ZENKO_PATH = `zenko`;
export const NHENTAI_PATH = `nhentai`;
export const COMICK_PATH = `comick`;
export const YANDERE_PATH = `yandere`;

const routes: Routes = [
{
Expand Down Expand Up @@ -68,6 +69,10 @@ const routes: Routes = [
path: COMICK_PATH,
loadChildren: () => import('./comick/comick.module').then(m => m.ComickModule)
},
{
path: YANDERE_PATH,
loadChildren: () => import('./yandere/yandere.module').then(m => m.YandereModule)
},
{
matcher: urlMatcher,
loadChildren: () => import('./link-parser/link-parser.module').then(m => m.LinkParserModule)
Expand Down
2 changes: 1 addition & 1 deletion src/app/link-parser/link-parser/link-parser.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h1 class="logo-text">@defer{ <app-text-embracer [text]="lang.ph().shortTitle" /> }</h1>
<div style="display: flex; gap: 1ch;">
<form (submit)="onSubmit()">
<input name="chtnk_url" type="url" required autofocus [placeholder]="lang.ph().enterLink"
<input name="chtnk_url" type="url" required autofocus [placeholder]="lang.ph().enterLink+supportSites().join(', ')"
(input)="inputLink($event)" [value]="link()">
</form>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/app/link-parser/link-parser/link-parser.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Signal, ViewChild, WritableSignal, computed, effect, inject, signal } from '@angular/core';
import { LinkParserService } from '../data-access/link-parser.service';
import {ZenkoLinkParser, ImgurLinkParser, JsonLinkParser, MangadexLinkParser, RedditLinkParser, TelegraphLinkParser, NhentaiLinkParser } from '../utils';
import {ZenkoLinkParser, ImgurLinkParser, JsonLinkParser, MangadexLinkParser, RedditLinkParser, TelegraphLinkParser, NhentaiLinkParser, YandereParser } from '../utils';
import { ActivatedRoute, Router } from '@angular/router';
import { LangService } from '../../shared/data-access/lang.service';
import { Base64 } from '../../shared/utils';
Expand Down Expand Up @@ -49,9 +49,12 @@ export class LinkParserComponent {
this.parser.parsers.push(new ZenkoLinkParser)
this.parser.parsers.push(new NhentaiLinkParser)
this.parser.parsers.push(new ComickLinkParser)
this.parser.parsers.push(new YandereParser)
this.parser.parsers.push(new JsonLinkParser)
}

supportSites = signal(["Imgur", "Telegra.ph", "Reddit", "MD", "Zenko","Comick", "NHentai", "Yande.re Pools"])

inputLink(event: Event) {
const v: string = (event.target as HTMLInputElement).value;

Expand Down Expand Up @@ -119,6 +122,7 @@ export class LinkParserComponent {
telegraph: '//telegra.ph/favicon.ico',
nhentai: '//nhentai.net/favicon.ico',
comick: '//comick.io/favicon.ico',
yandere: '//yande.re/favicon.ico',
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>'
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/link-parser/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export * from './json-link-parser';
export * from './telegraph-link-parser';
export * from './reddit-link-parser';
export * from './zenko-link-parser';
export * from './nhentai-link-parser'
export * from './nhentai-link-parser'
export * from './yandere-link-parser'
6 changes: 6 additions & 0 deletions src/app/link-parser/utils/yandere-link-parser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { LinkParser } from "./link-parser";

export class YandereParser extends LinkParser {
override regex = /yande\.re\/pool\/show\/(\d+)/;
override site = 'yandere';
};
3 changes: 2 additions & 1 deletion src/app/list/list-shell/list-shell.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, EffectCleanupRegisterFn, WritableSignal, computed, effect, inject, signal } from '@angular/core';
import { LinkParserService } from '../../link-parser/data-access/link-parser.service';
import { ImgurLinkParser, JsonLinkParser, LinkParser, MangadexLinkParser, NhentaiLinkParser, RedditLinkParser, TelegraphLinkParser, ZenkoLinkParser } from '../../link-parser/utils';
import { ImgurLinkParser, JsonLinkParser, LinkParser, MangadexLinkParser, NhentaiLinkParser, RedditLinkParser, TelegraphLinkParser, YandereParser, ZenkoLinkParser } from '../../link-parser/utils';
import { DomManipulationService } from '../../shared/data-access';
import { LangService } from '../../shared/data-access/lang.service';
import { ComickLinkParser } from '../../link-parser/utils/comick-link-parser';
Expand Down Expand Up @@ -89,6 +89,7 @@ export class ListShellComponent {
this.parser.parsers.push(new ZenkoLinkParser)
this.parser.parsers.push(new NhentaiLinkParser)
this.parser.parsers.push(new ComickLinkParser)
this.parser.parsers.push(new YandereParser)
this.parser.parsers.push(new JsonLinkParser)
}

Expand Down
19 changes: 18 additions & 1 deletion src/app/shared/ui/viewer/viewer.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, ElementRef, HostListener, Input, Signal, ViewChild, WritableSignal, computed, effect, inject, signal } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, HostListener, Input, Signal, ViewChild, WritableSignal, computed, effect, inject, signal } from '@angular/core';
import { CompositionEpisode } from '../../../common/common-read';
import { ViewerService, DomManipulationService } from '../../data-access';
import { ActivatedRoute, Router } from '@angular/router';
Expand Down Expand Up @@ -32,7 +32,23 @@ export class ViewerComponent {
@Input() playlistLink: string = "";
@Input() currentPlaylistItem: PlaylistItem | undefined;

cdr = inject(ChangeDetectorRef)

initListFromParrentWindow() {
if (!this.embedHelper.isEmbedded()) return

this.embedHelper.postMessage({}, 'listrequest');

window.addEventListener('message', ({data}) => {
if(data.event != "listresponse") return;

this.playlist = data.data as Playlist // !!!

this.cdr.detectChanges()

}, false);

}

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

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

toggleFullScreen = () => this.dm.toggleFullScreen(this.el.nativeElement)
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/utils/phrases.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export class Phrases {
title: string = "Chytanka — read it easily and comfortably!";
shortTitle: string = "Chytanka";
enterLink: string = "Enter link to episode on Imgur, Telegra.ph, Reddit, MD";
enterLink: string = "Enter link to episode on ";
slogan: string = "and read it easily and comfortably!";
letsgo: string = "Let's go"
dataLoadErr: string = "Data loading error. Please try again later."
Expand Down
42 changes: 42 additions & 0 deletions src/app/yandere/data-access/yandere.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { inject, Injectable } from '@angular/core';
import { environment } from '../../../environments/environment';
import { HttpClient } from '@angular/common/http';
import { Observable, map } from 'rxjs';
import { CompositionEpisode, CompositionPublisher } from '../../common/common-read';
import { Base64 } from '../../shared/utils';

@Injectable({
providedIn: 'root'
})
export class YandereService {
http: HttpClient = inject(HttpClient)

getComposition(id: string): Observable<CompositionEpisode> {
return this.http.get<any>(environment.yanderePoolsHost + id)
.pipe(map((data) => { return this.map(data) }))
}

map(data: any): CompositionEpisode {
const mappedResponse = {
title: data.name,

images: (data.posts.map((item: any) => {
return {
src: item.sample_url,
width: item.sample_width,
height: item.sample_height
};
})).filter((i: any) => i.src)
.map((img: any) => {
return {
src: environment.proxy + Base64.toBase64(img.src),
width: img.width,
height: img.height
}
})

};

return mappedResponse;
}
}
17 changes: 17 additions & 0 deletions src/app/yandere/yandere-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { YandereShellComponent } from './yandere-shell/yandere-shell.component';

const routes: Routes = [
{ path: '', redirectTo: '/', pathMatch: 'full' },
{
path: ':id',
component: YandereShellComponent
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class YandereRoutingModule { }
8 changes: 8 additions & 0 deletions src/app/yandere/yandere-shell/yandere-shell.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<app-common-read [episode$]="episode$" [error$]="error$" [loading$]="loading$" (refreshData)="refreshData()"
[playlist]="playlistService.playlist()" [playlistLink]="playlistLink()" [currentPlaylistItem]="currentPlItem()">

<p>{{lang.ph().imagesVia}}<a href="https://yande.re" target="_blank" rel="noopener noreferrer">Yande.re</a>
API.
{{lang.ph().thanks}}<br>{{lang.ph().detalisCopy}}</p>

</app-common-read>
Empty file.
39 changes: 39 additions & 0 deletions src/app/yandere/yandere-shell/yandere-shell.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Component, inject, OnDestroy } from '@angular/core';
import { switchMap, of } from 'rxjs';
import { ReadBaseComponent } from '../../common/common-read';
import { Base64 } from '../../shared/utils';
import { YandereService } from '../data-access/yandere.service';
import { YANDERE_PATH } from '../../app-routing.module';

@Component({
selector: 'app-yandere-shell',
templateUrl: './yandere-shell.component.html',
styleUrl: './yandere-shell.component.scss'
})
export class YandereShellComponent extends ReadBaseComponent implements OnDestroy {
yandere = inject(YandereService)

override episode$ = this.combineParamMapAndRefresh()
.pipe(this.tapStartLoading(),
switchMap(([params]) => {
const pathParam = params?.get('id');

if (!pathParam) return of(null);

const path = (Base64.isBase64(pathParam)) ? Base64.fromBase64(pathParam) : pathParam;

return (this.yandere.getComposition(path)).pipe(this.catchError(), this.tapSetTitle(),
this.tapSaveToHistory(YANDERE_PATH, path),
this.tapSaveToCurrentPlaylistItem(YANDERE_PATH, path),
this.finalizeLoading());
})
);

constructor() {
super()
}

ngOnDestroy(): void {
this.plObserv?.unsubscribe();
}
}
19 changes: 19 additions & 0 deletions src/app/yandere/yandere.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { YandereRoutingModule } from './yandere-routing.module';
import { YandereShellComponent } from './yandere-shell/yandere-shell.component';
import { CommonReadModule } from '../common/common-read';


@NgModule({
declarations: [
YandereShellComponent
],
imports: [
CommonModule,
YandereRoutingModule,
CommonReadModule
]
})
export class YandereModule { }
2 changes: 1 addition & 1 deletion src/assets/langs/uk.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Читанка — читай легко і комфортно!",
"shortTitle": "Читанка",
"enterLink": "Введи посилання на епізод з Imgur, Telegra.ph, Reddit, MD",
"enterLink": "Введи посилання на епізод з ",
"slogan": "і читай легко та зручно!",
"letsgo": "Вйо до",
"dataLoadErr": "Помилка завантаження даних. Будь ласка, спробуйте пізніше.",
Expand Down
3 changes: 2 additions & 1 deletion src/environments/environment.development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export const environment = {
redditHost: `https://www.reddit.com/r/all/comments/`,
zenkoHost: `https://zenko-api.onrender.com/chapters/`,
nhentaiHost: `https://nhentai.net/api/gallery/`,
comickHost: `https://api.comick.fun/chapter/`
comickHost: `https://api.comick.fun/chapter/`,
yanderePoolsHost: `https://yande.re/pool/show.json/`
};
3 changes: 2 additions & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export const environment = {
redditHost: `https://www.reddit.com/r/all/comments/`,
zenkoHost: `https://zenko-api.onrender.com/chapters/`,
nhentaiHost: `https://nhentai.net/api/gallery/`,
comickHost: `https://api.comick.fun/chapter/`
comickHost: `https://api.comick.fun/chapter/`,
yanderePoolsHost: `https://yande.re/pool/show.json/`
};

0 comments on commit 126fce6

Please sign in to comment.