From 4d34b571fe4a798e715eda19ad36a6cb1945623c Mon Sep 17 00:00:00 2001 From: Ziedelth Date: Mon, 5 Feb 2024 20:36:09 +0100 Subject: [PATCH] Add episode description on site --- .../episode/EpisodeDtoToEpisodeConverter.kt | 1 + .../episode/EpisodeToEpisodeDtoConverter.kt | 1 + .../kotlin/fr/shikkanime/dtos/EpisodeDto.kt | 1 + .../fr/shikkanime/services/EpisodeService.kt | 1 + .../fr/shikkanime/services/ImageService.kt | 2 +- src/main/resources/assets/css/main.css | 12 +-- .../templates/admin/episodes/edit.ftl | 5 ++ src/main/resources/templates/site/home.ftl | 76 ++++++++++++++----- 8 files changed, 72 insertions(+), 27 deletions(-) diff --git a/src/main/kotlin/fr/shikkanime/converters/episode/EpisodeDtoToEpisodeConverter.kt b/src/main/kotlin/fr/shikkanime/converters/episode/EpisodeDtoToEpisodeConverter.kt index f52eec53..16df2173 100644 --- a/src/main/kotlin/fr/shikkanime/converters/episode/EpisodeDtoToEpisodeConverter.kt +++ b/src/main/kotlin/fr/shikkanime/converters/episode/EpisodeDtoToEpisodeConverter.kt @@ -32,6 +32,7 @@ class EpisodeDtoToEpisodeConverter : AbstractConverter() { url = from.url, image = from.image, duration = from.duration, + description = from.description, ) } } \ No newline at end of file diff --git a/src/main/kotlin/fr/shikkanime/converters/episode/EpisodeToEpisodeDtoConverter.kt b/src/main/kotlin/fr/shikkanime/converters/episode/EpisodeToEpisodeDtoConverter.kt index 35bc4463..1864c2d4 100644 --- a/src/main/kotlin/fr/shikkanime/converters/episode/EpisodeToEpisodeDtoConverter.kt +++ b/src/main/kotlin/fr/shikkanime/converters/episode/EpisodeToEpisodeDtoConverter.kt @@ -23,6 +23,7 @@ class EpisodeToEpisodeDtoConverter : AbstractConverter() { url = from.url!!, image = from.image!!, duration = from.duration, + description = from.description, uncensored = from.image!!.contains("nc/", true), ) } diff --git a/src/main/kotlin/fr/shikkanime/dtos/EpisodeDto.kt b/src/main/kotlin/fr/shikkanime/dtos/EpisodeDto.kt index efe9abd4..d1e82959 100644 --- a/src/main/kotlin/fr/shikkanime/dtos/EpisodeDto.kt +++ b/src/main/kotlin/fr/shikkanime/dtos/EpisodeDto.kt @@ -20,5 +20,6 @@ data class EpisodeDto( val url: String, val image: String, val duration: Long, + val description: String?, val uncensored: Boolean, ) : Serializable diff --git a/src/main/kotlin/fr/shikkanime/services/EpisodeService.kt b/src/main/kotlin/fr/shikkanime/services/EpisodeService.kt index c8ac1893..275932c2 100644 --- a/src/main/kotlin/fr/shikkanime/services/EpisodeService.kt +++ b/src/main/kotlin/fr/shikkanime/services/EpisodeService.kt @@ -140,6 +140,7 @@ class EpisodeService : AbstractService() { } parameters["duration"]?.takeIf { it.isNotBlank() }?.let { episode.duration = it.toLong() } + parameters["description"]?.takeIf { it.isNotBlank() }?.let { episode.description = it } val update = super.update(episode) MapCache.invalidate(Episode::class.java) diff --git a/src/main/kotlin/fr/shikkanime/services/ImageService.kt b/src/main/kotlin/fr/shikkanime/services/ImageService.kt index 42038529..70917e58 100644 --- a/src/main/kotlin/fr/shikkanime/services/ImageService.kt +++ b/src/main/kotlin/fr/shikkanime/services/ImageService.kt @@ -123,7 +123,7 @@ object ImageService { file.writeBytes(FileManager.toGzip(ObjectParser.toJson(cache).toByteArray())) } - logger.info("Saved images cache in $take ms ($originalSize} -> $compressedSize)") + logger.info("Saved images cache in $take ms ($originalSize -> $compressedSize)") change.set(false) } diff --git a/src/main/resources/assets/css/main.css b/src/main/resources/assets/css/main.css index 2beba9be..163b89bb 100644 --- a/src/main/resources/assets/css/main.css +++ b/src/main/resources/assets/css/main.css @@ -5,18 +5,12 @@ overflow: hidden; } -.anime-card-description-truncate { +.text-truncate-6 { display: -webkit-box; - -webkit-line-clamp: 17; + -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; -} - -/* On mobile, make anime-card-description-truncate on 8 lines */ -@media (max-width: 576px) { - .anime-card-description-truncate { - -webkit-line-clamp: 9; - } + text-overflow: ellipsis; } .text-muted { diff --git a/src/main/resources/templates/admin/episodes/edit.ftl b/src/main/resources/templates/admin/episodes/edit.ftl index 1b39a6f1..a527d751 100644 --- a/src/main/resources/templates/admin/episodes/edit.ftl +++ b/src/main/resources/templates/admin/episodes/edit.ftl @@ -88,6 +88,11 @@ +
+ + +
diff --git a/src/main/resources/templates/site/home.ftl b/src/main/resources/templates/site/home.ftl index 2db68651..b216e1a2 100644 --- a/src/main/resources/templates/site/home.ftl +++ b/src/main/resources/templates/site/home.ftl @@ -8,14 +8,42 @@ <#list episodes as episode> @@ -37,15 +65,23 @@
-
- + ${anime.shortName?replace( ${anime.shortName} -
-
- ${anime.description} +
+
+ ${anime.name?upper_case}
+ +
+ + <#if anime.description??> +
+ ${anime.description} +
+
@@ -57,15 +93,21 @@