Cleanup data types

This commit is contained in:
2019-06-04 12:16:27 +09:00
parent e7f2550004
commit 3d526f9198
13 changed files with 23 additions and 210 deletions

View File

@ -65,7 +65,7 @@ func init() {
// Anime represents an anime.
type Anime struct {
Type string `json:"type" editable:"true" datalist:"anime-types"`
Title *AnimeTitle `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"`
@ -74,7 +74,7 @@ type Anime struct {
EpisodeCount int `json:"episodeCount" editable:"true"`
EpisodeLength int `json:"episodeLength" editable:"true"`
Source string `json:"source" editable:"true" datalist:"anime-sources"`
Image AnimeImage `json:"image"`
Image Image `json:"image"`
FirstChannel string `json:"firstChannel"`
Rating *AnimeRating `json:"rating"`
Popularity *AnimePopularity `json:"popularity"`
@ -107,7 +107,7 @@ func NewAnime() *Anime {
hasID: hasID{
ID: GenerateID("Anime"),
},
Title: &AnimeTitle{},
Title: &MediaTitle{},
Rating: &AnimeRating{},
Popularity: &AnimePopularity{},
Trailers: []*ExternalMedia{},

View File

@ -157,15 +157,6 @@ var animeImageOutputsHighDPI = []imageserver.Output{
},
}
// AnimeImage ...
type AnimeImage struct {
Extension string `json:"extension"`
Width int `json:"width"`
Height int `json:"height"`
AverageColor HSLColor `json:"averageColor"`
LastModified int64 `json:"lastModified"`
}
// SetImageBytes accepts a byte buffer that represents an image file and updates the anime image.
func (anime *Anime) SetImageBytes(data []byte) error {
// Decode

View File

@ -11,7 +11,7 @@ import (
// Character represents an anime or manga character.
type Character struct {
Name CharacterName `json:"name" editable:"true"`
Image CharacterImage `json:"image"`
Image Image `json:"image"`
MainQuoteID string `json:"mainQuoteId" editable:"true"`
Description string `json:"description" editable:"true" type:"textarea"`
Spoilers []Spoiler `json:"spoilers" editable:"true"`

View File

@ -148,9 +148,6 @@ var characterImageOutputsHighDPI = []imageserver.Output{
},
}
// CharacterImage ...
type CharacterImage AnimeImage
// SetImageBytes accepts a byte buffer that represents an image file and updates the character image.
func (character *Character) SetImageBytes(data []byte) error {
// Decode

View File

@ -15,7 +15,7 @@ import (
type Group struct {
Name string `json:"name" editable:"true"`
Tagline string `json:"tagline" editable:"true"`
Image GroupImage `json:"image"`
Image Image `json:"image"`
Description string `json:"description" editable:"true" type:"textarea"`
Rules string `json:"rules" editable:"true" type:"textarea"`
Restricted bool `json:"restricted" editable:"true" tooltip:"Restricted groups can only be joined with the founder's permission."`

View File

@ -116,9 +116,6 @@ var groupImageOutputsHighDPI = []imageserver.Output{
},
}
// GroupImage ...
type GroupImage AnimeImage
// SetImageBytes accepts a byte buffer that represents an image file and updates the group image.
func (group *Group) SetImageBytes(data []byte) error {
// Decode

10
arn/Image.go Normal file
View File

@ -0,0 +1,10 @@
package arn
// Image represents an image with meta data.
type Image struct {
Extension string `json:"extension"`
Width int `json:"width"`
Height int `json:"height"`
AverageColor HSLColor `json:"averageColor"`
LastModified int64 `json:"lastModified"`
}

View File

@ -1,7 +1,7 @@
package arn
// AnimeTitle ...
type AnimeTitle struct {
// MediaTitle represents a title for any kind of media.
type MediaTitle struct {
Canonical string `json:"canonical" editable:"true"`
Romaji string `json:"romaji" editable:"true"`
English string `json:"english" editable:"true"`
@ -11,7 +11,7 @@ type AnimeTitle struct {
}
// ByUser returns the preferred title for the given user.
func (title *AnimeTitle) ByUser(user *User) string {
func (title *MediaTitle) ByUser(user *User) string {
if user == nil {
return title.Canonical
}

View File

@ -10,8 +10,8 @@ import (
// Person represents a person in real life.
type Person struct {
Name PersonName `json:"name" editable:"true"`
Image PersonImage `json:"image"`
Name PersonName `json:"name" editable:"true"`
Image Image `json:"image"`
hasID
hasPosts
@ -33,7 +33,7 @@ func NewPerson() *Person {
}
}
// Link ...
// Link returns the path to the person.
func (person *Person) Link() string {
return "/person/" + person.ID
}

View File

@ -1,4 +0,0 @@
package arn
// PersonImage ...
type PersonImage CharacterImage