Improved editor log and anime page headers are linkable

This commit is contained in:
Eduard Urbach 2018-04-09 18:17:21 +02:00
parent 719c04f3d5
commit f3fd2d9619
13 changed files with 187 additions and 87 deletions

View File

@ -25,10 +25,10 @@ component AnimeMainColumn(anime *arn.Anime, listItem *arn.AnimeListItem, tracks
AnimeGenres(anime) AnimeGenres(anime)
AnimeActions(anime, listItem, user) AnimeActions(anime, listItem, user)
AnimeCharacters(anime) AnimeCharacters(anime, user, false)
AnimeRelations(anime, user) AnimeRelations(anime, user, false)
AnimeTracks(anime, tracks) AnimeTracks(anime, tracks, user, false)
AnimeEpisodes(anime, episodes, user) AnimeEpisodes(anime, episodes, user, false)
component AnimeSideColumn(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]*arn.AnimeListItem, user *arn.User) component AnimeSideColumn(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]*arn.AnimeListItem, user *arn.User)
AnimeTrailer(anime) AnimeTrailer(anime)
@ -143,20 +143,6 @@ component AnimeGenres(anime *arn.Anime)
a.anime-genre.mountable(href="/genre/" + strings.ToLower(genre), data-mountable-type="footer") a.anime-genre.mountable(href="/genre/" + strings.ToLower(genre), data-mountable-type="footer")
span= genre span= genre
component AnimeRelations(anime *arn.Anime, user *arn.User)
if anime.Relations() != nil && len(anime.Relations().Items) > 0
section.anime-section.mountable
h3.anime-section-name Relations
.anime-relations
each relation in anime.Relations().Items
if relation.Anime() != nil
a.anime-relation.mountable(href=relation.Anime().Link(), title=relation.Anime().Title.ByUser(user), data-mountable-type="relation")
img.anime-relation-image.lazy(data-src=relation.Anime().ImageLink("small"), data-webp="true", data-color=relation.Anime().AverageColor(), alt=relation.Anime().Title.ByUser(user))
.anime-relation-type= relation.HumanReadableType()
.anime-relation-year
if relation.Anime().StartDate != ""
span= relation.Anime().StartDate[:4]
component AnimeTrailer(anime *arn.Anime) component AnimeTrailer(anime *arn.Anime)
if len(anime.Trailers) > 0 && anime.Trailers[0].Service == "Youtube" && anime.Trailers[0].ServiceID != "" if len(anime.Trailers) > 0 && anime.Trailers[0].Service == "Youtube" && anime.Trailers[0].ServiceID != ""
section.anime-section.mountable section.anime-section.mountable

View File

@ -3,6 +3,8 @@ 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"
@ -12,11 +14,12 @@ import (
// Characters ... // Characters ...
func Characters(ctx *aero.Context) string { func Characters(ctx *aero.Context) string {
id := ctx.Get("id") id := ctx.Get("id")
user := utils.GetUser(ctx)
anime, err := arn.GetAnime(id) anime, err := arn.GetAnime(id)
if err != nil { if err != nil {
return ctx.Error(http.StatusNotFound, "Anime not found", err) return ctx.Error(http.StatusNotFound, "Anime not found", err)
} }
return ctx.HTML(components.AnimeCharacters(anime)) return ctx.HTML(components.AnimeCharacters(anime, user, true))
} }

View File

@ -1,11 +1,15 @@
component AnimeCharacters(anime *arn.Anime) component AnimeCharacters(anime *arn.Anime, user *arn.User, standAlonePage bool)
//- AnimeTabs(anime) if standAlonePage
h1.mountable
a(href=anime.Link())= anime.Title.ByUser(user)
if anime.Characters() != nil && len(anime.Characters().Items) > 0 if anime.Characters() != nil && len(anime.Characters().Items) > 0
.anime-section .anime-section.mountable
h3.anime-section-name Characters h3.anime-section-name
a(href=anime.Characters().Link()) Characters
.characters .characters
each character in anime.Characters().Items each character in anime.Characters().Items
if character.Role == "main" && character.Character() != nil if (character.Role == "main" || standAlonePage) && character.Character() != nil
.mountable(data-mountable-type="character") .mountable(data-mountable-type="character")
Character(character.Character()) Character(character.Character())

View File

@ -21,5 +21,5 @@ func Episodes(ctx *aero.Context) string {
return ctx.Error(http.StatusNotFound, "Anime not found", err) return ctx.Error(http.StatusNotFound, "Anime not found", err)
} }
return ctx.HTML(components.AnimeEpisodes(anime, anime.Episodes().Items, user)) return ctx.HTML(components.AnimeEpisodes(anime, anime.Episodes().Items, user, true))
} }

View File

@ -1,7 +1,13 @@
component AnimeEpisodes(anime *arn.Anime, episodes []*arn.AnimeEpisode, user *arn.User) component AnimeEpisodes(anime *arn.Anime, episodes []*arn.AnimeEpisode, user *arn.User, standAlonePage bool)
if standAlonePage
h1.mountable
a(href=anime.Link())= anime.Title.ByUser(user)
if len(episodes) > 0 if len(episodes) > 0
.anime-section.mountable .anime-section.mountable
h3.anime-section-name Episodes h3.anime-section-name
a(href=anime.Episodes().Link()) Episodes
.episodes .episodes
each episode in episodes each episode in episodes
a.episode.mountable(href=anime.Link() + "/episode/" + strconv.Itoa(episode.Number), data-mountable-type="episode", data-available=episode.Available()) a.episode.mountable(href=anime.Link() + "/episode/" + strconv.Itoa(episode.Number), data-mountable-type="episode", data-available=episode.Available())

24
pages/anime/relations.go Normal file
View File

@ -0,0 +1,24 @@
package anime
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Relations ...
func Relations(ctx *aero.Context) string {
user := utils.GetUser(ctx)
id := ctx.Get("id")
anime, err := arn.GetAnime(id)
if err != nil {
return ctx.Error(http.StatusNotFound, "Anime not found", err)
}
return ctx.HTML(components.AnimeRelations(anime, user, true))
}

View File

@ -0,0 +1,19 @@
component AnimeRelations(anime *arn.Anime, user *arn.User, standAlonePage bool)
if standAlonePage
h1.mountable
a(href=anime.Link())= anime.Title.ByUser(user)
if anime.Relations() != nil && len(anime.Relations().Items) > 0
section.anime-section.mountable
h3.anime-section-name
a(href=anime.Relations().Link()) Relations
.anime-relations
each relation in anime.Relations().Items
if relation.Anime() != nil
a.anime-relation.mountable(href=relation.Anime().Link(), title=relation.Anime().Title.ByUser(user), data-mountable-type="relation")
img.anime-relation-image.lazy(data-src=relation.Anime().ImageLink("small"), data-webp="true", data-color=relation.Anime().AverageColor(), alt=relation.Anime().Title.ByUser(user))
.anime-relation-type= relation.HumanReadableType()
.anime-relation-year
if relation.Anime().StartDate != ""
span= relation.Anime().StartDate[:4]

View File

@ -3,6 +3,8 @@ 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"
@ -12,6 +14,7 @@ import (
// Tracks ... // Tracks ...
func Tracks(ctx *aero.Context) string { func Tracks(ctx *aero.Context) string {
id := ctx.Get("id") id := ctx.Get("id")
user := utils.GetUser(ctx)
anime, err := arn.GetAnime(id) anime, err := arn.GetAnime(id)
@ -23,5 +26,5 @@ func Tracks(ctx *aero.Context) string {
return !track.IsDraft && len(track.Media) > 0 && arn.Contains(track.Tags, "anime:"+anime.ID) return !track.IsDraft && len(track.Media) > 0 && arn.Contains(track.Tags, "anime:"+anime.ID)
}) })
return ctx.HTML(components.AnimeTracks(anime, tracks)) return ctx.HTML(components.AnimeTracks(anime, tracks, user, true))
} }

View File

@ -1,7 +1,12 @@
component AnimeTracks(anime *arn.Anime, tracks []*arn.SoundTrack) component AnimeTracks(anime *arn.Anime, tracks []*arn.SoundTrack, user *arn.User, standAlonePage bool)
if standAlonePage
h1.mountable
a(href=anime.Link())= anime.Title.ByUser(user)
if len(tracks) > 0 if len(tracks) > 0
.anime-section.mountable .anime-section.mountable
h3.anime-section-name Tracks h3.anime-section-name
a(href="/anime/" + anime.ID + "/tracks") Tracks
.soundtracks.anime-soundtracks .soundtracks.anime-soundtracks
each track in tracks each track in tracks

View File

@ -14,7 +14,7 @@ import (
const ( const (
entriesFirstLoad = 120 entriesFirstLoad = 120
entriesPerScroll = 30 entriesPerScroll = 40
) )
// Get edit log. // Get edit log.

View File

@ -11,61 +11,74 @@ component EditLogPage(entries []*arn.EditLogEntry, nextIndex int, viewUser *arn.
LoadMore(nextIndex) LoadMore(nextIndex)
component EditLog(entries []*arn.EditLogEntry, user *arn.User) component EditLog(entries []*arn.EditLogEntry, user *arn.User)
table.edit-log #load-more-target.edit-log
thead .edit-log-header.mountable
tr.mountable .edit-log-icon Action
th.text-center Action .edit-log-user User
th User .edit-log-object Object
th Object .edit-log-key Key
th Key .edit-log-value Old
th Old .edit-log-value New
th New .edit-log-date Date
th Date
tbody#load-more-target EditLogScrollable(entries, user)
EditLogScrollable(entries, user)
component EditLogScrollable(entries []*arn.EditLogEntry, user *arn.User) component EditLogScrollable(entries []*arn.EditLogEntry, user *arn.User)
each entry in entries each entry in entries
tr.mountable .edit-log-entry.mountable
td .edit-log-icon(title=entry.Action)
.edit-log-icon(title=entry.Action) if entry.Action == "create"
if entry.Action == "create" .edit-log-create
.edit-log-create RawIcon("plus")
RawIcon("plus") else if entry.Action == "delete"
else if entry.Action == "delete" .edit-log-delete
.edit-log-delete RawIcon("minus")
RawIcon("minus") else if entry.Action == "edit" || entry.Action == "arrayAppend" || entry.Action == "arrayRemove"
else if entry.Action == "edit" || entry.Action == "arrayAppend" || entry.Action == "arrayRemove" .edit-log-change
.edit-log-change RawIcon("pencil")
RawIcon("pencil")
if entry.Action == "arrayAppend"
if entry.Action == "arrayAppend" .edit-log-sub-icon.edit-log-add
RawIcon("plus-square")
else if entry.Action == "arrayRemove"
.edit-log-sub-icon.edit-log-remove
RawIcon("minus-square")
else
if entry.OldValue == "" && entry.NewValue != ""
.edit-log-sub-icon.edit-log-add .edit-log-sub-icon.edit-log-add
RawIcon("plus-square") RawIcon("plus-circle")
else if entry.Action == "arrayRemove" else if entry.OldValue != "" && entry.NewValue == ""
.edit-log-sub-icon.edit-log-remove .edit-log-sub-icon.edit-log-remove
RawIcon("minus-square") RawIcon("minus-circle")
else
if entry.OldValue == "" && entry.NewValue != ""
.edit-log-sub-icon.edit-log-add
RawIcon("plus-circle")
else if entry.OldValue != "" && entry.NewValue == ""
.edit-log-sub-icon.edit-log-remove
RawIcon("minus-circle")
td .edit-log-user
.edit-log-user a.edit-log-user-link(href=entry.User().Link(), title=entry.User().Nick)
Avatar(entry.User()) AvatarNoLink(entry.User())
td.edit-log-object
if strings.HasPrefix(arn.GetObjectTitle(entry.ObjectType, entry.ObjectID), "<not found:") .edit-log-object
if arn.GetObjectTitle(entry.ObjectType, entry.ObjectID) == ""
.edit-log-empty empty
else if strings.HasPrefix(arn.GetObjectTitle(entry.ObjectType, entry.ObjectID), "<not found:")
span= arn.GetObjectTitle(entry.ObjectType, entry.ObjectID) span= arn.GetObjectTitle(entry.ObjectType, entry.ObjectID)
else else
a(href="/" + strings.ToLower(entry.ObjectType) + "/" + entry.ObjectID, target="_blank")= arn.GetObjectTitle(entry.ObjectType, entry.ObjectID) a(href=arn.GetObjectLink(entry.ObjectType, entry.ObjectID), target="_blank")= arn.GetObjectTitle(entry.ObjectType, entry.ObjectID)
td.edit-log-key
.edit-log-key
span= entry.ObjectType span= entry.ObjectType
if entry.Key != "" if entry.Key != ""
span= "." + entry.Key span= "." + entry.Key
td.edit-log-value(title=entry.OldValue)= entry.OldValue
td.edit-log-value(title=entry.NewValue)= entry.NewValue .edit-log-value(title=entry.OldValue)
td.edit-log-date.utc-date(data-date=entry.Created) if entry.OldValue == ""
.edit-log-empty empty
else
span= entry.OldValue
.edit-log-value(title=entry.NewValue)
if entry.NewValue == ""
.edit-log-empty empty
else
span= entry.NewValue
.edit-log-date.utc-date(data-date=entry.Created)

View File

@ -1,8 +1,18 @@
.edit-log .edit-log
max-width 1500px display grid
grid-template-columns 100%
td .edit-log-entry
padding 0.25rem 0.5rem table-row
horizontal
.edit-log-header
horizontal
font-weight bold
.edit-log-entry,
.edit-log-header
padding 0.25rem 0
.edit-log-object, .edit-log-object,
.edit-log-key, .edit-log-key,
@ -10,23 +20,32 @@
white-space nowrap white-space nowrap
.edit-log-user .edit-log-user
horizontal
align-items center
flex-basis calc(avatar-size / 1.5 + 1rem)
.user-image .user-image
width calc(avatar-size / 2) width calc(avatar-size / 1.5)
height calc(avatar-size / 2) height calc(avatar-size / 1.5)
margin-right 0.5rem margin-right 0.5rem
.edit-log-object .edit-log-user-link
max-width 150px horizontal
clip-long-text align-items center
.edit-log-object,
.edit-log-key,
.edit-log-value .edit-log-value
max-width 150px display flex
align-items center
flex 1 1 150px
clip-long-text clip-long-text
.edit-log-icon .edit-log-icon
display flex display flex
justify-content center justify-content center
align-items center align-items center
flex-basis 80px
.edit-log-sub-icon .edit-log-sub-icon
// //
@ -47,4 +66,21 @@
color hsl(214, 100%, 62%) color hsl(214, 100%, 62%)
.edit-log-date .edit-log-date
opacity 0.5 display flex
align-items center
opacity 0.5
flex-basis 120px
.edit-log-empty
opacity 0.25
pointer-events none
< 800px
.edit-log-header
display none
.edit-log-date
display none
.edit-log-user
flex 0 0 calc(avatar-size / 2)

View File

@ -118,6 +118,7 @@ func Configure(app *aero.Application) {
l.Page("/anime/:id/episodes", anime.Episodes) l.Page("/anime/:id/episodes", anime.Episodes)
l.Page("/anime/:id/characters", anime.Characters) l.Page("/anime/:id/characters", anime.Characters)
l.Page("/anime/:id/tracks", anime.Tracks) l.Page("/anime/:id/tracks", anime.Tracks)
l.Page("/anime/:id/relations", anime.Relations)
l.Page("/anime/:id/episode/:episode-number", episode.Get) l.Page("/anime/:id/episode/:episode-number", episode.Get)
// Anime redirects // Anime redirects