diff --git a/admin/templates.go b/admin/templates.go index ab4517e..12cdf08 100644 --- a/admin/templates.go +++ b/admin/templates.go @@ -11,44 +11,44 @@ import ( var indexTemplate = template.Must(template.ParseFiles( filepath.Join("admin", "views", "layout.html"), - filepath.Join("view", "prideflag.html"), + filepath.Join("views", "prideflag.html"), filepath.Join("admin", "components", "release", "release-list-item.html"), filepath.Join("admin", "views", "index.html"), )) var loginTemplate = template.Must(template.ParseFiles( filepath.Join("admin", "views", "layout.html"), - filepath.Join("view", "prideflag.html"), + filepath.Join("views", "prideflag.html"), filepath.Join("admin", "views", "login.html"), )) var loginTOTPTemplate = template.Must(template.ParseFiles( filepath.Join("admin", "views", "layout.html"), - filepath.Join("view", "prideflag.html"), + filepath.Join("views", "prideflag.html"), filepath.Join("admin", "views", "login-totp.html"), )) var registerTemplate = template.Must(template.ParseFiles( filepath.Join("admin", "views", "layout.html"), - filepath.Join("view", "prideflag.html"), + filepath.Join("views", "prideflag.html"), filepath.Join("admin", "views", "register.html"), )) var logoutTemplate = template.Must(template.ParseFiles( filepath.Join("admin", "views", "layout.html"), - filepath.Join("view", "prideflag.html"), + filepath.Join("views", "prideflag.html"), filepath.Join("admin", "views", "logout.html"), )) var accountTemplate = template.Must(template.ParseFiles( filepath.Join("admin", "views", "layout.html"), - filepath.Join("view", "prideflag.html"), + filepath.Join("views", "prideflag.html"), filepath.Join("admin", "views", "edit-account.html"), )) var totpSetupTemplate = template.Must(template.ParseFiles( filepath.Join("admin", "views", "layout.html"), - filepath.Join("view", "prideflag.html"), + filepath.Join("views", "prideflag.html"), filepath.Join("admin", "views", "totp-setup.html"), )) var totpConfirmTemplate = template.Must(template.ParseFiles( filepath.Join("admin", "views", "layout.html"), - filepath.Join("view", "prideflag.html"), + filepath.Join("views", "prideflag.html"), filepath.Join("admin", "views", "totp-confirm.html"), )) @@ -79,23 +79,23 @@ var logsTemplate = template.Must(template.New("layout.html").Funcs(template.Func }, }).ParseFiles( filepath.Join("admin", "views", "layout.html"), - filepath.Join("view", "prideflag.html"), + filepath.Join("views", "prideflag.html"), filepath.Join("admin", "views", "logs.html"), )) var releaseTemplate = template.Must(template.ParseFiles( filepath.Join("admin", "views", "layout.html"), - filepath.Join("view", "prideflag.html"), + filepath.Join("views", "prideflag.html"), filepath.Join("admin", "views", "edit-release.html"), )) var artistTemplate = template.Must(template.ParseFiles( filepath.Join("admin", "views", "layout.html"), - filepath.Join("view", "prideflag.html"), + filepath.Join("views", "prideflag.html"), filepath.Join("admin", "views", "edit-artist.html"), )) var trackTemplate = template.Must(template.ParseFiles( filepath.Join("admin", "views", "layout.html"), - filepath.Join("view", "prideflag.html"), + filepath.Join("views", "prideflag.html"), filepath.Join("admin", "components", "release", "release-list-item.html"), filepath.Join("admin", "views", "edit-track.html"), )) diff --git a/controller/bluesky.go b/controller/bluesky.go deleted file mode 100644 index 0e382df..0000000 --- a/controller/bluesky.go +++ /dev/null @@ -1,48 +0,0 @@ -package controller - -import ( - "arimelody-web/model" - "encoding/json" - "errors" - "fmt" - "net/http" - "net/url" - "strings" -) - -const BSKY_API_BASE = "https://public.api.bsky.app" - -func FetchThreadViewPost(actorID string, postID string) (*model.ThreadViewPost, error) { - uri := fmt.Sprintf("at://%s/app.bsky.feed.post/%s", actorID, postID) - - req, err := http.NewRequest( - http.MethodGet, - strings.Join([]string{BSKY_API_BASE, "xrpc", "app.bsky.feed.getPostThread"}, "/"), - nil, - ) - if err != nil { panic(err) } - - req.URL.RawQuery = url.Values{ - "uri": { uri }, - }.Encode() - req.Header.Set("User-Agent", "ari melody [https://arimelody.me]") - req.Header.Set("Accept", "application/json") - - client := &http.Client{} - - res, err := client.Do(req) - if err != nil { - return nil, errors.New(fmt.Sprintf("Failed to call Bluesky API: %v", err)) - } - - type Data struct { - Thread model.ThreadViewPost `json:"thread"` - } - data := Data{} - err = json.NewDecoder(res.Body).Decode(&data) - if err != nil { - return nil, errors.New(fmt.Sprintf("Invalid response from server: %v", err)) - } - - return &data.Thread, nil -} diff --git a/go.mod b/go.mod index e9fd53c..a1c6c76 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,6 @@ require ( require golang.org/x/crypto v0.27.0 // indirect require ( - github.com/gomarkdown/markdown v0.0.0-20250311123330-531bef5e742b // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect diff --git a/go.sum b/go.sum index d817720..f2ec7e7 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= -github.com/gomarkdown/markdown v0.0.0-20250311123330-531bef5e742b h1:EY/KpStFl60qA17CptGXhwfZ+k1sFNJIUNR8DdbcuUk= -github.com/gomarkdown/markdown v0.0.0-20250311123330-531bef5e742b/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o= diff --git a/main.go b/main.go index 8de29a3..2252622 100644 --- a/main.go +++ b/main.go @@ -448,7 +448,6 @@ func createServeMux(app *model.AppState) *http.ServeMux { mux.Handle("/admin/", http.StripPrefix("/admin", admin.Handler(app))) mux.Handle("/api/", http.StripPrefix("/api", api.Handler(app))) mux.Handle("/music/", http.StripPrefix("/music", view.MusicHandler(app))) - mux.Handle("/blog/", http.StripPrefix("/blog", view.BlogHandler(app))) mux.Handle("/uploads/", http.StripPrefix("/uploads", staticHandler(filepath.Join(app.Config.DataDirectory, "uploads")))) mux.Handle("/cursor-ws", cursor.Handler(app)) mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { diff --git a/model/blog.go b/model/blog.go deleted file mode 100644 index 7f0c87b..0000000 --- a/model/blog.go +++ /dev/null @@ -1,41 +0,0 @@ -package model - -import ( - "fmt" - "html/template" - "regexp" - "strings" - "time" -) - -type ( - Blog struct { - Title string `db:"title"` - Description string `db:"description"` - Visible bool `db:"visible"` - Date time.Time `db:"date"` - AuthorID string `db:"author"` - Markdown string `db:"markdown"` - HTML template.HTML `db:"html"` - BlueskyActorID string `db:"bsky_actor"` - BlueskyPostID string `db:"bsky_post"` - } -) - -func (b *Blog) TitleNormalised() string { - rgx := regexp.MustCompile(`[^a-z0-9\-]`) - return rgx.ReplaceAllString( - strings.ReplaceAll( - strings.ToLower(b.Title), " ", "-", - ), - "", - ) -} - -func (b *Blog) GetMonth() string { - return fmt.Sprintf("%02d", int(b.Date.Month())) -} - -func (b *Blog) PrintDate() string { - return b.Date.Format("02 January 2006") -} diff --git a/model/bluesky.go b/model/bluesky.go deleted file mode 100644 index dd8391e..0000000 --- a/model/bluesky.go +++ /dev/null @@ -1,82 +0,0 @@ -package model - -import ( - "fmt" - "strings" - "time" -) - -type ( - Record struct { - Type string `json:"$type"` - CreatedAt string `json:"createdAt"` - Text string `json:"text"` - } - - Profile struct { - DID string `json:"did"` - Handle string `json:"handle"` - Avatar string `json:"avatar"` - DisplayName string `json:"displayName"` - CreatedAt string `json:"createdAt"` - } - - PostImage struct { - Thumbnail string `json:"thumb"` - Fullsize string `json:"fullsize"` - Alt string `json:"alt"` - } - - EmbedMedia struct { - Images []PostImage `json:"images"` - } - - Embed struct { - Media EmbedMedia `json:"media"` - } - - Post struct { - Author Profile `json:"author"` - Record Record `json:"record"` - ReplyCount int `json:"replyCount"` - RepostCount int `json:"repostCount"` - LikeCount int `json:"likeCount"` - QuoteCount int `json:"quoteCount"` - Embed *Embed `json:"embed"` - URI string `json:"uri"` - } - - ThreadViewPost struct { - Post Post `json:"post"` - Replies []*ThreadViewPost `json:"replies"` - } -) - -func (record *Record) CreatedAtPrint() (string, error) { - t, err := record.CreatedAtTime() - if err != nil { return "", err } - return t.Format("15:04, 2 February 2006"), nil -} - -func (record *Record) CreatedAtTime() (time.Time, error) { - return time.Parse("2006-01-02T15:04:05Z", record.CreatedAt) -} - -func (post *Post) HasImage() bool { - return post.Embed != nil && len(post.Embed.Media.Images) > 0 -} - -func (post *Post) PostID() string { - return strings.TrimPrefix( - post.URI, - fmt.Sprintf("at://%s/app.bsky.feed.post/", post.Author.DID), - ) -} - -func (post *Post) BskyURL() string { - return fmt.Sprintf( - "https://bsky.app/profile/%s/post/%s", - post.Author.DID, - post.PostID(), - ) -} diff --git a/public/img/aridoodle.png b/public/img/aridoodle.png deleted file mode 100644 index c8328b5..0000000 Binary files a/public/img/aridoodle.png and /dev/null differ diff --git a/public/script/blog.js b/public/script/blog.js deleted file mode 100644 index e69de29..0000000 diff --git a/public/style/blog.css b/public/style/blog.css deleted file mode 100644 index 7f424d5..0000000 --- a/public/style/blog.css +++ /dev/null @@ -1,193 +0,0 @@ -:root { - --like: rgb(223, 104, 104); - --repost: rgb(162, 223, 73); - --bluesky: rgb(16, 131, 254); - --mastodon: rgb(86, 58, 204); -} - -main { - width: min(calc(100% - 4rem), 900px); - margin: 0 auto 1rem auto; -} - -.blog p:hover, -.comment p:hover { - background: inherit; -} - -article.blog { - font-family: 'Lora', serif; -} - -.blog-date { - margin-top: -1em; - opacity: .75; -} - -.blog p { - line-height: 1.5em; -} - -.blog sub { - opacity: .75; -} - -.blog pre { - max-height: 15em; - padding: .5em; - font-size: .9em; - border: 1px solid #8884; - border-radius: 2px; - overflow: scroll; - background: #060606; -} - -.blog p code { - padding: .2em .3em; - font-size: .9em; - border: 1px solid #8884; - border-radius: 2px; - background: #060606; -} - -.blog img { - max-height: 50%; - max-width: 100%; - - display: block; -} - -.blog i.end-mark { - width: 1.2em; - height: 1.2em; - margin-top: -.2em; - - display: inline-block; - transform: translateY(.2em); - - background: url("/img/aridoodle.png"); - background-size: contain; - background-repeat: no-repeat; - background-position: center; -} - - - -/* COMMENTS */ - -.interactions { - margin: 1em 0; - display: flex; - flex-direction: row; - gap: .5em; - flex-wrap: wrap; -} - -.btn { - display: inline-block; - padding: .4em .6em; - border: 1px solid var(--on-background); - border-radius: 2px; - color: inherit; - text-decoration: none; - font-weight: 600; -} - -.interactions .likes, -.interactions .reposts { - padding: 0 .5em; - min-width: fit-content; - font-family: monospace; - text-align: center; - line-height: 2em; - border: 1px solid var(--on-background); - border-radius: 2px; - text-wrap: nowrap; -} - -.interactions .likes { - border-color: var(--on-background); -} -.interactions .reposts { - border-color: var(--on-background); -} - -.btn.bluesky, -.btn.mastodon { - font-family: monospace; - text-wrap: nowrap; -} - -.btn.bluesky { - color: var(--bluesky); - border-color: var(--bluesky); -} - -.btn.mastodon { - color: var(--mastodon); - border-color: var(--mastodon); -} - -.comment { - font-family: 'Inter', 'Arial', sans-serif; - font-size: 1em; -} - -.comment .comment-hover { - padding: 1em; - transition: background-color .1s; -} - -.comment .comment-hover:hover { - background-color: #8881; -} - -.comment .comment-header a { - display: flex; - gap: .5em; - font-weight: 600; - color: var(--primary); - text-decoration: none; - align-items: center; - overflow: hidden; - text-overflow: ellipsis; -} - -.comment .comment-header a .display-name { - overflow: inherit; - text-overflow: inherit; -} - -.comment .comment-header a .handle { - opacity: .5; - font-family: monospace; - font-size: .9em; - overflow: inherit; - text-overflow: inherit; -} - -.comment .comment-header img.avatar { - width: 1.5em; - height: 1.5em; -} - -.comment .comment-body { - color: inherit; - text-decoration: none; -} - -.comment p.comment-text { - margin: .5em 0; - white-space: break-spaces; -} - -.comment .comment-footer .comment-date { - margin: 0; - font-size: .8em; - opacity: .5; -} - -.comment .comment-replies { - margin-left: 1em; - border-left: 2px solid #8884; -} diff --git a/templates/templates.go b/templates/templates.go index 4c5793b..8d1a5ca 100644 --- a/templates/templates.go +++ b/templates/templates.go @@ -6,30 +6,23 @@ import ( ) var IndexTemplate = template.Must(template.ParseFiles( - filepath.Join("view", "layout.html"), - filepath.Join("view", "header.html"), - filepath.Join("view", "footer.html"), - filepath.Join("view", "prideflag.html"), - filepath.Join("view", "index.html"), + filepath.Join("views", "layout.html"), + filepath.Join("views", "header.html"), + filepath.Join("views", "footer.html"), + filepath.Join("views", "prideflag.html"), + filepath.Join("views", "index.html"), )) var MusicTemplate = template.Must(template.ParseFiles( - filepath.Join("view", "layout.html"), - filepath.Join("view", "header.html"), - filepath.Join("view", "footer.html"), - filepath.Join("view", "prideflag.html"), - filepath.Join("view", "music.html"), + filepath.Join("views", "layout.html"), + filepath.Join("views", "header.html"), + filepath.Join("views", "footer.html"), + filepath.Join("views", "prideflag.html"), + filepath.Join("views", "music.html"), )) var MusicGatewayTemplate = template.Must(template.ParseFiles( - filepath.Join("view", "layout.html"), - filepath.Join("view", "header.html"), - filepath.Join("view", "footer.html"), - filepath.Join("view", "prideflag.html"), - filepath.Join("view", "music-gateway.html"), -)) -var BlogTemplate = template.Must(template.ParseFiles( - filepath.Join("view", "layout.html"), - filepath.Join("view", "header.html"), - filepath.Join("view", "footer.html"), - filepath.Join("view", "prideflag.html"), - filepath.Join("view", "blog.html"), + filepath.Join("views", "layout.html"), + filepath.Join("views", "header.html"), + filepath.Join("views", "footer.html"), + filepath.Join("views", "prideflag.html"), + filepath.Join("views", "music-gateway.html"), )) diff --git a/view/blog.go b/view/blog.go deleted file mode 100644 index 9ab52d2..0000000 --- a/view/blog.go +++ /dev/null @@ -1,135 +0,0 @@ -package view - -import ( - "fmt" - "html/template" - "net/http" - "os" - "time" - - "arimelody-web/controller" - "arimelody-web/model" - "arimelody-web/templates" - - "github.com/gomarkdown/markdown" - "github.com/gomarkdown/markdown/html" - "github.com/gomarkdown/markdown/parser" -) - -var mdRenderer = html.NewRenderer(html.RendererOptions{ - Flags: html.CommonFlags | html.HrefTargetBlank, -}) - -func BlogHandler(app *model.AppState) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - blog := model.Blog{ - Title: "hello world!", - Description: "lorem ipsum yadda yadda something boobies babababababababa", - Visible: true, - Date: time.Now(), - AuthorID: "ari", - Markdown: -` -**i'm ari!** - -she/her 🏳️‍⚧️🏳️‍🌈💫🦆🇮🇪 - -i'm a musician, developer, streamer, youtuber, and probably a bunch of other things i forgot to mention! - -you're very welcome to take a look around my little space on the internet here, or explore any of the other parts i inhabit! - -if you're looking to support me financially, that's so cool of you!! if you like, you can buy some of my music over on bandcamp so you can at least get something for your money. thank you very much either way!! 💕 - -for anything else, you can reach me for any and all communications through ari@arimelody.me. if your message contains anything beyond a silly gag, i strongly recommend encrypting your message using my public pgp key, listed below! - -thank you for stopping by- i hope you have a lovely rest of your day! 💫 - -## metadata - -**my colours 🌈** - -- primary: #b7fd49 -- secondary: #f8e05b -- tertiary: #f788fe - -**my keys 🔑** - -- pgp: [[link]](/keys/ari%20melody_0x92678188_public.asc) -- ssh (ed25519): [[link]](/keys/id_ari_ed25519.pub) - -**where to find me 🛰️** - -- youtube -- twitch -- spotify -- bandcamp -- github - -**projects i've worked on 🛠️** - -- catdance -- pride flag -- ipaddrgen -- impact meme -- OpenTerminal -- Silver.js - -### code block test - -~~~ c -#include - -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 += " " - - mdParser := parser.NewWithExtensions(parser.CommonExtensions | parser.AutoHeadingIDs) - md := mdParser.Parse([]byte(blog.Markdown)) - blog.HTML = template.HTML(markdown.Render(md, mdRenderer)) - - 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 - } - }) -} diff --git a/view/blog.html b/view/blog.html deleted file mode 100644 index f858252..0000000 --- a/view/blog.html +++ /dev/null @@ -1,86 +0,0 @@ -{{define "head"}} -{{.Title}} - ari melody 💫 - - - - - - - - - - - - - - -{{end}} - -{{define "content"}} -
-
-

{{.Title}}

-

Posted by {{.AuthorID}} @ {{.PrintDate}}

- -
- {{.HTML}} - -
- -
- -
- - 🔁 {{.Reposts}} - Bluesky 🦋 - - Mastodon 🐘 -
- -
- {{range .Comments}} - {{template "comment" .}} - {{end}} -
- - -
-{{end}} - -{{define "comment"}} -
- - -
- {{range .Replies}} - {{template "comment" .}} - {{end}} -
-
-{{end}} - diff --git a/view/music.go b/view/music.go index 3c27b6e..2d40ef0 100644 --- a/view/music.go +++ b/view/music.go @@ -89,7 +89,7 @@ func ServeGateway(app *model.AppState, release *model.Release) http.Handler { err := templates.MusicGatewayTemplate.Execute(w, response) if err != nil { - fmt.Fprintf(os.Stderr, "Error rendering music gateway for %s: %v\n", release.ID, err) + fmt.Printf("Error rendering music gateway for %s: %s\n", release.ID, err) http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) return } diff --git a/view/404.html b/views/404.html similarity index 100% rename from view/404.html rename to views/404.html diff --git a/view/footer.html b/views/footer.html similarity index 100% rename from view/footer.html rename to views/footer.html diff --git a/view/header.html b/views/header.html similarity index 100% rename from view/header.html rename to views/header.html diff --git a/view/index.html b/views/index.html similarity index 100% rename from view/index.html rename to views/index.html diff --git a/view/layout.html b/views/layout.html similarity index 100% rename from view/layout.html rename to views/layout.html diff --git a/view/music-gateway.html b/views/music-gateway.html similarity index 100% rename from view/music-gateway.html rename to views/music-gateway.html diff --git a/view/music.html b/views/music.html similarity index 100% rename from view/music.html rename to views/music.html diff --git a/view/prideflag.html b/views/prideflag.html similarity index 100% rename from view/prideflag.html rename to views/prideflag.html