Skip to content
Snippets Groups Projects
Verified Commit 7c8bb1c4 authored by orestis.malaspin's avatar orestis.malaspin
Browse files

refactor gen_index

parent dbe93ccf
No related branches found
No related tags found
No related merge requests found
#!/bin/bash #!/bin/bash
set -e
function get_info() {
local field=$(echo "$fullName" | sed "$2q;d" $1);
IFS=$3;
local field=($field);
if [ "${field}" != $5 ]; then
return 1
fi
local field=${field[1]};
IFS=$4;
local field=($field);
local field=${field[1]};
echo "$field"
}
function fail() {
printf '%s\n' "$1" >&2 ## Send message to stderr.
exit "${2-1}" ## Return a code specified by $2, or 1 by default.
}
OIFS=$IFS OIFS=$IFS
NUM_LINE=2 NUM_LINE=2
PREFIX="" PREFIX=""
...@@ -8,26 +29,17 @@ PREFIX="" ...@@ -8,26 +29,17 @@ PREFIX=""
classes=() classes=()
for i in *.md; do for i in *.md; do
[ -f "$i" ] || break [ -f "$i" ] || break
comp=$(echo "$fullName" | sed "${NUM_LINE}q;d" $i) date="$(get_info $i 3 ":" '"' "date")"
date=$(echo "$fullName" | sed "3q;d" $i) if [ "$date" == 1 ]; then
IFS=':' fail "Error date field not found"
comp=($comp); fi
comp=${comp[1]} comp="$(get_info $i 2 ":" '"' "title")"
date=($date); if [ "$comp" == 1 ]; then
date=${date[1]} fail "Error title field not found"
# echo $comp fi
IFS='"'
comp=($comp)
comp=${comp[1]}
date=($date);
date=${date[1]}
# echo $comp | awk '{ print substr( $0, 1, length($0)-1 ) }'
# echo $comp
# date=sed "${NUM_LINE}q;d" $i
i="${i%.*}" i="${i%.*}"
class="[${date} ${comp}](${PREFIX}${i}.pdf)" class="[${date} ${comp}](${PREFIX}${i}.pdf)"
classes+=($class) classes+=("$class")
# echo "[${date} ${comp}](${PREFIX}${i}.pdf)" >> index.md
done done
IFS=$'\n' IFS=$'\n'
classes=($(sort <<<"${classes[*]}")) classes=($(sort <<<"${classes[*]}"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment