Skip to content

Commit

Permalink
Merge pull request #5 from chytanka/develop
Browse files Browse the repository at this point in the history
Reddit
  • Loading branch information
rodzyk authored Feb 12, 2024
2 parents ae45c80 + 22424da commit 593ad44
Show file tree
Hide file tree
Showing 51 changed files with 575 additions and 302 deletions.
4 changes: 4 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const routes: Routes = [
path: 'telegr',
loadChildren: () => import('./telegraph/telegraph.module').then(m => m.TelegraphModule)
},
{
path: 'reddit',
loadChildren: () => import('./reddit/reddit.module').then(m => m.RedditModule)
},
{
path: '**',
component: PageNotFoundComponent
Expand Down
22 changes: 22 additions & 0 deletions src/app/common/common-read/common-read.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CommonReadComponent } from './ui/common-read/common-read.component';
import { SharedModule } from '../../shared/shared.module';
import { RouterModule } from '@angular/router';



@NgModule({
declarations: [
CommonReadComponent
],
imports: [
CommonModule,
RouterModule,
SharedModule
],
exports: [
CommonReadComponent
]
})
export class CommonReadModule { }
3 changes: 3 additions & 0 deletions src/app/common/common-read/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './common-read.module'
export * from './utils'
export * from './ui'
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@if(episode$ | async; as episode){
<app-viewer [episode]="episode"><ng-content/></app-viewer>
}

@if(error$ | async; as error){
<div style="padding: 1rem; margin: auto;">
<div class="error-message">
<h1>🤨</h1>
<p>{{ error }}</p>
<footer>
<a class="button mediun" [routerLink]="'/'">🏠</a>
<button autofocus class="button large primary" (click)="onRefreshData()">{{lang.phrases.tryAgain}}</button>
</footer>
</div>
</div>
}

@if(loading$ | async; as loading){
<div style="display: grid; place-items: center; width: min(50vw, 50vh); margin: auto; aspect-ratio: 1;">⏳ loading...
</div>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
:host {
display: grid;
min-height: 100dvh;
}

:host:has(.error-message) {
background-image: radial-gradient(circle, rgba(0, 0, 0, 0) 40%, rgba(207, 19, 82, .1) 100%);
}

.error-message {
display: grid;
place-items: center;
gap: 2ch;
min-width: min(50vw, 50vh);
margin: auto;
// aspect-ratio: 3/4;
border-radius: 1ch;
margin-inline: auto;
padding: 2rem;
text-wrap: balance;
text-align: center;
border: 1px solid;
border-color: rgba(207, 19, 82, .4);
background-color: rgba(207, 19, 82, .05);

p {
margin: 0;
font-size: clamp(1rem, 1.5vw, 2rem);
}

footer {
display: flex;
place-items: center;
gap: 1.5ch;
}
}

.button {
--q: 1;

user-select: none;
border: 0;
font: inherit;
color: inherit;
padding-inline: calc(var(--q) * 1ch);
padding-block: calc(var(--q) * 1ch);
border-radius: .5ch;
cursor: pointer;
background: hsl(203.44 8% 16%);
transition: all .25s ;
text-wrap: balance;
-webkit-tap-highlight-color: transparent;
box-shadow: 0 .1ch .2ch #0004;

&.mediun {
--q: 1.5
}

&.large {
--q: 2
}

&.primary {
background: #166496;
}

&:hover {
background-color: #166496;
color: #ffd60a;
}

&:active {
background-color: rgba(0, 15, 30, 1);
}
}
23 changes: 23 additions & 0 deletions src/app/common/common-read/ui/common-read/common-read.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Component, EventEmitter, Input, Output, inject, input } from '@angular/core';
import { LangService } from '../../../../shared/data-access/lang.service';
import { BehaviorSubject, Observable, of } from 'rxjs';
import { CompositionEpisode } from '../../utils';

@Component({
selector: 'app-common-read',
templateUrl: './common-read.component.html',
styleUrl: './common-read.component.scss'
})
export class CommonReadComponent {
public lang: LangService = inject(LangService);

@Input({ required: true }) error$!: BehaviorSubject<string | null>;
@Input({ required: true }) loading$!: BehaviorSubject<boolean>;
@Input({ required: true }) episode$!: Observable<CompositionEpisode | null>;

@Output() refreshData: EventEmitter<any> = new EventEmitter<any>();

onRefreshData() {
this.refreshData.emit();
}
}
1 change: 1 addition & 0 deletions src/app/common/common-read/ui/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './common-read/common-read.component'
File renamed without changes.
2 changes: 2 additions & 0 deletions src/app/common/common-read/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './composition';
export * from './read-base-component'
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { BehaviorSubject, MonoTypeOperatorFunction, Observable, OperatorFunction, catchError, combineLatest, finalize, of, tap } from "rxjs";
import { CompositionEpisode } from "./composition";
import { LangService } from "../data-access/lang.service";
import { ActivatedRoute, ParamMap } from "@angular/router";
import { Title } from "@angular/platform-browser";
import { inject } from "@angular/core";
import { LangService } from "../../../shared/data-access/lang.service";

export abstract class ReadBaseComponent {
protected refresh$: BehaviorSubject<null> = new BehaviorSubject<null>(null);
Expand Down
2 changes: 1 addition & 1 deletion src/app/imgur/data-access/imgur.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from '../../../environments/environment';
import { CompositionEpisode, CompositionImage } from '../../shared/utils';
import { Observable, map } from 'rxjs';
import { CompositionEpisode, CompositionImage } from '../../common/common-read';
interface ImgurRespCompImage {
link: string;
width: number;
Expand Down
24 changes: 0 additions & 24 deletions src/app/imgur/imgur-shell/imgur-shell.component.html

This file was deleted.

Empty file.
15 changes: 12 additions & 3 deletions src/app/imgur/imgur-shell/imgur-shell.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import { Component } from '@angular/core';
import { ImgurService } from '../data-access/imgur.service';
import { Base64, ReadBaseComponent } from '../../shared/utils';
import { Base64 } from '../../shared/utils';
import { of, switchMap } from 'rxjs';
import { ReadBaseComponent } from '../../common/common-read';

@Component({
selector: 'app-imgur-shell',
templateUrl: './imgur-shell.component.html',
styleUrl: './imgur-shell.component.scss'
template: `<app-common-read [episode$]="episode$" [error$]="error$" [loading$]="loading$" (refreshData)="refreshData()"><div style="direction: ltr; user-select: text !important; text-wrap: balance; padding: 1rem; text-align: center; display: grid;
place-content: center;
justify-items: center; min-height: 50vh;">
<a href="https://imgur.com" target="_blank" rel="noopener noreferrer" style="display: flex; gap: 1ch; ">
<img src="/assets/logos/imgur-logo.svg" alt="Imgur logo">
</a>
<p>{{lang.phrases.imagesVia}}<a href="https://imgur.com" target="_blank" rel="noopener noreferrer">Imgur</a>
API.
{{lang.phrases.thanks}}<br>{{lang.phrases.detalisCopy}}</p>
</div></app-common-read>`
})
export class ImgurShellComponent extends ReadBaseComponent {

Expand Down
4 changes: 2 additions & 2 deletions src/app/imgur/imgur.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common';

import { ImgurRoutingModule } from './imgur-routing.module';
import { ImgurShellComponent } from './imgur-shell/imgur-shell.component';
import { SharedModule } from '../shared/shared.module';
import { CommonReadModule } from '../common/common-read';


@NgModule({
Expand All @@ -13,7 +13,7 @@ import { SharedModule } from '../shared/shared.module';
imports: [
CommonModule,
ImgurRoutingModule,
SharedModule
CommonReadModule
]
})
export class ImgurModule { }
191 changes: 16 additions & 175 deletions src/app/link-parser/link-parser/link-parser.component.html

Large diffs are not rendered by default.

37 changes: 21 additions & 16 deletions src/app/link-parser/link-parser/link-parser.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
align-items: center;
// min-height: 100dvh;
height: 100dvh;
background: rgb(0,39,65);
background: radial-gradient(circle, rgba(0,39,65,1) 0%, rgba(0,15,30,1) 100%);
background: rgb(0, 39, 65);
background: radial-gradient(circle, rgba(0, 39, 65, 1) 0%, rgba(0, 15, 30, 1) 100%);

@media (max-aspect-ratio: 1) or (max-width: 640px) {
grid-template-columns: auto;
Expand All @@ -15,7 +15,6 @@ background: radial-gradient(circle, rgba(0,39,65,1) 0%, rgba(0,15,30,1) 100%);

&>div {
display: grid;
// align-content: center;
place-content: center;
gap: 2ch;
}
Expand All @@ -28,7 +27,8 @@ app-text-embracer {
margin: auto;
font-family: 'Rampart One', sans-serif;
font-size: clamp(1rem, 8vw, 5rem);
@media (max-aspect-ratio: 1) or (max-width: 640px) {

@media (max-aspect-ratio: 1) or (max-width: 640px) {
font-size: clamp(1rem, 10vw, 8rem);
}
}
Expand All @@ -37,7 +37,6 @@ input[type=url] {
font: inherit;
padding: 1ch;
background: transparent;
/* backdrop-filter: blur(1rem); */
font-family: 'Courier New', Courier, monospace;
border: 0;
outline: 1px solid;
Expand Down Expand Up @@ -81,27 +80,33 @@ a {
outline: 1px solid;
border-radius: .5ch;
transition: all cubic-bezier(0.075, 0.82, 0.165, 1) .25s;

&:hover {
outline-offset: .5ch;
}

&:active {
outline-offset: -.5ch;
}
}


#Path_602 {
transform-origin: 50% 50%;
transition: all .25s ease-in-out;
app-overlay {
position: absolute;
}

svg:hover {
#Path_602 {

scale: 1.16;
}
.logo {
display: block;
max-width: 100%;
max-height: 100%;
min-height: 0;
height: auto;
margin: auto;
}

app-overlay {
position: absolute;
:host ::ng-deep app-overlay {

&::after,
&::before {
content: unset;
}
}
11 changes: 8 additions & 3 deletions 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, WritableSignal, computed, signal } from '@angular/core';
import { LinkParserService } from '../data-access/link-parser.service';
import { ImgurLinkParser, JsonLinkParser, MangadexLinkParser, TelegraphLinkParser } from '../utils';
import { ImgurLinkParser, JsonLinkParser, MangadexLinkParser, RedditLinkParser, TelegraphLinkParser } from '../utils';
import { ActivatedRoute , Router} from '@angular/router';
import { LangService } from '../../shared/data-access/lang.service';
import { ViewModeOption } from '../../shared/data-access';
Expand Down Expand Up @@ -44,6 +44,7 @@ export class LinkParserComponent {
this.parser.parsers.push(new ImgurLinkParser)
this.parser.parsers.push(new MangadexLinkParser)
this.parser.parsers.push(new TelegraphLinkParser)
this.parser.parsers.push(new RedditLinkParser)
this.parser.parsers.push(new JsonLinkParser)
}

Expand All @@ -64,8 +65,12 @@ export class LinkParserComponent {
}

async initFromclipboard() {
const text = await navigator.clipboard?.readText()
this.link.set(text ?? '')
try {
const text = await navigator.clipboard?.readText()
this.link.set(text ?? '')
} catch (error) {

}

if (!this.linkParams()) { this.link.set('') }
}
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 @@ -2,4 +2,5 @@ export * from './link-parser';
export * from './imgur-link-parser';
export * from './mangadex-link-parser';
export * from './json-link-parser';
export * from './telegraph-link-parser';
export * from './telegraph-link-parser';
export * from './reddit-link-parser';
6 changes: 6 additions & 0 deletions src/app/link-parser/utils/reddit-link-parser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { LinkParser } from "./link-parser";

export class RedditLinkParser extends LinkParser {
override regex = /reddit\.com\/[ur]\/\w+(?:\/comments\/)([a-zA-Z0-9]+)(?=[\/?]|$)/;
override site = 'reddit';
};
2 changes: 1 addition & 1 deletion src/app/mangadex/data-access/mangadex.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from '../../../environments/environment';
import { Observable, catchError, map, throwError } from 'rxjs';
import { CompositionEpisode, CompositionImage } from '../../shared/utils';
import { CompositionEpisode, CompositionImage } from '../../common/common-read';

interface MdChapterImages {
hash: string;
Expand Down
Loading

0 comments on commit 593ad44

Please sign in to comment.