diff --git a/pkg/soundcloud/entities.go b/pkg/soundcloud/entities.go
index 390dec19..d43fea7d 100644
--- a/pkg/soundcloud/entities.go
+++ b/pkg/soundcloud/entities.go
@@ -22,6 +22,14 @@ func (p *Playlist) Section() string {
return "other"
}
+func (p *Playlist) URL() string {
+ return fmt.Sprintf("/album/%d", p.ID)
+}
+
+func (p *Playlist) IsExternal() bool { return false }
+
+func (p *Playlist) ImageURL() string { return p.ArtworkUrl }
+
func (p *Playlists) BySection(section string) []*Playlist {
out := []*Playlist{}
for _, playlist := range p.Playlists {
@@ -32,10 +40,10 @@ func (p *Playlists) BySection(section string) []*Playlist {
return out
}
-func (p *Playlist) URL() string {
- return fmt.Sprintf("/album/%d", p.ID)
+func (t *Track) URL() string {
+ return fmt.Sprintf("/track/%d", t.ID)
}
-func (p *Playlist) IsExternal() bool { return true }
+func (t *Track) IsExternal() bool { return false }
-func (p *Playlist) ImageURL() string { return p.ArtworkUrl }
+func (t *Track) ImageURL() string { return t.ArtworkUrl }
diff --git a/templates/album.tmpl b/templates/album.tmpl
new file mode 100644
index 00000000..441b5dd7
--- /dev/null
+++ b/templates/album.tmpl
@@ -0,0 +1,42 @@
+{{define "title"}}{{.album.Title}}{{end}}
+{{define "h1"}}Album {{ mot_cool }}{{end}}
+{{define "h1small"}}{{.album.Title}}{{end}}
+
+{{define "content"}}
+
+
+
+
+
+
+ {{ if .album.Description }}
+
{{ .album.Description | linkify }}
+ {{end}}
+
+
Tracks
+ {{ range $entry := .album.Tracks }}
+
+ {{ end }}
+
+
+{{end}}
diff --git a/templates/old/album.html b/templates/old/album.html
deleted file mode 100644
index 30a3ff5b..00000000
--- a/templates/old/album.html
+++ /dev/null
@@ -1,32 +0,0 @@
-{% set active_page = 'muzik' %}
-{% extends "base.html" %}
-{% set page_title = album.title %}
-{% set columns = 3 %}
-{% set grid_size = 12 // columns %}
-{% set title = 'Album {{ mot_cool() }}' %}
-{% set square_size = 250 %}
-
-{% block title %}Album {{ mot_cool() }}{% endblock %}
-{% block subtitle %}{{album.title}}{% endblock %}
-
-{% block content %}
-
- {% for track in album.tracks : %}
-
-
-
- {% endfor %}
-
-{% endblock %}
diff --git a/views/funcmap.go b/views/funcmap.go
index 7bc70fa5..b3d2f749 100644
--- a/views/funcmap.go
+++ b/views/funcmap.go
@@ -140,6 +140,7 @@ func (f *ctxFuncmap) resize(opts ...string) string {
buf := []byte(fmt.Sprintf("%s:%v", path, opts))
h := make([]byte, 8)
sha3.ShakeSum256(h, buf)
+ //FIXME: process hash based on file content instead of filepath (keep opts)
newpath := fmt.Sprintf("./static/img/cache/%x%s", h, filepath.Ext(path))
if _, err := os.Stat(newpath); !os.IsNotExist(err) {
diff --git a/views/views.go b/views/views.go
index 5a3d57c1..9fb00f7e 100644
--- a/views/views.go
+++ b/views/views.go
@@ -26,6 +26,7 @@ func Setup(opts *Options) error {
opts.Router.HandleFunc("/hackz", handlers.hackzHandler)
opts.Router.HandleFunc("/copaings", handlers.copaingsHandler)
opts.Router.HandleFunc("/track/{track_id:[0-9]+}", handlers.trackHandler)
+ opts.Router.HandleFunc("/album/{album_id:[0-9]+}", handlers.albumHandler)
//
// old routes (to be imported)
@@ -45,7 +46,6 @@ func Setup(opts *Options) error {
// /hackz/recettator
// /hackz/moijaime
// /hackz/phazms GET/POST
- // /album/
// /scorz/inc///
// /sitemap.xml
@@ -118,6 +118,24 @@ func (h *handlers) trackHandler(w http.ResponseWriter, r *http.Request) {
h.render(w, r, "track.tmpl", data)
}
+func (h *handlers) albumHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ albumId, err := strconv.ParseUint(vars["album_id"], 10, 64)
+ if err != nil {
+ h.renderError(w, r, err)
+ return
+ }
+ album, err := h.opts.Svc.SoundcloudPlaylist(r.Context(), &api.SoundcloudPlaylistInput{
+ PlaylistId: albumId,
+ })
+ if err != nil {
+ h.renderError(w, r, err)
+ return
+ }
+ data := renderData{"album": album}
+ h.render(w, r, "album.tmpl", data)
+}
+
func (h *handlers) copaingsHandler(w http.ResponseWriter, r *http.Request) {
h.setDefaultHeaders(w)
data := renderData{"friends": crew.CALC.Friends}