style improvements and bluesky comments!

This commit is contained in:
ari melody 2025-04-02 23:49:20 +01:00
parent 1a8dc4d9ce
commit 835dd344ca
Signed by: ari
GPG key ID: 60B5F0386E3DDB7E
7 changed files with 393 additions and 13 deletions

View file

@ -1,10 +1,13 @@
package view
import (
"fmt"
"html/template"
"net/http"
"os"
"time"
"arimelody-web/controller"
"arimelody-web/model"
"arimelody-web/templates"
@ -20,16 +23,14 @@ var mdRenderer = html.NewRenderer(html.RendererOptions{
func BlogHandler(app *model.AppState) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
blog := model.Blog{
Title: "hello world!~",
Title: "hello world!",
Description: "lorem ipsum yadda yadda something boobies babababababababa",
Visible: true,
Date: time.Now(),
AuthorID: "ari",
Markdown:
`
# hello, world!
i'm ari!
**i'm ari!**
she/her 🏳🏳🌈💫🦆🇮🇪
@ -72,7 +73,26 @@ thank you for stopping by- i hope you have a lovely rest of your day! 💫
- impact meme
- OpenTerminal
- Silver.js
### code block test
~~~ c
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("hello world!~\n");
return 0;
}
~~~
### aridoodle
this is `+"`"+`aridoodle`+"`"+`. please take care of her.
![aridoodle](/img/aridoodle.png)
`,
BlueskyActorID: "did:plc:yct6cvgfipngizry5umzkxr3",
BlueskyPostID: "3llsudsx7pc2u",
}
// blog.Markdown += " <i class=\"end-mark\"></i>"
@ -81,6 +101,35 @@ thank you for stopping by- i hope you have a lovely rest of your day! 💫
md := mdParser.Parse([]byte(blog.Markdown))
blog.HTML = template.HTML(markdown.Render(md, mdRenderer))
templates.BlogTemplate.Execute(w, &blog)
comments := []*model.ThreadViewPost{}
blueskyPost, err := controller.FetchThreadViewPost(blog.BlueskyActorID, blog.BlueskyPostID)
if err != nil {
fmt.Fprintf(os.Stderr, "WARN: Failed to fetch blog post Bluesky thread: %v\n", err)
} else {
comments = append(comments, blueskyPost.Replies...)
}
type BlogView struct {
*model.Blog
Comments []*model.ThreadViewPost
Likes int
Reposts int
BlueskyURL string
MastodonURL string
}
err = templates.BlogTemplate.Execute(w, BlogView{
Blog: &blog,
Comments: blueskyPost.Replies,
Likes: 10,
Reposts: 10,
BlueskyURL: fmt.Sprintf("https://bsky.app/profile/%s/post/%s", blog.BlueskyActorID, blog.BlueskyPostID),
MastodonURL: "#",
})
if err != nil {
fmt.Fprintf(os.Stderr, "Error rendering blog post: %v\n", err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}
})
}