Skip to content
Snippets Groups Projects
Commit 90f0dd60 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Switched to dark theme

parent a3cf9101
Branches
No related tags found
No related merge requests found
......@@ -346,6 +346,92 @@ func main() {
fmt.Fprint(w, "Image not found")
})))
http.Handle("/a/", http.StripPrefix("/a/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
user := parseUser(r)
type AlbumImage struct {
Id string
Title string
Description string
Position int
}
type Album struct {
Id string
Title string
Description string
CreatedAt time.Time
Images []AlbumImage
}
type AlbumDetailData struct {
User UserInfo
Album Album
IsMine bool
}
_, albumId := path.Split(r.URL.Path)
result, err := db.Query(`
SELECT
id,
owner,
coalesce(title, ''),
coalesce(description, ''),
coalesce(created_at, to_timestamp(0))
FROM albums
WHERE id = $1
`, albumId)
if err != nil {
panic(err)
}
var info Album
if result.Next() {
var owner string
err := result.Scan(&info.Id, &owner, &info.Title, &info.Description, &info.CreatedAt)
if err != nil {
panic(err)
}
result, err := db.Query(`
SELECT
image,
title,
description,
position
FROM album_images
WHERE album = $1
ORDER BY position ASC
`, albumId)
if err != nil {
panic(err)
}
for result.Next() {
var image AlbumImage
err := result.Scan(&image.Id, &owner, &image.Title, &image.Description, &image.Position)
if err != nil {
panic(err)
}
info.Images = append(info.Images, image)
}
if err = returnResult(w, "album_detail.html", AlbumDetailData{
user,
info,
owner == user.Id,
}); err != nil {
panic(err)
}
return
}
w.WriteHeader(http.StatusNotFound)
fmt.Fprint(w, "Image not found")
})))
http.HandleFunc("/me/images/", func(w http.ResponseWriter, r *http.Request) {
user := parseUser(r)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment