diff --git a/exampleSite/content/shortcodes/attachments.en.files/hugo.txt b/exampleSite/content/shortcodes/attachments.en.files/hugo.txt new file mode 100644 index 0000000000..19b69f481f --- /dev/null +++ b/exampleSite/content/shortcodes/attachments.en.files/hugo.txt @@ -0,0 +1 @@ +This is a small text \ No newline at end of file diff --git a/i18n/ar.toml b/i18n/ar.toml index 74e08805d6..85bbc01ff8 100644 --- a/i18n/ar.toml +++ b/i18n/ar.toml @@ -25,8 +25,14 @@ other = "المزيد" [Expand-title] other = "...قم بتوسيع" -[BinaryPrefix-kilobyte] -other = "kb" +[Byte-symbol] +other = "B" + +[Kilobyte-symbol] +other = "KB" + +[Megabyte-symbol] +other = "MB" [note] other = "Note" diff --git a/i18n/de.toml b/i18n/de.toml index 84fb38fd23..66ee78c98f 100644 --- a/i18n/de.toml +++ b/i18n/de.toml @@ -25,8 +25,14 @@ other = "Mehr" [Expand-title] other = "Erweitere mich..." -[BinaryPrefix-kilobyte] -other = "kb" +[Byte-symbol] +other = "B" + +[Kilobyte-symbol] +other = "KB" + +[Megabyte-symbol] +other = "MB" [note] other = "Anmerkung" diff --git a/i18n/en.toml b/i18n/en.toml index 5051c23e15..ef0d31b424 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -25,8 +25,14 @@ other = "More" [Expand-title] other = "Expand me..." -[BinaryPrefix-kilobyte] -other = "kb" +[Byte-symbol] +other = "B" + +[Kilobyte-symbol] +other = "KB" + +[Megabyte-symbol] +other = "MB" [note] other = "Note" diff --git a/i18n/es.toml b/i18n/es.toml index 49abeb55d8..4f8064f07c 100644 --- a/i18n/es.toml +++ b/i18n/es.toml @@ -25,8 +25,14 @@ other = "Más" [Expand-title] other = "Expandir..." -[BinaryPrefix-kilobyte] -other = "kb" +[Byte-symbol] +other = "B" + +[Kilobyte-symbol] +other = "KB" + +[Megabyte-symbol] +other = "MB" [note] other = "Nota" diff --git a/i18n/fr.toml b/i18n/fr.toml index 672f5b8f10..b92493fb6a 100644 --- a/i18n/fr.toml +++ b/i18n/fr.toml @@ -25,9 +25,15 @@ other = "Aller plus loin" [Expand-title] other = "Déroulez-moi..." -[BinaryPrefix-kilobyte] +[Byte-symbol] +other = "o" + +[Kilobyte-symbol] other = "ko" +[Megabyte-symbol] +other = "Mo" + [note] other = "Remarque" diff --git a/i18n/hi.toml b/i18n/hi.toml index 48d435defb..9e09f68687 100644 --- a/i18n/hi.toml +++ b/i18n/hi.toml @@ -25,8 +25,14 @@ other = "अधिक सामग्री दिखाएं" [Expand-title] other = "विस्तार करे..." -[BinaryPrefix-kilobyte] -other = "kb" +[Byte-symbol] +other = "B" + +[Kilobyte-symbol] +other = "KB" + +[Megabyte-symbol] +other = "MB" [note] other = "Note" diff --git a/i18n/id.toml b/i18n/id.toml index 1ab5c0775d..a8bcd3d55d 100644 --- a/i18n/id.toml +++ b/i18n/id.toml @@ -25,8 +25,14 @@ other = "Lainnya" [Expand-title] other = "Bentangkan..." -[BinaryPrefix-kilobyte] -other = "kb" +[Byte-symbol] +other = "B" + +[Kilobyte-symbol] +other = "KB" + +[Megabyte-symbol] +other = "MB" [note] other = "Note" diff --git a/i18n/ja.toml b/i18n/ja.toml index 3b84fd4bd2..c357d13a9c 100644 --- a/i18n/ja.toml +++ b/i18n/ja.toml @@ -25,8 +25,14 @@ other = "更に" [Expand-title] other = "開く..." -[BinaryPrefix-kilobyte] -other = "kb" +[Byte-symbol] +other = "B" + +[Kilobyte-symbol] +other = "KB" + +[Megabyte-symbol] +other = "MB" [note] other = "Note" diff --git a/i18n/nl.toml b/i18n/nl.toml index 63123dd00b..5ad56bd2e4 100644 --- a/i18n/nl.toml +++ b/i18n/nl.toml @@ -25,8 +25,14 @@ other = "Snelkoppelingen" [Expand-title] other = "Lees meer..." -[BinaryPrefix-kilobyte] -other = "kb" +[Byte-symbol] +other = "B" + +[Kilobyte-symbol] +other = "KB" + +[Megabyte-symbol] +other = "MB" [note] other = "Note" diff --git a/i18n/pt.toml b/i18n/pt.toml index b747d4f64f..6532da9cd2 100644 --- a/i18n/pt.toml +++ b/i18n/pt.toml @@ -25,8 +25,14 @@ other = "Mais" [Expand-title] other = "Expandir..." -[BinaryPrefix-kilobyte] -other = "kb" +[Byte-symbol] +other = "B" + +[Kilobyte-symbol] +other = "KB" + +[Megabyte-symbol] +other = "MB" [note] other = "Nota" diff --git a/i18n/ru.toml b/i18n/ru.toml index abfcf7ef52..69b44b7f6d 100644 --- a/i18n/ru.toml +++ b/i18n/ru.toml @@ -25,8 +25,14 @@ other = "Еще" [Expand-title] other = "Развернуть..." -[BinaryPrefix-kilobyte] -other = "килобайт" +[Byte-symbol] +other = "Б" + +[Kilobyte-symbol] +other = "КБ" + +[Megabyte-symbol] +other = "МБ" [note] other = "Заметка" diff --git a/i18n/tr.toml b/i18n/tr.toml index ad7747ec6b..a6a9babb5d 100644 --- a/i18n/tr.toml +++ b/i18n/tr.toml @@ -25,8 +25,14 @@ other = "Dahası Var" [Expand-title] other = "Genişlet..." -[BinaryPrefix-kilobyte] -other = "kb" +[Byte-symbol] +other = "B" + +[Kilobyte-symbol] +other = "KB" + +[Megabyte-symbol] +other = "MB" [note] other = "Note" diff --git a/i18n/zh-cn.toml b/i18n/zh-cn.toml index 5e34eb3f6b..8702b80d51 100644 --- a/i18n/zh-cn.toml +++ b/i18n/zh-cn.toml @@ -25,8 +25,14 @@ other = "更多" [Expand-title] other = "展开" -[BinaryPrefix-kilobyte] -other = "kb" +[Byte-symbol] +other = "B" + +[Kilobyte-symbol] +other = "KB" + +[Megabyte-symbol] +other = "MB" [note] other = "注释" diff --git a/layouts/shortcodes/attachments.html b/layouts/shortcodes/attachments.html index 2733247b53..7032a8023f 100644 --- a/layouts/shortcodes/attachments.html +++ b/layouts/shortcodes/attachments.html @@ -3,32 +3,34 @@ {{ $title := .Get "title" | default ("Attachments-label" | T) }}
{{ $title }}
- {{if eq .Page.File.BaseFileName "index"}} - {{$.Scratch.Add "filesName" "files"}} - {{else}} - {{$.Scratch.Add "filesName" (printf "%s.files" .Page.File.BaseFileName)}} - {{end}}
- {{ range (readDir (printf "./content/%s%s" .Page.File.Dir ($.Scratch.Get "filesName")) ) }} - {{ $fileDir := replace $.Page.File.Dir "\\" "/" }} - {{if ($.Get "pattern")}} - {{if (findRE ($.Get "pattern") .Name)}} + {{- $filesName := "files" }} + {{- if ne .Page.File.BaseFileName "index" }} + {{- $filesName = printf "%s.files" .Page.File.BaseFileName }} + {{- end}} + + {{- $fileDir := replace .Page.File.Dir "\\" "/" }} + {{- $pattern := .Get "pattern" | default "" }} + {{- range (readDir (printf "content/%s%s" .Page.File.Dir $filesName) ) }} + {{- if findRE $pattern .Name}} + {{- $size := .Size }} + {{- $unit := "Byte-symbol" }} + {{- if ge $size 1024 }} + {{- $size = div $size 1024 }} + {{- $unit = "Kilobyte-symbol" }} + {{- end }} + {{- if ge $size 1024 }} + {{- $size = div $size 1024 }} + {{- $unit = "Megabyte-symbol" }} + {{- end }} + {{- $unitsymbol := $unit | T }} +
  • - - {{.Name}} - - ({{div .Size 1024 }} {{T "BinaryPrefix-kilobyte"}}) + {{.Name}} + ({{$size}} {{$unitsymbol}})
  • - {{end}} - {{else}} -
  • - - {{.Name}} - - ({{div .Size 1024 }} {{T "BinaryPrefix-kilobyte"}}) -
  • - {{end}} - {{end}} + {{- end }} + {{- end }}
    - {{.Inner}} + {{- .Inner }}