Added image upload for editors
This commit is contained in:
parent
754bca2c6f
commit
ff7db4202b
@ -109,7 +109,7 @@ func work(anime *arn.Anime) error {
|
|||||||
// Afterwards, use the network sources
|
// Afterwards, use the network sources
|
||||||
sources = append(sources,
|
sources = append(sources,
|
||||||
&inputs.NetworkImage{
|
&inputs.NetworkImage{
|
||||||
URL: kitsuOriginal + anime.ImageExtension,
|
URL: kitsuOriginal + anime.Image.Extension,
|
||||||
},
|
},
|
||||||
&inputs.NetworkImage{
|
&inputs.NetworkImage{
|
||||||
URL: kitsuOriginal + ".png",
|
URL: kitsuOriginal + ".png",
|
||||||
|
@ -62,7 +62,7 @@ func sync(data *kitsu.Anime) *arn.Anime {
|
|||||||
anime.EpisodeCount = attr.EpisodeCount
|
anime.EpisodeCount = attr.EpisodeCount
|
||||||
anime.EpisodeLength = attr.EpisodeLength
|
anime.EpisodeLength = attr.EpisodeLength
|
||||||
anime.Status = attr.Status
|
anime.Status = attr.Status
|
||||||
anime.ImageExtension = filepath.Ext(kitsu.FixImageURL(attr.PosterImage.Original))
|
anime.Image.Extension = filepath.Ext(kitsu.FixImageURL(attr.PosterImage.Original))
|
||||||
|
|
||||||
// Status "unreleased" means the same as "upcoming" so we should normalize it
|
// Status "unreleased" means the same as "upcoming" so we should normalize it
|
||||||
if anime.Status == "unreleased" {
|
if anime.Status == "unreleased" {
|
||||||
@ -70,8 +70,8 @@ func sync(data *kitsu.Anime) *arn.Anime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Normalize image extension to .jpg if .jpeg is used
|
// Normalize image extension to .jpg if .jpeg is used
|
||||||
if anime.ImageExtension == ".jpeg" {
|
if anime.Image.Extension == ".jpeg" {
|
||||||
anime.ImageExtension = ".jpg"
|
anime.Image.Extension = ".jpg"
|
||||||
}
|
}
|
||||||
|
|
||||||
anime.Summary = arn.FixAnimeDescription(attr.Synopsis)
|
anime.Summary = arn.FixAnimeDescription(attr.Synopsis)
|
||||||
|
@ -3,7 +3,7 @@ component AnimeGrid(animeList []*arn.Anime, user *arn.User)
|
|||||||
each anime in animeList
|
each anime in animeList
|
||||||
.anime-grid-cell(data-added=(user != nil && user.AnimeList().Contains(anime.ID)))
|
.anime-grid-cell(data-added=(user != nil && user.AnimeList().Contains(anime.ID)))
|
||||||
a.ajax(href="/anime/" + toString(anime.ID))
|
a.ajax(href="/anime/" + toString(anime.ID))
|
||||||
img.anime-grid-image.lazy(data-src=anime.Image("medium"), data-webp="true", alt=anime.Title.Romaji)
|
img.anime-grid-image.lazy(data-src=anime.ImageLink("medium"), data-webp="true", alt=anime.Title.Romaji)
|
||||||
.anime-grid-title
|
.anime-grid-title
|
||||||
.anime-grid-title-text= anime.Title.ByUser(user)
|
.anime-grid-title-text= anime.Title.ByUser(user)
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ component AnimeListScrollable(animeListItems []*arn.AnimeListItem, viewUser *arn
|
|||||||
.anime-list-item.mountable(title=item.Notes, data-api="/api/animelist/" + viewUser.ID + "/field/Items[AnimeID=\"" + item.AnimeID + "\"]")
|
.anime-list-item.mountable(title=item.Notes, data-api="/api/animelist/" + viewUser.ID + "/field/Items[AnimeID=\"" + item.AnimeID + "\"]")
|
||||||
.anime-list-item-image-container
|
.anime-list-item-image-container
|
||||||
a.anime-list-item-image-link.ajax(href=item.Anime().Link())
|
a.anime-list-item-image-link.ajax(href=item.Anime().Link())
|
||||||
img.anime-list-item-image.lazy(data-src=item.Anime().Image("small"), data-webp="true", alt=item.Anime().Title.ByUser(user))
|
img.anime-list-item-image.lazy(data-src=item.Anime().ImageLink("small"), data-webp="true", alt=item.Anime().Title.ByUser(user))
|
||||||
|
|
||||||
.anime-list-item-name
|
.anime-list-item-name
|
||||||
a.ajax(href=item.Link(viewUser.Nick))= item.Anime().Title.ByUser(user)
|
a.ajax(href=item.Link(viewUser.Nick))= item.Anime().Title.ByUser(user)
|
||||||
|
@ -7,7 +7,7 @@ component SoundTrackContent(track *arn.SoundTrack)
|
|||||||
.soundtrack-content
|
.soundtrack-content
|
||||||
if track.MainAnime() != nil
|
if track.MainAnime() != nil
|
||||||
a.soundtrack-anime-link.ajax(href="/anime/" + track.MainAnime().ID)
|
a.soundtrack-anime-link.ajax(href="/anime/" + track.MainAnime().ID)
|
||||||
img.soundtrack-anime-image.lazy(data-src=track.MainAnime().Image("medium"), data-webp="true", alt=track.MainAnime().Title.Canonical, title=track.MainAnime().Title.Canonical)
|
img.soundtrack-anime-image.lazy(data-src=track.MainAnime().ImageLink("medium"), data-webp="true", alt=track.MainAnime().Title.Canonical, title=track.MainAnime().Title.Canonical)
|
||||||
|
|
||||||
SoundTrackMedia(track)
|
SoundTrackMedia(track)
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
openGraph := &arn.OpenGraph{
|
openGraph := &arn.OpenGraph{
|
||||||
Tags: map[string]string{
|
Tags: map[string]string{
|
||||||
"og:title": anime.Title.Canonical,
|
"og:title": anime.Title.Canonical,
|
||||||
"og:image": "https:" + anime.Image("large"),
|
"og:image": "https:" + anime.ImageLink("large"),
|
||||||
"og:url": "https://" + ctx.App.Config.Domain + anime.Link(),
|
"og:url": "https://" + ctx.App.Config.Domain + anime.Link(),
|
||||||
"og:site_name": "notify.moe",
|
"og:site_name": "notify.moe",
|
||||||
"og:description": description,
|
"og:description": description,
|
||||||
|
@ -7,8 +7,8 @@ component Anime(anime *arn.Anime, listItem *arn.AnimeListItem, tracks []*arn.Sou
|
|||||||
|
|
||||||
component AnimeMainColumn(anime *arn.Anime, listItem *arn.AnimeListItem, tracks []*arn.SoundTrack, episodes []*arn.AnimeEpisode, user *arn.User)
|
component AnimeMainColumn(anime *arn.Anime, listItem *arn.AnimeListItem, tracks []*arn.SoundTrack, episodes []*arn.AnimeEpisode, user *arn.User)
|
||||||
.anime-header(data-id=anime.ID)
|
.anime-header(data-id=anime.ID)
|
||||||
a.anime-image-container.mountable(href=anime.Image("original"), target="_blank")
|
a.anime-image-container.mountable(href=anime.ImageLink("original"), target="_blank")
|
||||||
img.anime-cover-image.lazy(data-src=anime.Image("large"), data-webp="true", alt=anime.Title.ByUser(user))
|
img.anime-cover-image.lazy(data-src=anime.ImageLink("large"), data-webp="true", alt=anime.Title.ByUser(user))
|
||||||
|
|
||||||
.space
|
.space
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ component AnimeRelations(anime *arn.Anime, user *arn.User)
|
|||||||
.anime-relations
|
.anime-relations
|
||||||
each relation in anime.Relations().Items
|
each relation in anime.Relations().Items
|
||||||
a.anime-relation.mountable.ajax(href=relation.Anime().Link(), title=relation.Anime().Title.ByUser(user), data-mountable-type="relation")
|
a.anime-relation.mountable.ajax(href=relation.Anime().Link(), title=relation.Anime().Title.ByUser(user), data-mountable-type="relation")
|
||||||
img.anime-relation-image.lazy(data-src=relation.Anime().Image("small"), data-webp="true", alt=relation.Anime().Title.ByUser(user))
|
img.anime-relation-image.lazy(data-src=relation.Anime().ImageLink("small"), data-webp="true", alt=relation.Anime().Title.ByUser(user))
|
||||||
.anime-relation-type= relation.HumanReadableType()
|
.anime-relation-type= relation.HumanReadableType()
|
||||||
.anime-relation-year
|
.anime-relation-year
|
||||||
if relation.Anime().StartDate != ""
|
if relation.Anime().StartDate != ""
|
||||||
|
@ -12,7 +12,7 @@ component Calendar(days []*utils.CalendarDay, user *arn.User)
|
|||||||
.calendar-entries
|
.calendar-entries
|
||||||
each entry in day.Entries
|
each entry in day.Entries
|
||||||
a.calendar-entry.mountable.ajax(href=entry.Anime.Link(), data-mountable-type=day.Name, data-added=entry.Added)
|
a.calendar-entry.mountable.ajax(href=entry.Anime.Link(), data-mountable-type=day.Name, data-added=entry.Added)
|
||||||
img.calendar-entry-image.lazy(data-src=entry.Anime.Image("small"), data-webp="true", alt=entry.Anime.Title.ByUser(user))
|
img.calendar-entry-image.lazy(data-src=entry.Anime.ImageLink("small"), data-webp="true", alt=entry.Anime.Title.ByUser(user))
|
||||||
.calendar-entry-info
|
.calendar-entry-info
|
||||||
.calendar-entry-title= entry.Anime.Title.ByUser(user)
|
.calendar-entry-title= entry.Anime.Title.ByUser(user)
|
||||||
.calendar-entry-time-and-episode
|
.calendar-entry-time-and-episode
|
||||||
|
@ -14,7 +14,7 @@ component CharacterDetails(character *arn.Character, characterAnime []*arn.Anime
|
|||||||
.character-anime
|
.character-anime
|
||||||
each anime in characterAnime
|
each anime in characterAnime
|
||||||
a.character-anime-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
a.character-anime-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
||||||
img.character-anime-item-image.lazy(data-src=anime.Image("small"), data-webp="true", alt=anime.Title.ByUser(user))
|
img.character-anime-item-image.lazy(data-src=anime.ImageLink("small"), data-webp="true", alt=anime.Title.ByUser(user))
|
||||||
|
|
||||||
if len(quotes) >0
|
if len(quotes) >0
|
||||||
h3 Quotes
|
h3 Quotes
|
||||||
|
@ -43,7 +43,7 @@ component CompanyAnime(label string, animes []*arn.Anime, user *arn.User)
|
|||||||
.company-anime.mountable
|
.company-anime.mountable
|
||||||
each anime in animes
|
each anime in animes
|
||||||
a.company-anime-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
a.company-anime-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
||||||
img.company-anime-item-image.lazy(data-src=anime.Image("small"), data-webp="true", alt=anime.Title.ByUser(user))
|
img.company-anime-item-image.lazy(data-src=anime.ImageLink("small"), data-webp="true", alt=anime.Title.ByUser(user))
|
||||||
|
|
||||||
component CompanyTabs(company *arn.Company, user *arn.User)
|
component CompanyTabs(company *arn.Company, user *arn.User)
|
||||||
.tabs
|
.tabs
|
||||||
|
@ -20,7 +20,7 @@ component CompareAnimeList(a *arn.User, b *arn.User, countA int, countB int, com
|
|||||||
tr.anime-list-item.mountable
|
tr.anime-list-item.mountable
|
||||||
td.anime-list-item-image-container
|
td.anime-list-item-image-container
|
||||||
a.ajax(href=comparison.Anime.Link())
|
a.ajax(href=comparison.Anime.Link())
|
||||||
img.anime-list-item-image.lazy(data-src=comparison.Anime.Image("small"), data-webp="true", alt=comparison.Anime.Title.ByUser(user))
|
img.anime-list-item-image.lazy(data-src=comparison.Anime.ImageLink("small"), data-webp="true", alt=comparison.Anime.Title.ByUser(user))
|
||||||
|
|
||||||
td.anime-list-item-name
|
td.anime-list-item-name
|
||||||
a.ajax(href=comparison.Anime.Link())= comparison.Anime.Title.ByUser(user)
|
a.ajax(href=comparison.Anime.Link())= comparison.Anime.Title.ByUser(user)
|
||||||
|
@ -28,6 +28,24 @@ func Main(ctx *aero.Context) string {
|
|||||||
return ctx.HTML(components.EditAnimeTabs(anime) + editform.Render(anime, "Edit anime", user))
|
return ctx.HTML(components.EditAnimeTabs(anime) + editform.Render(anime, "Edit anime", user))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Images anime images edit page.
|
||||||
|
func Images(ctx *aero.Context) string {
|
||||||
|
id := ctx.Get("id")
|
||||||
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
|
return ctx.Error(http.StatusUnauthorized, "Not logged in or not auhorized to edit this anime", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
anime, err := arn.GetAnime(id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ctx.Error(http.StatusNotFound, "Anime not found", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx.HTML(components.EditAnimeImages(anime))
|
||||||
|
}
|
||||||
|
|
||||||
// Characters anime characters edit page.
|
// Characters anime characters edit page.
|
||||||
func Characters(ctx *aero.Context) string {
|
func Characters(ctx *aero.Context) string {
|
||||||
id := ctx.Get("id")
|
id := ctx.Get("id")
|
||||||
|
@ -5,7 +5,8 @@ component EditAnimeTabs(anime *arn.Anime)
|
|||||||
span Anime
|
span Anime
|
||||||
|
|
||||||
Tab("Edit", "pencil", anime.Link() + "/edit")
|
Tab("Edit", "pencil", anime.Link() + "/edit")
|
||||||
Tab("Characters", "pencil", anime.Link() + "/edit/characters")
|
Tab("Images", "image", anime.Link() + "/edit/images")
|
||||||
Tab("Relations", "pencil", anime.Link() + "/edit/relations")
|
Tab("Characters", "users", anime.Link() + "/edit/characters")
|
||||||
Tab("Episodes", "pencil", anime.Link() + "/edit/episodes")
|
Tab("Relations", "sync-alt", anime.Link() + "/edit/relations")
|
||||||
|
Tab("Episodes", "list-ol", anime.Link() + "/edit/episodes")
|
||||||
Tab("History", "history", anime.Link() + "/edit/history")
|
Tab("History", "history", anime.Link() + "/edit/history")
|
15
pages/editanime/images.pixy
Normal file
15
pages/editanime/images.pixy
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
component EditAnimeImages(anime *arn.Anime)
|
||||||
|
EditAnimeTabs(anime)
|
||||||
|
|
||||||
|
.widget-form
|
||||||
|
h1.mountable Edit anime images
|
||||||
|
|
||||||
|
.widget.mountable(data-api="/api/anime/" + anime.ID)
|
||||||
|
h3.widget-title
|
||||||
|
Icon("picture-o")
|
||||||
|
span Image
|
||||||
|
|
||||||
|
InputImage("anime-image-input", "File", "/api/upload/anime/" + anime.ID + "/image")
|
||||||
|
|
||||||
|
.anime-image-container
|
||||||
|
img#anime-image-input-preview.anime-cover-image.lazy(data-src=anime.ImageLink("large"), data-webp="true", alt="Anime image")
|
@ -8,7 +8,7 @@ component CompareMAL(comparisons []*utils.MALComparison, year string, status str
|
|||||||
.data-comparison.mountable
|
.data-comparison.mountable
|
||||||
.data-comparison-header
|
.data-comparison-header
|
||||||
a.data-comparison-image-container(href=comparison.Anime.Link(), target="_blank")
|
a.data-comparison-image-container(href=comparison.Anime.Link(), target="_blank")
|
||||||
img.data-comparison-image.lazy(data-src=comparison.Anime.Image("small"), data-webp="true", alt=comparison.Anime.Title.ByUser(user))
|
img.data-comparison-image.lazy(data-src=comparison.Anime.ImageLink("small"), data-webp="true", alt=comparison.Anime.Title.ByUser(user))
|
||||||
|
|
||||||
.data-comparison-title
|
.data-comparison-title
|
||||||
a(href=comparison.Anime.Link(), target="_blank")= comparison.Anime.Title.Canonical
|
a(href=comparison.Anime.Link(), target="_blank")= comparison.Anime.Title.Canonical
|
||||||
|
@ -3,7 +3,7 @@ component AnimeEpisode(anime *arn.Anime, episode *arn.AnimeEpisode, user *arn.Us
|
|||||||
|
|
||||||
.episode-view-image-container
|
.episode-view-image-container
|
||||||
a.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
a.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
||||||
img.anime-cover-image.lazy(data-src=anime.Image("large"), data-webp="true", alt=anime.Title.ByUser(user))
|
img.anime-cover-image.lazy(data-src=anime.ImageLink("large"), data-webp="true", alt=anime.Title.ByUser(user))
|
||||||
|
|
||||||
h3.episode-view-number= "Episode " + strconv.Itoa(episode.Number)
|
h3.episode-view-number= "Episode " + strconv.Itoa(episode.Number)
|
||||||
|
|
||||||
|
@ -9,4 +9,4 @@ component Genres(genres []string, genreToAnime map[string]*arn.Anime, user *arn.
|
|||||||
RawIcon(arn.GetGenreIcon(genre))
|
RawIcon(arn.GetGenreIcon(genre))
|
||||||
span.genre-text-only= genre
|
span.genre-text-only= genre
|
||||||
|
|
||||||
img.genre-image.back(src=genreToAnime[genre].Image("medium"), alt=genreToAnime[genre].Title.ByUser(user), title=genre)
|
img.genre-image.back(src=genreToAnime[genre].ImageLink("medium"), alt=genreToAnime[genre].Title.ByUser(user), title=genre)
|
@ -108,6 +108,7 @@ func Configure(app *aero.Application) {
|
|||||||
|
|
||||||
// Edit anime
|
// Edit anime
|
||||||
l.Page("/anime/:id/edit", editanime.Main)
|
l.Page("/anime/:id/edit", editanime.Main)
|
||||||
|
l.Page("/anime/:id/edit/images", editanime.Images)
|
||||||
l.Page("/anime/:id/edit/characters", editanime.Characters)
|
l.Page("/anime/:id/edit/characters", editanime.Characters)
|
||||||
l.Page("/anime/:id/edit/relations", editanime.Relations)
|
l.Page("/anime/:id/edit/relations", editanime.Relations)
|
||||||
l.Page("/anime/:id/edit/episodes", editanime.Episodes)
|
l.Page("/anime/:id/edit/episodes", editanime.Episodes)
|
||||||
@ -216,6 +217,7 @@ func Configure(app *aero.Application) {
|
|||||||
// Upload
|
// Upload
|
||||||
app.Post("/api/upload/avatar", upload.Avatar)
|
app.Post("/api/upload/avatar", upload.Avatar)
|
||||||
app.Post("/api/upload/cover", upload.Cover)
|
app.Post("/api/upload/cover", upload.Cover)
|
||||||
|
app.Post("/api/upload/anime/:id/image", upload.AnimeImage)
|
||||||
|
|
||||||
// Admin
|
// Admin
|
||||||
l.Page("/admin", admin.Get)
|
l.Page("/admin", admin.Get)
|
||||||
|
@ -8,7 +8,7 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
|
|||||||
each item in animeList.Items
|
each item in animeList.Items
|
||||||
if item.Status == arn.AnimeListStatusWatching || item.Status == arn.AnimeListStatusCompleted
|
if item.Status == arn.AnimeListStatusWatching || item.Status == arn.AnimeListStatusCompleted
|
||||||
a.profile-watching-list-item.ajax(href=item.Anime().Link(), title=item.Anime().Title.ByUser(user) + " (" + toString(item.Episodes) + " / " + arn.EpisodesToString(item.Anime().EpisodeCount) + ")")
|
a.profile-watching-list-item.ajax(href=item.Anime().Link(), title=item.Anime().Title.ByUser(user) + " (" + toString(item.Episodes) + " / " + arn.EpisodesToString(item.Anime().EpisodeCount) + ")")
|
||||||
img.profile-watching-list-item-image.lazy(data-src=item.Anime().Image("small"), data-webp="true", alt=item.Anime().Title.ByUser(user))
|
img.profile-watching-list-item-image.lazy(data-src=item.Anime().ImageLink("small"), data-webp="true", alt=item.Anime().Title.ByUser(user))
|
||||||
|
|
||||||
.footer
|
.footer
|
||||||
.buttons
|
.buttons
|
||||||
|
@ -58,4 +58,4 @@ component QuoteTabs(quote *arn.Quote, user *arn.User)
|
|||||||
|
|
||||||
component QuoteAnime(anime *arn.Anime, user *arn.User)
|
component QuoteAnime(anime *arn.Anime, user *arn.User)
|
||||||
a.quote-anime-list-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
a.quote-anime-list-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
||||||
img.quote-anime-list-item-image.lazy(data-src=anime.Image("small"), data-webp="true", alt=anime.Title.ByUser(user))
|
img.quote-anime-list-item-image.lazy(data-src=anime.ImageLink("small"), data-webp="true", alt=anime.Title.ByUser(user))
|
@ -44,7 +44,7 @@ component AnimeSearchResults(animes []*arn.Anime)
|
|||||||
.profile-watching-list.anime-search
|
.profile-watching-list.anime-search
|
||||||
each anime in animes
|
each anime in animes
|
||||||
a.profile-watching-list-item.mountable.ajax(href=anime.Link(), title=anime.Title.Canonical, data-mountable-type="anime")
|
a.profile-watching-list-item.mountable.ajax(href=anime.Link(), title=anime.Title.Canonical, data-mountable-type="anime")
|
||||||
img.anime-cover-image.anime-search-result.lazy(data-src=anime.Image("small"), data-webp="true", alt=anime.Title.Canonical)
|
img.anime-cover-image.anime-search-result.lazy(data-src=anime.ImageLink("small"), data-webp="true", alt=anime.Title.Canonical)
|
||||||
|
|
||||||
component CharacterSearchResults(characters []*arn.Character)
|
component CharacterSearchResults(characters []*arn.Character)
|
||||||
if len(characters) == 0
|
if len(characters) == 0
|
||||||
|
@ -31,7 +31,7 @@ func Edit(ctx *aero.Context) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if track.MainAnime() != nil {
|
if track.MainAnime() != nil {
|
||||||
ctx.Data.(*arn.OpenGraph).Tags["og:image"] = track.MainAnime().Image("large")
|
ctx.Data.(*arn.OpenGraph).Tags["og:image"] = track.MainAnime().ImageLink("large")
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.HTML(components.SoundTrackTabs(track, user) + editform.Render(track, "Edit soundtrack", user))
|
return ctx.HTML(components.SoundTrackTabs(track, user) + editform.Render(track, "Edit soundtrack", user))
|
||||||
|
@ -29,7 +29,7 @@ func Get(ctx *aero.Context) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if track.MainAnime() != nil {
|
if track.MainAnime() != nil {
|
||||||
openGraph.Tags["og:image"] = track.MainAnime().Image("large")
|
openGraph.Tags["og:image"] = track.MainAnime().ImageLink("large")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set video so that it can be played
|
// Set video so that it can be played
|
||||||
|
@ -26,7 +26,7 @@ component SoundTrackPage(track *arn.SoundTrack, user *arn.User)
|
|||||||
.soundtrack-anime-list
|
.soundtrack-anime-list
|
||||||
each anime in track.Anime()
|
each anime in track.Anime()
|
||||||
a.soundtrack-anime-list-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
a.soundtrack-anime-list-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
||||||
img.soundtrack-anime-list-item-image.lazy(data-src=anime.Image("small"), data-webp="true", alt=anime.Title.ByUser(user))
|
img.soundtrack-anime-list-item-image.lazy(data-src=anime.ImageLink("small"), data-webp="true", alt=anime.Title.ByUser(user))
|
||||||
|
|
||||||
//- TODO: This is quite ineffective, performance-wise
|
//- TODO: This is quite ineffective, performance-wise
|
||||||
if len(track.OsuBeatmaps()) > 0 || len(track.EtternaBeatmaps()) > 0
|
if len(track.OsuBeatmaps()) > 0 || len(track.EtternaBeatmaps()) > 0
|
||||||
|
45
pages/upload/anime-image.go
Normal file
45
pages/upload/anime-image.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package upload
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/animenotifier/arn"
|
||||||
|
|
||||||
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AnimeImage handles the anime image upload.
|
||||||
|
func AnimeImage(ctx *aero.Context) string {
|
||||||
|
user := utils.GetUser(ctx)
|
||||||
|
animeID := ctx.Get("id")
|
||||||
|
|
||||||
|
if user == nil || (user.Role != "editor" && user.Role != "admin") {
|
||||||
|
return ctx.Error(http.StatusUnauthorized, "Not authorized", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
anime, err := arn.GetAnime(animeID)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ctx.Error(http.StatusNotFound, "Anime not found", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve file from post body
|
||||||
|
data, err := ctx.Request().Body().Bytes()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ctx.Error(http.StatusInternalServerError, "Reading request body failed", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set anime image file
|
||||||
|
err = anime.SetImageBytes(data)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ctx.Error(http.StatusInternalServerError, "Invalid image format", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save image information
|
||||||
|
anime.Save()
|
||||||
|
|
||||||
|
return "ok"
|
||||||
|
}
|
@ -11,34 +11,34 @@ func main() {
|
|||||||
defer arn.Node.Close()
|
defer arn.Node.Close()
|
||||||
|
|
||||||
for anime := range arn.StreamAnime() {
|
for anime := range arn.StreamAnime() {
|
||||||
base := path.Join(os.Getenv("GOPATH"), "/src/github.com/animenotifier/notify.moe/images/anime/original/", anime.ID)
|
base := path.Join(arn.Root, "/images/anime/original/", anime.ID)
|
||||||
|
|
||||||
if _, err := os.Stat(base + ".png"); err == nil {
|
if _, err := os.Stat(base + ".png"); err == nil {
|
||||||
anime.ImageExtension = ".png"
|
anime.Image.Extension = ".png"
|
||||||
anime.Save()
|
anime.Save()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(base + ".jpg"); err == nil {
|
if _, err := os.Stat(base + ".jpg"); err == nil {
|
||||||
anime.ImageExtension = ".jpg"
|
anime.Image.Extension = ".jpg"
|
||||||
anime.Save()
|
anime.Save()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(base + ".jpeg"); err == nil {
|
if _, err := os.Stat(base + ".jpeg"); err == nil {
|
||||||
anime.ImageExtension = ".jpg"
|
anime.Image.Extension = ".jpg"
|
||||||
anime.Save()
|
anime.Save()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(base + ".gif"); err == nil {
|
if _, err := os.Stat(base + ".gif"); err == nil {
|
||||||
anime.ImageExtension = ".gif"
|
anime.Image.Extension = ".gif"
|
||||||
anime.Save()
|
anime.Save()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(base + ".webp"); err == nil {
|
if _, err := os.Stat(base + ".webp"); err == nil {
|
||||||
anime.ImageExtension = ".webp"
|
anime.Image.Extension = ".webp"
|
||||||
anime.Save()
|
anime.Save()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import { StatusMessage } from "../StatusMessage"
|
|||||||
|
|
||||||
// Select file
|
// Select file
|
||||||
export function selectFile(arn: AnimeNotifier, button: HTMLButtonElement) {
|
export function selectFile(arn: AnimeNotifier, button: HTMLButtonElement) {
|
||||||
if(arn.user.dataset.pro !== "true") {
|
if(button.dataset.endpoint === "/api/upload/cover" && arn.user.dataset.pro !== "true") {
|
||||||
alert("Please buy a PRO account to use this feature.")
|
alert("Please buy a PRO account to use this feature.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ func RenderField(b *bytes.Buffer, v *reflect.Value, field reflect.StructField, i
|
|||||||
anime, err := arn.GetAnime(animeID)
|
anime, err := arn.GetAnime(animeID)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
b.WriteString(components.EditFormImagePreview(anime.Link(), anime.Image("small"), true))
|
b.WriteString(components.EditFormImagePreview(anime.Link(), anime.ImageLink("small"), true))
|
||||||
}
|
}
|
||||||
|
|
||||||
case "Character":
|
case "Character":
|
||||||
|
Loading…
Reference in New Issue
Block a user