Introduced length limits

This commit is contained in:
2019-08-31 16:52:42 +09:00
parent 9338f7bdeb
commit 3ef41b1cdd
21 changed files with 110 additions and 80 deletions

View File

@ -26,7 +26,7 @@ component AnimeListItem(viewUser *arn.User, item *arn.AnimeListItem, anime *arn.
InputBool("Private", item.Private, "Private", "Hidden entry")
.mountable
InputTextArea("Notes", item.Notes, "Notes", "Your notes")
InputTextArea("Notes", item.Notes, "Notes", "Your notes", 2000)
.buttons.mountable
a.button.mountable(href="/+" + viewUser.Nick + "/animelist/" + item.Status)

View File

@ -5,7 +5,7 @@ component NewThread(user *arn.User)
.widget
input#title.widget-ui-element(type="text", placeholder="Title")
textarea#text.widget-ui-element(placeholder="Content")
textarea#text.widget-ui-element(placeholder="Content", maxlength=limits.DefaultTextAreaMaxLength)
select#tag.widget-ui-element(value="general")
option(value="general") General

View File

@ -1,3 +1,3 @@
component MultiSearch
textarea.action(data-action="multiSearchAnime", data-trigger="change", placeholder="Paste multiple anime titles here, one per line")
textarea.action(data-action="multiSearchAnime", data-trigger="change", placeholder="Paste multiple anime titles here, one per line", maxlength=limits.DefaultTextAreaMaxLength)
#multi-search-anime

View File

@ -1,7 +1,7 @@
package search
import (
"strings"
"net/http"
"github.com/animenotifier/notify.moe/utils"
@ -24,9 +24,12 @@ const (
// Get search page.
func Get(ctx aero.Context) error {
term := ctx.Get("term")
term = strings.TrimPrefix(term, "/")
user := utils.GetUser(ctx)
if len(term) > search.MaxSearchTermLength {
ctx.SetStatus(http.StatusRequestEntityTooLarge)
}
users, animes, posts, threads, tracks, characters, amvs, companies := search.All(
term,
maxUsers,
@ -50,9 +53,12 @@ func GetEmptySearch(ctx aero.Context) error {
// Anime search.
func Anime(ctx aero.Context) error {
term := ctx.Get("term")
term = strings.TrimPrefix(term, "/")
user := utils.GetUser(ctx)
if len(term) > search.MaxSearchTermLength {
ctx.SetStatus(http.StatusRequestEntityTooLarge)
}
animes := search.Anime(term, maxAnime)
return ctx.HTML(components.AnimeSearchResults(animes, user))
}
@ -60,9 +66,12 @@ func Anime(ctx aero.Context) error {
// Characters search.
func Characters(ctx aero.Context) error {
term := ctx.Get("term")
term = strings.TrimPrefix(term, "/")
user := utils.GetUser(ctx)
if len(term) > search.MaxSearchTermLength {
ctx.SetStatus(http.StatusRequestEntityTooLarge)
}
characters := search.Characters(term, maxCharacters)
return ctx.HTML(components.CharacterSearchResults(characters, user))
}
@ -70,29 +79,38 @@ func Characters(ctx aero.Context) error {
// Posts search.
func Posts(ctx aero.Context) error {
term := ctx.Get("term")
term = strings.TrimPrefix(term, "/")
user := utils.GetUser(ctx)
posts := search.Posts(term, maxPosts)
if len(term) > search.MaxSearchTermLength {
ctx.SetStatus(http.StatusRequestEntityTooLarge)
}
posts := search.Posts(term, maxPosts)
return ctx.HTML(components.PostsSearchResults(posts, user))
}
// Threads search.
func Threads(ctx aero.Context) error {
term := ctx.Get("term")
term = strings.TrimPrefix(term, "/")
user := utils.GetUser(ctx)
threads := search.Threads(term, maxThreads)
if len(term) > search.MaxSearchTermLength {
ctx.SetStatus(http.StatusRequestEntityTooLarge)
}
threads := search.Threads(term, maxThreads)
return ctx.HTML(components.ThreadsSearchResults(threads, user))
}
// SoundTracks search.
func SoundTracks(ctx aero.Context) error {
term := ctx.Get("term")
term = strings.TrimPrefix(term, "/")
user := utils.GetUser(ctx)
if len(term) > search.MaxSearchTermLength {
ctx.SetStatus(http.StatusRequestEntityTooLarge)
}
tracks := search.SoundTracks(term, maxSoundTracks)
return ctx.HTML(components.SoundTrackSearchResults(tracks, user))
}
@ -100,9 +118,12 @@ func SoundTracks(ctx aero.Context) error {
// AMVs search.
func AMVs(ctx aero.Context) error {
term := ctx.Get("term")
term = strings.TrimPrefix(term, "/")
user := utils.GetUser(ctx)
if len(term) > search.MaxSearchTermLength {
ctx.SetStatus(http.StatusRequestEntityTooLarge)
}
amvs := search.AMVs(term, maxAMVs)
return ctx.HTML(components.AMVSearchResults(amvs, user))
}
@ -110,7 +131,10 @@ func AMVs(ctx aero.Context) error {
// Users search.
func Users(ctx aero.Context) error {
term := ctx.Get("term")
term = strings.TrimPrefix(term, "/")
if len(term) > search.MaxSearchTermLength {
ctx.SetStatus(http.StatusRequestEntityTooLarge)
}
users := search.Users(term, maxUsers)
return ctx.HTML(components.UserSearchResults(users))
@ -119,7 +143,10 @@ func Users(ctx aero.Context) error {
// Companies search.
func Companies(ctx aero.Context) error {
term := ctx.Get("term")
term = strings.TrimPrefix(term, "/")
if len(term) > search.MaxSearchTermLength {
ctx.SetStatus(http.StatusRequestEntityTooLarge)
}
companies := search.Companies(term, maxCompanies)
return ctx.HTML(components.CompanySearchResults(companies))

View File

@ -9,20 +9,20 @@ component SettingsAccounts(user *arn.User)
Icon("cubes")
span Accounts
InputText("Accounts.AniList.Nick", user.Accounts.AniList.Nick, "AniList", "Your username on anilist.co")
InputText("Accounts.Kitsu.Nick", user.Accounts.Kitsu.Nick, "Kitsu", "Your username on kitsu.io")
InputText("Accounts.MyAnimeList.Nick", user.Accounts.MyAnimeList.Nick, "MyAnimeList", "Your username on myanimelist.net")
InputText("Accounts.Discord.Nick", user.Accounts.Discord.Nick, "Discord", "Your username on Discord")
InputText("Accounts.AniList.Nick", user.Accounts.AniList.Nick, "AniList", "Your username on anilist.co", 30)
InputText("Accounts.Kitsu.Nick", user.Accounts.Kitsu.Nick, "Kitsu", "Your username on kitsu.io", 30)
InputText("Accounts.MyAnimeList.Nick", user.Accounts.MyAnimeList.Nick, "MyAnimeList", "Your username on myanimelist.net", 30)
InputText("Accounts.Discord.Nick", user.Accounts.Discord.Nick, "Discord", "Your username on Discord", 30)
.widget.mountable(data-api="/api/user/" + user.ID)
h3.widget-title
Icon("gamepad")
span Games
InputText("Accounts.FinalFantasyXIV.Nick", user.Accounts.FinalFantasyXIV.Nick, "Final Fantasy XIV", "Your character name on FFXIV")
InputText("Accounts.FinalFantasyXIV.Nick", user.Accounts.FinalFantasyXIV.Nick, "Final Fantasy XIV", "Your character name on FFXIV", 30)
InputSelection("Accounts.FinalFantasyXIV.Server", user.Accounts.FinalFantasyXIV.Server, "Final Fantasy XIV - World", "Your server/world on FFXIV", arn.DataLists["ffxiv-servers"])
InputText("Accounts.Osu.Nick", user.Accounts.Osu.Nick, "Osu", "Your username on osu.ppy.sh")
InputText("Accounts.Overwatch.BattleTag", user.Accounts.Overwatch.BattleTag, "Overwatch", "Your battletag on Overwatch")
InputText("Accounts.Osu.Nick", user.Accounts.Osu.Nick, "Osu", "Your username on osu.ppy.sh", 30)
InputText("Accounts.Overwatch.BattleTag", user.Accounts.Overwatch.BattleTag, "Overwatch", "Your battletag on Overwatch", 30)
.widget.mountable
h3.widget-title

View File

@ -10,8 +10,8 @@ component SettingsInfo(user *arn.User)
span Info
InputSelection("Gender", user.Gender, "Gender", "Your gender", arn.DataLists["genders"])
InputText("BirthDay", user.BirthDay, "Birthday", "YYYY-MM-DD")
InputText("Website", user.Website, "Website", "Your homepage")
InputText("BirthDay", user.BirthDay, "Birthday", "YYYY-MM-DD", len("YYYY-MM-DD"))
InputText("Website", user.Website, "Website", "Your homepage", 100)
.widget.mountable(data-api="/api/settings/" + user.ID)
h3.widget-title

View File

@ -9,38 +9,13 @@ component SettingsPersonal(user *arn.User)
Icon("user")
span Personal
InputText("Nick", user.Nick, "Username", "Your username on notify.moe")
InputTextArea("Introduction", user.Introduction, "Introduction", "Tell us a little bit about yourself")
InputText("Nick", user.Nick, "Username", "Your username on notify.moe", 25)
InputTextArea("Introduction", user.Introduction, "Introduction", "Tell us a little bit about yourself", 2000)
.widget.mountable(data-api="/api/settings/" + user.ID)
h3.widget-title
Icon("camera")
span Avatar
//- .widget-section
//- label(for="Avatar.Source") Source:
//- select.widget-ui-element.action(id="Avatar.Source", data-field="Avatar.Source", value=user.Settings().Avatar.Source, data-action="save", data-trigger="change")
//- option(value="") Automatic
//- option(value="Gravatar") Gravatar
//- option(value="URL") Link
//- option(value="FileSystem") Upload
//- //- URL input
//- if user.Settings().Avatar.Source == "URL"
//- InputText("Avatar.SourceURL", user.Settings().Avatar.SourceURL, "Link", "Post the link to the image here")
//- //- Gravatar preview image
//- if user.Settings().Avatar.Source == "Gravatar" || (user.Settings().Avatar.Source == "" && user.Avatar.Source == "Gravatar")
//- .profile-image-container.avatar-preview
//- img.profile-image.mountable(src=user.Gravatar(), alt="Gravatar (" + user.Email + ")", title="Gravatar (" + user.Email + ")")
//- //- URL preview image
//- if user.Settings().Avatar.Source == "URL" && user.Settings().Avatar.SourceURL != ""
//- .profile-image-container.avatar-preview
//- img.profile-image.mountable(src=strings.Replace(user.Settings().Avatar.SourceURL, "http://", "https://", 1), alt="Avatar preview")
//- //- File upload
//- if user.Settings().Avatar.Source == "FileSystem"
AvatarInput(user)

View File

@ -10,7 +10,7 @@ component Welcome(user *arn.User)
.mountable(data-api="/api/user/" + user.ID)
//- [^\\W\\s\\d]{1,24}[A-Za-z]{1}
InputText("Nick", user.CleanNick(), "Nick", "Your username on notify.moe")
InputText("Nick", user.CleanNick(), "Nick", "Your username on notify.moe", 25)
.footer.mountable
p Only letters and underscore.
@ -26,7 +26,7 @@ component Welcome(user *arn.User)
p.welcome-text.mountable Write a little introduction for your profile.
.mountable(data-api="/api/user/" + user.ID)
InputTextArea("Introduction", user.Introduction, "Introduction", "Tell us a little bit about yourself")
InputTextArea("Introduction", user.Introduction, "Introduction", "Tell us a little bit about yourself", 2000)
.footer.mountable
p Markdown allowed.