_pages and _blogs: Run _cleanup last

This commit is contained in:
Stig-Ørjan Smelror 2024-02-01 16:53:30 +01:00
parent 797f082bb7
commit 459dc43f50

27
qsgen2
View File

@ -417,14 +417,14 @@ function _pages() {
if (${debug}) _msg debug "_pages: _last_updated in pages_tpl" if (${debug}) _msg debug "_pages: _last_updated in pages_tpl"
local pages_tpl=$( _last_updated ${pages_tpl} ) local pages_tpl=$( _last_updated ${pages_tpl} )
# Clean up unused tags, if any
if (${debug}) _msg debug "_pages: Running _cleanup"
local pages_tpl=$( _cleanup "${pages_tpl}" )
# Always use lowercase for file names # Always use lowercase for file names
if (${debug}) _msg debug "_pages: Lowercase filnames, always" if (${debug}) _msg debug "_pages: Lowercase filnames, always"
local pages_title_lower=$( _file_to_lower "${pages_in_array}" ) local pages_title_lower=$( _file_to_lower "${pages_in_array}" )
# Clean up unused tags, if any
if (${debug}) _msg debug "_pages: Running _cleanup"
local pages_tpl=$( _cleanup "${pages_tpl}" )
# Write pages_tpl to disk # Write pages_tpl to disk
_msg std "Writing ${www_root}/${pages_title_lower%.*}.html to disk." _msg std "Writing ${www_root}/${pages_title_lower%.*}.html to disk."
echo "${pages_tpl}" > ${www_root}/${pages_title_lower%.*}.html echo "${pages_tpl}" > ${www_root}/${pages_title_lower%.*}.html
@ -443,7 +443,6 @@ function _pages() {
} }
function _blogs() { function _blogs() {
# Rewritten _blogs function
# This function either generates blog files or exports metadata based on the argument # This function either generates blog files or exports metadata based on the argument
local debug=false local debug=false
@ -512,26 +511,25 @@ function _blogs() {
blog_content=$(echo "${blog_content}" | perl -pe "s|\QINGRESS\E|${ingress}|g") blog_content=$(echo "${blog_content}" | perl -pe "s|\QINGRESS\E|${ingress}|g")
blog_content=$(echo "${blog_content}" | perl -pe "s|\QBODY\E|${body}|g") blog_content=$(echo "${blog_content}" | perl -pe "s|\QBODY\E|${body}|g")
if (${debug}) _msg debug "_blogs: Running function _html for ${blog}" if (${debug}) _msg debug "_blogs: Running function _html for ${blog}"
# Apply transformations # Apply transformations
blog_content="$(_html "${blog_content}")" blog_content="$(_html "${blog_content}")"
# Look for links, images and videos and convert them if present. # Look for links, images and videos and convert them if present.
if (${debug}) _msg debug "_blogs: Checking for #link, #showimg and #ytvideo in blog_content" if (${debug}) _msg debug "_blogs: Checking for #link, #showimg and #ytvideo in blog_content"
if [[ $( echo ${blog_content} | grep \#link ) ]]; then if [[ $( echo ${blog_content} | grep \#link ) ]]; then
if (${debug}) _msg debug "_blogs: If #link is present, run _link: blog_content" if (${debug}) _msg debug "_blogs: #link is present, run _link: blog_content"
blog_content="$(_link "${blog_content}")" blog_content="$(_link "${blog_content}")"
fi fi
if [[ $( echo ${blog_content} | grep \#showimg ) ]]; then if [[ $( echo ${blog_content} | grep \#showimg ) ]]; then
if (${debug}) _msg debug "_blogs: If #showimg is present, run _link: blog_content" if (${debug}) _msg debug "_blogs: #showimg is present, run _link: blog_content"
blog_content="$(_image "${blog_content}")" blog_content="$(_image "${blog_content}")"
fi fi
if [[ $( echo ${blog_content} | grep \#ytvideo ) ]]; then if [[ $( echo ${blog_content} | grep \#ytvideo ) ]]; then
if (${debug}) _msg debug "_blogs: If #ytvideo is present, run _link: blog_content" if (${debug}) _msg debug "_blogs: #ytvideo is present, run _link: blog_content"
blog_content="$(_youtube "${blog_content}")" blog_content="$(_youtube "${blog_content}")"
fi fi
blog_content="$(_cleanup "${blog_content}")"
blog_content="$(_last_updated "${blog_content}")" blog_content="$(_last_updated "${blog_content}")"
blog_content="$(_cleanup "${blog_content}")"
# Create directory if it doesn't exist # Create directory if it doesn't exist
if (${debug}) _msg debug "_blogs: Creating directoty ${www_root}/${blog_dir}" if (${debug}) _msg debug "_blogs: Creating directoty ${www_root}/${blog_dir}"
@ -552,6 +550,9 @@ function _blogs() {
_msg info "No new or updated Blogs detected." _msg info "No new or updated Blogs detected."
export new_updated_blogs=false export new_updated_blogs=false
fi fi
_blog_idx_for_index
_blog_index
} }
function _blog_idx_for_index() { function _blog_idx_for_index() {
@ -851,12 +852,6 @@ _html() {
} }
# Time to test the first function # Time to test the first function
#_msg std "Running function blogs"
_blogs _blogs
#_msg std "Running function blog_idx_for_index"
_blog_idx_for_index
_blog_index
#_msg std "Running function pages"
_pages _pages
#_msg std "Running function sitemap"
_sitemap _sitemap