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)
AnimeActions(anime, listItem, user)
AnimeCharacters(anime)
AnimeRelations(anime, user)
AnimeTracks(anime, tracks)
AnimeEpisodes(anime, episodes, user)
AnimeCharacters(anime, user, false)
AnimeRelations(anime, user, false)
AnimeTracks(anime, tracks, user, false)
AnimeEpisodes(anime, episodes, user, false)
component AnimeSideColumn(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]*arn.AnimeListItem, user *arn.User)
AnimeTrailer(anime)
@ -143,20 +143,6 @@ component AnimeGenres(anime *arn.Anime)
a.anime-genre.mountable(href="/genre/" + strings.ToLower(genre), data-mountable-type="footer")
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)
if len(anime.Trailers) > 0 && anime.Trailers[0].Service == "Youtube" && anime.Trailers[0].ServiceID != ""
section.anime-section.mountable

View File

@ -3,6 +3,8 @@ package anime
import (
"net/http"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/components"
"github.com/aerogo/aero"
@ -12,11 +14,12 @@ import (
// Characters ...
func Characters(ctx *aero.Context) string {
id := ctx.Get("id")
user := utils.GetUser(ctx)
anime, err := arn.GetAnime(id)
if err != nil {
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)
//- AnimeTabs(anime)
component AnimeCharacters(anime *arn.Anime, user *arn.User, standAlonePage bool)
if standAlonePage
h1.mountable
a(href=anime.Link())= anime.Title.ByUser(user)
if anime.Characters() != nil && len(anime.Characters().Items) > 0
.anime-section
h3.anime-section-name Characters
.anime-section.mountable
h3.anime-section-name
a(href=anime.Characters().Link()) Characters
.characters
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")
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.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
.anime-section.mountable
h3.anime-section-name Episodes
h3.anime-section-name
a(href=anime.Episodes().Link()) Episodes
.episodes
each episode in episodes
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 (
"net/http"
"github.com/animenotifier/notify.moe/utils"
"github.com/animenotifier/notify.moe/components"
"github.com/aerogo/aero"
@ -12,6 +14,7 @@ import (
// Tracks ...
func Tracks(ctx *aero.Context) string {
id := ctx.Get("id")
user := utils.GetUser(ctx)
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 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
.anime-section.mountable
h3.anime-section-name Tracks
h3.anime-section-name
a(href="/anime/" + anime.ID + "/tracks") Tracks
.soundtracks.anime-soundtracks
each track in tracks

View File

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

View File

@ -11,23 +11,21 @@ component EditLogPage(entries []*arn.EditLogEntry, nextIndex int, viewUser *arn.
LoadMore(nextIndex)
component EditLog(entries []*arn.EditLogEntry, user *arn.User)
table.edit-log
thead
tr.mountable
th.text-center Action
th User
th Object
th Key
th Old
th New
th Date
tbody#load-more-target
#load-more-target.edit-log
.edit-log-header.mountable
.edit-log-icon Action
.edit-log-user User
.edit-log-object Object
.edit-log-key Key
.edit-log-value Old
.edit-log-value New
.edit-log-date Date
EditLogScrollable(entries, user)
component EditLogScrollable(entries []*arn.EditLogEntry, user *arn.User)
each entry in entries
tr.mountable
td
.edit-log-entry.mountable
.edit-log-icon(title=entry.Action)
if entry.Action == "create"
.edit-log-create
@ -53,19 +51,34 @@ component EditLogScrollable(entries []*arn.EditLogEntry, user *arn.User)
.edit-log-sub-icon.edit-log-remove
RawIcon("minus-circle")
td
.edit-log-user
Avatar(entry.User())
td.edit-log-object
if strings.HasPrefix(arn.GetObjectTitle(entry.ObjectType, entry.ObjectID), "<not found:")
a.edit-log-user-link(href=entry.User().Link(), title=entry.User().Nick)
AvatarNoLink(entry.User())
.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)
else
a(href="/" + strings.ToLower(entry.ObjectType) + "/" + entry.ObjectID, target="_blank")= arn.GetObjectTitle(entry.ObjectType, entry.ObjectID)
td.edit-log-key
a(href=arn.GetObjectLink(entry.ObjectType, entry.ObjectID), target="_blank")= arn.GetObjectTitle(entry.ObjectType, entry.ObjectID)
.edit-log-key
span= entry.ObjectType
if entry.Key != ""
span= "." + entry.Key
td.edit-log-value(title=entry.OldValue)= entry.OldValue
td.edit-log-value(title=entry.NewValue)= entry.NewValue
td.edit-log-date.utc-date(data-date=entry.Created)
.edit-log-value(title=entry.OldValue)
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
max-width 1500px
display grid
grid-template-columns 100%
td
padding 0.25rem 0.5rem
.edit-log-entry
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-key,
@ -10,23 +20,32 @@
white-space nowrap
.edit-log-user
horizontal
align-items center
flex-basis calc(avatar-size / 1.5 + 1rem)
.user-image
width calc(avatar-size / 2)
height calc(avatar-size / 2)
width calc(avatar-size / 1.5)
height calc(avatar-size / 1.5)
margin-right 0.5rem
.edit-log-object
max-width 150px
clip-long-text
.edit-log-user-link
horizontal
align-items center
.edit-log-object,
.edit-log-key,
.edit-log-value
max-width 150px
display flex
align-items center
flex 1 1 150px
clip-long-text
.edit-log-icon
display flex
justify-content center
align-items center
flex-basis 80px
.edit-log-sub-icon
//
@ -47,4 +66,21 @@
color hsl(214, 100%, 62%)
.edit-log-date
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/characters", anime.Characters)
l.Page("/anime/:id/tracks", anime.Tracks)
l.Page("/anime/:id/relations", anime.Relations)
l.Page("/anime/:id/episode/:episode-number", episode.Get)
// Anime redirects