{{album.Title}}
+ ++ {{#unless isAlbum}} + {{album.Views}}
+ {{album.Upvotes}}
+ {{/unless}} + {{album.Downvotes}}
{{this.Title}}
+ {{/if}} + {{#if this.Description}} +{{this.Description}}
+ {{/if}} + {{/each}}diff --git a/README.md b/README.md index 85f1539..7a331f3 100644 --- a/README.md +++ b/README.md @@ -27,15 +27,13 @@ Features: This is currently very early stage software. Some things left to implement (contributions welcome!): -- [ ] Streaming (currently media is downloaded in full in rimgu before it's returned) +- [x] Streaming (currently media is downloaded in full in rimgu before it's returned) - [ ] Localization/internationalization -- [ ] Pretty CSS styling (responsive?) -- [ ] Automatically fetch / rotate / renew client ID +- [x] Pretty CSS styling (responsive?) - [ ] Support for other popular image sites than only imgur - [ ] Filtering and exploration on user/tags pages - [ ] Responsive scaling of videos on user/tags pages -- [ ] Prometheus metrics -- [ ] Logo +- [x] Logo - [ ] SOCKS5 proxy support Things that are *currently* considered out of scope: diff --git a/api/album.go b/api/album.go index 6ef9948..780d861 100644 --- a/api/album.go +++ b/api/album.go @@ -26,12 +26,19 @@ func FetchAlbum(albumID string) (types.Album, error) { data := gjson.Parse(string(body)) - media := make([]string, 0) + media := make([]types.Media, 0) data.Get("media").ForEach( func(key gjson.Result, value gjson.Result) bool { url := value.Get("url").String() url = strings.ReplaceAll(url, "https://i.imgur.com", "/media") - media = append(media, url) + + media = append(media, types.Media{ + Id: value.Get("id").String(), + Name: value.Get("name").String(), + Title: value.Get("metadata.title").String(), + Description: value.Get("metadata.description").String(), + Url: url, + }) return true }, @@ -46,8 +53,6 @@ func FetchAlbum(albumID string) (types.Album, error) { Id: data.Get("id").String(), Title: data.Get("title").String(), Views: data.Get("view_count").Int(), - Upvotes: data.Get("upvote_count").Int(), - Downvotes: data.Get("downvote_count").Int(), CreatedAt: createdAt.Format("January 2, 2006 3:04 PM"), Media: media, }, nil diff --git a/main.go b/main.go index ea911e2..c253ac1 100644 --- a/main.go +++ b/main.go @@ -43,7 +43,7 @@ func main() { Root: http.FS(static.GetFiles()), })) - app.Get("/media/:baseName.:extension", pages.HandleMedia) + app.Get("/:baseName.:extension", pages.HandleMedia) app.Get("/a/:albumID", pages.HandleAlbum) app.Get("/t/:tagID", pages.HandleAlbum) /*app.Get("/user/:userID", pages.HandleUser) diff --git a/pages/album.go b/pages/album.go index ddf901f..aec0be0 100644 --- a/pages/album.go +++ b/pages/album.go @@ -16,5 +16,6 @@ func HandleAlbum(c *fiber.Ctx) error { return c.Render("gallery", fiber.Map{ "album": album, + "isAlbum": true, }) } diff --git a/static/css/album.css b/static/css/album.css index e69de29..80c56b7 100644 --- a/static/css/album.css +++ b/static/css/album.css @@ -0,0 +1,17 @@ +h1 { + margin: 0; +} + +img { + max-width: 100%; +} + +.imageMeta__wrapper, +.imageMeta { + display: flex; + gap: 12px; +} + +.imageMeta__wrapper { + gap: 2rem; +} \ No newline at end of file diff --git a/static/css/base.css b/static/css/base.css index 6b4e203..bc7a47f 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -1,11 +1,39 @@ +a { + text-decoration: none; +} + body { + background-color: black; + color: white; font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Ubuntu, roboto, noto, arial, sans-serif; } -main { - margin: 0 18vw; +nav { + display: flex; + align-items: center; } -img { - max-width: 100%; +.logo { + filter: invert(1) hue-rotate(180deg); +} + +main { + margin: 0 24vw; +} + +footer { + display: flex; + justify-content: center; + flex-direction: row; + gap: 10px; +} + +@media only screen and (max-width: 812px) { + main { + margin: 0; + } + footer { + flex-direction: column; + text-align: center; + } } \ No newline at end of file diff --git a/static/fonts/Material-Icons-Outlined.css b/static/fonts/Material-Icons-Outlined.css new file mode 100644 index 0000000..f616471 --- /dev/null +++ b/static/fonts/Material-Icons-Outlined.css @@ -0,0 +1,22 @@ +/* fallback */ +@font-face { + font-family: 'Material Icons Outlined'; + font-style: normal; + font-weight: 400; + src: url(Material-Icons-Outlined.woff2) format('woff2'); +} + +.material-icons-outlined { + font-family: 'Material Icons Outlined'; + font-weight: normal; + font-style: normal; + line-height: 1; + letter-spacing: normal; + text-transform: none; + display: inline-block; + white-space: nowrap; + word-wrap: normal; + direction: ltr; + -moz-font-feature-settings: 'liga'; + -moz-osx-font-smoothing: grayscale; +} diff --git a/static/fonts/Material-Icons-Outlined.woff2 b/static/fonts/Material-Icons-Outlined.woff2 new file mode 100644 index 0000000..f720d32 Binary files /dev/null and b/static/fonts/Material-Icons-Outlined.woff2 differ diff --git a/types/Album.go b/types/Album.go index b6c112c..8a476c4 100644 --- a/types/Album.go +++ b/types/Album.go @@ -8,5 +8,5 @@ type Album struct { Downvotes int64 CreatedAt string UpdatedAt string - Media []string + Media []Media } diff --git a/types/Media.go b/types/Media.go new file mode 100644 index 0000000..dc7cef8 --- /dev/null +++ b/types/Media.go @@ -0,0 +1,9 @@ +package types + +type Media struct { + Id string + Name string + Title string + Description string + Url string +} diff --git a/types/User.go b/types/User.go new file mode 100644 index 0000000..57d3624 --- /dev/null +++ b/types/User.go @@ -0,0 +1,8 @@ +package types + +type User struct { + Id string + Username string + Avatar string + CreatedAt string +} diff --git a/views/gallery.hbs b/views/gallery.hbs index 813fc86..a68132b 100644 --- a/views/gallery.hbs +++ b/views/gallery.hbs @@ -3,17 +3,52 @@
{{> partials/head }} + + + {{> partials/header }}+ {{#unless isAlbum}} + {{album.Views}}
+ {{album.Upvotes}}
+ {{/unless}} + {{album.Downvotes}}
{{this.Description}}
+ {{/if}} + {{/each}}