imporve microblog text layout
")
")
", p.Source, p.RemoteID[:10]))
")
", p.ID))
posted: %s
", p.Timestamp.Format("2006-01-02 15:04")))
")
", p.ID, p.Title))
",
")
")
")
This commit is contained in:
parent
8c28d2ee0c
commit
86f3ea76b3
2 changed files with 11 additions and 12 deletions
|
|
@ -167,6 +167,10 @@ func (mb *MicroBlog) GetRecentPosts(limit int, page int) ([]post, error) {
|
|||
return filteredPosts, nil
|
||||
}
|
||||
|
||||
func formatContent(content string) string {
|
||||
return replaceLinks(content)
|
||||
}
|
||||
|
||||
func replaceLinks(content string) string {
|
||||
// Regex: ^(https?://\S+)
|
||||
// ^ : start of line
|
||||
|
|
@ -204,16 +208,11 @@ func (mb *MicroBlog) HandleBlogRequest(w gemini.ResponseWriter, req *gemini.Requ
|
|||
}
|
||||
|
||||
func drawPost(builder *strings.Builder, p post) {
|
||||
builder.WriteString("+------------------------------------------+\n")
|
||||
content := replaceLinks(p.Content)
|
||||
builder.WriteString(content)
|
||||
builder.WriteString("\n")
|
||||
builder.WriteString(fmt.Sprintf("source: %s, id: %s...\n", p.Source, p.RemoteID[:10]))
|
||||
builder.WriteString("+------------------------------------------+\n\n\n")
|
||||
builder.WriteString(fmt.Sprintf("=> / 🖋️ nostr post: %s \n", p.ID))
|
||||
builder.WriteString(formatContent(p.Content))
|
||||
builder.WriteString(fmt.Sprintf("\nposted: %s\n", p.Timestamp.Format("2006-01-02 15:04")))
|
||||
builder.WriteString("\n\n")
|
||||
|
||||
// builder.WriteString(fmt.Sprintf("=> /blog/post/%s %s\n", p.ID, p.Title))
|
||||
// builder.WriteString(fmt.Sprintf(" By %s on %s\n\n",
|
||||
// p.Timestamp.Format("2006-01-02 15:04")))
|
||||
}
|
||||
|
||||
//go:embed microblog.gmi
|
||||
|
|
@ -224,9 +223,6 @@ func (mb *MicroBlog) serveIndex(w gemini.ResponseWriter, req *gemini.Request, pa
|
|||
w.WriteStatusMsg(gemini.StatusSuccess, "text/gemini")
|
||||
|
||||
var content strings.Builder
|
||||
// content.WriteString("# Gemini Microblog\n\n")
|
||||
// content.WriteString("Here are my microblog posts from various plantforms\n")
|
||||
// Read and include the contents of ../../pages/microblog.gmi
|
||||
if pageNum == 1 {
|
||||
content.Write([]byte(pageContnet))
|
||||
content.WriteString("\n")
|
||||
|
|
|
|||
|
|
@ -6,3 +6,6 @@ DONE task: implement codbase root codeview pages
|
|||
DONE task: add hexidecimal numbering to gemlog
|
||||
DONE task: add request counter
|
||||
DONE task: embed static pages
|
||||
|
||||
|
||||
project tracking method inspired by: https://cblgh.org/posts/2025-10-10-the-done-line/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue