Migration to new soundtrack title struct

This commit is contained in:
Eduard Urbach 2018-04-08 22:23:07 +02:00
parent dea33ab01d
commit 1ba0da36e2
9 changed files with 29 additions and 19 deletions

View File

@ -28,10 +28,10 @@ component SoundTrackMedia(track *arn.SoundTrack)
component SoundTrackFooter(track *arn.SoundTrack) component SoundTrackFooter(track *arn.SoundTrack)
.soundtrack-footer .soundtrack-footer
if track.Title == "" if track.NewTitle.ByUser(nil) == ""
a(href=track.Link() + "/edit") untitled a(href=track.Link() + "/edit") untitled
else else
a(href=track.Link())= track.Title a(href=track.Link())= track.NewTitle.ByUser(nil)
span posted span posted
span.utc-date(data-date=track.Created) span.utc-date(data-date=track.Created)
span by span by

View File

@ -1,6 +1,4 @@
component AnimeTracks(anime *arn.Anime, tracks []*arn.SoundTrack) component AnimeTracks(anime *arn.Anime, tracks []*arn.SoundTrack)
//- AnimeTabs(anime)
if len(tracks) > 0 if len(tracks) > 0
.anime-section.mountable .anime-section.mountable
h3.anime-section-name Tracks h3.anime-section-name Tracks
@ -8,10 +6,3 @@ component AnimeTracks(anime *arn.Anime, tracks []*arn.SoundTrack)
.soundtracks.anime-soundtracks .soundtracks.anime-soundtracks
each track in tracks each track in tracks
SoundTrack(track) SoundTrack(track)
//- .anime-soundtracks
//- each track in tracks
//- .anime-soundtrack.mountable(data-mountable-type="track")
//- .video-container
//- iframe.video.lazy(data-src=track.Media[0].EmbedLink(), allowfullscreen="allowfullscreen")
//- a.soundtrack-footer(href=track.Link())= track.Title

View File

@ -13,7 +13,7 @@ component SoundTracksEditorList(tracks []*arn.SoundTrack, count int, url string,
tr.mountable tr.mountable
td= len(track.Likes) td= len(track.Likes)
td td
a(href=track.Link(), target="_blank", rel="noopener")= track.Title a(href=track.Link(), target="_blank", rel="noopener")= track.NewTitle.ByUser(user)
td td
each media in track.Media each media in track.Media
if media.Service == "Youtube" if media.Service == "Youtube"

View File

@ -104,7 +104,7 @@ component SoundTrackSearchResults(tracks []*arn.SoundTrack)
ul.soundtrack-search ul.soundtrack-search
each track in tracks each track in tracks
li.mountable(data-mountable-type="track") li.mountable(data-mountable-type="track")
a(href=track.Link())= track.Title a(href=track.Link())= track.NewTitle.ByUser(nil)
span.soundtrack-search-anime= " - " + track.MainAnime().Title.Canonical span.soundtrack-search-anime= " - " + track.MainAnime().Title.Canonical
component CompanySearchResults(companies []*arn.Company) component CompanySearchResults(companies []*arn.Company)

View File

@ -23,7 +23,7 @@ func Edit(ctx *aero.Context) string {
ctx.Data = &arn.OpenGraph{ ctx.Data = &arn.OpenGraph{
Tags: map[string]string{ Tags: map[string]string{
"og:title": track.Title, "og:title": track.NewTitle.ByUser(user),
"og:url": "https://" + ctx.App.Config.Domain + track.Link(), "og:url": "https://" + ctx.App.Config.Domain + track.Link(),
"og:site_name": "notify.moe", "og:site_name": "notify.moe",
"og:type": "music.song", "og:type": "music.song",

View File

@ -32,7 +32,7 @@ func Get(ctx *aero.Context) string {
openGraph := &arn.OpenGraph{ openGraph := &arn.OpenGraph{
Tags: map[string]string{ Tags: map[string]string{
"og:title": track.Title, "og:title": track.NewTitle.ByUser(user),
"og:description": track.MainAnime().Title.Canonical + " (" + strings.Join(descriptionTags, ", ") + ")", "og:description": track.MainAnime().Title.Canonical + " (" + strings.Join(descriptionTags, ", ") + ")",
"og:url": "https://" + ctx.App.Config.Domain + track.Link(), "og:url": "https://" + ctx.App.Config.Domain + track.Link(),
"og:site_name": ctx.App.Config.Domain, "og:site_name": ctx.App.Config.Domain,

View File

@ -2,10 +2,10 @@ component SoundTrackPage(track *arn.SoundTrack, user *arn.User)
SoundTrackTabs(track, user) SoundTrackTabs(track, user)
.soundtrack-full-page .soundtrack-full-page
if track.Title == "" if track.NewTitle.ByUser(user) == ""
h1.mountable untitled h1.mountable untitled
else else
h1.mountable= track.Title h1.mountable= track.NewTitle.ByUser(user)
.widget-form.soundtrack-media-list .widget-form.soundtrack-media-list
each media in track.Media each media in track.Media

View File

@ -0,0 +1,19 @@
package main
import (
"github.com/animenotifier/arn"
)
func main() {
defer arn.Node.Close()
for track := range arn.StreamSoundTracks() {
if arn.ContainsUnicodeLetters(track.Title) {
track.NewTitle.Native = track.Title
} else {
track.NewTitle.Canonical = track.Title
}
track.Save()
}
}

View File

@ -260,7 +260,7 @@ export default class AudioPlayer {
let trackInfoResponse = await fetch("/api/soundtrack/" + trackId) let trackInfoResponse = await fetch("/api/soundtrack/" + trackId)
let track = await trackInfoResponse.json() let track = await trackInfoResponse.json()
this.trackLink.href = "/soundtrack/" + track.id this.trackLink.href = "/soundtrack/" + track.id
this.trackLink.innerText = track.title this.trackLink.innerText = track.title.canonical || track.title.native
let animeId = "" let animeId = ""