Editors can now add anime from scratch

This commit is contained in:
Eduard Urbach 2019-10-16 14:44:53 +09:00
parent 5ec435cf99
commit 75c03c7bdc
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
9 changed files with 180 additions and 62 deletions

View File

@ -8,6 +8,7 @@ import (
"strings"
"time"
"github.com/aerogo/api"
"github.com/aerogo/nano"
"github.com/animenotifier/notify.moe/arn/validate"
"github.com/animenotifier/twist"
@ -60,6 +61,14 @@ func init() {
for _, option := range DataLists["anime-sources"] {
AnimeSourceHumanReadable[option.Value] = option.Label
}
API.RegisterActions("Anime", []*api.Action{
// Publish
PublishAction(),
// Unpublish
UnpublishAction(),
})
}
// AnimeID represents an anime ID.
@ -69,7 +78,7 @@ type AnimeID = string
type Anime struct {
ID AnimeID `json:"id" primary:"true"`
Type string `json:"type" editable:"true" datalist:"anime-types"`
Title *MediaTitle `json:"title" editable:"true"`
Title MediaTitle `json:"title" editable:"true"`
Summary string `json:"summary" editable:"true" type:"textarea"`
Status string `json:"status" editable:"true" datalist:"anime-status"`
Genres []string `json:"genres" editable:"true"`
@ -80,10 +89,10 @@ type Anime struct {
Source string `json:"source" editable:"true" datalist:"anime-sources"`
Image Image `json:"image"`
FirstChannel string `json:"firstChannel"`
Rating *AnimeRating `json:"rating"`
Popularity *AnimePopularity `json:"popularity"`
Rating AnimeRating `json:"rating"`
Popularity AnimePopularity `json:"popularity"`
Trailers []*ExternalMedia `json:"trailers" editable:"true"`
EpisodeIDs []string `json:"episodes" editable:"true"`
EpisodeIDs []string `json:"episodes"`
// Mixins
hasMappings
@ -107,19 +116,19 @@ type Anime struct {
// NewAnime creates a new anime.
func NewAnime() *Anime {
return &Anime{
ID: GenerateID("Anime"),
Title: &MediaTitle{},
Rating: &AnimeRating{},
Popularity: &AnimePopularity{},
Trailers: []*ExternalMedia{},
hasCreator: hasCreator{
Created: DateTimeUTC(),
},
hasMappings: hasMappings{
Mappings: []*Mapping{},
},
}
anime := Anime{}
return anime.init()
}
// init is the constructor for Anime.
func (anime *Anime) init() *Anime {
anime.ID = GenerateID("Anime")
anime.Type = "tv"
anime.Status = "upcoming"
anime.Trailers = []*ExternalMedia{}
anime.Mappings = []*Mapping{}
anime.Created = DateTimeUTC()
return anime
}
// GetAnime gets the anime with the given ID.
@ -138,6 +147,41 @@ func (anime *Anime) TitleByUser(user *User) string {
return anime.Title.ByUser(user)
}
// Publish publishes the anime draft.
func (anime *Anime) Publish() error {
// No type
if anime.Type == "" {
return errors.New("No type")
}
// No name
if anime.Title.Canonical == "" {
return errors.New("No canonical anime name")
}
// No status
if anime.Status == "" {
return errors.New("No status")
}
// No genres
if len(anime.Genres) == 0 {
return errors.New("No genres")
}
// No image
if !anime.HasImage() {
return errors.New("No anime image")
}
return publish(anime)
}
// Unpublish turns the anime into a draft.
func (anime *Anime) Unpublish() error {
return unpublish(anime)
}
// AddStudio adds the company ID to the studio ID list if it doesn't exist already.
func (anime *Anime) AddStudio(companyID string) {
// Is the ID valid?
@ -299,16 +343,6 @@ func (anime *Anime) Season() string {
// Characters returns the anime characters for this anime.
func (anime *Anime) Characters() *AnimeCharacters {
characters, _ := GetAnimeCharacters(anime.ID)
if characters != nil {
// TODO: Sort by role in sync-characters job
// Sort by role
sort.Slice(characters.Items, func(i, j int) bool {
// A little trick because "main" < "supporting"
return characters.Items[i].Role < characters.Items[j].Role
})
}
return characters
}

View File

@ -18,6 +18,8 @@ var (
_ fmt.Stringer = (*Anime)(nil)
_ Likeable = (*Anime)(nil)
_ PostParent = (*Anime)(nil)
_ Publishable = (*Anime)(nil)
_ api.Creatable = (*Anime)(nil)
_ api.Deletable = (*Anime)(nil)
_ api.Editable = (*Anime)(nil)
_ api.CustomEditable = (*Anime)(nil)
@ -35,6 +37,48 @@ func init() {
})
}
// Create sets the data for a new anime.
func (anime *Anime) Create(ctx aero.Context) error {
user := GetUserFromContext(ctx)
if user == nil {
return errors.New("Not logged in")
}
anime.init()
anime.CreatedBy = user.ID
// Characters
characters := anime.Characters()
if characters == nil {
characters = &AnimeCharacters{
AnimeID: anime.ID,
Items: []*AnimeCharacter{},
}
characters.Save()
}
// Relations
relations := anime.Relations()
if relations == nil {
relations = &AnimeRelations{
AnimeID: anime.ID,
Items: []*AnimeRelation{},
}
relations.Save()
}
// Write log entry
logEntry := NewEditLogEntry(user.ID, "create", "Anime", anime.ID, "", "", "")
logEntry.Save()
return anime.Unpublish()
}
// Edit creates an edit log entry.
func (anime *Anime) Edit(ctx aero.Context, key string, value reflect.Value, newValue reflect.Value) (consumed bool, err error) {
user := GetUserFromContext(ctx)
@ -104,6 +148,12 @@ func (anime *Anime) DeleteInContext(ctx aero.Context) error {
// Delete deletes the anime from the database.
func (anime *Anime) Delete() error {
if anime.IsDraft {
draftIndex := anime.Creator().DraftIndex()
draftIndex.AnimeID = ""
draftIndex.Save()
}
// Delete anime characters
DB.Delete("AnimeCharacters", anime.ID)

View File

@ -2,6 +2,7 @@ package arn
import (
"errors"
"sort"
"sync"
"github.com/aerogo/nano"
@ -81,6 +82,17 @@ func (characters *AnimeCharacters) Self() Loggable {
return characters
}
// Sort sorts the characters by role.
func (characters *AnimeCharacters) Sort() {
characters.Lock()
defer characters.Unlock()
sort.Slice(characters.Items, func(i, j int) bool {
// A little trick because "main" < "supporting"
return characters.Items[i].Role < characters.Items[j].Role
})
}
// Contains tells you whether the given character ID exists.
func (characters *AnimeCharacters) Contains(characterID string) bool {
characters.Lock()

View File

@ -93,7 +93,6 @@ func publish(draft Publishable) error {
}
draftIndex.Save()
return nil
}

View File

@ -35,6 +35,10 @@ func Anime(originalTerm string, maxLength int) []*arn.Anime {
}
for anime := range arn.StreamAnime() {
if anime.IsDraft {
continue
}
if anime.ID == originalTerm {
return []*arn.Anime{anime}
}

16
go.mod
View File

@ -3,9 +3,9 @@ module github.com/animenotifier/notify.moe
go 1.12
require (
cloud.google.com/go v0.46.3 // indirect
cloud.google.com/go v0.47.0 // indirect
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/aerogo/aero v1.3.26
github.com/aerogo/aero v1.3.27
github.com/aerogo/api v0.2.2
github.com/aerogo/crawler v0.2.5
github.com/aerogo/flow v0.1.5
@ -23,7 +23,7 @@ require (
github.com/aerogo/sitemap v0.1.4
github.com/akyoto/assert v0.2.1
github.com/akyoto/cache v1.0.3
github.com/akyoto/color v1.8.8
github.com/akyoto/color v1.8.9
github.com/akyoto/go-matroska v0.1.1
github.com/akyoto/hash v0.4.6
github.com/akyoto/imageserver v0.3.7
@ -49,7 +49,7 @@ require (
github.com/logpacker/PayPal-Go-SDK v1.1.4
github.com/mailgun/mailgun-go/v3 v3.6.0
github.com/mailru/easyjson v0.7.0 // indirect
github.com/minio/minio-go/v6 v6.0.38
github.com/minio/minio-go/v6 v6.0.39
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/mssola/user_agent v0.5.0
github.com/pariz/gountries v0.0.0-20171019111738-adb00f6513a3
@ -61,11 +61,11 @@ require (
github.com/ungerik/go-gravatar v0.0.0-20120802094239-6ab22628222a
github.com/ventu-io/go-shortid v0.0.0-20171029131806-771a37caa5cf
github.com/xrash/smetrics v0.0.0-20170218160415-a3153f7040e9
golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc // indirect
golang.org/x/net v0.0.0-20191003171128-d98b1b443823 // indirect
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 // indirect
golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582 // indirect
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9 // indirect
google.golang.org/appengine v1.6.4 // indirect
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 // indirect
google.golang.org/appengine v1.6.5 // indirect
gopkg.in/ini.v1 v1.48.0 // indirect
gopkg.in/yaml.v2 v2.2.4 // indirect
)

56
go.sum
View File

@ -8,9 +8,13 @@ cloud.google.com/go v0.45.1 h1:lRi0CHyU+ytlvylOlFKKq0af6JncuyoRh1J+QJBqQx0=
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
cloud.google.com/go v0.46.3 h1:AVXDdKsrtX33oR9fbCMu/+c1o8Ofjq6Ku/MInaLVg5Y=
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
cloud.google.com/go v0.47.0 h1:1JUtpcY9E7+eTospEwWS2QXP3DEn7poB3E2j0jN74mM=
cloud.google.com/go v0.47.0/go.mod h1:5p3Ky/7f3N10VBkhuR5LFtddroTiMyjZV/Kj5qOQFxU=
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
@ -20,8 +24,8 @@ github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUW
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/aerogo/aero v1.3.21 h1:tipV8etMEj11VF9ekkI3pEAaGJkuWKzhbwdSHQreONU=
github.com/aerogo/aero v1.3.21/go.mod h1:Or3OxJsAPB6fuYK5Y7CJGgc+wFzZMDI4E2Svv65kkKA=
github.com/aerogo/aero v1.3.26 h1:kKGUZrh3VaLRrz+P0WcRLFNflr01EE2toHYh2sYc+aw=
github.com/aerogo/aero v1.3.26/go.mod h1:5kaUzoRdKn9btlzPjcog4IboE7TXRk/n0iUi7TVJMsU=
github.com/aerogo/aero v1.3.27 h1:FQOzSM2ACuAQldRLpNuacLDQ4PpBN527/JdxgGcTl+k=
github.com/aerogo/aero v1.3.27/go.mod h1:AhHIh2UjmNKkjAM7lerDVPh+tKRyp+ttmbk2QbaL83c=
github.com/aerogo/api v0.2.2 h1:6+hrwD7ZypvVnVKa/3J96QRaZu6gUnmFsMS49yc8rLg=
github.com/aerogo/api v0.2.2/go.mod h1:FjpGimrlG1nemBNPmVzpQ3ZEP0TGSLK71j4ssnd9Bsg=
github.com/aerogo/cluster v0.1.8 h1:N/jU2t7kQfKjXzQIArBQvtNkJCiaP9+jgdEid3P2Omc=
@ -91,10 +95,10 @@ github.com/akyoto/color v1.8.4 h1:XS1AL8/JmDHNgN9JRMd1epsQADQF7UXMzUz0nx0kTvY=
github.com/akyoto/color v1.8.4/go.mod h1:JXiVjSFNVJjEAneE77ovynlZFYuaDo6yTanD+OHAN/E=
github.com/akyoto/color v1.8.7 h1:Sr9z8iFoFF9KMJpHmQH+raFaVrO3wHNFIkFdyQdTsVY=
github.com/akyoto/color v1.8.7/go.mod h1:eNfGr527GIJME/houfnrEIGiVlL5IJsOfuC2I+oby+4=
github.com/akyoto/color v1.8.8 h1:t9TlY9ZHPhcDbzJocbxQcyI9tpCvIBzlUZd4hontND0=
github.com/akyoto/color v1.8.8/go.mod h1:5tQRfUSJlJuhyCffpcHmfqNJ+0g8Ahu3u/A9QCrG1lo=
github.com/akyoto/colorable v0.1.3 h1:e8HALH6FekJKTaEtTU6gZY2u+WtSGcjdwr3t6wKO1Fs=
github.com/akyoto/colorable v0.1.3/go.mod h1:AUfZwbC9OzwBaIbVTyNpD2UmwPbh3ZQqpyrHzb2ZymY=
github.com/akyoto/color v1.8.9 h1:Uv8/rFdvq06ntG+GibKjbT+jWtc6o88SjKMUmi1Nom8=
github.com/akyoto/color v1.8.9/go.mod h1:ImvfyQaQbqtKLwiafRiRu6Fq98f4f9HBI/J0WK7q3Oc=
github.com/akyoto/colorable v0.1.4 h1:BPwbsaUmo90/JiwTB7v7TpRHkNsfIxsb9s25eASwwDg=
github.com/akyoto/colorable v0.1.4/go.mod h1:AUfZwbC9OzwBaIbVTyNpD2UmwPbh3ZQqpyrHzb2ZymY=
github.com/akyoto/go-matroska v0.1.1 h1:HgoCAkeWrGjYr0FZr3yCzAIkXuOGRiVil7Ul329lm+A=
github.com/akyoto/go-matroska v0.1.1/go.mod h1:x+GUVwyby6HN/MKKNP4BvGqP9VrHuEznfBf288gehek=
github.com/akyoto/hash v0.4.4 h1:mabc0rYfRdpCZtnn1AI1k2fCPKDG/1GwYQ3yEf0BqqM=
@ -115,6 +119,8 @@ github.com/akyoto/stringutils v0.2.4 h1:VYW2FH2qjmQyJWZDSNFSP8btbSwJDoY0x14uiD/0
github.com/akyoto/stringutils v0.2.4/go.mod h1:nyO78pc92gciYObsOGWasnQN/s18JEQusXtN/7iC2AM=
github.com/akyoto/tty v0.1.0 h1:JsqLCfihFhY8TISBOQ6pEEJC0U954EJYMk5wjMEn5es=
github.com/akyoto/tty v0.1.0/go.mod h1:UMkevvI7yitoMBNoA9ALtJU0AL/6XGNkyuh9DqPvIOs=
github.com/akyoto/tty v0.1.1 h1:ZOJpp9fj0Y0CNVl9j7MJ7sJvlf9yVlFyDTiahD8FbUo=
github.com/akyoto/tty v0.1.1/go.mod h1:DLx0iz7IeaEsdXQkZ5IN/YOoWRvuV+JOSy6AQjyxA50=
github.com/akyoto/uuid v1.1.3 h1:FEz14tNTfaUeY0Jrkz2F17rjKiks6hOALGcPmAmtn1s=
github.com/akyoto/uuid v1.1.3/go.mod h1:8dgzDQyrpuApBGIQHOX7JkvCZHusXZ0tGlQcxxv4bYg=
github.com/akyoto/webpush-go v0.1.2 h1:Ufg8Al6xyyaTmdlLkfOGDEapVClymzJl/Whu8pOydjM=
@ -166,6 +172,7 @@ github.com/go-chi/chi v4.0.0+incompatible h1:SiLLEDyAkqNnw+T/uDTf3aFB9T4FTrwMpuY
github.com/go-chi/chi v4.0.0+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
github.com/go-chi/chi v4.0.2+incompatible h1:maB6vn6FqCxrpz4FqWdh4+lwpyZIQS7YEAUcHlgXVRs=
github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI=
github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM=
github.com/gojp/kana v0.0.0-20190509023103-3514925d577b/go.mod h1:kWp5hDdJQqnZ2E3SQNQe+iejY63SZ+JdlbnW+qn7vxY=
@ -219,8 +226,6 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/logpacker/PayPal-Go-SDK v1.1.4 h1:YXfHvkDLMKkdmHmeusBum45MMG4n3iJeeQ9mZPWPAUQ=
github.com/logpacker/PayPal-Go-SDK v1.1.4/go.mod h1:DUf5ncyG0n3jFnU9VsuQqe/Vo6KHtWQ6HYf80JwP4rY=
github.com/logpacker/PayPal-Go-SDK v2.0.5+incompatible h1:FGElA5Evfcolh+1jivSPd6Fz2zYCNtjHnoJqGUR/Ztc=
github.com/logpacker/PayPal-Go-SDK v2.0.5+incompatible/go.mod h1:DUf5ncyG0n3jFnU9VsuQqe/Vo6KHtWQ6HYf80JwP4rY=
github.com/mailgun/mailgun-go/v3 v3.6.0 h1:oQWhyDTFjSiuO6vx1PRlfLZ7Fu+oK0Axn0UTREh3k/g=
github.com/mailgun/mailgun-go/v3 v3.6.0/go.mod h1:E81I5Agcfi/u1szdehi6p6ttdRX/UD3Rq2SrUzwyFIU=
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic=
@ -241,10 +246,8 @@ github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
github.com/microcosm-cc/bluemonday v1.0.2 h1:5lPfLTTAvAbtS0VqT+94yOtFnGfUWYyx0+iToC3Os3s=
github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc=
github.com/minio/minio-go/v6 v6.0.37 h1:rqot4cO9+mLpf56q+yumA0xZlncbkFpqa4A8jw1Y2XE=
github.com/minio/minio-go/v6 v6.0.37/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
github.com/minio/minio-go/v6 v6.0.38 h1:zd3yagckaBVAMJT+HsbpURx9ndqYQp/N/udc1UVS72E=
github.com/minio/minio-go/v6 v6.0.38/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
github.com/minio/minio-go/v6 v6.0.39 h1:9qmKCTBpQpMdGlDAbs3mbb4mmL45/lwRUvHL1VLhYUk=
github.com/minio/minio-go/v6 v6.0.39/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
github.com/minio/sha256-simd v0.1.1 h1:5QHSlgo3nt5yKOJrC7W8w7X+NFl8cMPZm96iu8kKUJU=
github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
@ -273,8 +276,6 @@ github.com/rjeczalik/notify v0.9.2/go.mod h1:aErll2f0sUX9PXZnVNyeiObbmTlk5jnMoCa
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday v2.0.0+incompatible h1:cBXrhZNUf9C+La9/YpS+UHpUT8YD6Td9ZMSU9APFcsk=
github.com/russross/blackfriday v2.0.0+incompatible/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/shirou/gopsutil v2.18.12+incompatible h1:1eaJvGomDnH74/5cF4CTmTbLHAriGFsTZppLXDX93OM=
github.com/shirou/gopsutil v2.18.12+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v2.19.9+incompatible h1:IrPVlK4nfwW10DF7pW+7YJKws9NkgNzWozwwWv9FsgY=
github.com/shirou/gopsutil v2.19.9+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+DfgoHVedieIzIXE8uylPue0U=
@ -332,14 +333,13 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 h1:58fnuSXlxZmFdJyvtTFVmVhcMLU6v5fEb/ok4wyqtNU=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad h1:5E5raQxcv+6CZ11RrBYQe5WRbUIWpScjh0kvHZkZIrQ=
golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc h1:c0o/qxkaO2LF5t6fQrT4b5hzyggAkLLlCUjqfRxd8Q4=
golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgnvsSFpcKLM5xXVWnvZS97DWHgE=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@ -348,6 +348,7 @@ golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTk
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
@ -371,10 +372,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwL
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 h1:fHDIZ2oxGnUZRN6WgWFCbYBjH9uqVPRCUVUDhs0wnbA=
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190926025831-c00fd9afed17 h1:qPnAdmjNA41t3QBTx2mFGf/SD1IoslhYu7AmdsVzCcs=
golang.org/x/net v0.0.0-20190926025831-c00fd9afed17/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191003171128-d98b1b443823 h1:Ypyv6BNJh07T1pUSrehkLemqPKXhus2MkfktJ91kRh4=
golang.org/x/net v0.0.0-20191003171128-d98b1b443823/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582 h1:p9xBe/w/OzkeYVKm234g55gMdD1nSIooTir5kV11kfA=
golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
@ -415,8 +414,10 @@ golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b h1:3S2h5FadpNr0zUUCVZjlKIEYF
golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190927073244-c990c680b611 h1:q9u40nxWT5zRClI/uU9dHCiYGottAg6Nzz4YUQyHxdA=
golang.org/x/sys v0.0.0-20190927073244-c990c680b611/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9 h1:L2auWcuQIvxz9xSEqzESnV/QN/gNRXNApHi3fYwl2w0=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191007154456-ef33b2fb2c41 h1:OC2BiV9nQHWgVMNbxZ5/eZKWnnd3Z4H9W5zdNvC4EBc=
golang.org/x/sys v0.0.0-20191007154456-ef33b2fb2c41/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY=
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To=
@ -441,6 +442,8 @@ golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgw
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191010171213-8abd42400456/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
@ -452,8 +455,8 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3I=
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.4 h1:WiKh4+/eMB2HaY7QhCfW/R7MuRAoA8QMCSJA6jP5/fo=
google.golang.org/appengine v1.6.4/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
@ -462,6 +465,7 @@ google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRn
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
google.golang.org/genproto v0.0.0-20191009194640-548a555dbc03/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=

View File

@ -60,6 +60,10 @@ func filterAnime(year, season, status, typ string) []*arn.Anime {
results := make([]*arn.Anime, 0, 1024)
for anime := range arn.StreamAnime() {
if anime.IsDraft {
continue
}
if year != "any" {
if len(anime.StartDate) < 4 {
continue

View File

@ -29,6 +29,17 @@ component ExploreAnime(animes []*arn.Anime, year string, season string, status s
p.no-data.mountable No anime found using the above filters.
else
AnimeGrid(animes, user)
if user != nil && (user.Role == "editor" || user.Role == "admin")
.buttons
if user.DraftIndex().AnimeID == ""
button.mountable.action(data-action="newObject", data-trigger="click", data-type="anime")
Icon("plus")
span Add anime
else
a.button.mountable(href="/anime/" + user.DraftIndex().AnimeID + "/edit")
Icon("pencil")
span Edit draft
component ExploreFilters(year string, season string, status string, typ string, advancedFilters bool)
.explore-filters