From 192d95b1bf44eed1406ffd9d29e845facda64b65 Mon Sep 17 00:00:00 2001 From: schreifuchs Date: Fri, 17 Oct 2025 23:51:19 +0200 Subject: [PATCH] feat: private posts --- .../routes/dashboard/dashboard.component.html | 11 +++++++- .../routes/dashboard/dashboard.component.ts | 4 +++ web/src/app/routes/post/post.component.ts | 1 - .../secret-post/secret-post.component.html | 7 +++++ .../post/secret-post/secret-post.component.ts | 28 +++++++++++++++++++ 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 web/src/app/routes/post/secret-post/secret-post.component.html create mode 100644 web/src/app/routes/post/secret-post/secret-post.component.ts diff --git a/web/src/app/routes/dashboard/dashboard.component.html b/web/src/app/routes/dashboard/dashboard.component.html index 30dcd41..92f4ec3 100644 --- a/web/src/app/routes/dashboard/dashboard.component.html +++ b/web/src/app/routes/dashboard/dashboard.component.html @@ -12,7 +12,7 @@

{{ post.title }}

@@ -31,5 +31,14 @@ > Delete + @if (post.secret !== undefined) { + + Copy Link + + }

diff --git a/web/src/app/routes/dashboard/dashboard.component.ts b/web/src/app/routes/dashboard/dashboard.component.ts index 3368765..857fa61 100644 --- a/web/src/app/routes/dashboard/dashboard.component.ts +++ b/web/src/app/routes/dashboard/dashboard.component.ts @@ -17,4 +17,8 @@ export class DashboardComponent { delete(id: number) { this.postsService.deletePost(id); } + getPath(secret: string) { + const url = document.URL.replaceAll('/dashboard', ''); + navigator.clipboard.writeText(`${url}/post/secret/${secret}`); + } } diff --git a/web/src/app/routes/post/post.component.ts b/web/src/app/routes/post/post.component.ts index 7a54e8c..575cbe5 100644 --- a/web/src/app/routes/post/post.component.ts +++ b/web/src/app/routes/post/post.component.ts @@ -1,6 +1,5 @@ import { Component, inject, Input } from '@angular/core'; import { PostsService } from '../../shared/services/posts.service'; -import { JsonPipe, NgIf } from '@angular/common'; import { MarkdownComponent } from '../../components/markdown/markdown.component'; @Component({ diff --git a/web/src/app/routes/post/secret-post/secret-post.component.html b/web/src/app/routes/post/secret-post/secret-post.component.html new file mode 100644 index 0000000..5193ad4 --- /dev/null +++ b/web/src/app/routes/post/secret-post/secret-post.component.html @@ -0,0 +1,7 @@ +

{{ post()?.title }}

+

TL;DR; {{ post()?.tldr }}

+ + diff --git a/web/src/app/routes/post/secret-post/secret-post.component.ts b/web/src/app/routes/post/secret-post/secret-post.component.ts new file mode 100644 index 0000000..3c67b8d --- /dev/null +++ b/web/src/app/routes/post/secret-post/secret-post.component.ts @@ -0,0 +1,28 @@ +import { + Component, + inject, + Input, + OnInit, + signal, + WritableSignal, +} from '@angular/core'; +import { PostsService } from '../../../shared/services/posts.service'; +import { Post } from '../../../shared/interfaces/post'; +import { MarkdownComponent } from '../../../components/markdown/markdown.component'; + +@Component({ + selector: 'app-secret-post', + imports: [MarkdownComponent], + templateUrl: './secret-post.component.html', +}) +export class SecretPostComponent implements OnInit { + @Input() secret!: string; + private postsService = inject(PostsService); + post: WritableSignal = signal(undefined); + + ngOnInit(): void { + this.postsService.getPostBySecret(this.secret).subscribe((post) => { + this.post.set(post); + }); + } +}