Fixed unused parameters

This commit is contained in:
Eduard Urbach 2019-06-05 16:18:04 +09:00
parent 8b583d46b9
commit 1c0dc14317
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
15 changed files with 18 additions and 23 deletions

View File

@ -1,7 +1,6 @@
package main package main
import ( import (
"fmt"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"strings" "strings"
@ -121,6 +120,6 @@ func testRoute(t *testing.T, app *aero.Application, route string) {
case http.StatusOK, http.StatusTemporaryRedirect, http.StatusPermanentRedirect: case http.StatusOK, http.StatusTemporaryRedirect, http.StatusPermanentRedirect:
// OK // OK
default: default:
panic(fmt.Errorf("%s | Wrong status code | %v instead of %v", route, status, http.StatusOK)) t.Fatalf("%s | Wrong status code | %v instead of %v", route, status, http.StatusOK)
} }
} }

View File

@ -123,12 +123,12 @@ func Get(ctx aero.Context) error {
// Open Graph // Open Graph
customCtx := ctx.(*middleware.OpenGraphContext) customCtx := ctx.(*middleware.OpenGraphContext)
customCtx.OpenGraph = getOpenGraph(ctx, anime) customCtx.OpenGraph = getOpenGraph(anime)
return ctx.HTML(components.Anime(anime, animeListItem, tracks, amvs, amvAppearances, episodes, friends, friendsAnimeListItems, episodeToFriends, user)) return ctx.HTML(components.Anime(anime, animeListItem, tracks, amvs, amvAppearances, episodes, friends, friendsAnimeListItems, episodeToFriends, user))
} }
func getOpenGraph(ctx aero.Context, anime *arn.Anime) *arn.OpenGraph { func getOpenGraph(anime *arn.Anime) *arn.OpenGraph {
description := anime.Summary description := anime.Summary
if len(description) > maxDescriptionLength { if len(description) > maxDescriptionLength {

View File

@ -20,7 +20,7 @@ func editorList(ctx aero.Context, title string, filter func(*arn.SoundTrack) boo
return ctx.Error(http.StatusUnauthorized, "Not authorized") return ctx.Error(http.StatusUnauthorized, "Not authorized")
} }
tracks, count := filterSoundTracks(ctx, user, filter) tracks, count := filterSoundTracks(filter)
url := strings.TrimPrefix(ctx.Path(), "/_") url := strings.TrimPrefix(ctx.Path(), "/_")
return ctx.HTML(components.SoundTracksEditorListFull( return ctx.HTML(components.SoundTracksEditorListFull(
@ -34,7 +34,7 @@ func editorList(ctx aero.Context, title string, filter func(*arn.SoundTrack) boo
} }
// filterSoundTracks filters soundtracks by the given filter function. // filterSoundTracks filters soundtracks by the given filter function.
func filterSoundTracks(ctx aero.Context, user *arn.User, filter func(*arn.SoundTrack) bool) ([]*arn.SoundTrack, int) { func filterSoundTracks(filter func(*arn.SoundTrack) bool) ([]*arn.SoundTrack, int) {
// Filter // Filter
tracks := arn.FilterSoundTracks(func(track *arn.SoundTrack) bool { tracks := arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
return !track.IsDraft && filter(track) return !track.IsDraft && filter(track)

View File

@ -27,6 +27,6 @@ func Feed(ctx aero.Context) error {
} }
customCtx := ctx.(*middleware.OpenGraphContext) customCtx := ctx.(*middleware.OpenGraphContext)
customCtx.OpenGraph = getOpenGraph(ctx, group) customCtx.OpenGraph = getOpenGraph(group)
return ctx.HTML(components.GroupFeed(group, member, user)) return ctx.HTML(components.GroupFeed(group, member, user))
} }

View File

@ -27,6 +27,6 @@ func Info(ctx aero.Context) error {
} }
customCtx := ctx.(*middleware.OpenGraphContext) customCtx := ctx.(*middleware.OpenGraphContext)
customCtx.OpenGraph = getOpenGraph(ctx, group) customCtx.OpenGraph = getOpenGraph(group)
return ctx.HTML(components.GroupInfo(group, member, user)) return ctx.HTML(components.GroupInfo(group, member, user))
} }

View File

@ -27,6 +27,6 @@ func Members(ctx aero.Context) error {
} }
customCtx := ctx.(*middleware.OpenGraphContext) customCtx := ctx.(*middleware.OpenGraphContext)
customCtx.OpenGraph = getOpenGraph(ctx, group) customCtx.OpenGraph = getOpenGraph(group)
return ctx.HTML(components.GroupMembers(group, member, user)) return ctx.HTML(components.GroupMembers(group, member, user))
} }

View File

@ -1,12 +1,11 @@
package group package group
import ( import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn" "github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/assets" "github.com/animenotifier/notify.moe/assets"
) )
func getOpenGraph(ctx aero.Context, group *arn.Group) *arn.OpenGraph { func getOpenGraph(group *arn.Group) *arn.OpenGraph {
return &arn.OpenGraph{ return &arn.OpenGraph{
Tags: map[string]string{ Tags: map[string]string{
"og:title": group.Name, "og:title": group.Name,

View File

@ -1,13 +1,12 @@
package post package post
import ( import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn" "github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/assets" "github.com/animenotifier/notify.moe/assets"
"github.com/animenotifier/notify.moe/utils" "github.com/animenotifier/notify.moe/utils"
) )
func getOpenGraph(ctx aero.Context, post *arn.Post) *arn.OpenGraph { func getOpenGraph(post *arn.Post) *arn.OpenGraph {
openGraph := &arn.OpenGraph{ openGraph := &arn.OpenGraph{
Tags: map[string]string{ Tags: map[string]string{
"og:title": post.TitleByUser(nil), "og:title": post.TitleByUser(nil),

View File

@ -21,6 +21,6 @@ func Get(ctx aero.Context) error {
} }
customCtx := ctx.(*middleware.OpenGraphContext) customCtx := ctx.(*middleware.OpenGraphContext)
customCtx.OpenGraph = getOpenGraph(ctx, post) customCtx.OpenGraph = getOpenGraph(post)
return ctx.HTML(components.Post(post, user)) return ctx.HTML(components.Post(post, user))
} }

View File

@ -20,7 +20,7 @@ func Lyrics(ctx aero.Context) error {
return ctx.Error(http.StatusNotFound, "Track not found", err) return ctx.Error(http.StatusNotFound, "Track not found", err)
} }
openGraph := getOpenGraph(ctx, track) openGraph := getOpenGraph(track)
if track.Lyrics.Native != "" { if track.Lyrics.Native != "" {
openGraph.Tags["og:description"] = utils.CutLongDescription(track.Lyrics.Native) openGraph.Tags["og:description"] = utils.CutLongDescription(track.Lyrics.Native)

View File

@ -3,12 +3,11 @@ package soundtrack
import ( import (
"strings" "strings"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn" "github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/assets" "github.com/animenotifier/notify.moe/assets"
) )
func getOpenGraph(ctx aero.Context, track *arn.SoundTrack) *arn.OpenGraph { func getOpenGraph(track *arn.SoundTrack) *arn.OpenGraph {
openGraph := &arn.OpenGraph{ openGraph := &arn.OpenGraph{
Tags: map[string]string{ Tags: map[string]string{
"og:title": track.Title.ByUser(nil), "og:title": track.Title.ByUser(nil),

View File

@ -21,6 +21,6 @@ func Get(ctx aero.Context) error {
} }
customCtx := ctx.(*middleware.OpenGraphContext) customCtx := ctx.(*middleware.OpenGraphContext)
customCtx.OpenGraph = getOpenGraph(ctx, track) customCtx.OpenGraph = getOpenGraph(track)
return ctx.HTML(components.SoundTrackPage(track, user)) return ctx.HTML(components.SoundTrackPage(track, user))
} }

View File

@ -1,13 +1,12 @@
package thread package thread
import ( import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn" "github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/assets" "github.com/animenotifier/notify.moe/assets"
"github.com/animenotifier/notify.moe/utils" "github.com/animenotifier/notify.moe/utils"
) )
func getOpenGraph(ctx aero.Context, thread *arn.Thread) *arn.OpenGraph { func getOpenGraph(thread *arn.Thread) *arn.OpenGraph {
openGraph := &arn.OpenGraph{ openGraph := &arn.OpenGraph{
Tags: map[string]string{ Tags: map[string]string{
"og:title": thread.Title, "og:title": thread.Title,

View File

@ -23,6 +23,6 @@ func Get(ctx aero.Context) error {
} }
customCtx := ctx.(*middleware.OpenGraphContext) customCtx := ctx.(*middleware.OpenGraphContext)
customCtx.OpenGraph = getOpenGraph(ctx, thread) customCtx.OpenGraph = getOpenGraph(thread)
return ctx.HTML(components.Thread(thread, user)) return ctx.HTML(components.Thread(thread, user))
} }

View File

@ -168,7 +168,7 @@ func RenderField(b *strings.Builder, v *reflect.Value, field reflect.StructField
// Any kind of array // Any kind of array
if strings.HasPrefix(fieldType, "[]") { if strings.HasPrefix(fieldType, "[]") {
renderSliceField(b, v, field, idPrefix, fieldType, fieldValue) renderSliceField(b, field, idPrefix, fieldType, fieldValue)
return return
} }
@ -258,7 +258,7 @@ func renderStringField(b *strings.Builder, v *reflect.Value, field reflect.Struc
} }
// Slice field // Slice field
func renderSliceField(b *strings.Builder, v *reflect.Value, field reflect.StructField, idPrefix string, fieldType string, fieldValue reflect.Value) { func renderSliceField(b *strings.Builder, field reflect.StructField, idPrefix string, fieldType string, fieldValue reflect.Value) {
b.WriteString(`<div class="widget-section">`) b.WriteString(`<div class="widget-section">`)
b.WriteString(`<h3 class="widget-title">`) b.WriteString(`<h3 class="widget-title">`)
b.WriteString(field.Name) b.WriteString(field.Name)