try page embed
This commit is contained in:
parent
be89141c06
commit
513d0e57ce
10 changed files with 29 additions and 26 deletions
9
internal/gemlog/gemlog.gmi
Normal file
9
internal/gemlog/gemlog.gmi
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Gemlog
|
||||
|
||||
Welcome to my gemlog!
|
||||
|
||||
I'm still figureing out exactly what I'll be posting here as I already maintain a tech blog on my personal site. For now it will mostly be about my experience with the gemini protocal. Maybe some tutorials on how to self-host a capsule.
|
||||
|
||||
Abandoned capsules are a commmon sight here in gemspace. While this gemlog might go stale, the content on the micro-blog page is dynamic and as long as I'm posting to social media will have fresh content. Remember to check that page out as well.
|
||||
|
||||
=> /microblog Microblog
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package gemlog
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
|
|
@ -51,16 +52,14 @@ func (g *Gemlog) HandleRequest(w gemini.ResponseWriter, req *gemini.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
//go:embed gemlog.gmi
|
||||
var pageContnet string
|
||||
|
||||
func (g *Gemlog) serveIndex(w gemini.ResponseWriter, req *gemini.Request) {
|
||||
w.WriteStatusMsg(gemini.StatusSuccess, "text/gemini")
|
||||
|
||||
var content strings.Builder
|
||||
page, err := os.ReadFile("./pages/gemlog.gmi")
|
||||
if err != nil {
|
||||
slog.Error("Problem reading gemlog page", "error", err)
|
||||
return
|
||||
}
|
||||
content.Write(page)
|
||||
content.Write([]byte(pageContnet))
|
||||
content.WriteString("\n")
|
||||
|
||||
posts, err := gemlog.ListGemLogs(g.config)
|
||||
|
|
|
|||
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")
|
||||
|
|
|
|||
14
internal/microblog/microblog.gmi
Normal file
14
internal/microblog/microblog.gmi
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Microblog
|
||||
|
||||
An aggregation of tweet like posts from my various social media platforms.
|
||||
|
||||
clearnet version:
|
||||
|
||||
=> https://travisshears.com/micro-blog
|
||||
|
||||
So for it renders posts from:
|
||||
* nostr, id: nprofile1qyxhwumn8ghj7mn0wvhxcmmvqqs9udcv9uhqggjz87js9rtaph4lajlxnxsvwvm7zwdjt6etzyk52rgeg4wrz
|
||||
|
||||
I plan to add more platforms in the future:
|
||||
* mastodon, id: dice.camp/@travisshears
|
||||
* bluesky, id: @travisshears.bsky.social
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package microblog
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"gemini_site/internal/pocketbase"
|
||||
"log/slog"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -216,6 +216,9 @@ func drawPost(builder *strings.Builder, p post) {
|
|||
// p.Timestamp.Format("2006-01-02 15:04")))
|
||||
}
|
||||
|
||||
//go:embed microblog.gmi
|
||||
var pageContnet string
|
||||
|
||||
// serveBlogIndex serves the main blog page with recent posts
|
||||
func (mb *MicroBlog) serveIndex(w gemini.ResponseWriter, req *gemini.Request, pageNum int) {
|
||||
w.WriteStatusMsg(gemini.StatusSuccess, "text/gemini")
|
||||
|
|
@ -225,12 +228,7 @@ func (mb *MicroBlog) serveIndex(w gemini.ResponseWriter, req *gemini.Request, pa
|
|||
// content.WriteString("Here are my microblog posts from various plantforms\n")
|
||||
// Read and include the contents of ../../pages/microblog.gmi
|
||||
if pageNum == 1 {
|
||||
page, err := os.ReadFile("./pages/microblog.gmi")
|
||||
if err != nil {
|
||||
slog.Error("Problem reading microblog page", "error", err)
|
||||
return
|
||||
}
|
||||
content.Write(page)
|
||||
content.Write([]byte(pageContnet))
|
||||
content.WriteString("\n")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue