Skip to content

Commit b01466a

Browse files
authored
Merge pull request #36 from chytanka/develop
Develop
2 parents 76d9fc8 + fc782c7 commit b01466a

File tree

56 files changed

+492
-203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+492
-203
lines changed

.directory

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[Desktop Entry]
2+
Icon=folder-chytanka

.github/workflows/node.js.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,21 @@ permissions:
1717
jobs:
1818
build:
1919
runs-on: ubuntu-latest
20-
2120
strategy:
2221
matrix:
2322
node-version: [22.x]
24-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2523

2624
steps:
27-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v4
2826
- name: Use Node.js ${{ matrix.node-version }}
29-
uses: actions/setup-node@v3
27+
uses: actions/setup-node@v4
3028
with:
3129
node-version: ${{ matrix.node-version }}
3230
cache: "npm"
3331
- run: npm ci --force
3432
- run: npm install -g @angular/cli > /dev/null
3533
- run: ng build --output-path dist
36-
37-
- name: Copy index.html to 404.html
38-
run: cp dist/browser/index.html dist/browser/404.html
34+
- run: cp dist/browser/index.html dist/browser/404.html
3935

4036
- name: Upload artifact
4137
uses: actions/upload-pages-artifact@v3

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chytanka",
3-
"version": "0.13.32",
3+
"version": "0.14.33",
44
"scripts": {
55
"ng": "ng",
66
"start": "ng serve",

src/app/@site-modules/@common-read/ui/common-read/common-read.component.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
@if (!(loading$ | async)) {
44
<app-viewer [playlist]="playlist" [playlistLink]="playlistLink" [currentPlaylistItem]="currentPlaylistItem"
5-
[episode]="episode"><ng-content /></app-viewer>
5+
[episode]="episode">
6+
<div ngProjectAs="source-logo"><ng-content select="source-logo" /></div>
7+
<ng-content />
8+
</app-viewer>
69
}
710

811
}

src/app/@site-modules/comick/comick.service.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
import { HttpClient } from '@angular/common/http';
2-
import { inject, Injectable } from '@angular/core';
2+
import { inject, Injectable, PLATFORM_ID } from '@angular/core';
33
import { Observable, map } from 'rxjs';
44
import { environment } from '../../../environments/environment';
55
import { CompositionEpisode } from '../@common-read';
66
import { ProxyService } from '../../shared/data-access/proxy.service';
7+
import { isPlatformServer } from '@angular/common';
78

89
@Injectable({
910
providedIn: 'root'
1011
})
1112
export class ComickService {
13+
platformId = inject(PLATFORM_ID)
1214
http: HttpClient = inject(HttpClient)
1315
proxy: ProxyService = inject(ProxyService)
1416

1517
getComposition(id: string): Observable<CompositionEpisode> {
16-
// this.proxy.proxyUrl()
17-
return this.http.get<any>((environment.comickHost + id))
18+
const url = isPlatformServer(this.platformId)
19+
? environment.comickHost + id
20+
: this.proxy.proxyUrl(environment.comickHost + id);
21+
22+
return this.http.get<any>(url)
1823
.pipe(map((data) => { return this.map(data) }))
1924
}
2025

@@ -30,11 +35,11 @@ export class ComickService {
3035
width: item.w
3136
};
3237
})).filter((i: any) => i.src)
33-
// .map((img: any) => {
34-
// return {
35-
// src: this.proxy.proxyUrl(`${img.src}`)
36-
// }
37-
// })
38+
// .map((img: any) => {
39+
// return {
40+
// src: this.proxy.proxyUrl(`${img.src}`)
41+
// }
42+
// })
3843

3944
};
4045

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { Component } from '@angular/core';
2+
import { ImgchestService } from './imgchest.service';
3+
import { Base64 } from '../../shared/utils';
4+
import { of, switchMap } from 'rxjs';
5+
import { CommonReadModule, ReadBaseComponent } from '../@common-read';
6+
import { IMGCHEST_PATH } from '../../app-routing.module';
7+
8+
@Component({
9+
imports: [CommonReadModule],
10+
selector: 'app-imgchest-shell',
11+
template: `<app-common-read [episode$]="episode$" [error$]="error$" [loading$]="loading$" (refreshData)="refreshData()" [playlist]="playlistService.playlist()" [playlistLink]="playlistLink()" [currentPlaylistItem]="currentPlItem()">
12+
13+
<a ngProjectAs="source-logo" href="https://imgchest.com" target="_blank" rel="noopener noreferrer" style="display: flex; gap: 1ch; ">
14+
<img style="max-width: 40px;" src="/assets/logos/imgchest.png" alt="Imgchest logo">
15+
</a>
16+
17+
<div style="direction: ltr; user-select: text !important; text-wrap: balance; text-align: center; display: grid; place-content: center; justify-items: center;">
18+
<p>{{lang.ph().imagesVia}}<a href="https://imgchest.com" target="_blank" rel="noopener noreferrer">Imgchest</a>
19+
API.
20+
{{lang.ph().thanks}}<br>{{lang.ph().detalisCopy}}</p>
21+
</div></app-common-read>`
22+
})
23+
export default class ImgchestShellComponent extends ReadBaseComponent {
24+
25+
override episode$ = this.combineParamMapAndRefresh()
26+
.pipe(this.tapStartLoading(),
27+
switchMap(([params]) => {
28+
const idParam = params?.get('id');
29+
30+
if (!idParam) return of(null);
31+
32+
const id = (Base64.isBase64(idParam)) ? Base64.fromBase64(idParam) : idParam;
33+
const id64 = Base64.toBase64(id);
34+
35+
return (this.imgchest.getComposition(id)).pipe(this.catchError(), this.tapSetMetaTags(),
36+
this.tapSaveToHistory(IMGCHEST_PATH, id64),
37+
this.tapSaveToCurrentPlaylistItem(IMGCHEST_PATH, id),
38+
39+
40+
this.finalizeLoading());
41+
})
42+
);
43+
44+
constructor(public imgchest: ImgchestService) { super() }
45+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import { HttpClient, HttpHeaders } from '@angular/common/http';
2+
import { inject, Injectable, PLATFORM_ID } from '@angular/core';
3+
import { environment } from '../../../environments/environment';
4+
import { Observable, map } from 'rxjs';
5+
import { CompositionEpisode, CompositionImage } from '../@common-read';
6+
import { ProxyService } from '../../shared/data-access/proxy.service';
7+
import { isPlatformServer } from '@angular/common';
8+
interface ImgchestRespCompImage {
9+
id: string;
10+
description: string;
11+
link: string;
12+
position: number
13+
created: string;
14+
}
15+
interface ImgchestRespComp {
16+
id: string;
17+
title: string;
18+
username: string;
19+
privacy: string;
20+
report_status: number;
21+
views: number;
22+
nsfw: number;
23+
image_count: number;
24+
created: string;
25+
images: Array<ImgchestRespCompImage>;
26+
}
27+
interface ImgchestResp {
28+
data: any | ImgchestRespComp
29+
}
30+
31+
@Injectable({
32+
providedIn: 'root'
33+
})
34+
export class ImgchestService {
35+
private readonly clientId: string = 'T0eSFX9IOg0Okcg7g3UN7jp8MDreLglRyYKYkw2Gd74de321';
36+
platformId = inject(PLATFORM_ID)
37+
38+
proxy: ProxyService = inject(ProxyService)
39+
http: HttpClient = inject(HttpClient)
40+
41+
constructor() { }
42+
43+
getComposition(id: string): Observable<CompositionEpisode> {
44+
const headers = new HttpHeaders({
45+
'Authorization': `Bearer ${this.clientId}`
46+
});
47+
48+
const url = isPlatformServer(this.platformId)
49+
? environment.imgchestHost + id
50+
: this.proxy.proxyUrl(environment.imgchestHost + id);
51+
52+
return this.http.get<ImgchestResp>(url, { headers })
53+
.pipe(map((data: ImgchestResp) => { return this.map(data.data) }))
54+
}
55+
56+
57+
map(data: ImgchestRespComp): CompositionEpisode {
58+
const res: CompositionEpisode = {
59+
title: data.title,
60+
episode: 0,
61+
nsfw: (data.nsfw) as unknown as boolean,
62+
images: data.images.map((i): CompositionImage => {
63+
return {
64+
src: this.proxy.proxyUrl(i.link),
65+
alt: i.description,
66+
}
67+
})
68+
69+
}
70+
return res;
71+
}
72+
73+
}
74+
75+
/**
76+
{
77+
"data": {
78+
"id": "wl7l2rvgo4x",
79+
"title": null,
80+
"username": "Anonymous",
81+
"privacy": "hidden",
82+
"report_status": 1,
83+
"views": 1,
84+
"nsfw": 0,
85+
"image_count": 3,
86+
"created": "2025-06-13T13:37:01.000000Z",
87+
"images": [
88+
{
89+
"id": "46acqe3zkk7",
90+
"description": null,
91+
"link": "https:\/\/cdn.imgchest.com\/files\/46acqe3zkk7.jpg",
92+
"position": 1,
93+
"created": "2025-06-13T13:37:01.000000Z"
94+
},
95+
{
96+
"id": "yvdcwog6vpy",
97+
"description": null,
98+
"link": "https:\/\/cdn.imgchest.com\/files\/yvdcwog6vpy.jpg",
99+
"position": 2,
100+
"created": "2025-06-13T13:37:02.000000Z"
101+
},
102+
{
103+
"id": "yxkczok2ro7",
104+
"description": null,
105+
"link": "https:\/\/cdn.imgchest.com\/files\/yxkczok2ro7.jpg",
106+
"position": 3,
107+
"created": "2025-06-13T13:37:03.000000Z"
108+
}
109+
]
110+
}
111+
}
112+
113+
*/

src/app/@site-modules/mangadex/mangadex.service.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { HttpClient } from '@angular/common/http';
2-
import { inject, Injectable } from '@angular/core';
2+
import { inject, Injectable, PLATFORM_ID } from '@angular/core';
33
import { environment } from '../../../environments/environment';
44
import { Observable, catchError, map, throwError } from 'rxjs';
55
import { CompositionEpisode, CompositionImage } from '../@common-read';
66
import { ProxyService } from '../../shared/data-access/proxy.service';
7+
import { isPlatformServer } from '@angular/common';
78

89
interface MdChapterImages {
910
hash: string;
@@ -63,11 +64,16 @@ interface MdMangaResp {
6364
providedIn: 'root'
6465
})
6566
export class MangadexService {
67+
platformId = inject(PLATFORM_ID)
6668
http: HttpClient = inject(HttpClient)
6769
proxy: ProxyService = inject(ProxyService)
6870

6971
getChapterImages(id: string): Observable<CompositionImage[]> {
70-
return this.http.get<MdChapterImagesResp>(this.proxy.proxyUrl(environment.mangadexHost + id))
72+
const url = isPlatformServer(this.platformId)
73+
? environment.mangadexHost + id
74+
: this.proxy.proxyUrl(environment.mangadexHost + id);
75+
76+
return this.http.get<MdChapterImagesResp>(url)
7177
.pipe(
7278
map((data: MdChapterImagesResp) => data.chapter.dataSaver.map((item: string) => {
7379
return {
@@ -81,7 +87,11 @@ export class MangadexService {
8187
}
8288

8389
getChapter(id: string): Observable<CompositionEpisode> {
84-
return this.http.get<MdChapterResp>(this.proxy.proxyUrl(environment.mangadexChapter + id))
90+
const url = isPlatformServer(this.platformId)
91+
? environment.mangadexChapter + id
92+
: this.proxy.proxyUrl(environment.mangadexChapter + id);
93+
94+
return this.http.get<MdChapterResp>(url)
8595
.pipe(
8696
map((data: MdChapterResp) => {
8797
return {
@@ -99,7 +109,11 @@ export class MangadexService {
99109

100110

101111
getManga(id: string): Observable<{ nsfw: boolean }> {
102-
return this.http.get<MdMangaResp>(this.proxy.proxyUrl(environment.mangadexManga + id)).pipe(this.nsfwMap())
112+
const url = isPlatformServer(this.platformId)
113+
? environment.mangadexManga + id
114+
: this.proxy.proxyUrl(environment.mangadexManga + id);
115+
116+
return this.http.get<MdMangaResp>(url).pipe(this.nsfwMap())
103117
}
104118

105119
nsfwMap() {

src/app/@site-modules/nhentai/nhentai.service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
import { HttpClient } from '@angular/common/http';
2-
import { inject, Injectable } from '@angular/core';
2+
import { inject, Injectable, PLATFORM_ID } from '@angular/core';
33
import { Observable, map } from 'rxjs';
44
import { environment } from '../../../environments/environment';
55
import { CompositionEpisode } from '../@common-read';
66
import { ProxyService } from '../../shared/data-access/proxy.service';
7+
import { isPlatformServer } from '@angular/common';
78

89
@Injectable({
910
providedIn: 'root'
1011
})
1112
export class NhentaiService {
13+
platformId = inject(PLATFORM_ID)
1214
http: HttpClient = inject(HttpClient)
1315
proxy: ProxyService = inject(ProxyService)
1416

1517
getComposition(id: string): Observable<CompositionEpisode> {
16-
return this.http.get<any>(this.proxy.proxyUrl(environment.nhentaiHost + id))
18+
const url = isPlatformServer(this.platformId)
19+
? environment.nhentaiHost + id
20+
: this.proxy.proxyUrl(environment.nhentaiHost + id);
21+
22+
return this.http.get<any>(url)
1723
.pipe(map((data) => { return this.map(data) }))
1824
}
1925

src/app/@site-modules/pixiv/pixiv.service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
import { HttpClient } from '@angular/common/http';
2-
import { inject, Injectable } from '@angular/core';
2+
import { inject, Injectable, PLATFORM_ID } from '@angular/core';
33
import { Observable, map } from 'rxjs';
44
import { environment } from '../../../environments/environment';
55
import { CompositionEpisode, CompositionPublisher } from '../@common-read';
66
import { ProxyService } from '../../shared/data-access/proxy.service';
7+
import { isPlatformServer } from '@angular/common';
78

89
@Injectable({
910
providedIn: 'root'
1011
})
1112
export class PixivService {
13+
platformId = inject(PLATFORM_ID)
1214
http: HttpClient = inject(HttpClient)
1315
proxy: ProxyService = inject(ProxyService)
1416

1517
getComposition(id: string): Observable<CompositionEpisode> {
16-
return this.http.get<any>(this.proxy.proxyUrl(environment.pixivHost + id))
18+
const url = isPlatformServer(this.platformId)
19+
? environment.pixivHost + id
20+
: this.proxy.proxyUrl(environment.pixivHost + id);
21+
22+
return this.http.get<any>(url)
1723
.pipe(map((data) => { return this.map(data.body) }))
1824
}
1925

0 commit comments

Comments
 (0)