Skip to content

Commit

Permalink
Merge pull request #299 from Shikkanime/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Ziedelth committed Mar 20, 2024
2 parents bde0ae9 + 716e67f commit e2ac8c2
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
val ktorVersion = "2.3.9"
val ktorSwaggerUiVersion = "2.7.4"
val ktorSwaggerUiVersion = "2.7.5"
val hibernateCoreVersion = "6.4.4.Final"
val ehcacheVersion = "3.10.8"
val glassfishJaxbVersion = "4.0.5"
Expand Down
37 changes: 30 additions & 7 deletions src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fr.shikkanime.controllers.site

import com.google.inject.Inject
import fr.shikkanime.dtos.AnimeDto
import fr.shikkanime.entities.SortParameter
import fr.shikkanime.entities.enums.CountryCode
import fr.shikkanime.entities.enums.Link
Expand Down Expand Up @@ -36,19 +37,41 @@ class SiteController {
)
}

private fun getFullAnimesSimulcast(): MutableList<AnimeDto> {
val animeSimulcastLimit = 6

val animes = animeCacheService.findAllBy(
CountryCode.FR,
simulcastCacheService.currentSimulcast?.uuid,
listOf(SortParameter("name", SortParameter.Order.ASC)),
1,
animeSimulcastLimit
)!!.data.toMutableList()

val simulcasts = simulcastCacheService.findAll()

if (animes.size in 1..<animeSimulcastLimit && simulcasts!!.size > 1) {
val previousSimulcastAnimes = animeCacheService.findAllBy(
CountryCode.FR,
simulcasts[1].uuid,
listOf(SortParameter("name", SortParameter.Order.ASC)),
1,
animeSimulcastLimit - animes.size
)!!.data

animes.addAll(previousSimulcastAnimes)
}

return animes
}

@Path
@Get
private fun home(): Response {
return Response.template(
Link.HOME,
mutableMapOf(
"animes" to animeCacheService.findAllBy(
CountryCode.FR,
simulcastCacheService.currentSimulcast?.uuid,
listOf(SortParameter("name", SortParameter.Order.ASC)),
1,
6
)!!.data,
"animes" to getFullAnimesSimulcast(),
"episodes" to episodeCacheService.findAllBy(
CountryCode.FR,
null,
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/site/_navigation.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</div>
</main>

<div class="container">
<div class="container-fluid px-md-5">
<footer class="d-flex flex-wrap justify-content-between align-items-center py-3 my-4 border-top">
<div class="col-md-4 d-flex align-items-center">
<div>
Expand Down Expand Up @@ -116,7 +116,7 @@
<ul class="mt-3 list-unstyled justify-content-end text-md-end">
<#list footerLinks as link>
<li>
<a href="${link.href}" class="text-muted">
<a href="${link.href}" class="text-muted text-decoration-none">
${link.name}
</a>
</li>
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/templates/site/anime.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
height="720">
</div>

<div class="col-md-8 col-12 mt-0 text-start mt-md-0 mt-5 d-flex flex-column justify-content-center">
<div class="col-md-8 col-12 text-start mt-md-0 mt-5 d-flex flex-column justify-content-center">
<h6 class="h6">${anime.shortName?upper_case}</h6>
<p class="text-muted">${anime.name}</p>

Expand All @@ -31,9 +31,9 @@
</div>
</div>

<div class="row mt-5 justify-content-center">
<div class="row g-3 mt-5 justify-content-center">
<#list episodes as episode>
<@episodeComponent.display episode=episode cover=false col="col-md-2" />
<@episodeComponent.display episode=episode cover=false desktopColSize="col-md-2" mobileColSize="col-6" />
</#list>
</div>
</@navigation.display>
5 changes: 3 additions & 2 deletions src/main/resources/templates/site/components/episode.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
</#switch>
</#function>

<#macro display episode col cover>
<div class="${col} col-12" x-data="{ hover: false }" @mouseenter="hover = true" @mouseleave="hover = false">
<#macro display episode desktopColSize mobileColSize cover>
<div class="${desktopColSize} ${mobileColSize}" x-data="{ hover: false }" @mouseenter="hover = true"
@mouseleave="hover = false">
<article>
<a href="${episode.url}" target="_blank" class="text-decoration-none text-white">
<div class="position-relative">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/site/home.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<#assign firstRow=true>
</#if>

<@episodeComponent.display episode=episode col=col cover=firstRow />
<@episodeComponent.display episode=episode desktopColSize=col mobileColSize="col-12" cover=firstRow />
</#list>
</div>
<#else>
Expand Down

0 comments on commit e2ac8c2

Please sign in to comment.