diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build_content.sh | 32 | ||||
-rwxr-xr-x[-rw-r--r--] | scripts/metadata_tpl.json | 0 | ||||
-rwxr-xr-x | scripts/watch_filters.sh | 7 |
3 files changed, 34 insertions, 5 deletions
diff --git a/scripts/build_content.sh b/scripts/build_content.sh index 719b7c9..b258449 100755 --- a/scripts/build_content.sh +++ b/scripts/build_content.sh | |||
@@ -1,14 +1,31 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | CONTENT_DIR="content/" | 3 | CONTENT_DIR="content/" |
4 | FILTERS_DIR="filters/" | ||
4 | METADATA_DIR="metadata/" | 5 | METADATA_DIR="metadata/" |
5 | TEMPLATES_DIR="templates/" | 6 | TEMPLATES_DIR="templates/" |
6 | OUTPUT_DIR="output/" | 7 | OUTPUT_DIR="output/" |
7 | 8 | ||
8 | CATEGORY_SHORT_LEN=3 | ||
9 | CATEGORY_MAP=$(cat "$METADATA_DIR/categories.json") | 9 | CATEGORY_MAP=$(cat "$METADATA_DIR/categories.json") |
10 | 10 | ||
11 | target_filename () { | 11 | get_filters() { |
12 | filters_args="" | ||
13 | |||
14 | mapfile -d $'\0' filters < <(find $FILTERS_DIR \ | ||
15 | -type f \ | ||
16 | -name "*.lua" ! -name ".*" \ | ||
17 | -print0) | ||
18 | |||
19 | for file in "${filters[@]}"; do | ||
20 | filters_args="$filters_args --lua-filter $file" | ||
21 | done | ||
22 | |||
23 | echo $filters_args | ||
24 | } | ||
25 | |||
26 | FILTERS=$(get_filters) | ||
27 | |||
28 | target_filename() { | ||
12 | filename=$1 | 29 | filename=$1 |
13 | filename=${filename#"$CONTENT_DIR"} | 30 | filename=${filename#"$CONTENT_DIR"} |
14 | if [ "${filename##*.}" = "md" ]; then | 31 | if [ "${filename##*.}" = "md" ]; then |
@@ -17,7 +34,7 @@ target_filename () { | |||
17 | echo "$OUTPUT_DIR$filename" | 34 | echo "$OUTPUT_DIR$filename" |
18 | } | 35 | } |
19 | 36 | ||
20 | target_url_rel () { | 37 | target_url_rel() { |
21 | basedir=$1 | 38 | basedir=$1 |
22 | filename=$2 | 39 | filename=$2 |
23 | filename=$(realpath --relative-to="$basedir" "$filename") | 40 | filename=$(realpath --relative-to="$basedir" "$filename") |
@@ -28,7 +45,7 @@ target_url_rel () { | |||
28 | echo "$filename" | 45 | echo "$filename" |
29 | } | 46 | } |
30 | 47 | ||
31 | target_url_abs () { | 48 | target_url_abs() { |
32 | echo "/$(target_url_rel "$CONTENT_DIR" "$1")" | 49 | echo "/$(target_url_rel "$CONTENT_DIR" "$1")" |
33 | } | 50 | } |
34 | 51 | ||
@@ -148,6 +165,10 @@ handle () { | |||
148 | # echo "$(get_metadata "$1")" | 165 | # echo "$(get_metadata "$1")" |
149 | echo "$(get_metadata "$1")" > "$subpages_meta_file" | 166 | echo "$(get_metadata "$1")" > "$subpages_meta_file" |
150 | 167 | ||
168 | # echo $(pandoc "$1" \ | ||
169 | # -f markdown \ | ||
170 | # -t json) | ||
171 | |||
151 | pandoc "$1" \ | 172 | pandoc "$1" \ |
152 | -f markdown \ | 173 | -f markdown \ |
153 | -t html5 \ | 174 | -t html5 \ |
@@ -157,7 +178,8 @@ handle () { | |||
157 | --metadata section=$section \ | 178 | --metadata section=$section \ |
158 | --metadata "is$section" \ | 179 | --metadata "is$section" \ |
159 | --metadata-file metadata/metadata.yaml \ | 180 | --metadata-file metadata/metadata.yaml \ |
160 | --metadata-file "$subpages_meta_file" | 181 | --metadata-file "$subpages_meta_file" \ |
182 | $FILTERS | ||
161 | # --lua-filter "filters/add_refs.lua" | 183 | # --lua-filter "filters/add_refs.lua" |
162 | 184 | ||
163 | rm "$subpages_meta_file" | 185 | rm "$subpages_meta_file" |
diff --git a/scripts/metadata_tpl.json b/scripts/metadata_tpl.json index 76e4439..76e4439 100644..100755 --- a/scripts/metadata_tpl.json +++ b/scripts/metadata_tpl.json | |||
diff --git a/scripts/watch_filters.sh b/scripts/watch_filters.sh new file mode 100755 index 0000000..9bb3b44 --- /dev/null +++ b/scripts/watch_filters.sh | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | inotifywait -qrme close_write,delete,move --format "%w%f" filters \ | ||
4 | | while read file | ||
5 | do | ||
6 | scripts/build_content.sh "all_md" | ||
7 | done | ||