try page embed
This commit is contained in:
parent
be89141c06
commit
513d0e57ce
10 changed files with 29 additions and 26 deletions
17
internal/guestbook/guestbook.gmi
Normal file
17
internal/guestbook/guestbook.gmi
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Guestbook
|
||||
|
||||
A place to leave messages.
|
||||
|
||||
Hey gemspace! Thanks for visiting my capsule. Why not leave a message?
|
||||
|
||||
=> /guestbook/new Sign the guestbook
|
||||
=> /guestbook/admin Admin
|
||||
=> /codeview/raw/personal-gemini-capsule/src/branch/main/internal/guestbook/guestbook.go View code for this page
|
||||
|
||||
Messages like "xxxxx xxxx" mean they are awaiting my approval. Once approved, the actual text will be rendered.
|
||||
|
||||
== 2025.10.09 ==
|
||||
|
||||
Addressing the issue gdorn raised I've added the option to set a username.
|
||||
|
||||
------------------------
|
||||
|
|
@ -4,10 +4,10 @@ import (
|
|||
"crypto/sha256"
|
||||
"crypto/x509"
|
||||
"database/sql"
|
||||
_ "embed"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -215,15 +215,13 @@ func censorString(s string) string {
|
|||
return string(masked)
|
||||
}
|
||||
|
||||
//go:embed guestbook.gmi
|
||||
var pageContnet string
|
||||
|
||||
func (book *GuestBook) serveIndex(w gemini.ResponseWriter, req *gemini.Request) {
|
||||
w.WriteStatusMsg(gemini.StatusSuccess, "text/gemini")
|
||||
var content strings.Builder
|
||||
page, err := os.ReadFile("./pages/guestbook.gmi")
|
||||
if err != nil {
|
||||
slog.Error("Problem reading guestbook.gmi", "error", err)
|
||||
return
|
||||
}
|
||||
content.Write(page)
|
||||
content.Write([]byte(pageContnet))
|
||||
content.WriteString("\n")
|
||||
|
||||
rows, err := book.db.Query("SELECT id, name, approved, created_at, message FROM guestbook ORDER BY created_at DESC")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue