-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from chytanka/develop
feat: zenko
- Loading branch information
Showing
21 changed files
with
230 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { LinkParser } from "./link-parser"; | ||
|
||
export class ZenkoLinkParser extends LinkParser { | ||
override regex = /zenko\.online\/titles\/\d+\/(\d+)/; | ||
override site = 'zenko'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,6 @@ svg { | |
font-weight: bold; | ||
font-style: italic; | ||
opacity: .8; | ||
font-family: cursive; | ||
font-family: 'EB Garamond'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { HttpClient, HttpParams } from '@angular/common/http'; | ||
import { inject, Injectable } from '@angular/core'; | ||
import { Observable, map } from 'rxjs'; | ||
import { environment } from '../../../environments/environment'; | ||
import { CompositionEpisode, CompositionPublisher } from '../../common/common-read'; | ||
import { Base64 } from '../../shared/utils'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class ZenkoService { | ||
http: HttpClient = inject(HttpClient) | ||
|
||
getComposition(id: string): Observable<CompositionEpisode> { | ||
return this.http.get<any>(environment.zenkoHost + id) | ||
.pipe(map((data) => { return this.map(data) })) | ||
} | ||
|
||
map(data: any): CompositionEpisode { | ||
const mappedResponse = { | ||
title: this.titleDecode(data.name), | ||
|
||
publisher: { | ||
id: data.publisher.id as string, | ||
site: data.publisher.id as string, | ||
name: data.publisher.name as string, | ||
avatar: environment.proxy + Base64.toBase64(`https://zenko.b-cdn.net/${data.publisher.avatar}?optimizer=image&width=900&quality=90&height=auto`) as string, | ||
description: data.publisher.description as string, | ||
links: data.publisher.links.map((l: any) => { return { link: l.link, title: l.title }; }) | ||
} as unknown as CompositionPublisher, | ||
|
||
images: (data.pages.map((item: any) => { | ||
return { | ||
src: item.imgUrl | ||
}; | ||
})).filter((i: any) => i.src).map((img: any) => { return { src: environment.proxy + Base64.toBase64(`https://zenko.b-cdn.net/${img.src}?optimizer=image&width=900&quality=90&height=auto`) } }) | ||
|
||
}; | ||
|
||
return mappedResponse; | ||
} | ||
|
||
titleDecode(input: string) { | ||
const parts = input.split("@#%&;№%#&**#!@"); | ||
|
||
const tom = parts[0]; | ||
const chapter = parts[1]; | ||
const name = parts[2] ?? 'Без назви'; | ||
|
||
const output = `Том ${tom} Розділ ${chapter}: ${name}`; | ||
return output | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { ZenkoShellComponent } from './zenko-shell/zenko-shell.component'; | ||
|
||
const routes: Routes = [ | ||
{ path: '', redirectTo: '/', pathMatch: 'full' }, | ||
{ | ||
path: ':id', | ||
component: ZenkoShellComponent | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule] | ||
}) | ||
export class ZenkoRoutingModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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://zenko.online" target="_blank" rel="noopener noreferrer">Zenko</a> | ||
API. | ||
{{lang.ph().thanks}}<br>{{lang.ph().detalisCopy}}</p> | ||
|
||
</app-common-read> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { ZENKO_PATH } from '../../app-routing.module'; | ||
import { ReadBaseComponent } from '../../common/common-read'; | ||
import { Base64 } from '../../shared/utils'; | ||
import { ZenkoService } from '../data-access/zenko.service'; | ||
|
||
@Component({ | ||
selector: 'app-zenko-shell', | ||
templateUrl: './zenko-shell.component.html', | ||
styleUrl: './zenko-shell.component.scss' | ||
}) | ||
export class ZenkoShellComponent extends ReadBaseComponent implements OnDestroy { | ||
zenko = inject(ZenkoService) | ||
|
||
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.zenko.getComposition(path)).pipe(this.catchError(), this.tapSetTitle(), | ||
this.tapSaveToHistory(ZENKO_PATH, path), | ||
this.tapSaveToCurrentPlaylistItem(ZENKO_PATH, path), | ||
this.finalizeLoading()); | ||
}) | ||
); | ||
|
||
constructor() { | ||
super() | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.plObserv?.unsubscribe(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { ZenkoRoutingModule } from './zenko-routing.module'; | ||
import { ZenkoShellComponent } from './zenko-shell/zenko-shell.component'; | ||
import { CommonReadModule } from '../common/common-read'; | ||
|
||
|
||
@NgModule({ | ||
declarations: [ | ||
ZenkoShellComponent | ||
], | ||
imports: [ | ||
CommonModule, | ||
ZenkoRoutingModule, | ||
CommonReadModule | ||
] | ||
}) | ||
export class ZenkoModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.