move tag parsing to parse_file

This commit is contained in:
Alexey Shpakovsky 2014-03-01 12:30:08 +01:00 committed by Aleksei Shpakovskii
parent 8762db0fb2
commit 699ecc6005

27
bb.sh
View file

@ -476,6 +476,16 @@ parse_file() {
suffix="$RANDOM"
filename="$(echo $filename | sed 's/\.html/'$suffix'\.html/g')"
done
# Parse possible tags
elif [[ "$line" = "<p>$template_tags_line_header"* ]]; then
tags="$(echo "$line" | cut -d ":" -f 2- | sed -e 's/<\/p>//g' -e 's/^ *//' -e 's/ *$//' -e 's/, /,/g')"
IFS=, read -r -a array <<< "$tags"
echo -n "<p>$template_tags_line_header " >> "$content"
(for item in "${array[@]}"; do
echo -n "<a href='$prefix_tags$item.html'>$item</a>, "
done ) | sed 's/, $//g' >> "$content"
echo -e "</p>" >> "$content"
else
echo "$line" >> "$content"
fi
@ -574,23 +584,6 @@ EOF
done
rm "$TMPFILE"
# Parse possible tags
cp "$filename" "$filename.bak"
while read line; do
if [[ "$line" = "<p>$template_tags_line_header"* ]]; then
tags="$(echo "$line" | cut -d ":" -f 2- | sed -e 's/<\/p>//g' -e 's/^ *//' -e 's/ *$//' -e 's/, /,/g')"
IFS=, read -r -a array <<< "$tags"
echo -n "<p>$template_tags_line_header "
(for item in "${array[@]}"; do
echo -n "<a href='$prefix_tags$item.html'>$item</a>, "
done ) | sed 's/, $//g'
echo -e "</p>"
else echo "$line"
fi
done < "$filename.bak" > "$filename"
rm "$filename.bak"
chmod 644 "$filename"
echo "Posted $filename"
}