cblgh / cerca

lean forum software
Other
127 stars 18 forks source link

feat: edit thread title #91

Closed decentral1se closed 8 hours ago

decentral1se commented 1 day ago

Closes https://github.com/cblgh/cerca/issues/81. Related: https://github.com/cblgh/cerca/pull/89.

I've tried to keep this changeset small. I've tested that other users can't edit threads of other users, the existing 403 handling works.

Open to suggestions on naming and potentially how to bundle the post update into a single statement? Doesn't seem like a biggie but I'm curios if anyone knows how.

image

image

cblgh commented 1 day ago

nice! can you apply these tweaks and lmk if you agree?

edit: golfed it and added a little more

git apply <input or file with patch>

From 05d9765a684c59d4db9e5d152072f9d6301be188 Mon Sep 17 00:00:00 2001
From: cblgh <cblgh@cblgh.org>
Date: Thu, 21 Nov 2024 15:53:56 +0100
Subject: [PATCH] tweaks

---
 html/edit-post.html | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/html/edit-post.html b/html/edit-post.html
index 3cd2cf1..559f24a 100644
--- a/html/edit-post.html
+++ b/html/edit-post.html
@@ -1,15 +1,15 @@
 {{ template "head" . }}
 <main>
-    <h1>{{ "PostEdit" | translate }}</h1>
-       <article>
-    {{ if eq .IsOP true }}
-        {{.Data.ThreadTitle | markup }}
+    <h1> {{ if .IsOP }} Thread preview {{ else }} {{ "PostEdit" | translate }} {{ end }}</h1>
+       <article style="margin: 0;">
+    {{ if .IsOP }}
+        <h2> {{.Data.ThreadTitle }} </h2>
     {{ end }}
     {{.Data.Content | markup }}
        </article>
     <form method="POST">
         <div class="post-container" >
-            {{ if eq .IsOP true }}
+            {{ if .IsOP }}
                 <label for="title">{{ "Title" | translate }}:</label>
                 <input required name="title" type="text" id="title" value="{{ .Data.ThreadTitle }}">
             <label for="content">{{ "Content" | translate }}:</label>
-- 
2.46.0
cblgh commented 1 day ago

also lmk if the above way of iterating is way too cumbersome :) just wanted to try something out that is more collaborative than "can you do xx yy zz pls ok thx"

decentral1se commented 1 day ago

seems legit!

I had to use git apply --ignore-space-change --ignore-whitespace ... to apply it due to their being a mix of space/tabs in the file 😅 I like this approach tho, happy to experiment!

also caught a potential hack scenario where you can edit the title on non-op posts in https://github.com/cblgh/cerca/pull/91/commits/53125af4cf5afd8676d8b3ee4a50b87247d367a6 (does involve a "all posts" query but this can be optimised later with a LIMIT at some point with some sort of "GetFirstPost" API?)

decentral1se commented 1 day ago

happy to experiment!

As a demonstration of my chaotic zeal, I'd even be up for moving the entire development of this forum on to a cerca instance itself to dogfood and doing some sort of devilish send-patch machinery for development 😂

cblgh commented 9 hours ago

happy to experiment!

As a demonstration of my chaotic zeal, I'd even be up for moving the entire development of this forum on to a cerca instance itself to dogfood and doing some sort of devilish send-patch machinery for development 😂

ahah yees! :star_struck: i'll see about setting this up next week!!

cblgh commented 8 hours ago

btw, i'm ready to merge this! wdyt?

decentral1se commented 8 hours ago

@cblgh yesssssssssss

cblgh commented 8 hours ago

:tada: :tada: :tada: nicely done!