Deleted utils.GetUser
This commit is contained in:
parent
ad9870b1c1
commit
daed4146ed
@ -166,3 +166,20 @@ func SortUsersFollowers(users []*User) map[string]int {
|
|||||||
|
|
||||||
return followCount
|
return followCount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SameUser returns true or false depending on if the users are the same.
|
||||||
|
func SameUser(a *User, b *User) bool {
|
||||||
|
if a == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if b == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if a.ID == b.ID {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/aerogo/log"
|
"github.com/aerogo/log"
|
||||||
"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"
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
"golang.org/x/oauth2/facebook"
|
"golang.org/x/oauth2/facebook"
|
||||||
@ -100,7 +99,7 @@ func Facebook(app *aero.Application, authLog *log.Log) {
|
|||||||
fbUser.Email = strings.Replace(fbUser.Email, "googlemail.com", "gmail.com", 1)
|
fbUser.Email = strings.Replace(fbUser.Email, "googlemail.com", "gmail.com", 1)
|
||||||
|
|
||||||
// Is this an existing user connecting another social account?
|
// Is this an existing user connecting another social account?
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user != nil {
|
if user != nil {
|
||||||
// Add FacebookToUser reference
|
// Add FacebookToUser reference
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/aerogo/log"
|
"github.com/aerogo/log"
|
||||||
"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"
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
"golang.org/x/oauth2/google"
|
"golang.org/x/oauth2/google"
|
||||||
@ -111,7 +110,7 @@ func Google(app *aero.Application, authLog *log.Log) {
|
|||||||
googleUser.Email = strings.Replace(googleUser.Email, "googlemail.com", "gmail.com", 1)
|
googleUser.Email = strings.Replace(googleUser.Email, "googlemail.com", "gmail.com", 1)
|
||||||
|
|
||||||
// Is this an existing user connecting another social account?
|
// Is this an existing user connecting another social account?
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user != nil {
|
if user != nil {
|
||||||
// Add GoogleToUser reference
|
// Add GoogleToUser reference
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/aerogo/log"
|
"github.com/aerogo/log"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Logout is called when the user clicks the logout button.
|
// Logout is called when the user clicks the logout button.
|
||||||
@ -13,7 +13,7 @@ import (
|
|||||||
func Logout(app *aero.Application, authLog *log.Log) {
|
func Logout(app *aero.Application, authLog *log.Log) {
|
||||||
app.Get("/logout", func(ctx aero.Context) error {
|
app.Get("/logout", func(ctx aero.Context) error {
|
||||||
if ctx.HasSession() {
|
if ctx.HasSession() {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user != nil {
|
if user != nil {
|
||||||
authLog.Info("%s logged out | %s | %s | %s | %s", user.Nick, user.ID, ctx.IP(), user.Email, user.RealName())
|
authLog.Info("%s logged out | %s | %s | %s | %s", user.Nick, user.ID, ctx.IP(), user.Email, user.RealName())
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
"github.com/aerogo/log"
|
"github.com/aerogo/log"
|
||||||
"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/gomodule/oauth1/oauth"
|
"github.com/gomodule/oauth1/oauth"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
)
|
)
|
||||||
@ -112,7 +111,7 @@ func Twitter(app *aero.Application, authLog *log.Log) {
|
|||||||
twUser.Email = strings.Replace(twUser.Email, "googlemail.com", "gmail.com", 1)
|
twUser.Email = strings.Replace(twUser.Email, "googlemail.com", "gmail.com", 1)
|
||||||
|
|
||||||
// Is this an existing user connecting another social account?
|
// Is this an existing user connecting another social account?
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user != nil {
|
if user != nil {
|
||||||
// Add TwitterToUser reference
|
// Add TwitterToUser reference
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/aerogo/log"
|
"github.com/aerogo/log"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -54,7 +54,7 @@ func logRequest(ctx aero.Context, responseTime time.Duration) {
|
|||||||
|
|
||||||
responseTimeString = strings.Repeat(" ", repeatSpaceCount) + responseTimeString
|
responseTimeString = strings.Repeat(" ", repeatSpaceCount) + responseTimeString
|
||||||
|
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
ip := ctx.IP()
|
ip := ctx.IP()
|
||||||
hostNames, cached := GetHostsForIP(ip)
|
hostNames, cached := GetHostsForIP(ip)
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/aerogo/http/client"
|
"github.com/aerogo/http/client"
|
||||||
"github.com/akyoto/color"
|
"github.com/akyoto/color"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/mssola/user_agent"
|
"github.com/mssola/user_agent"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -25,7 +24,7 @@ func UserInfo(next aero.Handler) aero.Handler {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
// When there's no user logged in, nothing to update
|
// When there's no user logged in, nothing to update
|
||||||
if user == nil {
|
if user == nil {
|
||||||
|
@ -30,7 +30,7 @@ component AnimeListScrollable(animeListItems []*arn.AnimeListItem, viewUser *arn
|
|||||||
if item.Status != arn.AnimeListStatusCompleted
|
if item.Status != arn.AnimeListStatusCompleted
|
||||||
.anime-list-item-episodes
|
.anime-list-item-episodes
|
||||||
.anime-list-item-episodes-watched
|
.anime-list-item-episodes-watched
|
||||||
.action(contenteditable=utils.SameUser(user, viewUser), data-field="Episodes", data-type="number", data-trigger="focusout", data-action="save")= item.Episodes
|
.action(contenteditable=arn.SameUser(user, viewUser), data-field="Episodes", data-type="number", data-trigger="focusout", data-action="save")= item.Episodes
|
||||||
|
|
||||||
if item.Status == arn.AnimeListStatusWatching && user != nil && user.ID == viewUser.ID
|
if item.Status == arn.AnimeListStatusWatching && user != nil && user.ID == viewUser.ID
|
||||||
.plus-episode.action(data-action="increaseEpisode", data-trigger="click") +
|
.plus-episode.action(data-action="increaseEpisode", data-trigger="click") +
|
||||||
@ -41,4 +41,4 @@ component AnimeListScrollable(animeListItems []*arn.AnimeListItem, viewUser *arn
|
|||||||
.anime-list-item-episodes-max= item.Anime().EpisodeCountString()
|
.anime-list-item-episodes-max= item.Anime().EpisodeCountString()
|
||||||
|
|
||||||
.anime-list-item-rating-container
|
.anime-list-item-rating-container
|
||||||
.anime-list-item-rating.action.tip(contenteditable=utils.SameUser(user, viewUser), data-field="Rating.Overall", data-type="number", data-trigger="focusout", data-action="save", aria-label="O: " + utils.FormatRating(item.Rating.Overall) + " | S: " + utils.FormatRating(item.Rating.Story) + " | V: " + utils.FormatRating(item.Rating.Visuals) + " | M: " + utils.FormatRating(item.Rating.Soundtrack))= utils.FormatRating(item.Rating.Overall)
|
.anime-list-item-rating.action.tip(contenteditable=arn.SameUser(user, viewUser), data-field="Rating.Overall", data-type="number", data-trigger="focusout", data-action="save", aria-label="O: " + utils.FormatRating(item.Rating.Overall) + " | S: " + utils.FormatRating(item.Rating.Story) + " | V: " + utils.FormatRating(item.Rating.Visuals) + " | M: " + utils.FormatRating(item.Rating.Soundtrack))= utils.FormatRating(item.Rating.Overall)
|
||||||
|
@ -3,19 +3,18 @@ package activity
|
|||||||
import (
|
import (
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Global activity page.
|
// Global activity page.
|
||||||
func Global(ctx aero.Context) error {
|
func Global(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
activities := fetchActivities(user, false)
|
activities := fetchActivities(user, false)
|
||||||
return render(ctx, activities)
|
return render(ctx, activities)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Followed activity page.
|
// Followed activity page.
|
||||||
func Followed(ctx aero.Context) error {
|
func Followed(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
activities := fetchActivities(user, true)
|
activities := fetchActivities(user, true)
|
||||||
return render(ctx, activities)
|
return render(ctx, activities)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ const (
|
|||||||
|
|
||||||
// render renders the activities page with the given activities.
|
// render renders the activities page with the given activities.
|
||||||
func render(ctx aero.Context, allActivities []arn.Activity) error {
|
func render(ctx aero.Context, allActivities []arn.Activity) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
index, _ := ctx.GetInt("index")
|
index, _ := ctx.GetInt("index")
|
||||||
|
|
||||||
// Slice the part that we need
|
// Slice the part that we need
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/shirou/gopsutil/cpu"
|
"github.com/shirou/gopsutil/cpu"
|
||||||
"github.com/shirou/gopsutil/disk"
|
"github.com/shirou/gopsutil/disk"
|
||||||
"github.com/shirou/gopsutil/host"
|
"github.com/shirou/gopsutil/host"
|
||||||
@ -16,7 +16,7 @@ import (
|
|||||||
|
|
||||||
// Get admin page.
|
// Get admin page.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
||||||
return ctx.Redirect(http.StatusTemporaryRedirect, "/")
|
return ctx.Redirect(http.StatusTemporaryRedirect, "/")
|
||||||
|
@ -7,12 +7,11 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// PaymentHistory ...
|
// PaymentHistory ...
|
||||||
func PaymentHistory(ctx aero.Context) error {
|
func PaymentHistory(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
|
@ -7,12 +7,11 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// PurchaseHistory ...
|
// PurchaseHistory ...
|
||||||
func PurchaseHistory(ctx aero.Context) error {
|
func PurchaseHistory(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
// UserRegistrations ...
|
// UserRegistrations ...
|
||||||
func UserRegistrations(ctx aero.Context) error {
|
func UserRegistrations(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
|
@ -7,14 +7,13 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/middleware"
|
"github.com/animenotifier/notify.moe/middleware"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get a single AMV.
|
// Get a single AMV.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
amv, err := arn.GetAMV(id)
|
amv, err := arn.GetAMV(id)
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Error(http.StatusNotFound, "AMV not found", err)
|
return ctx.Error(http.StatusNotFound, "AMV not found", err)
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/editform"
|
"github.com/animenotifier/notify.moe/utils/editform"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,7 +13,7 @@ import (
|
|||||||
func Edit(ctx aero.Context) error {
|
func Edit(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
amv, err := arn.GetAMV(id)
|
amv, err := arn.GetAMV(id)
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Error(http.StatusNotFound, "AMV not found", err)
|
return ctx.Error(http.StatusNotFound, "AMV not found", err)
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ const (
|
|||||||
|
|
||||||
// render renders the AMVs page with the given AMVs.
|
// render renders the AMVs page with the given AMVs.
|
||||||
func render(ctx aero.Context, allAMVs []*arn.AMV) error {
|
func render(ctx aero.Context, allAMVs []*arn.AMV) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
index, _ := ctx.GetInt("index")
|
index, _ := ctx.GetInt("index")
|
||||||
tag := ctx.Get("tag")
|
tag := ctx.Get("tag")
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/assets"
|
"github.com/animenotifier/notify.moe/assets"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/middleware"
|
"github.com/animenotifier/notify.moe/middleware"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -22,7 +21,7 @@ const (
|
|||||||
// Get anime page.
|
// Get anime page.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
anime, err := arn.GetAnime(id)
|
anime, err := arn.GetAnime(id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -3,8 +3,6 @@ package anime
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
|
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
@ -14,7 +12,7 @@ import (
|
|||||||
// Characters ...
|
// Characters ...
|
||||||
func Characters(ctx aero.Context) error {
|
func Characters(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
anime, err := arn.GetAnime(id)
|
anime, err := arn.GetAnime(id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
@ -12,7 +11,7 @@ import (
|
|||||||
|
|
||||||
// Comments ...
|
// Comments ...
|
||||||
func Comments(ctx aero.Context) error {
|
func Comments(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
anime, err := arn.GetAnime(id)
|
anime, err := arn.GetAnime(id)
|
||||||
|
|
||||||
|
@ -6,14 +6,13 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/editform"
|
"github.com/animenotifier/notify.moe/utils/editform"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Main anime edit page.
|
// Main anime edit page.
|
||||||
func Main(ctx aero.Context) error {
|
func Main(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this anime")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this anime")
|
||||||
@ -31,7 +30,7 @@ func Main(ctx aero.Context) error {
|
|||||||
// Images anime images edit page.
|
// Images anime images edit page.
|
||||||
func Images(ctx aero.Context) error {
|
func Images(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this anime")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this anime")
|
||||||
@ -49,7 +48,7 @@ func Images(ctx aero.Context) error {
|
|||||||
// Characters anime characters edit page.
|
// Characters anime characters edit page.
|
||||||
func Characters(ctx aero.Context) error {
|
func Characters(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit")
|
||||||
@ -73,7 +72,7 @@ func Characters(ctx aero.Context) error {
|
|||||||
// Relations anime relations edit page.
|
// Relations anime relations edit page.
|
||||||
func Relations(ctx aero.Context) error {
|
func Relations(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit")
|
||||||
@ -97,7 +96,7 @@ func Relations(ctx aero.Context) error {
|
|||||||
// Episodes anime episodes edit page.
|
// Episodes anime episodes edit page.
|
||||||
func Episodes(ctx aero.Context) error {
|
func Episodes(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit")
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
@ -12,7 +11,7 @@ import (
|
|||||||
|
|
||||||
// Episodes ...
|
// Episodes ...
|
||||||
func Episodes(ctx aero.Context) error {
|
func Episodes(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
anime, err := arn.GetAnime(id)
|
anime, err := arn.GetAnime(id)
|
||||||
episodeToFriends := map[int][]*arn.User{}
|
episodeToFriends := map[int][]*arn.User{}
|
||||||
|
@ -6,12 +6,11 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Relations ...
|
// Relations ...
|
||||||
func Relations(ctx aero.Context) error {
|
func Relations(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
|
|
||||||
anime, err := arn.GetAnime(id)
|
anime, err := arn.GetAnime(id)
|
||||||
|
@ -3,8 +3,6 @@ package anime
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
|
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
@ -14,7 +12,7 @@ import (
|
|||||||
// Tracks ...
|
// Tracks ...
|
||||||
func Tracks(ctx aero.Context) error {
|
func Tracks(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
anime, err := arn.GetAnime(id)
|
anime, err := arn.GetAnime(id)
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// DeleteKitsu marks an anime for deletion.
|
// DeleteKitsu marks an anime for deletion.
|
||||||
@ -14,7 +13,7 @@ func DeleteKitsu(ctx aero.Context) error {
|
|||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
|
|
||||||
// Is the user allowed to delete?
|
// Is the user allowed to delete?
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
||||||
|
@ -10,13 +10,12 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Kitsu anime import.
|
// Kitsu anime import.
|
||||||
func Kitsu(ctx aero.Context) error {
|
func Kitsu(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/assets"
|
"github.com/animenotifier/notify.moe/assets"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/middleware"
|
"github.com/animenotifier/notify.moe/middleware"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,7 +19,7 @@ const (
|
|||||||
|
|
||||||
// Filter filters a user's anime list item by the status.
|
// Filter filters a user's anime list item by the status.
|
||||||
func Filter(ctx aero.Context) error {
|
func Filter(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
status := ctx.Get("status")
|
status := ctx.Get("status")
|
||||||
sortBy := arn.SortByRating
|
sortBy := arn.SortByRating
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// DeleteConfirmation shows the confirmation page before deleting an anime list.
|
// DeleteConfirmation shows the confirmation page before deleting an anime list.
|
||||||
func DeleteConfirmation(ctx aero.Context) error {
|
func DeleteConfirmation(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
@ -21,7 +21,7 @@ func DeleteConfirmation(ctx aero.Context) error {
|
|||||||
|
|
||||||
// Delete deletes your entire anime list.
|
// Delete deletes your entire anime list.
|
||||||
func Delete(ctx aero.Context) error {
|
func Delete(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
|
@ -4,12 +4,12 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Redirect to the full URL including the user nick.
|
// Redirect to the full URL including the user nick.
|
||||||
func Redirect(ctx aero.Context) error {
|
func Redirect(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
|
@ -7,12 +7,11 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get anime page.
|
// Get anime page.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
nick := ctx.Get("nick")
|
nick := ctx.Get("nick")
|
||||||
viewUser, err := arn.GetUserByNick(nick)
|
viewUser, err := arn.GetUserByNick(nick)
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ var weekdayNames = []string{
|
|||||||
|
|
||||||
// Get renders the calendar page.
|
// Get renders the calendar page.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
oneWeek := 7 * 24 * time.Hour
|
oneWeek := 7 * 24 * time.Hour
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
@ -19,7 +19,7 @@ const (
|
|||||||
|
|
||||||
// Get character.
|
// Get character.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
character, err := arn.GetCharacter(id)
|
character, err := arn.GetCharacter(id)
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/editform"
|
"github.com/animenotifier/notify.moe/utils/editform"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,7 +13,7 @@ import (
|
|||||||
func Edit(ctx aero.Context) error {
|
func Edit(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
character, err := arn.GetCharacter(id)
|
character, err := arn.GetCharacter(id)
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Error(http.StatusNotFound, "Character not found", err)
|
return ctx.Error(http.StatusNotFound, "Character not found", err)
|
||||||
@ -27,7 +26,7 @@ func Edit(ctx aero.Context) error {
|
|||||||
func EditImages(ctx aero.Context) error {
|
func EditImages(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
character, err := arn.GetCharacter(id)
|
character, err := arn.GetCharacter(id)
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Error(http.StatusNotFound, "Character not found", err)
|
return ctx.Error(http.StatusNotFound, "Character not found", err)
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ const (
|
|||||||
|
|
||||||
// render renders the characters page with the given characters.
|
// render renders the characters page with the given characters.
|
||||||
func render(ctx aero.Context, allCharacters []*arn.Character) error {
|
func render(ctx aero.Context, allCharacters []*arn.Character) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
index, _ := ctx.GetInt("index")
|
index, _ := ctx.GetInt("index")
|
||||||
tag := ctx.Get("tag")
|
tag := ctx.Get("tag")
|
||||||
|
|
||||||
|
@ -3,15 +3,14 @@ package charge
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/animenotifier/notify.moe/components"
|
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
|
"github.com/animenotifier/notify.moe/components"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get charge page.
|
// Get charge page.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
|
@ -8,12 +8,11 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// All renders an index of all companies.
|
// All renders an index of all companies.
|
||||||
func All(ctx aero.Context) error {
|
func All(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
companies := arn.FilterCompanies(func(company *arn.Company) bool {
|
companies := arn.FilterCompanies(func(company *arn.Company) bool {
|
||||||
return !company.IsDraft
|
return !company.IsDraft
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -12,7 +11,7 @@ const maxPopularCompanies = 10
|
|||||||
|
|
||||||
// Popular renders the best companies.
|
// Popular renders the best companies.
|
||||||
func Popular(ctx aero.Context) error {
|
func Popular(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
index, _ := ctx.GetInt("index")
|
index, _ := ctx.GetInt("index")
|
||||||
|
|
||||||
// Fetch all eligible companies
|
// Fetch all eligible companies
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
// Get renders a company page.
|
// Get renders a company page.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
company, err := arn.GetCompany(id)
|
company, err := arn.GetCompany(id)
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/assets"
|
"github.com/animenotifier/notify.moe/assets"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/middleware"
|
"github.com/animenotifier/notify.moe/middleware"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/editform"
|
"github.com/animenotifier/notify.moe/utils/editform"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,7 +15,7 @@ import (
|
|||||||
func Edit(ctx aero.Context) error {
|
func Edit(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
company, err := arn.GetCompany(id)
|
company, err := arn.GetCompany(id)
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Error(http.StatusNotFound, "Company not found", err)
|
return ctx.Error(http.StatusNotFound, "Company not found", err)
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
// AnimeList ...
|
// AnimeList ...
|
||||||
func AnimeList(ctx aero.Context) error {
|
func AnimeList(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
nickA := ctx.Get("nick-1")
|
nickA := ctx.Get("nick-1")
|
||||||
nickB := ctx.Get("nick-2")
|
nickB := ctx.Get("nick-2")
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -19,7 +18,7 @@ const (
|
|||||||
|
|
||||||
// Get edit log.
|
// Get edit log.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
index, _ := ctx.GetInt("index")
|
index, _ := ctx.GetInt("index")
|
||||||
nick := ctx.Get("nick")
|
nick := ctx.Get("nick")
|
||||||
|
|
||||||
|
@ -7,12 +7,11 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get ...
|
// Get ...
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
||||||
return ctx.Redirect(http.StatusTemporaryRedirect, "/")
|
return ctx.Redirect(http.StatusTemporaryRedirect, "/")
|
||||||
|
@ -7,14 +7,13 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxAnimeEntries = 70
|
const maxAnimeEntries = 70
|
||||||
|
|
||||||
// editorList renders the anime list with the given title and filter.
|
// editorList renders the anime list with the given title and filter.
|
||||||
func editorList(ctx aero.Context, title string, filter func(*arn.Anime) bool, searchLink func(*arn.Anime) string) error {
|
func editorList(ctx aero.Context, title string, filter func(*arn.Anime) bool, searchLink func(*arn.Anime) string) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
||||||
|
@ -6,14 +6,13 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxEntries = 70
|
const maxEntries = 70
|
||||||
|
|
||||||
// NoDescription ...
|
// NoDescription ...
|
||||||
func NoDescription(ctx aero.Context) error {
|
func NoDescription(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
||||||
return ctx.Redirect(http.StatusTemporaryRedirect, "/")
|
return ctx.Redirect(http.StatusTemporaryRedirect, "/")
|
||||||
|
@ -7,14 +7,13 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxSoundTrackEntries = 70
|
const maxSoundTrackEntries = 70
|
||||||
|
|
||||||
// editorList renders the soundtrack list with the given title and filter.
|
// editorList renders the soundtrack list with the given title and filter.
|
||||||
func editorList(ctx aero.Context, title string, filter func(*arn.SoundTrack) bool, searchLink func(*arn.SoundTrack) string) error {
|
func editorList(ctx aero.Context, title string, filter func(*arn.SoundTrack) bool, searchLink func(*arn.SoundTrack) string) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
if user == nil || (user.Role != "admin" && user.Role != "editor") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
)
|
)
|
||||||
@ -30,7 +31,7 @@ var jobLogs = []string{}
|
|||||||
|
|
||||||
// Overview shows all background jobs.
|
// Overview shows all background jobs.
|
||||||
func Overview(ctx aero.Context) error {
|
func Overview(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
jobs := []*utils.JobInfo{}
|
jobs := []*utils.JobInfo{}
|
||||||
|
|
||||||
for _, job := range jobInfo {
|
for _, job := range jobInfo {
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Only allow one job to be started at a time
|
// Only allow one job to be started at a time
|
||||||
@ -18,7 +17,7 @@ func Start(ctx aero.Context) error {
|
|||||||
jobStartMutex.Lock()
|
jobStartMutex.Lock()
|
||||||
defer jobStartMutex.Unlock()
|
defer jobStartMutex.Unlock()
|
||||||
|
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
return ctx.Error(http.StatusUnauthorized, "Not authorized")
|
||||||
|
@ -7,12 +7,11 @@ import (
|
|||||||
"github.com/animenotifier/kitsu"
|
"github.com/animenotifier/kitsu"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewKitsuAnime ...
|
// NewKitsuAnime ...
|
||||||
func NewKitsuAnime(ctx aero.Context) error {
|
func NewKitsuAnime(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
finder := arn.NewAnimeFinder("kitsu/anime")
|
finder := arn.NewAnimeFinder("kitsu/anime")
|
||||||
deletedIDs, err := arn.GetIDList("deleted kitsu anime")
|
deletedIDs, err := arn.GetIDList("deleted kitsu anime")
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ type diffFunction func(*arn.Anime, *mal.Anime) []animediff.Difference
|
|||||||
|
|
||||||
// CompareMAL ...
|
// CompareMAL ...
|
||||||
func CompareMAL(ctx aero.Context) error {
|
func CompareMAL(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
year := ctx.Get("year")
|
year := ctx.Get("year")
|
||||||
status := ctx.Get("status")
|
status := ctx.Get("status")
|
||||||
season := ctx.Get("season")
|
season := ctx.Get("season")
|
||||||
|
@ -4,13 +4,13 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get anime list in the browser extension.
|
// Get anime list in the browser extension.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.HTML(components.Login("_blank"))
|
return ctx.HTML(components.Login("_blank"))
|
||||||
|
@ -7,13 +7,12 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
minio "github.com/minio/minio-go/v6"
|
minio "github.com/minio/minio-go/v6"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get renders the anime episode.
|
// Get renders the anime episode.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
|
|
||||||
// Get episode
|
// Get episode
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Filter filters the anime for the explore page.
|
// Filter filters the anime for the explore page.
|
||||||
@ -16,7 +15,7 @@ func Filter(ctx aero.Context) error {
|
|||||||
season := ctx.Get("season")
|
season := ctx.Get("season")
|
||||||
status := ctx.Get("status")
|
status := ctx.Get("status")
|
||||||
typ := ctx.Get("type")
|
typ := ctx.Get("type")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
if year == "" {
|
if year == "" {
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,7 +18,7 @@ const (
|
|||||||
|
|
||||||
// AnimeByAverageColor returns all anime with an image in the given color.
|
// AnimeByAverageColor returns all anime with an image in the given color.
|
||||||
func AnimeByAverageColor(ctx aero.Context) error {
|
func AnimeByAverageColor(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
color := ctx.Get("color")
|
color := ctx.Get("color")
|
||||||
index, _ := ctx.GetInt("index")
|
index, _ := ctx.GetInt("index")
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
// Sequels ...
|
// Sequels ...
|
||||||
func Sequels(ctx aero.Context) error {
|
func Sequels(ctx aero.Context) error {
|
||||||
nick := ctx.Get("nick")
|
nick := ctx.Get("nick")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
viewUser, err := arn.GetUserByNick(nick)
|
viewUser, err := arn.GetUserByNick(nick)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -14,7 +14,7 @@ const minYear = 1963
|
|||||||
|
|
||||||
// Get ...
|
// Get ...
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
maxYear := time.Now().Year() - 1
|
maxYear := time.Now().Year() - 1
|
||||||
hallOfFameEntries := []*utils.HallOfFameEntry{}
|
hallOfFameEntries := []*utils.HallOfFameEntry{}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const animePerPage = 100
|
const animePerPage = 100
|
||||||
@ -14,7 +13,7 @@ const animeRatingCountThreshold = 5
|
|||||||
|
|
||||||
// Get renders the genre page.
|
// Get renders the genre page.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
genreName := ctx.Get("name")
|
genreName := ctx.Get("name")
|
||||||
animes := []*arn.Anime{}
|
animes := []*arn.Anime{}
|
||||||
|
|
||||||
|
@ -4,12 +4,11 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get ...
|
// Get ...
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
genres := []string{}
|
genres := []string{}
|
||||||
genreToAnime := map[string]*arn.Anime{}
|
genreToAnime := map[string]*arn.Anime{}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/editform"
|
"github.com/animenotifier/notify.moe/utils/editform"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,7 +13,7 @@ import (
|
|||||||
func Edit(ctx aero.Context) error {
|
func Edit(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
group, err := arn.GetGroup(id)
|
group, err := arn.GetGroup(id)
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Error(http.StatusNotFound, "Group not found", err)
|
return ctx.Error(http.StatusNotFound, "Group not found", err)
|
||||||
@ -33,7 +32,7 @@ func Edit(ctx aero.Context) error {
|
|||||||
func EditImage(ctx aero.Context) error {
|
func EditImage(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
group, err := arn.GetGroup(id)
|
group, err := arn.GetGroup(id)
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Error(http.StatusNotFound, "Group not found", err)
|
return ctx.Error(http.StatusNotFound, "Group not found", err)
|
||||||
|
@ -7,12 +7,11 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/middleware"
|
"github.com/animenotifier/notify.moe/middleware"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Feed shows the group front page.
|
// Feed shows the group front page.
|
||||||
func Feed(ctx aero.Context) error {
|
func Feed(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
group, err := arn.GetGroup(id)
|
group, err := arn.GetGroup(id)
|
||||||
|
|
||||||
|
@ -7,12 +7,11 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/middleware"
|
"github.com/animenotifier/notify.moe/middleware"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Info shows the group information page.
|
// Info shows the group information page.
|
||||||
func Info(ctx aero.Context) error {
|
func Info(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
group, err := arn.GetGroup(id)
|
group, err := arn.GetGroup(id)
|
||||||
|
|
||||||
|
@ -7,12 +7,11 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/middleware"
|
"github.com/animenotifier/notify.moe/middleware"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Members shows the group members.
|
// Members shows the group members.
|
||||||
func Members(ctx aero.Context) error {
|
func Members(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
group, err := arn.GetGroup(id)
|
group, err := arn.GetGroup(id)
|
||||||
|
|
||||||
|
@ -4,14 +4,13 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Joined shows the most popular joined groups.
|
// Joined shows the most popular joined groups.
|
||||||
func Joined(ctx aero.Context) error {
|
func Joined(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ const (
|
|||||||
|
|
||||||
// render renders the groups page with the given groups.
|
// render renders the groups page with the given groups.
|
||||||
func render(ctx aero.Context, allGroups []*arn.Group) error {
|
func render(ctx aero.Context, allGroups []*arn.Group) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
index, _ := ctx.GetInt("index")
|
index, _ := ctx.GetInt("index")
|
||||||
|
|
||||||
// Slice the part that we need
|
// Slice the part that we need
|
||||||
|
@ -2,13 +2,14 @@ package home
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/pages/frontpage"
|
"github.com/animenotifier/notify.moe/pages/frontpage"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get the anime list or the frontpage when logged out.
|
// Get the anime list or the frontpage when logged out.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return frontpage.Get(ctx)
|
return frontpage.Get(ctx)
|
||||||
|
@ -8,12 +8,11 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get inventory page.
|
// Get inventory page.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
viewUser := user
|
viewUser := user
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
|
@ -4,13 +4,13 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get ...
|
// Get ...
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
|
@ -10,12 +10,11 @@ import (
|
|||||||
"github.com/animenotifier/anilist"
|
"github.com/animenotifier/anilist"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Preview shows an import preview.
|
// Preview shows an import preview.
|
||||||
func Preview(ctx aero.Context) error {
|
func Preview(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
@ -32,7 +31,7 @@ func Preview(ctx aero.Context) error {
|
|||||||
|
|
||||||
// Finish ...
|
// Finish ...
|
||||||
func Finish(ctx aero.Context) error {
|
func Finish(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
@ -74,7 +73,7 @@ func Finish(ctx aero.Context) error {
|
|||||||
|
|
||||||
// getMatches finds and returns all matches for the logged in user.
|
// getMatches finds and returns all matches for the logged in user.
|
||||||
func getMatches(ctx aero.Context) ([]*arn.AniListMatch, error) {
|
func getMatches(ctx aero.Context) ([]*arn.AniListMatch, error) {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return nil, errors.New("Not logged in")
|
return nil, errors.New("Not logged in")
|
||||||
|
@ -9,12 +9,11 @@ import (
|
|||||||
"github.com/animenotifier/kitsu"
|
"github.com/animenotifier/kitsu"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Preview shows an import preview.
|
// Preview shows an import preview.
|
||||||
func Preview(ctx aero.Context) error {
|
func Preview(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
@ -31,7 +30,7 @@ func Preview(ctx aero.Context) error {
|
|||||||
|
|
||||||
// Finish ...
|
// Finish ...
|
||||||
func Finish(ctx aero.Context) error {
|
func Finish(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
@ -85,7 +84,7 @@ func Finish(ctx aero.Context) error {
|
|||||||
|
|
||||||
// getMatches finds and returns all matches for the logged in user.
|
// getMatches finds and returns all matches for the logged in user.
|
||||||
func getMatches(ctx aero.Context) ([]*arn.KitsuMatch, error) {
|
func getMatches(ctx aero.Context) ([]*arn.KitsuMatch, error) {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return nil, errors.New("Not logged in")
|
return nil, errors.New("Not logged in")
|
||||||
|
@ -10,12 +10,11 @@ import (
|
|||||||
"github.com/animenotifier/mal"
|
"github.com/animenotifier/mal"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Preview shows an import preview.
|
// Preview shows an import preview.
|
||||||
func Preview(ctx aero.Context) error {
|
func Preview(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
@ -32,7 +31,7 @@ func Preview(ctx aero.Context) error {
|
|||||||
|
|
||||||
// Finish ...
|
// Finish ...
|
||||||
func Finish(ctx aero.Context) error {
|
func Finish(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
@ -79,7 +78,7 @@ func Finish(ctx aero.Context) error {
|
|||||||
|
|
||||||
// getMatches finds and returns all matches for the logged in user.
|
// getMatches finds and returns all matches for the logged in user.
|
||||||
func getMatches(ctx aero.Context) ([]*arn.MyAnimeListMatch, error) {
|
func getMatches(ctx aero.Context) ([]*arn.MyAnimeListMatch, error) {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return nil, errors.New("Not logged in")
|
return nil, errors.New("Not logged in")
|
||||||
|
@ -2,12 +2,12 @@ package me
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get ...
|
// Get ...
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.JSON(nil)
|
return ctx.JSON(nil)
|
||||||
|
@ -4,13 +4,13 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get forums page.
|
// Get forums page.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
|
@ -8,12 +8,11 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"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"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// CountUnseen sends the number of unseen notifications.
|
// CountUnseen sends the number of unseen notifications.
|
||||||
func CountUnseen(ctx aero.Context) error {
|
func CountUnseen(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
@ -26,7 +25,7 @@ func CountUnseen(ctx aero.Context) error {
|
|||||||
|
|
||||||
// MarkNotificationsAsSeen marks all notifications as seen.
|
// MarkNotificationsAsSeen marks all notifications as seen.
|
||||||
func MarkNotificationsAsSeen(ctx aero.Context) error {
|
func MarkNotificationsAsSeen(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
@ -73,7 +72,7 @@ func Latest(ctx aero.Context) error {
|
|||||||
|
|
||||||
// Test sends a test notification to the logged in user.
|
// Test sends a test notification to the logged in user.
|
||||||
func Test(ctx aero.Context) error {
|
func Test(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
|
@ -8,14 +8,13 @@ import (
|
|||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxNotifications = 30
|
const maxNotifications = 30
|
||||||
|
|
||||||
// ByUser shows all notifications sent to the given user.
|
// ByUser shows all notifications sent to the given user.
|
||||||
func ByUser(ctx aero.Context) error {
|
func ByUser(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
return ctx.Error(http.StatusBadRequest, "Not logged in")
|
||||||
|
@ -6,14 +6,13 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"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"
|
|
||||||
paypalsdk "github.com/logpacker/PayPal-Go-SDK"
|
paypalsdk "github.com/logpacker/PayPal-Go-SDK"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreatePayment creates the PayPal payment, typically via a JSON API route.
|
// CreatePayment creates the PayPal payment, typically via a JSON API route.
|
||||||
func CreatePayment(ctx aero.Context) error {
|
func CreatePayment(ctx aero.Context) error {
|
||||||
// Make sure the user is logged in
|
// Make sure the user is logged in
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/arn/stringutils"
|
"github.com/animenotifier/notify.moe/arn/stringutils"
|
||||||
"github.com/animenotifier/notify.moe/assets"
|
"github.com/animenotifier/notify.moe/assets"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const adminID = "4J6qpK1ve"
|
const adminID = "4J6qpK1ve"
|
||||||
@ -18,7 +17,7 @@ const adminID = "4J6qpK1ve"
|
|||||||
// Success is called once the payment has been confirmed by the user on the PayPal website.
|
// Success is called once the payment has been confirmed by the user on the PayPal website.
|
||||||
// However, the actual payment still needs to be executed and can fail.
|
// However, the actual payment still needs to be executed and can fail.
|
||||||
func Success(ctx aero.Context) error {
|
func Success(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
|
@ -6,14 +6,13 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/editform"
|
"github.com/animenotifier/notify.moe/utils/editform"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get post edit page.
|
// Get post edit page.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this post")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this post")
|
||||||
|
@ -7,13 +7,12 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/middleware"
|
"github.com/animenotifier/notify.moe/middleware"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get post.
|
// Get post.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
post, err := arn.GetPost(id)
|
post, err := arn.GetPost(id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -6,13 +6,12 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ReplyUI renders a new post area.
|
// ReplyUI renders a new post area.
|
||||||
func ReplyUI(ctx aero.Context) error {
|
func ReplyUI(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
post, err := arn.GetPost(id)
|
post, err := arn.GetPost(id)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -21,6 +21,6 @@ package profile
|
|||||||
// followers := viewUser.Followers()
|
// followers := viewUser.Followers()
|
||||||
// arn.SortUsersLastSeenFirst(followers)
|
// arn.SortUsersLastSeenFirst(followers)
|
||||||
|
|
||||||
// return ctx.HTML(components.ProfileFollowers(followers, viewUser, utils.GetUser(ctx), ctx.Path()))
|
// return ctx.HTML(components.ProfileFollowers(followers, viewUser, arn.GetUserFromContext(ctx), ctx.Path()))
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
@ -27,6 +27,6 @@ package profile
|
|||||||
// posts = posts[:postLimit]
|
// posts = posts[:postLimit]
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// return ctx.HTML(components.LatestPosts(arn.ToPostables(posts), viewUser, utils.GetUser(ctx), ctx.Path()))
|
// return ctx.HTML(components.LatestPosts(arn.ToPostables(posts), viewUser, arn.GetUserFromContext(ctx), ctx.Path()))
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
@ -33,7 +33,7 @@ func Get(ctx aero.Context) error {
|
|||||||
|
|
||||||
// Profile renders the user profile page of the given viewUser.
|
// Profile renders the user profile page of the given viewUser.
|
||||||
func Profile(ctx aero.Context, viewUser *arn.User) error {
|
func Profile(ctx aero.Context, viewUser *arn.User) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
sortBy := arn.SortByRating
|
sortBy := arn.SortByRating
|
||||||
|
|
||||||
if user != nil {
|
if user != nil {
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Liked shows all liked characters of a particular user.
|
// Liked shows all liked characters of a particular user.
|
||||||
@ -40,5 +39,5 @@ func Liked(ctx aero.Context) error {
|
|||||||
// return aLikes > bLikes
|
// return aLikes > bLikes
|
||||||
})
|
})
|
||||||
|
|
||||||
return ctx.HTML(components.ProfileCharacters(characters, viewUser, utils.GetUser(ctx), ctx.Path()))
|
return ctx.HTML(components.ProfileCharacters(characters, viewUser, arn.GetUserFromContext(ctx), ctx.Path()))
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ package profilequotes
|
|||||||
// func render(ctx aero.Context, fetch func(userID string) []*arn.Quote) string {
|
// func render(ctx aero.Context, fetch func(userID string) []*arn.Quote) string {
|
||||||
// nick := ctx.Get("nick")
|
// nick := ctx.Get("nick")
|
||||||
// index, _ := ctx.GetInt("index")
|
// index, _ := ctx.GetInt("index")
|
||||||
// user := utils.GetUser(ctx)
|
// user := arn.GetUserFromContext(ctx)
|
||||||
// viewUser, err := arn.GetUserByNick(nick)
|
// viewUser, err := arn.GetUserByNick(nick)
|
||||||
|
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
|
@ -19,7 +19,7 @@ package profiletracks
|
|||||||
// func render(ctx aero.Context, fetch func(userID string) []*arn.SoundTrack) string {
|
// func render(ctx aero.Context, fetch func(userID string) []*arn.SoundTrack) string {
|
||||||
// nick := ctx.Get("nick")
|
// nick := ctx.Get("nick")
|
||||||
// index, _ := ctx.GetInt("index")
|
// index, _ := ctx.GetInt("index")
|
||||||
// user := utils.GetUser(ctx)
|
// user := arn.GetUserFromContext(ctx)
|
||||||
// viewUser, err := arn.GetUserByNick(nick)
|
// viewUser, err := arn.GetUserByNick(nick)
|
||||||
|
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
|
@ -98,5 +98,5 @@ package profile
|
|||||||
// arn.NewPieChart("Soundtracks", trackTags),
|
// arn.NewPieChart("Soundtracks", trackTags),
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// return ctx.HTML(components.ProfileStats(&userStats, viewUser, utils.GetUser(ctx), ctx.Path()))
|
// return ctx.HTML(components.ProfileStats(&userStats, viewUser, arn.GetUserFromContext(ctx), ctx.Path()))
|
||||||
// }
|
// }
|
||||||
|
@ -27,5 +27,5 @@ package profile
|
|||||||
// threads = threads[:maxThreads]
|
// threads = threads[:maxThreads]
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// return ctx.HTML(components.ProfileThreads(threads, viewUser, utils.GetUser(ctx), ctx.Path()))
|
// return ctx.HTML(components.ProfileThreads(threads, viewUser, arn.GetUserFromContext(ctx), ctx.Path()))
|
||||||
// }
|
// }
|
||||||
|
@ -9,13 +9,12 @@ import (
|
|||||||
"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/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/editform"
|
"github.com/animenotifier/notify.moe/utils/editform"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Edit quote.
|
// Edit quote.
|
||||||
func Edit(ctx aero.Context) error {
|
func Edit(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
quote, err := arn.GetQuote(id)
|
quote, err := arn.GetQuote(id)
|
||||||
|
|
||||||
|
@ -8,12 +8,11 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/assets"
|
"github.com/animenotifier/notify.moe/assets"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/middleware"
|
"github.com/animenotifier/notify.moe/middleware"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get quote.
|
// Get quote.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
quote, err := arn.GetQuote(id)
|
quote, err := arn.GetQuote(id)
|
||||||
|
|
||||||
|
@ -4,13 +4,12 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Best renders the best quotes.
|
// Best renders the best quotes.
|
||||||
func Best(ctx aero.Context) error {
|
func Best(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
index, _ := ctx.GetInt("index")
|
index, _ := ctx.GetInt("index")
|
||||||
|
|
||||||
// Fetch all eligible quotes
|
// Fetch all eligible quotes
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
"github.com/animenotifier/notify.moe/utils/infinitescroll"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -12,7 +11,7 @@ const maxQuotes = 15
|
|||||||
|
|
||||||
// Latest renders the latest quotes.
|
// Latest renders the latest quotes.
|
||||||
func Latest(ctx aero.Context) error {
|
func Latest(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
index, _ := ctx.GetInt("index")
|
index, _ := ctx.GetInt("index")
|
||||||
|
|
||||||
// Fetch all eligible quotes
|
// Fetch all eligible quotes
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -18,7 +17,7 @@ const (
|
|||||||
|
|
||||||
// Anime shows a list of recommended anime.
|
// Anime shows a list of recommended anime.
|
||||||
func Anime(ctx aero.Context) error {
|
func Anime(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
nick := ctx.Get("nick")
|
nick := ctx.Get("nick")
|
||||||
viewUser, err := arn.GetUserByNick(nick)
|
viewUser, err := arn.GetUserByNick(nick)
|
||||||
|
|
||||||
|
@ -3,9 +3,8 @@ package search
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/arn/search"
|
"github.com/animenotifier/notify.moe/arn/search"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
)
|
)
|
||||||
@ -24,7 +23,7 @@ const (
|
|||||||
// Get search page.
|
// Get search page.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
term := ctx.Get("term")
|
term := ctx.Get("term")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if len(term) > search.MaxSearchTermLength {
|
if len(term) > search.MaxSearchTermLength {
|
||||||
ctx.SetStatus(http.StatusRequestEntityTooLarge)
|
ctx.SetStatus(http.StatusRequestEntityTooLarge)
|
||||||
@ -47,13 +46,13 @@ func Get(ctx aero.Context) error {
|
|||||||
|
|
||||||
// GetEmptySearch renders the search page with no contents.
|
// GetEmptySearch renders the search page with no contents.
|
||||||
func GetEmptySearch(ctx aero.Context) error {
|
func GetEmptySearch(ctx aero.Context) error {
|
||||||
return ctx.HTML(components.SearchResults("", nil, nil, nil, nil, nil, nil, nil, nil, nil, utils.GetUser(ctx)))
|
return ctx.HTML(components.SearchResults("", nil, nil, nil, nil, nil, nil, nil, nil, nil, arn.GetUserFromContext(ctx)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Anime search.
|
// Anime search.
|
||||||
func Anime(ctx aero.Context) error {
|
func Anime(ctx aero.Context) error {
|
||||||
term := ctx.Get("term")
|
term := ctx.Get("term")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if len(term) > search.MaxSearchTermLength {
|
if len(term) > search.MaxSearchTermLength {
|
||||||
ctx.SetStatus(http.StatusRequestEntityTooLarge)
|
ctx.SetStatus(http.StatusRequestEntityTooLarge)
|
||||||
@ -66,7 +65,7 @@ func Anime(ctx aero.Context) error {
|
|||||||
// Characters search.
|
// Characters search.
|
||||||
func Characters(ctx aero.Context) error {
|
func Characters(ctx aero.Context) error {
|
||||||
term := ctx.Get("term")
|
term := ctx.Get("term")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if len(term) > search.MaxSearchTermLength {
|
if len(term) > search.MaxSearchTermLength {
|
||||||
ctx.SetStatus(http.StatusRequestEntityTooLarge)
|
ctx.SetStatus(http.StatusRequestEntityTooLarge)
|
||||||
@ -79,7 +78,7 @@ func Characters(ctx aero.Context) error {
|
|||||||
// Posts search.
|
// Posts search.
|
||||||
func Posts(ctx aero.Context) error {
|
func Posts(ctx aero.Context) error {
|
||||||
term := ctx.Get("term")
|
term := ctx.Get("term")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if len(term) > search.MaxSearchTermLength {
|
if len(term) > search.MaxSearchTermLength {
|
||||||
ctx.SetStatus(http.StatusRequestEntityTooLarge)
|
ctx.SetStatus(http.StatusRequestEntityTooLarge)
|
||||||
@ -92,7 +91,7 @@ func Posts(ctx aero.Context) error {
|
|||||||
// Threads search.
|
// Threads search.
|
||||||
func Threads(ctx aero.Context) error {
|
func Threads(ctx aero.Context) error {
|
||||||
term := ctx.Get("term")
|
term := ctx.Get("term")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if len(term) > search.MaxSearchTermLength {
|
if len(term) > search.MaxSearchTermLength {
|
||||||
ctx.SetStatus(http.StatusRequestEntityTooLarge)
|
ctx.SetStatus(http.StatusRequestEntityTooLarge)
|
||||||
@ -105,7 +104,7 @@ func Threads(ctx aero.Context) error {
|
|||||||
// SoundTracks search.
|
// SoundTracks search.
|
||||||
func SoundTracks(ctx aero.Context) error {
|
func SoundTracks(ctx aero.Context) error {
|
||||||
term := ctx.Get("term")
|
term := ctx.Get("term")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if len(term) > search.MaxSearchTermLength {
|
if len(term) > search.MaxSearchTermLength {
|
||||||
ctx.SetStatus(http.StatusRequestEntityTooLarge)
|
ctx.SetStatus(http.StatusRequestEntityTooLarge)
|
||||||
@ -118,7 +117,7 @@ func SoundTracks(ctx aero.Context) error {
|
|||||||
// AMVs search.
|
// AMVs search.
|
||||||
func AMVs(ctx aero.Context) error {
|
func AMVs(ctx aero.Context) error {
|
||||||
term := ctx.Get("term")
|
term := ctx.Get("term")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if len(term) > search.MaxSearchTermLength {
|
if len(term) > search.MaxSearchTermLength {
|
||||||
ctx.SetStatus(http.StatusRequestEntityTooLarge)
|
ctx.SetStatus(http.StatusRequestEntityTooLarge)
|
||||||
|
@ -5,13 +5,12 @@ import (
|
|||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get settings.
|
// Get settings.
|
||||||
func Get(component func(*arn.User) string) func(aero.Context) error {
|
func Get(component func(*arn.User) string) func(aero.Context) error {
|
||||||
return func(ctx aero.Context) error {
|
return func(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var itemBuyMutex sync.Mutex
|
var itemBuyMutex sync.Mutex
|
||||||
@ -18,7 +17,7 @@ func BuyItem(ctx aero.Context) error {
|
|||||||
defer itemBuyMutex.Unlock()
|
defer itemBuyMutex.Unlock()
|
||||||
|
|
||||||
// Logged in user
|
// Logged in user
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
|
@ -7,12 +7,11 @@ import (
|
|||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// PurchaseHistory ...
|
// PurchaseHistory ...
|
||||||
func PurchaseHistory(ctx aero.Context) error {
|
func PurchaseHistory(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
|
@ -8,12 +8,11 @@ import (
|
|||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get shop page.
|
// Get shop page.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||||
|
@ -5,13 +5,12 @@ import (
|
|||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Download tries to refresh the soundtrack file.
|
// Download tries to refresh the soundtrack file.
|
||||||
func Download(ctx aero.Context) error {
|
func Download(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this soundtrack")
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this soundtrack")
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
|
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/middleware"
|
"github.com/animenotifier/notify.moe/middleware"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
"github.com/animenotifier/notify.moe/utils/editform"
|
"github.com/animenotifier/notify.moe/utils/editform"
|
||||||
|
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
@ -16,7 +15,7 @@ import (
|
|||||||
func Edit(ctx aero.Context) error {
|
func Edit(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
track, err := arn.GetSoundTrack(id)
|
track, err := arn.GetSoundTrack(id)
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Error(http.StatusNotFound, "Track not found", err)
|
return ctx.Error(http.StatusNotFound, "Track not found", err)
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
func Lyrics(ctx aero.Context) error {
|
func Lyrics(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
track, err := arn.GetSoundTrack(id)
|
track, err := arn.GetSoundTrack(id)
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Error(http.StatusNotFound, "Track not found", err)
|
return ctx.Error(http.StatusNotFound, "Track not found", err)
|
||||||
|
@ -7,14 +7,13 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/arn"
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/middleware"
|
"github.com/animenotifier/notify.moe/middleware"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get track.
|
// Get track.
|
||||||
func Get(ctx aero.Context) error {
|
func Get(ctx aero.Context) error {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
track, err := arn.GetSoundTrack(id)
|
track, err := arn.GetSoundTrack(id)
|
||||||
user := utils.GetUser(ctx)
|
user := arn.GetUserFromContext(ctx)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Error(http.StatusNotFound, "Track not found", err)
|
return ctx.Error(http.StatusNotFound, "Track not found", err)
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user