diff --git a/views/components/doctype.templ b/views/components/doctype.templ
index 51d3de2..825eed4 100644
--- a/views/components/doctype.templ
+++ b/views/components/doctype.templ
@@ -2,7 +2,7 @@ package components
templ Doctype() {
-
+
{ children... }
}
diff --git a/views/homeview/homeview.templ b/views/homeview/homeview.templ
index d4413b5..751e371 100644
--- a/views/homeview/homeview.templ
+++ b/views/homeview/homeview.templ
@@ -49,7 +49,7 @@ templ HomeContent(c *views.Context, data Data) {
There are no recently added images in the current time range.
} else {
- Added Images: { strconv.FormatInt(data.TotalImages, 10) }
+ { strconv.FormatInt(data.TotalImages, 10) } Images
}
for _, recently := range data.RecentlyAddedImages {
diff --git a/views/homeview/recently_added_image.templ b/views/homeview/recently_added_image.templ
index 9b85e76..7393daa 100644
--- a/views/homeview/recently_added_image.templ
+++ b/views/homeview/recently_added_image.templ
@@ -3,8 +3,6 @@ package homeview
import "github.com/tigorlazuardi/redmage/models"
import "fmt"
import "github.com/tigorlazuardi/redmage/views/utils"
-import "strconv"
-import "github.com/alecthomas/units"
type ImageCardOption uint
@@ -45,18 +43,28 @@ templ RecentlyAddedImageCard(data *models.Image, opts ImageCardOption) {
@utils.RelativeTimeNode(fmt.Sprintf("relative-time-%s", data.PostName), data.CreatedAt, "text-sm")
-
-
Width
-
{ strconv.Itoa(int(data.ImageWidth)) } px
-
Height
-
{ strconv.Itoa(int(data.ImageHeight)) } px
-
Size
-
{ units.MetricBytes(data.ImageSize).Round(1).String() }
+
+
{ fmt.Sprintf("%d \u00d7 %d", data.ImageWidth, data.ImageHeight) } px
+
{ formatByteSize(data.ImageSize) }
}
+func formatByteSize(size int64) string {
+ if size < 1024 {
+ return fmt.Sprintf("%d B", size)
+ }
+ if size < 1024*1024 {
+ return fmt.Sprintf("%.2f KiB", float64(size)/1024)
+ }
+ if size < 1024*1024*1024 {
+ return fmt.Sprintf("%.2f MiB", float64(size)/(1024*1024))
+ }
+ return fmt.Sprintf("%.2f GiB", float64(size)/(1024*1024*1024))
+
+}
+
func truncateTitle(title string) string {
if len(title) > 50 {
return title[:50] + "..."