~wegtam/smederee
Showing details for patch e8c99a780b74b016dddf0748007331af7323ebfb.
diff -rN -u old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/format/formatBytes.scala.html new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/format/formatBytes.scala.html --- old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/format/formatBytes.scala.html 1970-01-01 00:00:00.000000000 +0000 +++ new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/format/formatBytes.scala.html 2024-11-22 21:39:18.017644641 +0000 @@ -0,0 +1,4 @@ +@(bytes: Long) +@defining((63 - java.lang.Long.numberOfLeadingZeros(bytes)) / 10) { exponent => + @defining(List("B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB").get(exponent)) { unit => @{Messages.DefaultByteFormat.format(bytes.toDouble / (1L << (exponent * 10)))} @unit } +} diff -rN -u old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryFiles.scala.html new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryFiles.scala.html --- old-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryFiles.scala.html 2024-11-22 21:39:18.017644641 +0000 +++ new-smederee/modules/hub/src/main/twirl/de/smederee/hub/views/showRepositoryFiles.scala.html 2024-11-22 21:39:18.017644641 +0000 @@ -2,6 +2,7 @@ @import de.smederee.html.RenderableContent @import de.smederee.html.ToDoTextCssMapping.* @import de.smederee.hub.* +@import de.smederee.hub.views.html.format.* @( baseUri: Uri, @@ -46,7 +47,7 @@ <tr> <th></th> <th>Name</th> - <th>Size</th> + <th style="text-align: right;">Size</th> <th>Modified</th> </tr> </thead> @@ -62,7 +63,7 @@ <tr> <td>@if(entry._2.isDir) { @icon(baseUri)("folder") } else { @icon(baseUri)("file") }</td> <td><a href="@actionBaseUri.addSegment(entry._1.last)">@{entry._1}</a></td> - <td>@{entry._2.size}</td> + <td style="text-align: right;">@formatBytes(entry._2.size)</td> <td>@{entry._2.mtime}</td> </tr> } diff -rN -u old-smederee/modules/i18n/src/main/scala/de/smederee/i18n/Messages.scala new-smederee/modules/i18n/src/main/scala/de/smederee/i18n/Messages.scala --- old-smederee/modules/i18n/src/main/scala/de/smederee/i18n/Messages.scala 2024-11-22 21:39:18.017644641 +0000 +++ new-smederee/modules/i18n/src/main/scala/de/smederee/i18n/Messages.scala 2024-11-22 21:39:18.021644648 +0000 @@ -6,6 +6,7 @@ package de.smederee.i18n +import java.text.DecimalFormat import java.text.MessageFormat import java.util.Locale import java.util.ResourceBundle @@ -19,8 +20,9 @@ object Messages { private val log = LoggerFactory.getLogger(getClass) - val DefaultLocale: Locale = Locale.ENGLISH - val Filename: String = "messages" + val DefaultByteFormat: DecimalFormat = new DecimalFormat("#.##") + val DefaultLocale: Locale = Locale.ENGLISH + val Filename: String = "messages" /** Provide a way to simply write `Messages("my.key", foo, bar)` to translate stuff. This function will catch * possible exceptions underneath and in case of an error will log an error message and the underlying exception