2022-03-12 09:39:40 -05:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
timestamp="$(date '+%s')"
|
|
|
|
title="$(date '+%Y-%m-%d %H:%M' --date="@$timestamp")"
|
|
|
|
year="$(date '+%Y')"
|
|
|
|
month="$(date '+%m')"
|
|
|
|
|
|
|
|
archive=./doc/log/archive
|
|
|
|
|
|
|
|
for dir in "$archive" "$archive/$year" "$archive/$year/$month"; do
|
|
|
|
if [ ! -d "$dir" ]; then
|
|
|
|
mkdir -- "$dir"
|
|
|
|
name="$(basename -- "$dir")"
|
|
|
|
if [ "$name" = archive ]; then
|
|
|
|
name=Archive
|
|
|
|
fi
|
2023-04-10 08:43:31 -04:00
|
|
|
<<-EOF cat - >"$dir/index.md"
|
2022-07-12 18:07:32 -04:00
|
|
|
# $name
|
2022-03-12 09:39:40 -05:00
|
|
|
|
2022-07-12 18:07:32 -04:00
|
|
|
\`\`\`{toctree}
|
|
|
|
---
|
2023-04-10 08:43:31 -04:00
|
|
|
maxdepth: 1
|
|
|
|
glob:
|
2022-07-12 18:07:32 -04:00
|
|
|
---
|
2022-03-12 09:39:40 -05:00
|
|
|
|
2023-04-10 08:43:31 -04:00
|
|
|
*/index
|
2022-07-12 18:07:32 -04:00
|
|
|
\`\`\`
|
2022-03-12 09:39:40 -05:00
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
mkdir -- "$archive/$year/$month/$timestamp"
|
|
|
|
|
|
|
|
|
2022-07-12 18:07:32 -04:00
|
|
|
<<-EOF cat - >"$archive/$year/$month/$timestamp/index.md"
|
|
|
|
# $title
|
|
|
|
*Written $title*
|
2022-03-12 09:39:40 -05:00
|
|
|
|
2022-07-12 18:07:32 -04:00
|
|
|
\`\`\`{contents}
|
|
|
|
\`\`\`
|
2022-03-12 09:39:40 -05:00
|
|
|
|
2022-07-12 18:07:32 -04:00
|
|
|
## TODO
|
2022-03-12 09:39:40 -05:00
|
|
|
EOF
|
|
|
|
|
|
|
|
printf '%s\n' "$archive/$year/$month/$timestamp"
|
|
|
|
exit 0
|