From bdc218a0a0ae7b11e40292884a56abbf7a631fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig-=C3=98rjan=20Smelror?= Date: Mon, 12 Feb 2024 18:42:29 +0100 Subject: [PATCH] Refactor page generation in qsgen2 This commit refactors the function in script. It updates the order of operations and improves code readability. The changes include: - Replacing with in after replacing other placeholders. - Updating debug messages for better logging. Additionally, the commit generates the blog index file and updates the message accordingly. These changes improve the page generation process and ensure that the blog index file is correctly generated. --- qsgen2 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qsgen2 b/qsgen2 index 6e39561..bca2097 100755 --- a/qsgen2 +++ b/qsgen2 @@ -556,14 +556,14 @@ function _pages() { page_content=$(echo "$page_content" | ${engine} ${engine_opts}) fi - if (${debug}) _msg debug "_pages: Replacing BODY with page_content in pages_tpl" - # Use awk for multi-line and special character handling - pages_tpl=$( awk -v new_body="$page_content" '{sub(/BODY/, new_body)} 1' <(echo "${pages_tpl}") ) - # Replace every #pagetitle in pages_tpl if (${debug}) _msg debug "_pages: Replacing #pagetitle, #tagline and #sitename in pages_tpl" pages_tpl=$(echo "${pages_tpl}" | perl -pe "s|#pagetitle|${page_title}|gs; s|#tagline|${site_tagline}|gs; s|#sitename|${site_name}|gs") + if (${debug}) _msg debug "_pages: Replacing BODY with page_content in pages_tpl" + # Use awk for multi-line and special character handling + pages_tpl=$( awk -v new_body="$page_content" '{sub(/BODY/, new_body)} 1' <(echo "${pages_tpl}") ) + # Replace #updated with today's date and #version with Name and Version to footer if (${debug}) _msg debug "_pages: _last_updated in pages_tpl" pages_tpl=$( _last_updated ${pages_tpl} ) @@ -610,7 +610,7 @@ function _pages() { export new_updated_pages=false fi - + } function _blogs() { @@ -898,7 +898,7 @@ function _blog_index() { if (${debug}) _msg debug "Running function _blog_index" if (${debug}) _msg debug "_blog_index: blog_in_index = ${blog_in_index}" - _msg std "- Generating the Blog index file" + _msg std "- Generating Page: blog/index.html" local blog_index_tpl=$(<${project_dir}/themes/${theme}/blog_index.tpl) local blog_index_list=$(<${project_dir}/blog/index.tmp.html)