-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1e81d5
commit 7812674
Showing
76 changed files
with
1,832 additions
and
1,993 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
backend/src/main/kotlin/net/perfectdreams/galleryofdreams/backend/components/FanArtArtist.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package net.perfectdreams.galleryofdreams.backend.components | ||
|
||
import kotlinx.html.* | ||
import kotlinx.serialization.json.buildJsonObject | ||
import kotlinx.serialization.json.put | ||
import net.perfectdreams.galleryofdreams.backend.utils.FanArtUtils | ||
import net.perfectdreams.galleryofdreams.backend.utils.websiteLocaleIdPath | ||
import net.perfectdreams.galleryofdreams.common.data.FanArtArtistX | ||
import net.perfectdreams.i18nhelper.core.I18nContext | ||
|
||
fun FlowContent.fanArtArtist( | ||
i18nContext: I18nContext, | ||
dssBaseUrl: String, | ||
namespace: String, | ||
artist: FanArtArtistX, | ||
fanArtCount: Long | ||
) { | ||
div { | ||
a(classes = "entry", href = "/${i18nContext.websiteLocaleIdPath}/artists/${artist.slug}") { | ||
attributes["hx-target"] = "#content" | ||
|
||
val url = FanArtUtils.getArtistAvatarUrl(dssBaseUrl, namespace, artist, 32) | ||
|
||
img(src = url) { | ||
style = "object-fit: cover; border-radius: 100%;" | ||
attributes["loading"] = "lazy" | ||
width = "32" | ||
height = "32" | ||
} | ||
|
||
div { | ||
style = "display: flex; flex-direction: column;" | ||
|
||
div { | ||
text(artist.name) | ||
} | ||
|
||
div { | ||
style = "font-size: 0.8em;" | ||
text("$fanArtCount fan arts") | ||
} | ||
} | ||
} | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
backend/src/main/kotlin/net/perfectdreams/galleryofdreams/backend/components/FanArtCard.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package net.perfectdreams.galleryofdreams.backend.components | ||
|
||
import kotlinx.datetime.toLocalDateTime | ||
import kotlinx.html.* | ||
import net.perfectdreams.galleryofdreams.backend.GalleryOfDreamsBackend | ||
import net.perfectdreams.galleryofdreams.backend.utils.FanArtUtils | ||
import net.perfectdreams.galleryofdreams.backend.utils.icon | ||
import net.perfectdreams.galleryofdreams.backend.utils.websiteLocaleIdPath | ||
import net.perfectdreams.galleryofdreams.common.MediaTypeUtils | ||
import net.perfectdreams.galleryofdreams.common.data.FanArt | ||
import net.perfectdreams.galleryofdreams.common.data.FanArtArtistX | ||
import net.perfectdreams.galleryofdreams.common.i18n.I18nKeysData | ||
import net.perfectdreams.i18nhelper.core.I18nContext | ||
|
||
fun FlowContent.fanArtCard(m: GalleryOfDreamsBackend, i18nContext: I18nContext, dssBaseUrl: String, namespace: String, fanArtArtist: FanArtArtistX, fanArt: FanArt) { | ||
a(classes = "fan-art-card", href = "/${i18nContext.websiteLocaleIdPath}/artists/${fanArtArtist.slug}/${fanArt.slug}") { | ||
attributes["hx-target"] = "#content" | ||
|
||
div(classes = "fan-art-info-card") { | ||
div(classes = "fan-art-tags") { | ||
for (tag in fanArt.tags) { | ||
val icon = tag.icon(m) | ||
icon?.apply(this) { | ||
style = "height: 100%;" | ||
} | ||
} | ||
} | ||
|
||
div(classes = "fan-art-info") { | ||
div(classes = "fan-art-info-wrapper") { | ||
div(classes = "fan-art-title") { | ||
text(fanArt.title ?: i18nContext.get(I18nKeysData.FanArtBy(fanArtArtist.name))) | ||
} | ||
|
||
div(classes = "fan-art-avatar-artist-and-date") { | ||
img(src = FanArtUtils.getArtistAvatarUrl(dssBaseUrl, namespace, fanArtArtist, 32)) { | ||
style = "object-fit: cover; border-radius: 100%;" | ||
width = "32" | ||
height = "32" | ||
attributes["loading"] = "lazy" | ||
} | ||
|
||
div(classes = "fan-art-artist-and-date") { | ||
div(classes = "fan-art-artist") { | ||
text(fanArtArtist.name) | ||
} | ||
div(classes = "fan-art-info-date") { | ||
val date = fanArt.createdAt | ||
.toLocalDateTime(kotlinx.datetime.TimeZone.UTC) | ||
.date | ||
|
||
val year = date.year.toString().padStart(4, '0') | ||
val month = date.monthNumber.toString().padStart(2, '0') | ||
val day = date.dayOfMonth.toString().padStart(2, '0') | ||
text("$day/$month/$year") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
val extension = MediaTypeUtils.convertContentTypeToExtension(fanArt.preferredMediaType) | ||
img(src = "$dssBaseUrl/$namespace/fan-arts/${fanArt.file}.$extension") { | ||
style = "width: 100%; height: 100%; object-fit: cover;" | ||
attributes["loading"] = "lazy" | ||
alt = i18nContext.get(I18nKeysData.FanArtBy(fanArtArtist.name)) | ||
} | ||
} | ||
} |
Oops, something went wrong.