Tracks have permalinks now
This commit is contained in:
parent
5099c0b0e7
commit
d5dcd9c909
@ -25,10 +25,11 @@ var colorPool = []*color.Color{
|
||||
var jobs = map[string]time.Duration{
|
||||
"active-users": 1 * time.Minute,
|
||||
"avatars": 1 * time.Hour,
|
||||
"sync-anime": 10 * time.Hour,
|
||||
"popular-anime": 11 * time.Hour,
|
||||
"refresh-track-titles": 10 * time.Hour,
|
||||
"sync-anime": 12 * time.Hour,
|
||||
"popular-anime": 12 * time.Hour,
|
||||
"airing-anime": 12 * time.Hour,
|
||||
"search-index": 13 * time.Hour,
|
||||
"search-index": 12 * time.Hour,
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
37
jobs/refresh-track-titles/main.go
Normal file
37
jobs/refresh-track-titles/main.go
Normal file
@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
func main() {
|
||||
color.Yellow("Refreshing track titles")
|
||||
|
||||
// Get a stream of all soundtracks
|
||||
soundtracks, err := arn.StreamSoundTracks()
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Iterate over the stream
|
||||
for track := range soundtracks {
|
||||
sync(track)
|
||||
}
|
||||
|
||||
color.Green("Finished.")
|
||||
}
|
||||
|
||||
func sync(track *arn.SoundTrack) {
|
||||
for _, media := range track.Media {
|
||||
media.RefreshMetaData()
|
||||
println(media.Service, media.Title)
|
||||
}
|
||||
|
||||
err := track.Save()
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ func main() {
|
||||
sync(anime)
|
||||
}
|
||||
|
||||
println("Finished.")
|
||||
color.Green("Finished.")
|
||||
}
|
||||
|
||||
func sync(data *kitsu.Anime) {
|
||||
|
2
main.go
2
main.go
@ -27,6 +27,7 @@ import (
|
||||
"github.com/animenotifier/notify.moe/pages/search"
|
||||
"github.com/animenotifier/notify.moe/pages/settings"
|
||||
"github.com/animenotifier/notify.moe/pages/threads"
|
||||
"github.com/animenotifier/notify.moe/pages/tracks"
|
||||
"github.com/animenotifier/notify.moe/pages/user"
|
||||
"github.com/animenotifier/notify.moe/pages/users"
|
||||
"github.com/animenotifier/notify.moe/pages/webdev"
|
||||
@ -61,6 +62,7 @@ func configure(app *aero.Application) *aero.Application {
|
||||
app.Ajax("/forum/:tag", forum.Get)
|
||||
app.Ajax("/threads/:id", threads.Get)
|
||||
app.Ajax("/posts/:id", posts.Get)
|
||||
app.Ajax("/tracks/:id", tracks.Get)
|
||||
app.Ajax("/user", user.Get)
|
||||
app.Ajax("/user/:nick", profile.Get)
|
||||
app.Ajax("/user/:nick/threads", profile.GetThreadsByUser)
|
||||
|
@ -1,10 +1,19 @@
|
||||
component SoundTrack(track *arn.SoundTrack)
|
||||
SoundTrackMedia(track, track.Media[0])
|
||||
|
||||
component SoundTrackAllMedia(track *arn.SoundTrack)
|
||||
each media in track.Media
|
||||
SoundTrackMedia(track, media)
|
||||
|
||||
component SoundTrackMedia(track *arn.SoundTrack, media *arn.ExternalMedia)
|
||||
.sound-track.mountable(id=track.ID)
|
||||
.sound-track-content
|
||||
a.sound-track-anime-link.ajax(href="/anime/" + track.MainAnime().ID)
|
||||
img.sound-track-anime-image.lazy(data-src=track.MainAnime().Image.Small, alt=track.MainAnime().Title.Canonical, title=track.MainAnime().Title.Canonical)
|
||||
|
||||
iframe.lazy(data-src=track.Media[0].EmbedLink())
|
||||
iframe.lazy(data-src=media.EmbedLink())
|
||||
.sound-track-footer
|
||||
a.ajax(href=track.Link())
|
||||
Icon("music")
|
||||
span posted by
|
||||
a.ajax(href=track.CreatedByUser().Link())= track.CreatedByUser().Nick
|
||||
a.ajax(href=track.CreatedByUser().Link())= track.CreatedByUser().Nick + " "
|
@ -34,10 +34,10 @@ component Dashboard(posts []*arn.Post, soundTracks []*arn.SoundTrack, following
|
||||
|
||||
for i := 0; i <= 4; i++
|
||||
if i < len(soundTracks)
|
||||
a.widget-element.ajax(href="/music")
|
||||
a.widget-element.ajax(href=soundTracks[i].Link())
|
||||
.widget-element-text
|
||||
Icon("music")
|
||||
span= soundTracks[i].MainAnime().Title.Canonical
|
||||
span= soundTracks[i].Media[0].Title
|
||||
else
|
||||
.widget-element
|
||||
.widget-element-text
|
||||
|
@ -1,6 +1,8 @@
|
||||
package posts
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
@ -12,7 +14,7 @@ func Get(ctx *aero.Context) string {
|
||||
post, err := arn.GetPost(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(404, "Post not found", err)
|
||||
return ctx.Error(http.StatusNotFound, "Post not found", err)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Post(post))
|
||||
|
21
pages/tracks/tracks.go
Normal file
21
pages/tracks/tracks.go
Normal file
@ -0,0 +1,21 @@
|
||||
package tracks
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
// Get post.
|
||||
func Get(ctx *aero.Context) string {
|
||||
id := ctx.Get("id")
|
||||
track, err := arn.GetSoundTrack(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusNotFound, "Track not found", err)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Track(track))
|
||||
}
|
5
pages/tracks/tracks.pixy
Normal file
5
pages/tracks/tracks.pixy
Normal file
@ -0,0 +1,5 @@
|
||||
component Track(track *arn.SoundTrack)
|
||||
h2= track.Media[0].Title
|
||||
|
||||
.sound-tracks
|
||||
SoundTrackAllMedia(track)
|
Loading…
Reference in New Issue
Block a user