From caeb4af27ac9b532d4ef445cd3ef29770b3ce671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig-=C3=98rjan=20Smelror?= Date: Mon, 12 Feb 2024 20:40:53 +0100 Subject: [PATCH] Refactor _blogs and _blog_index functions This commit refactors the _blogs and _blog_index functions in the qsgen2 script. In the _blogs function, the directory creation message is updated to use the correct variable instead of . Additionally, a debug message is added to indicate when is set to true. In the _blog_index function, debug messages are added to display the values of and . The debug message for generating the page is updated to include the correct file path . These changes improve the clarity and accuracy of the script's functionality. --- qsgen2 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/qsgen2 b/qsgen2 index 35bbde5..8ad08a6 100755 --- a/qsgen2 +++ b/qsgen2 @@ -779,7 +779,7 @@ function _blogs() { blog_content=$(_cleanup "${blog_content}") # Create directory if it doesn't exist - if (${debug}) _msg debug "_blogs: Creating directoty ${www_root}/${blog_dir}" + if (${debug}) _msg debug "_blogs: Creating directory ${www_root}${blog_dir}" [[ ! -d "${www_root}/${blog_dir}" ]] && mkdir -p "${www_root}/${blog_dir}" # Write to file @@ -791,6 +791,7 @@ function _blogs() { done # Now BLOG_META_STR_ARRAY contains the metadata string for each blog post export BLOG_META_STR_ARRAY + if (${debug}) _msg debug "_blogs: new_updated_blogs=true" export new_updated_blogs=true else @@ -894,14 +895,16 @@ function _blog_index() { local debug=true fi - # This function generates the /blog/index.html file that gets its data from _blog_list_for_index() + # This function generates the www_root/blog/index.html file that gets its data from _blog_list_for_index() # ${new_updated_blogs} comes from the function _blogs if anything new or updated is detected if [[ ${blog_in_index} == "false" ]] && [[ ${new_updated_blogs} = "true" ]]; then - if (${debug}) _msg debug "Running function _blog_index" + if (${debug}) _msg debug "_blog_index: blog_in_index=${blog_in_index}" + if (${debug}) _msg debug "_blog_index: new_updated_blogs=${new_updated_blogs}" + if (${debug}) _msg debug "_blog_index: Running function _blog_index" if (${debug}) _msg debug "_blog_index: blog_in_index = ${blog_in_index}" - _msg std "- Generating Page: blog/index.html" + _msg std "- Generating Page: ${www_root}/blog/index.html" local blog_index_tpl=$(<${project_dir}/themes/${theme}/blog_index.tpl) local blog_index_list=$(<${project_dir}/blog/index.tmp.html)