aboutsummaryrefslogtreecommitdiffstats
path: root/bin/gen.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/gen.sh')
-rwxr-xr-xbin/gen.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/bin/gen.sh b/bin/gen.sh
new file mode 100755
index 0000000..99aab55
--- /dev/null
+++ b/bin/gen.sh
@@ -0,0 +1,29 @@
+#!/bin/sh -ex
+
+srcdir="./en/visual"
+categories="drawings photos logos renders"
+index="index.md"
+
+list_images() {
+ # $1 -- directory
+ find "$1" -type f \
+ | grep -E "(\.jpe?g)|(\.png)|(\.gif)"
+}
+
+append_image() {
+ # $1 -- directory
+ c_index="$1/$index"
+ while read -r i; do
+ i=$(basename "$i")
+ if ! (grep "$i" "$c_index"); then
+ printf "\n" >> "$c_index"
+ echo "![${i%%.*}]($i)" >> "$c_index"
+ fi
+ done
+}
+
+cd "$srcdir" || exit 1
+for c in $categories;
+do
+ list_images "$c" | append_image "$c"
+done