More correct and effective use of arrays
This commit is contained in:
parent
2b24132f3c
commit
ba012c436e
1 changed files with 8 additions and 9 deletions
17
bb.sh
17
bb.sh
|
@ -392,7 +392,7 @@ is_boilerplate_file() {
|
||||||
( "$index_file" | "$archive_index" | "$tags_index" | "$footer_file" | "$header_file" | "$global_analytics_file" | "$prefix_tags"* )
|
( "$index_file" | "$archive_index" | "$tags_index" | "$footer_file" | "$header_file" | "$global_analytics_file" | "$prefix_tags"* )
|
||||||
return 0 ;;
|
return 0 ;;
|
||||||
( * ) # Check for excluded
|
( * ) # Check for excluded
|
||||||
for excl in ${html_exclude[*]}; do
|
for excl in "${html_exclude[@]}"; do
|
||||||
[[ $name == "$excl" ]] && return 0
|
[[ $name == "$excl" ]] && return 0
|
||||||
done
|
done
|
||||||
return 1 ;;
|
return 1 ;;
|
||||||
|
@ -523,9 +523,9 @@ parse_file() {
|
||||||
IFS=, read -r -a array <<< "$tags"
|
IFS=, read -r -a array <<< "$tags"
|
||||||
|
|
||||||
echo -n "<p>$template_tags_line_header " >> "$content"
|
echo -n "<p>$template_tags_line_header " >> "$content"
|
||||||
(for item in "${array[@]}"; do
|
for item in "${array[@]}"; do
|
||||||
echo -n "<a href='$prefix_tags$item.html'>$item</a>, "
|
echo -n "<a href='$prefix_tags$item.html'>$item</a>, "
|
||||||
done ) | sed 's/, $/<\/p>/g' >> "$content"
|
done | sed 's/, $/<\/p>/g' >> "$content"
|
||||||
else
|
else
|
||||||
echo "$line" >> "$content"
|
echo "$line" >> "$content"
|
||||||
fi
|
fi
|
||||||
|
@ -738,7 +738,7 @@ rebuild_index() {
|
||||||
# Accepts either filename as first argument, or post content at stdin
|
# Accepts either filename as first argument, or post content at stdin
|
||||||
# Prints one line with space-separated tags to stdout
|
# Prints one line with space-separated tags to stdout
|
||||||
tags_in_post() {
|
tags_in_post() {
|
||||||
sed -n "/^<p>$template_tags_line_header/{s/^<p>$template_tags_line_header//;s/<[^>]*>//g;s/[ ,]\+/ /g;p;}" $1 | tr ', ' ' '
|
sed -n "/^<p>$template_tags_line_header/{s/^<p>$template_tags_line_header//;s/<[^>]*>//g;s/[ ,]\+/ /g;p;}" "$1" | tr ', ' ' '
|
||||||
}
|
}
|
||||||
|
|
||||||
# Finds all posts referenced in a number of tags.
|
# Finds all posts referenced in a number of tags.
|
||||||
|
@ -746,8 +746,9 @@ tags_in_post() {
|
||||||
# Prints one line with space-separated tags to stdout
|
# Prints one line with space-separated tags to stdout
|
||||||
posts_with_tags() {
|
posts_with_tags() {
|
||||||
(($# < 1)) && return
|
(($# < 1)) && return
|
||||||
tag_files=$(for i in "$@"; do echo -n $prefix_tags""$i.html" "; done)
|
set -- "${@/#/$prefix_tags}"
|
||||||
sed -n '/^<h3><a class="ablack" href="[^"]*">/{s/.*href="\([^"]*\)">.*/\1/;p;}' $tag_files 2> /dev/null
|
set -- "${@/%/.html}"
|
||||||
|
sed -n '/^<h3><a class="ablack" href="[^"]*">/{s/.*href="\([^"]*\)">.*/\1/;p;}' "$@" 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Rebuilds tag_*.html files
|
# Rebuilds tag_*.html files
|
||||||
|
@ -880,9 +881,7 @@ create_includes() {
|
||||||
echo '<html xmlns="http://www.w3.org/1999/xhtml"><head>' >> ".header.html"
|
echo '<html xmlns="http://www.w3.org/1999/xhtml"><head>' >> ".header.html"
|
||||||
echo '<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />' >> ".header.html"
|
echo '<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />' >> ".header.html"
|
||||||
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0">' >> ".header.html"
|
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0">' >> ".header.html"
|
||||||
for css_file in ${css_include[*]}; do
|
printf '<link rel="stylesheet" href="%s" type="text/css" />\n' "${css_include[@]}" >> ".header.html"
|
||||||
echo '<link rel="stylesheet" href="'$css_file'" type="text/css" />' >> ".header.html"
|
|
||||||
done
|
|
||||||
if [[ -z $global_feedburner ]]; then
|
if [[ -z $global_feedburner ]]; then
|
||||||
echo '<link rel="alternate" type="application/rss+xml" title="'$template_subscribe_browser_button'" href="'$blog_feed'" />' >> ".header.html"
|
echo '<link rel="alternate" type="application/rss+xml" title="'$template_subscribe_browser_button'" href="'$blog_feed'" />' >> ".header.html"
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue