From 65851b9128518f87b983443ea488e23b0e5b9eb6 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 9 Mar 2018 05:26:34 +0100 Subject: [PATCH] Added short synopsis diff --- pages/editor/mal.go | 13 +++++++++++-- pages/editor/mal.scarlet | 1 + utils/animediff/LongerSynopsis.go | 22 ++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 utils/animediff/LongerSynopsis.go diff --git a/pages/editor/mal.go b/pages/editor/mal.go index 6b49cfa5..959b96d8 100644 --- a/pages/editor/mal.go +++ b/pages/editor/mal.go @@ -12,7 +12,7 @@ import ( "github.com/animenotifier/notify.moe/utils" ) -const maxCompareMALEntries = 10 +const maxCompareMALEntries = 20 // CompareMAL ... func CompareMAL(ctx *aero.Context) string { @@ -60,7 +60,7 @@ func CompareMAL(ctx *aero.Context) string { malAnime := obj.(*mal.Anime) var differences []animediff.Difference - // Compare canonical titles + // Canonical title if anime.Title.Canonical != malAnime.Title { differences = append(differences, &animediff.CanonicalTitle{ TitleA: anime.Title.Canonical, @@ -68,6 +68,7 @@ func CompareMAL(ctx *aero.Context) string { }) } + // Japanese title if anime.Title.Japanese != malAnime.JapaneseTitle { differences = append(differences, &animediff.JapaneseTitle{ TitleA: anime.Title.Japanese, @@ -75,6 +76,14 @@ func CompareMAL(ctx *aero.Context) string { }) } + // Synopsis + if len(anime.Summary) < len(malAnime.Synopsis) { + differences = append(differences, &animediff.ShorterSynopsis{ + SynopsisA: anime.Summary, + SynopsisB: malAnime.Synopsis, + }) + } + // Compare genres hashA := utils.HashStringsNoOrder(anime.Genres) hashB := utils.HashStringsNoOrder(malAnime.Genres) diff --git a/pages/editor/mal.scarlet b/pages/editor/mal.scarlet index cfc37bbf..2a070dab 100644 --- a/pages/editor/mal.scarlet +++ b/pages/editor/mal.scarlet @@ -43,3 +43,4 @@ .data-comparison-difference-detail flex 1 + padding 0.5rem 0.75rem diff --git a/utils/animediff/LongerSynopsis.go b/utils/animediff/LongerSynopsis.go new file mode 100644 index 00000000..49a9cd6c --- /dev/null +++ b/utils/animediff/LongerSynopsis.go @@ -0,0 +1,22 @@ +package animediff + +// ShorterSynopsis describes differing Japanese titles. +type ShorterSynopsis struct { + SynopsisA string + SynopsisB string +} + +// String returns the description. +func (diff *ShorterSynopsis) String() string { + return "Synopsis is shorter" +} + +// DetailsA shows the details for the first anime. +func (diff *ShorterSynopsis) DetailsA() string { + return diff.SynopsisA +} + +// DetailsB shows the details for the second anime. +func (diff *ShorterSynopsis) DetailsB() string { + return diff.SynopsisB +}