diff --git a/qsgen2 b/qsgen2 index 7337888..491353a 100755 --- a/qsgen2 +++ b/qsgen2 @@ -260,7 +260,20 @@ function _pages_cache() { } function _last_updated() { - cat ${1} | sed -e "s|#updated|${TODAY}|" | sed -e "s|\#version|${QSGEN} ${VERSION}|" > ${1} + # This function updates #updated and #version tags in the provided string + + local content="${1}" + local debug=false + + if (${debug}) echo "${red}_last_updated: Setting date and version in footer${end}" + + # Perform the replacements + local updated_content=$(echo "${content}" | sed \ + -e "s|#updated|${TODAY}|" \ + -e "s|#version|${QSGEN} ${VERSION}|") + + # Return the updated content + echo "${updated_content}" } function _file_to_lower() { @@ -339,24 +352,24 @@ function _pages() { # Replace #updated with today's date and #version with Name and Version to footer if (${debug}) echo "_pages: _last_updated in pages_tpl" - _last_updated ${www_root}/${pages_title_lower%.*}.html + pages_tpl=$( _last_updated ${pages_tpl} ) # Look for links, images and videos and convert them if present. if (${debug}) echo "_pages: Checking for #link, #showimg and #ytvideo in page_content" - if [[ $( grep \#link ${page_content} ) ]]; then - echo "If #link is present, run _link: page_content" - page_content=$( _link "${page_content}" ) - elif [[ $( grep \#showimg ${page_content} ) ]]; then - echo "If #showimg is present, run _image: page_content" - page_content=$( _image "${page_content}" ) - elif [[ $( grep \#ytvideo ${page_content} ) ]]; then - echo "If #ytvideo is present, run _youtube: page_content" - page_content=$( _youtube "${page_content}" ) + if [[ $( grep \#link ${pages_tpl} > /dev/null ) ]]; then + echo "If #link is present, run _link: pages_tpl" + page_content=$( _link "${pages_tpl}" ) + elif [[ $( grep \#showimg ${pages_tpl} > /dev/null ) ]]; then + echo "If #showimg is present, run _image: pages_tpl" + page_content=$( _image "${pages_tpl}" ) + elif [[ $( grep \#ytvideo ${pages_tpl} > /dev/null ) ]]; then + echo "If #ytvideo is present, run _youtube: pages_tpl" + page_content=$( _youtube "${pages_tpl}" ) fi # Clean up unused tags, if any if (${debug}) echo "_pages: Running _cleanup" - page_content=$( _cleanup "${page_content}" ) + page_content=$( _cleanup "${pages_tpl}" ) # Always use lowercase for file names if (${debug}) echo "_pages: Lowercase filnames, always"