@ -68,6 +68,18 @@ add_header_and_footer() {
mv $BASE_PATH /temp/temp.html $1
}
add_header_and_footer_to_index( ) {
# Add header
cat $BASE_PATH /header.html | head -n -1 | cat - $1 > $BASE_PATH /temp/temp.html # For the index page, remove the last line of the header (date published)
# Add footer
echo >> $BASE_PATH /temp/temp.html
cat $BASE_PATH /footer.html >> $BASE_PATH /temp/temp.html
# Move temp file to original location
mv $BASE_PATH /temp/temp.html $1
}
replace_vars( ) {
# Loop through 'meta_key' array, search for all occurences of the values in the HTML doc, and replace them with corresponding values in 'meta_value'.
for index in $( seq 0 ` expr " ${# meta_key [@] } " - 1` ) ; do
@ -136,6 +148,9 @@ gen_sorted_file_list() { # Generate a list of the HTMl files, sorted by when the
}
gen_index_page( ) { # Generate an index page (site map) that includes links to the other pages
index_file_html = "<nav class=\"toc\">" $'\n' # Variable to store the body HTML of the index page; enclose the list in a nav
for file in $1 ; do
title = $( cat $file | grep "<title>" | head -n 1 | awk -F'[<>]' '{print $3}' ) # Find the title of the web page
suffix = " - Two More Cents"
@ -148,14 +163,19 @@ gen_index_page() { # Generate an index page (site map) that includes links to th
file_path = $( realpath --relative-to= " ${ BASE_PATH } /output " $file )
echo " $pub_date - $file_path "
index_file_list += " <li><time> ${ pub_date } </time> - <a href=\" $file_path \"> $title </a></li> "
index_file_list += $'\n'
index_file_html += " <li><time> ${ pub_date } </time> - <a href=\" $file_path \"> $title </a></li> " # Add a line of HTML containing the date and title of the article
index_file_html += $'\n'
done
index_file_list = $( echo " $index_file_list " | head -n -1) # Remove last (empty) line from variable
index_file_html = $( echo " $index_file_html " | head -n -1) # Remove last (empty) line from variable
index_file_html += "</nav>"
path_for_output = " ${ BASE_PATH } /output/site-map.html "
echo " $index_file_html " > " $path_for_output " # Output variable to file
add_header_and_footer_to_index " $path_for_output " # Add header and footer to index file
sed -i 's/[\$][\$]title[\$][\$]/Site Map - Two More Cents/g' " $path_for_output " # Replace title variable with 'site map' title
}
clean_up( ) {