Skip to content

Commit

Permalink
release: 0.1.4 (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb authored Apr 13, 2024
2 parents 5f4bcd5 + 57f884d commit 055c3fc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AnimationController(
@PathVariable("username") username: String,
response: HttpServletResponse
): String {
response.noCache()
response.cacheControl(3600)
return animationFacade.getFarmAnimation(username)
}

Expand All @@ -28,14 +28,16 @@ class AnimationController(
@RequestParam(name = "pet-id", defaultValue = "0") personaId: Long,
response: HttpServletResponse,
): String {
response.noCache()
response.cacheControl(3600)
return animationFacade.getLineAnimation(username, personaId)
}

fun HttpServletResponse.noCache(): HttpServletResponse {
this.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, must-revalidate")
fun HttpServletResponse.cacheControl(maxAgeSeconds: Int): HttpServletResponse {
this.setHeader(
HttpHeaders.CACHE_CONTROL,
"no-cache, no-store, must-revalidate, max-age=$maxAgeSeconds"
)
this.setHeader(HttpHeaders.PRAGMA, "no-cache")
this.setHeader(HttpHeaders.EXPIRES, "0")
return this
}
}
10 changes: 4 additions & 6 deletions src/main/kotlin/org/gitanimals/render/domain/FieldType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package org.gitanimals.render.domain
enum class FieldType {

WHITE_FIELD {
override fun loadComponent(name: String, commit: Long, visit: Long): String {
override fun loadComponent(name: String, commit: Long): String {
return whiteFieldSvg.replace(NAME_FIX, name.uppercase().toSvg(0.0, 3.0))
.replace(COMMIT_FIX, commit.toSvg("commit", 85.0, 4.0))
.replace(VISIT_FIX, visit.toSvg("visit", 70.0, 4.0))
}

override fun fillBackground(): String =
Expand All @@ -16,10 +15,9 @@ enum class FieldType {
"<rect x=\"0.5\" y=\"0.5\" width=\"599\" height=\"299\" rx=\"4.5\" stroke=\"#D9D9D9\" fill=\"none\"/>"
},
SNOWY_FIELD {
override fun loadComponent(name: String, commit: Long, visit: Long): String {
override fun loadComponent(name: String, commit: Long): String {
return snowyFieldSvg.replace(NAME_FIX, name.uppercase().toSvg(0.0, 3.0))
.replace(COMMIT_FIX, commit.toSvg("commit", 85.0, 4.0))
.replace(VISIT_FIX, visit.toSvg("visit", 70.0, 4.0))
}

override fun fillBackground(): String {
Expand All @@ -43,7 +41,7 @@ enum class FieldType {
},
;

abstract fun loadComponent(name: String, commit: Long, visit: Long): String
abstract fun loadComponent(name: String, commit: Long): String

abstract fun fillBackground(): String

Expand Down Expand Up @@ -158,7 +156,7 @@ enum class FieldType {
this.toString().forEach { char ->
val index = char.digitToInt()
val mediumNumberSvg = mediumNumberSvgs[index]
builder.append("<g id=\"$id$index\" transform=\"translate($currentX, 2)\">")
builder.append("<g id=\"$id$index\" transform=\"translate($currentX, 0)\">")
.append(mediumNumberSvg)
.append("</g>")
currentX += xIncrease + mediumNumberWidth[index]
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/gitanimals/render/domain/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class User(
personas.asSequence()
.forEach { builder.append(it.toSvg()) }

return builder.append(field.loadComponent(name, contributions.totalCount(), visit))
return builder.append(field.loadComponent(name, contributions.totalCount()))
.append(field.drawBorder())
.closeSvg()
}
Expand Down
7 changes: 1 addition & 6 deletions src/main/resources/persona/field/snowy-field.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 1 addition & 6 deletions src/main/resources/persona/field/white-field.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 055c3fc

Please sign in to comment.