Rewrite _last_updated
This commit is contained in:
parent
8844f83276
commit
bf8c59e14f
37
qsgen2
37
qsgen2
@ -260,7 +260,20 @@ function _pages_cache() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _last_updated() {
|
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() {
|
function _file_to_lower() {
|
||||||
@ -339,24 +352,24 @@ function _pages() {
|
|||||||
|
|
||||||
# Replace #updated with today's date and #version with Name and Version to footer
|
# Replace #updated with today's date and #version with Name and Version to footer
|
||||||
if (${debug}) echo "_pages: _last_updated in pages_tpl"
|
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.
|
# 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 (${debug}) echo "_pages: Checking for #link, #showimg and #ytvideo in page_content"
|
||||||
if [[ $( grep \#link ${page_content} ) ]]; then
|
if [[ $( grep \#link ${pages_tpl} > /dev/null ) ]]; then
|
||||||
echo "If #link is present, run _link: page_content"
|
echo "If #link is present, run _link: pages_tpl"
|
||||||
page_content=$( _link "${page_content}" )
|
page_content=$( _link "${pages_tpl}" )
|
||||||
elif [[ $( grep \#showimg ${page_content} ) ]]; then
|
elif [[ $( grep \#showimg ${pages_tpl} > /dev/null ) ]]; then
|
||||||
echo "If #showimg is present, run _image: page_content"
|
echo "If #showimg is present, run _image: pages_tpl"
|
||||||
page_content=$( _image "${page_content}" )
|
page_content=$( _image "${pages_tpl}" )
|
||||||
elif [[ $( grep \#ytvideo ${page_content} ) ]]; then
|
elif [[ $( grep \#ytvideo ${pages_tpl} > /dev/null ) ]]; then
|
||||||
echo "If #ytvideo is present, run _youtube: page_content"
|
echo "If #ytvideo is present, run _youtube: pages_tpl"
|
||||||
page_content=$( _youtube "${page_content}" )
|
page_content=$( _youtube "${pages_tpl}" )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean up unused tags, if any
|
# Clean up unused tags, if any
|
||||||
if (${debug}) echo "_pages: Running _cleanup"
|
if (${debug}) echo "_pages: Running _cleanup"
|
||||||
page_content=$( _cleanup "${page_content}" )
|
page_content=$( _cleanup "${pages_tpl}" )
|
||||||
|
|
||||||
# Always use lowercase for file names
|
# Always use lowercase for file names
|
||||||
if (${debug}) echo "_pages: Lowercase filnames, always"
|
if (${debug}) echo "_pages: Lowercase filnames, always"
|
||||||
|
Loading…
Reference in New Issue
Block a user