Editors can now refresh audio downloads

This commit is contained in:
Eduard Urbach 2018-10-31 05:24:12 +09:00
parent 3a6cd6b3bc
commit 000f04025b
11 changed files with 107 additions and 2 deletions

View File

@ -13,7 +13,7 @@ import (
const ( const (
// The maximum age of files we accept until we force a refresh. // The maximum age of files we accept until we force a refresh.
maxAge = 24 * time.Hour maxAge = 7 * 24 * time.Hour
delayBetweenRequests = 1100 * time.Millisecond delayBetweenRequests = 1100 * time.Millisecond
userAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.20 Safari/537.36" userAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.20 Safari/537.36"
animeDirectory = "anime" animeDirectory = "anime"

View File

@ -78,6 +78,13 @@ component CharacterSidebar(character *arn.Character, friends []*arn.User, releva
td.character-attributes-value!= markdown.Render(attribute.Value) td.character-attributes-value!= markdown.Render(attribute.Value)
else else
td.character-attributes-value= attribute.Value td.character-attributes-value= attribute.Value
//- td.character-attributes-value
//- if strings.Contains(attribute.Value, ",")
//- ul
//- each part in strings.Split(attribute.Value, ",")
//- li= strings.TrimSpace(part)
//- else
//- span= attribute.Value
if len(relevantCharacters) > 0 if len(relevantCharacters) > 0
h3.mountable(data-mountable-type="sidebar") Relevant h3.mountable(data-mountable-type="sidebar") Relevant

View File

@ -39,6 +39,10 @@
.character-attributes-value .character-attributes-value
text-align right text-align right
li
list-style-type none
margin 0
.character-anime .character-anime
horizontal-wrap horizontal-wrap

View File

@ -39,6 +39,9 @@ func Register(l *layout.Layout, app *aero.Application) {
app.Get("/api/next/soundtrack", soundtrack.Next) app.Get("/api/next/soundtrack", soundtrack.Next)
app.Get("/api/character/:id/ranking", character.Ranking) app.Get("/api/character/:id/ranking", character.Ranking)
// SoundTrack
app.Post("/api/soundtrack/:id/download", soundtrack.Download)
// Upload // Upload
app.Post("/api/upload/avatar", upload.Avatar) app.Post("/api/upload/avatar", upload.Avatar)
app.Post("/api/upload/cover", upload.Cover) app.Post("/api/upload/cover", upload.Cover)

View File

@ -13,6 +13,7 @@ func Register(l *layout.Layout) {
l.Page("/users/noavatar", users.ActiveNoAvatar) l.Page("/users/noavatar", users.ActiveNoAvatar)
l.Page("/users/games/osu", users.Osu) l.Page("/users/games/osu", users.Osu)
l.Page("/users/games/overwatch", users.Overwatch) l.Page("/users/games/overwatch", users.Overwatch)
l.Page("/users/games/ffxiv", users.FFXIV)
l.Page("/users/staff", users.Staff) l.Page("/users/staff", users.Staff)
l.Page("/users/pro", users.Pro) l.Page("/users/pro", users.Pro)
l.Page("/users/editors", users.Editors) l.Page("/users/editors", users.Editors)

View File

@ -0,0 +1,29 @@
package soundtrack
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/utils"
)
// Download tries to refresh the soundtrack file.
func Download(ctx *aero.Context) string {
id := ctx.Get("id")
user := utils.GetUser(ctx)
if user == nil || (user.Role != "editor" && user.Role != "admin") {
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this soundtrack")
}
track, err := arn.GetSoundTrack(id)
if err != nil {
return ctx.Error(http.StatusNotFound, "Track not found", err)
}
track.Download()
return ""
}

23
pages/users/ffxiv.pixy Normal file
View File

@ -0,0 +1,23 @@
component FinalFantasyXIVRankingList(users []*arn.User, url string)
h1.page-title FinalFantasy XIV ranking list
UsersTabs(url)
table.ranking-list
thead
tr.mountable
th #
th Player
th.ranking-class Class
th.ranking-level Level
th.ranking-score Item Level
tbody
for index, user := range users
tr.ranking.mountable
td= fmt.Sprint(index + 1) + "."
td.ranking-user
Avatar(user)
a.ranking-user-nick(href=user.Link())= user.Nick
td.ranking-class= user.Accounts.FinalFantasyXIV.Class
td.ranking-level= strconv.Itoa(user.Accounts.FinalFantasyXIV.Level)
td.ranking-score= strconv.Itoa(user.Accounts.FinalFantasyXIV.ItemLevel)

View File

@ -149,6 +149,24 @@ func Overwatch(ctx *aero.Context) string {
return ctx.HTML(components.OverwatchRankingList(users, ctx.URI())) return ctx.HTML(components.OverwatchRankingList(users, ctx.URI()))
} }
// FFXIV ...
func FFXIV(ctx *aero.Context) string {
users := arn.FilterUsers(func(user *arn.User) bool {
return user.HasAvatar() && user.HasNick() && user.IsActive() && user.Accounts.FinalFantasyXIV.ItemLevel > 0
})
// Sort by item level
sort.Slice(users, func(i, j int) bool {
return users[i].Accounts.FinalFantasyXIV.ItemLevel > users[j].Accounts.FinalFantasyXIV.ItemLevel
})
if len(users) > 50 {
users = users[:50]
}
return ctx.HTML(components.FinalFantasyXIVRankingList(users, ctx.URI()))
}
// Staff ... // Staff ...
func Staff(ctx *aero.Context) string { func Staff(ctx *aero.Context) string {
users := arn.FilterUsers(func(user *arn.User) bool { users := arn.FilterUsers(func(user *arn.User) bool {

View File

@ -52,3 +52,4 @@ component UsersTabs(url string)
.tabs .tabs
Tab("Osu", "gamepad", "/users/games/osu") Tab("Osu", "gamepad", "/users/games/osu")
Tab("Overwatch", "overwatch", "/users/games/overwatch") Tab("Overwatch", "overwatch", "/users/games/overwatch")
Tab("FFXIV", "gamepad", "/users/games/ffxiv")

View File

@ -1,6 +1,7 @@
import AnimeNotifier from "../AnimeNotifier" import AnimeNotifier from "../AnimeNotifier"
import { findAllInside } from "../Utils"; import { findAllInside } from "../Utils";
import { showSearchResults } from "./Search" import { showSearchResults } from "./Search"
import { arrayAppend } from "./Serialization";
// newAnimeDiffIgnore // newAnimeDiffIgnore
export function newAnimeDiffIgnore(arn: AnimeNotifier, button: HTMLButtonElement) { export function newAnimeDiffIgnore(arn: AnimeNotifier, button: HTMLButtonElement) {
@ -72,6 +73,17 @@ export async function multiSearchAnime(arn: AnimeNotifier, textarea: HTMLTextAre
showSearchResults(arn, results) showSearchResults(arn, results)
} }
// Download soundtrack file
export async function downloadSoundTrackFile(arn: AnimeNotifier, button: HTMLButtonElement) {
let id = button.dataset.id
try {
await arn.post(`/api/soundtrack/${id}/download`)
arn.reloadContent()
} catch(err) {
arn.statusMessage.showError(err)
}
}
// Start background job // Start background job
export async function startJob(arn: AnimeNotifier, button: HTMLButtonElement) { export async function startJob(arn: AnimeNotifier, button: HTMLButtonElement) {

View File

@ -49,6 +49,13 @@ func Render(obj interface{}, title string, user *arn.User) string {
} }
} }
// Redownload button
track, isSoundTrack := obj.(*arn.SoundTrack)
if isSoundTrack && !track.IsDraft && track.HasMediaByService("Youtube") && track.File == "" && (user.Role == "editor" || user.Role == "admin") {
b.WriteString(`<button class="mountable action" data-action="downloadSoundTrackFile" data-trigger="click" data-id="` + track.ID + `">` + utils.Icon("refresh") + `Redownload</button>`)
}
// Delete button // Delete button
_, isDeletable := obj.(api.Deletable) _, isDeletable := obj.(api.Deletable)