qsgen2: Updates towards complete localization. Update to version 0.4.0 beta 1.

This commit is contained in:
Stig-Ørjan Smelror 2024-02-14 17:32:49 +01:00
parent a88100ff47
commit 3caae5c274
4 changed files with 186 additions and 188 deletions

View File

@ -1,4 +1,3 @@
typeset -A qsgenlang
qsgenlang=( qsgenlang=(
_qsgen2_msg_2 "- Forced Update: Generating Everything" _qsgen2_msg_2 "- Forced Update: Generating Everything"
_qsgen2_msg_3 "* %SCRIPT_NAME% cannot parse this site. Exiting. *" _qsgen2_msg_3 "* %SCRIPT_NAME% cannot parse this site. Exiting. *"
@ -54,12 +53,11 @@ _pages_msg_21 "_pages: Lowercase filnames, always"
_pages_msg_22 "_pages: Running _cleanup" _pages_msg_22 "_pages: Running _cleanup"
_pages_msg_23 "- Parsing" _pages_msg_23 "- Parsing"
_pages_msg_24 "- blog_in_index =" _pages_msg_24 "- blog_in_index ="
_pages_msg_25 "- Listing blog temp file:" _pages_msg_25 "- Printing blog temp file:"
_pages_msg_26 "Updating index.html with new blog posts" _pages_msg_26 "Updating index.html with new blog posts"
_pages_msg_27 "- Parsing" _pages_msg_27 "- Parsing"
_pages_msg_28 "- blog_in_index =" _pages_msg_28 "- blog_in_index ="
_pages_msg_29 "- Listing blog temp file:" _pages_msg_29 "- No new or updated Pages found"
_pages_msg_30 "- No new or updated Pages found"
_blogs_msg_1 "_blogs: Running function _list_blogs" _blogs_msg_1 "_blogs: Running function _list_blogs"
_blogs_msg_2 "* You do not have any blogs *" _blogs_msg_2 "* You do not have any blogs *"
_blogs_msg_3 "Generating Blogs" _blogs_msg_3 "Generating Blogs"

View File

@ -1,114 +1,118 @@
typeset -A qsgenlang
qsgenlang=( qsgenlang=(
_qsgen2_msg_2 "- Actualización forzada: Generando todo" _qsgen2_msg_2 "- Actualización forzada: Generando todo"
_qsgen2_msg_3 "* %SCRIPT_NAME% no puede analizar este sitio. Saliendo. *" _qsgen2_msg_3 "* %SCRIPT_NAME% no puede analizar este sitio. Saliendo. *"
_qsgen2_msg_4 "Por favor instala Pandoc." _qsgen2_msg_4 "Por favor, instala Pandoc."
_qsgen2_msg_5 "No se encontró un generador válido. ¿Estás seguro de haber seleccionado el generador correcto en 'config'?" _qsgen2_msg_5 "No se encontró un generador válido. ¿Estás seguro de que has seleccionado el generador correcto en 'config'?"
_qsgen2_msg_6 "Usando el motor ${generator} para archivos: ${file_ext}" _qsgen2_msg_6 "Usando el"
_qsgen2_msg_6.1 "-motor para archivos:"
_qsgen2_msg_7 "- Creado por kekePower - 2018-" _qsgen2_msg_7 "- Creado por kekePower - 2018-"
_qsgen2_msg_8 "- Consulta '${1} help' para más información." _qsgen2_msg_8 "- Ver"
_qsgen2_msg_9 "Contenido del archivo de configuración:" _qsgen2_msg_8.1 "para más información."
_list_pages_msg_1 "_list_pages: No se encontraron páginas con extensión ${file_ext}." _qsgen2_msg_9 "Contenidos del archivo Config:"
_list_pages_msg_2 "_list_pages: Añadiendo archivo al array: ${file}" _list_pages_msg_1 "_list_pages: No se encontraron páginas con ext"
_list_blogs_msg_3 "_list_blogs: No se encontraron blogs." _list_pages_msg_2 "_list_pages: Añadiendo archivo al array:"
_list_blogs_msg_4 "_list_blogs: Añadiendo archivo al array: $file" _list_blogs_msg_1 "_list_blogs: No se encontraron archivos de blog."
_blog_cache_msg_1 "_blog_cache: VALOR HASH: ${blog_cache[${name}]}" _list_blogs_msg_2 "_list_blogs: Añadiendo archivo al array:"
_blog_cache_msg_2 "1. _blog_cache: ${blog_file}" _blog_cache_msg_1 "_blog_cache: VALOR HASH:"
_blog_cache_msg_3 "2. _blog_cache: caché actual: ${current_hash}" _blog_cache_msg_2 "1. _blog_cache:"
_blog_cache_msg_4 "3. _blog_cache: nuevo archivo en caché: ${blog_file}$" _blog_cache_msg_3 "2. _blog_cache: cache_actual:"
_blog_cache_msg_5 "4. _blog_cache: nuevo caché actual: ${current_hash}" _blog_cache_msg_4 "3. _blog_cache: nuevo_archivo_cache:"
_pages_cache_msg_1 "VALOR HASH DE PÁGINAS: ${pages_cache[${name}]}" _blog_cache_msg_5 "4. _blog_cache: nueva_cache_actual:"
_pages_cache_msg_2 "1. pages_cache: ${pages_cache[$file]}" _pages_cache_msg_1 "VALOR HASH PÁGINAS:"
_pages_cache_msg_3 "1. _pages_cache: caché actual: ${current_hash}" _pages_cache_msg_2 "1. pages_cache:"
_pages_cache_msg_4 "2. _pages_cache: archivo de páginas: ${pages_cache[$file]}" _pages_cache_msg_3 "1. _pages_cache: cache_actual:"
_pages_cache_msg_5 "2. _pages_cache: caché actual: ${current_hash}" _pages_cache_msg_4 "2. _pages_cache: archivo_páginas:"
_pages_cache_msg_5 "2. _pages_cache: cache_actual:"
_last_updated_msg_1 "_last_updated: Estableciendo fecha y versión en el pie de página" _last_updated_msg_1 "_last_updated: Estableciendo fecha y versión en el pie de página"
_last_updated_msg_1 "_last_updated: ${upd_msg}" _last_updated_msg_1 "_last_updated:"
_f_last_updated_msg_1 "_f_last_updated: Estableciendo fecha y versión en el pie de página del archivo ${1}" _f_last_updated_msg_1 "_f_last_updated: Estableciendo fecha y versión en el pie de página del archivo"
_f_last_updated_msg_2 "_f_last_updated: ${upd_msg}" _f_last_updated_msg_2 "_f_last_updated:"
_f_last_updated_msg_3 "_f_last_updated: Archivo '${1}' no encontrado." _f_last_updated_msg_3 "_f_last_updated: Archivo"
_f_last_updated_msg_3.1 "no encontrado."
_pages_msg_1 "_pages: Ejecutando función _pages_cache" _pages_msg_1 "_pages: Ejecutando función _pages_cache"
_pages_msg_2 "* No tienes ninguna página *" _pages_msg_2 "* No tienes ninguna página *"
_pages_msg_3 "Generando Páginas" _pages_msg_3 "Generando Páginas"
_pages_msg_4 "_pages: el array de páginas no está vacío" _pages_msg_4 "_pages: array_de_páginas no está vacío"
_pages_msg_5 "_pages: Estableciendo plantilla de Páginas" _pages_msg_5 "_pages: Estableciendo plantilla de Páginas"
_pages_msg_6 "No se pudo encontrar la plantilla de Páginas: ${pages}" _pages_msg_6 "No se puede encontrar la plantilla de Páginas:"
_pages_msg_7 "_pages: Leyendo la plantilla de Páginas en pages_tpl" _pages_msg_7 "_pages: Leyendo plantilla de Páginas en pages_tpl"
_pages_msg_8 "- Generando Página: ${pages_in_array%.*}.html" _pages_msg_8 "- Generando Página:"
_pages_msg_9 "_pages: Cargando contenido de página una vez - ${pages_in_array}" _pages_msg_9 "_pages: Cargando contenido de la página una vez -"
_pages_msg_10 "_pages: Encontrando título de página" _pages_msg_10 "_pages: Buscando título de página"
_pages_msg_11 "_pages: ${page_title}" _pages_msg_11 "_pages:"
_pages_msg_12 "_pages: Eliminando línea #title del contenido de página" _pages_msg_12 "_pages: Eliminando línea #título del contenido de la página"
_pages_msg_13 "_pages: Ejecutando motor en ${pages_in_array}" _pages_msg_13 "_pages: Ejecutando motor en"
_pages_msg_14 "_pages: Comprobando #link, #showimg y #ytvideo en contenido de página" _pages_msg_14 "_pages: Verificando #link, #showimg y #ytvideo en contenido de la página"
_pages_msg_15 "_pages: #link presente, ejecutar _link: contenido de página" _pages_msg_15 "_pages: #link presente, ejecutar _link: contenido de la página"
_pages_msg_16 "_pages: #showimg presente, ejecutar _image: contenido de página" _pages_msg_16 "_pages: #showimg presente, ejecutar _image: contenido de la página"
_pages_msg_17 "_pages: #ytvideo presente, ejecutar _youtube: contenido de página" _pages_msg_17 "_pages: #ytvideo presente, ejecutar _youtube: contenido de la página"
_pages_msg_18 "_pages: Reemplazando #pagetitle, #tagline y #sitename en pages_tpl" _pages_msg_18 "_pages: Reemplazando #tituloDePagina, #tagline y #nombreDeSitio en pages_tpl"
_pages_msg_19 "_pages: Reemplazando BODY con contenido de página en pages_tpl" _pages_msg_19 "_pages: Reemplazando CUERPO con contenido de la página en pages_tpl"
_pages_msg_20 "_pages: _last_updated en pages_tpl" _pages_msg_20 "_pages: _last_updated en pages_tpl"
_pages_msg_21 "_pages: Nombres de archivos en minúsculas, siempre" _pages_msg_21 "_pages: Nombres de archivo en minúsculas, siempre"
_pages_msg_22 "_pages: Ejecutando _cleanup" _pages_msg_22 "_pages: Ejecutando _cleanup"
_pages_msg_23 "- Analizando ${pages_in_array}" _pages_msg_23 "- Analizando"
_pages_msg_24 "- blog_in_index = ${blog_in_index}" _pages_msg_24 "- blog_en_indice ="
_pages_msg_25 "- Listando archivo temporal de blog:" _pages_msg_25 "- Imprimiendo archivo temporal del blog:"
_pages_msg_26 "Actualizando index.html con nuevas publicaciones de blog" _pages_msg_26 "Actualizando index.html con nuevas publicaciones de blog"
_pages_msg_27 "- Analizando ${pages_in_array}" _pages_msg_27 "- Analizando"
_pages_msg_28 "- blog_in_index = ${blog_in_index}" _pages_msg_28 "- blog_en_indice ="
_pages_msg_29 "- Listando archivo temporal de blog:" _pages_msg_29 "- No se encontraron nuevas o actualizadas Páginas"
_pages_msg_30 "- No se encontraron Páginas nuevas o actualizadas"
_blogs_msg_1 "_blogs: Ejecutando función _list_blogs" _blogs_msg_1 "_blogs: Ejecutando función _list_blogs"
_blogs_msg_2 "* No tienes ningún blog *" _blogs_msg_2 "* No tienes ningún blog *"
_blogs_msg_3 "Generando Blogs" _blogs_msg_3 "Generando Blogs"
_blogs_msg_4 "_blogs: Ejecutando función _blog_cache" _blogs_msg_4 "_blogs: Ejecutando función _blog_cache"
_blogs_msg_5 "No se pudo encontrar la plantilla temática para Blogs." _blogs_msg_5 "No se puede encontrar la plantilla de tema para Blogs."
_blogs_msg_6 "_blogs: Procesando datos previos para ${blog}" _blogs_msg_6 "_blogs: Procesando datos previos para"
_blogs_msg_7 "_blogs: Buscando FECHA: Encontrada" _blogs_msg_7 "_blogs: Buscando FECHA: Encontrado"
_blogs_msg_8 "_blogs: Buscando TÍTULO DEL BLOG: Encontrado" _blogs_msg_8 "_blogs: Buscando TÍTULO DEL BLOG: Encontrado"
_blogs_msg_9 "* _blogs: Falta metadatos de FECHA en ${blog}." _blogs_msg_9 "* _blogs: Falta metadatos de FECHA en"
_blogs_msg_10 "* _blogs: Falta metadatos de TÍTULO DEL BLOG en ${blog}." _blogs_msg_10 "* _blogs: Falta metadatos de TÍTULO DEL BLOG en"
_blogs_msg_11 "_blogs: Añadiendo datos para ${blog} al array para exportar" _blogs_msg_11 "_blogs: Añadiendo datos para"
_blogs_msg_12 "_blogs: Procesando ${blog}" _blogs_msg_11.1 "al array para exportar"
_blogs_msg_13 "- Generando Blog: ${blog_index}.html" _blogs_msg_12 "_blogs: Procesando"
_blogs_msg_14 "_blogs: Procesando sustituciones en ${blog}" _blogs_msg_13 "- Generando Blog:"
_blogs_msg_15 "_blogs: Ejecutando función $engine para ${blog}" _blogs_msg_14 "_blogs: Procesando sustitutos en"
_blogs_msg_16 "_blogs: Comprobando #link, #showimg y #ytvideo en contenido del blog" _blogs_msg_15 "_blogs: Ejecutando función $engine para"
_blogs_msg_16 "_blogs: Verificando #link, #showimg y #ytvideo en contenido del blog"
_blogs_msg_17 "_blogs: #link presente, ejecutar _link: contenido del blog" _blogs_msg_17 "_blogs: #link presente, ejecutar _link: contenido del blog"
_blogs_msg_18 "_blogs: #showimg presente, ejecutar _link: contenido del blog" _blogs_msg_18 "_blogs: #showimg presente, ejecutar _link: contenido del blog"
_blogs_msg_19 "_blogs: #ytvideo presente, ejecutar _link: contenido del blog" _blogs_msg_19 "_blogs: #ytvideo presente, ejecutar _link: contenido del blog"
_blogs_msg_20 "_blogs: Reemplazando tagline, sitename y pagetitle" _blogs_msg_20 "_blogs: Reemplazando tagline, nombreDeSitio y tituloDePagina"
_blogs_msg_21 "_blogs: Creando directorio ${www_root}${blog_dir}" _blogs_msg_21 "_blogs: Creando directorio"
_blogs_msg_22 "_blogs: Escribiendo blog en disco: ${www_root}${blog_url}" _blogs_msg_22 "_blogs: Escribiendo blog en disco:"
_blogs_msg_23 "_blogs: new_updated_blogs=true" _blogs_msg_23 "_blogs: blogs_actualizados=true"
_blogs_msg_24 "- No se encontraron Blogs nuevos o actualizados" _blogs_msg_24 "- No se encontraron nuevos o actualizados Blogs"
_blogs_msg_25 "* _blogs: Ejecutando _blog_idx_for_index" _blogs_msg_25 "* _blogs: Ejecutando _blog_idx_for_index"
_blogs_msg_26 "* _blogs: Ejecutando _blog_index" _blogs_msg_26 "* _blogs: Ejecutando _blog_index"
_blog_idx_for_index_msg_1 "- Poblando ${project_dir}/blog/index.tmp.html" _blog_idx_for_index_msg_1 "- Llenando"
_blog_idx_for_index_msg_2 "_blog_idx_for_index: Iniciando función" _blog_idx_for_index_msg_2 "_blog_idx_for_index: Iniciando función"
BODY_blog_idx_for_index_msg_3 "_blog_idx_for_index: BLOG_META_STR_ARRAY: ${BLOG_META_STR_ARRAY[@]}" _blog_idx_for_index_msg_3 "_blog_idx_for_index: BLOG_META_STR_ARRAY:"
_blog_idx_for_index_msg_4 "_blog_idx_for_index: meta_str de BLOG_META_STR_ARRAY de _blogs" _blog_idx_for_index_msg_4 "_blog_idx_for_index: meta_str de BLOG_META_STR_ARRAY de _blogs"
_blog_idx_for_index_msg_5 "_blog_idx_for_index: ${meta_str}" _blog_idx_for_index_msg_5 "_blog_idx_for_index:"
_blog_idx_for_index_msg_6 "_blog_idx_for_index: Iterando sobre cada componente y extrayendo información" _blog_idx_for_index_msg_6 "_blog_idx_for_index: Iterar sobre cada componente y extraer información"
_blog_idx_for_index_msg_7 "_blog_idx_for_index: Ejecutando ${engine} en contenido para capturar QStags en Ingress" _blog_idx_for_index_msg_7 "_blog_idx_for_index: Ejecutando"
_blog_idx_for_index_msg_8 "_blog_idx_for_index: Escribiendo _blog_idx_for_index en archivo: ${project_dir}/blog/index.tmp.html" _blog_idx_for_index_msg_7.1 "en contenido para capturar QStags en Ingress"
_blog_idx_for_index_msg_9 "_blog_idx_for_index: blog_list_content = ${blog_list_content}" _blog_idx_for_index_msg_8 "_blog_idx_for_index: Escribiendo _blog_idx_for_index en archivo:"
_blog_index_msg_1 "_blog_index: blog_in_index=${blog_in_index}" _blog_idx_for_index_msg_9 "_blog_idx_for_index: contenido_de_lista_de_blogs ="
_blog_index_msg_2 "_blog_index: new_updated_blogs=${new_updated_blogs}" _blog_index_msg_1 "_blog_index: blog_en_indice="
_blog_index_msg_2 "_blog_index: blogs_actualizados="
_blog_index_msg_3 "_blog_index: Ejecutando función _blog_index" _blog_index_msg_3 "_blog_index: Ejecutando función _blog_index"
_blog_index_msg_4 "_blog_index: blog_in_index = ${blog_in_index}" _blog_index_msg_4 "_blog_index: blog_en_indice ="
_blog_index_msg_5 "- Generando Página: ${www_root}/blog/index.html" _blog_index_msg_5 "- Generando Página:"
_blog_index_msg_6 "_blog_index: Reemplazando sitename y tagline" _blog_index_msg_6 "_blog_index: Reemplazando nombreDeSitio y tagline"
_blog_index_msg_7 "_blog_index: Reemplazando BODY con contenido de ${project_dir}/blog/index.tmp.html" _blog_index_msg_7 "_blog_index: Reemplazando CUERPO con contenido de"
_blog_index_msg_8 "_blog_index: Escribiendo ${www_root}/blog/index.html" _blog_index_msg_8 "_blog_index: Escribiendo"
_blog_index_msg_9 "_blog_index: Longitud de contenido de blog_index_content:"
_add_blog_list_to_index_msg_1 "_add_blog_list_to_index: Insertando lista de blogs en index.html" _add_blog_list_to_index_msg_1 "_add_blog_list_to_index: Insertando lista de blogs en index.html"
_sitemap_msg_1 "Generando Sitemap" _sitemap_msg_1 "Generando Mapa del Sitio"
_sitemap_msg_2 "Sitemap generado en ${sitemap_file}" _sitemap_msg_2 "Mapa del sitio generado en"
_link_msg_1 "_link: LÍNEA PRINCIPAL DE URL: ${line}" _link_msg_1 "_link: LÍNEA URL_PRINCIPAL:"
_link_msg_2 "_link_ URL: ${url_dest}" _link_msg_2 "_link_ URL:"
_link_msg_3 "_link: Texto: ${url_txt}" _link_msg_3 "_link: Texto:"
_image_msg_1 "_image: Procesando línea: ${line}" _image_msg_1 "_image: Procesando línea:"
_youtube_msg_1 "_youtube: Procesando línea: ${line}" _youtube_msg_1 "_youtube: Procesando línea:"
_cleanup_msg_1 "_cleanup: Limpiando etiquetas en contenido" _cleanup_msg_1 "_cleanup: Limpiando etiquetas en contenido"
_html_msg_1 "_html: Convirtiendo QStags en contenido" _html_msg_1 "_html: Convirtiendo QStags en contenido"
_zhtml_msg_1 "_zhtml: Convirtiendo QStags en contenido" _zhtml_msg_1 "_zhtml: Convirtiendo QStags en contenido"
) )

View File

@ -52,12 +52,11 @@ _pages_msg_21 "_pages: Filnavn i små bokstaver, alltid"
_pages_msg_22 "_pages: Kjører _cleanup" _pages_msg_22 "_pages: Kjører _cleanup"
_pages_msg_23 "- Analyserer" _pages_msg_23 "- Analyserer"
_pages_msg_24 "- blog_in_index =" _pages_msg_24 "- blog_in_index ="
_pages_msg_25 "- Lister opp blogg midlertidig fil:" _pages_msg_25 "- Skriver ut blogg midlertidig fil:"
_pages_msg_26 "Oppdaterer index.html med nye blogginnlegg" _pages_msg_26 "Oppdaterer index.html med nye blogginnlegg"
_pages_msg_27 "- Analyserer" _pages_msg_27 "- Analyserer"
_pages_msg_28 "- blog_in_index =" _pages_msg_28 "- blog_in_index ="
_pages_msg_29 "- Lister opp blogg midlertidig fil:" _pages_msg_29 "- Ingen nye eller oppdaterte Sider funnet"
_pages_msg_30 "- Ingen nye eller oppdaterte Sider funnet"
_blogs_msg_1 "_blogs: Kjører funksjon _list_blogs" _blogs_msg_1 "_blogs: Kjører funksjon _list_blogs"
_blogs_msg_2 "* Du har ingen blogger *" _blogs_msg_2 "* Du har ingen blogger *"
_blogs_msg_3 "Genererer Blogger" _blogs_msg_3 "Genererer Blogger"

189
qsgen2
View File

@ -10,7 +10,7 @@
# https://github.com/kekePower/qsgen2/ # https://github.com/kekePower/qsgen2/
# #
VERSION="0.4.0 beta" # Wed-2024-02-14 VERSION="0.4.0 beta 1" # Wed-2024-02-14
QSGEN="Quick Site Generator 2" QSGEN="Quick Site Generator 2"
# Set to true or false # Set to true or false
@ -120,6 +120,7 @@ function _version() {
} }
function _help() { function _help() {
# This will also be translated some time in the future
echo "This is where I'll write the Help documentation." echo "This is where I'll write the Help documentation."
exit exit
} }
@ -345,10 +346,10 @@ function _last_updated() {
local debug=${globaldebug:-false} local debug=${globaldebug:-false}
if (${debug}); then _msg debug "_last_updated: Setting date and version in footer"; fi
if (${debug}); then _msg debug "_last_updated: ${upd_msg}"; fi
local upd_msg="Last updated ${today} by <a href=\"https://blog.kekepower.com/qsgen2.html\">${QSGEN} ${VERSION}</a>" local upd_msg="Last updated ${today} by <a href=\"https://blog.kekepower.com/qsgen2.html\">${QSGEN} ${VERSION}</a>"
if (${debug}); then _msg debug "${0:t}_msg_1"; fi
if (${debug}); then _msg debug "${0:t}_msg_2" " ${upd_msg}"; fi
local content="${1}" local content="${1}"
@ -370,8 +371,8 @@ function _f_last_updated() {
local upd_msg="Last updated ${today} by <a href=\"https://blog.kekepower.com/qsgen2.html\">${QSGEN} ${VERSION}</a>" local upd_msg="Last updated ${today} by <a href=\"https://blog.kekepower.com/qsgen2.html\">${QSGEN} ${VERSION}</a>"
if ${debug}; then if ${debug}; then
_msg debug "_f_last_updated: Setting date and version in footer of file ${1}" _msg debug "${0:t}_msg_1" " ${1}"
_msg debug "_f_last_updated: ${upd_msg}" _msg debug "${0:t}_msg_2" " ${upd_msg}"
fi fi
# Read the file content into a variable # Read the file content into a variable
@ -383,7 +384,7 @@ function _f_last_updated() {
if [[ -f "${1}" ]]; then if [[ -f "${1}" ]]; then
sed -i -e "s|#updated|${upd_msg}|" "${1}" sed -i -e "s|#updated|${upd_msg}|" "${1}"
else else
_msg debug "_f_last_updated: File '${1}' not found." _msg debug "${0:t}_msg_3" " '${1}' " "${0:t}_msg_3.1"
fi fi
} }
@ -409,44 +410,44 @@ function _pages() {
local debug=${globaldebug:-false} local debug=${globaldebug:-false}
# Load the cache for Pages # Load the cache for Pages
if (${debug}) _msg debug "_pages: Running function _pages_cache" if (${debug}) _msg debug "${0:t}_msg_1"
_pages_cache _pages_cache
if [[ ${no_pages_found} == "true" ]]; then if [[ ${no_pages_found} == "true" ]]; then
_msg sub "* You do not have any pages *" _msg sub "${0:t}_msg_1"
return return
fi fi
_msg main "Generating Pages" _msg main "${0:t}_msg_3"
if (( ${#pages_array[@]} > 0 )); then if (( ${#pages_array[@]} > 0 )); then
# If pages_array is not empty, we do work # If pages_array is not empty, we do work
if (${debug}) _msg debug "_pages: pages_array is not empty" if (${debug}) _msg debug "${0:t}_msg_4"
for pages_in_array in ${pages_array[@]} for pages_in_array in ${pages_array[@]}
do do
if (${debug}) _msg debug "_pages: Setting Pages template" if (${debug}) _msg debug "${0:t}_msg_5"
local pages=${project_dir}/themes/${theme}/pages.tpl local pages=${project_dir}/themes/${theme}/pages.tpl
# Let's check if we can access the pages.tpl file. # Let's check if we can access the pages.tpl file.
# It not, exit script. # It not, exit script.
if [[ ! -f ${pages} ]]; then if [[ ! -f ${pages} ]]; then
_msg info "Unable to find the Pages template: ${pages}" _msg info "${0:t}_msg_6" " ${pages}"
exit exit
else else
# Read template once # Read template once
if (${debug}) _msg debug "_pages: Reading Pages template into pages_tpl" if (${debug}) _msg debug "${0:t}_msg_7"
local pages_tpl="$(<${pages})" local pages_tpl="$(<${pages})"
fi fi
_msg std "- Generating Page: ${pages_in_array%.*}.html" _msg std "${0:t}_msg_8" " ${pages_in_array%.*}.html"
# Read the file once # Read the file once
if (${debug}) _msg debug "_pages: Loading page_content once - ${pages_in_array}" if (${debug}) _msg debug "${0:t}_msg_9" " ${pages_in_array}"
local page_content="$(<${pages_in_array})" local page_content="$(<${pages_in_array})"
# Grab the title from the Page # Grab the title from the Page
if (${debug}) _msg debug "_pages: Finding page_title" if (${debug}) _msg debug "${0:t}_msg_10"
if [[ ${generator} == "native" ]]; then if [[ ${generator} == "native" ]]; then
while read -r line while read -r line
do do
@ -469,28 +470,28 @@ function _pages() {
fi fi
done <<< ${page_content} done <<< ${page_content}
fi fi
if (${debug}) _msg debug "_pages: ${page_title}" if (${debug}) _msg debug "${0:t}_msg_11" " ${page_title}"
# Remove the #title line from the buffer. No longer needed. # Remove the #title line from the buffer. No longer needed.
if (${debug}) _msg debug "_pages: Removing #title line from page_content" if (${debug}) _msg debug "${0:t}_msg_12"
page_content=$( echo ${page_content} | grep -v \#title ) page_content=$( echo ${page_content} | grep -v \#title )
# HTML'ify the page content # HTML'ify the page content
if (${debug}) _msg debug "_pages: Running engine on ${pages_in_array}" if (${debug}) _msg debug "${0:t}_msg_13" " ${pages_in_array}"
if [[ ${generator} == "native" ]]; then if [[ ${generator} == "native" ]]; then
page_content=$( ${engine} "$page_content" ) page_content=$( ${engine} "$page_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 "_pages: Checking for #link, #showimg and #ytvideo in page_content" if (${debug}) _msg debug "${0:t}_msg_14"
if [[ $( echo ${page_content} | grep \#link ) ]]; then if [[ $( echo ${page_content} | grep \#link ) ]]; then
if (${debug}) _msg debug "_pages: #link is present, run _link: page_content" if (${debug}) _msg debug "${0:t}_msg_15"
page_content=$( _link "${page_content}" ) page_content=$( _link "${page_content}" )
fi fi
if [[ $( echo ${page_content} | grep \#showimg ) ]]; then if [[ $( echo ${page_content} | grep \#showimg ) ]]; then
if (${debug}) _msg debug "_pages: #showimg is present, run _image: page_content" if (${debug}) _msg debug "${0:t}_msg_16"
page_content=$( _image "${page_content}" ) page_content=$( _image "${page_content}" )
fi fi
if [[ $( echo ${page_content} | grep \#ytvideo ) ]]; then if [[ $( echo ${page_content} | grep \#ytvideo ) ]]; then
if (${debug}) _msg debug "_pages: #ytvideo is present, run _youtube: page_content" if (${debug}) _msg debug "${0:t}_msg_17"
page_content=$( _youtube "${page_content}" ) page_content=$( _youtube "${page_content}" )
fi fi
elif [[ ${generator} == "markdown" ]]; then elif [[ ${generator} == "markdown" ]]; then
@ -498,23 +499,23 @@ function _pages() {
fi fi
# Replace every #pagetitle in pages_tpl # Replace every #pagetitle in pages_tpl
if (${debug}) _msg debug "_pages: Replacing #pagetitle, #tagline and #sitename in pages_tpl" if (${debug}) _msg debug "${0:t}_msg_18"
pages_tpl=$(echo "${pages_tpl}" | perl -pe "s|#pagetitle|${page_title}|gs; s|#tagline|${site_tagline}|gs; s|#sitename|${site_name}|gs") 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" if (${debug}) _msg debug "${0:t}_msg_19"
# Use awk for multi-line and special character handling # 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}") ) 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 # Replace #updated with today's date and #version with Name and Version to footer
if (${debug}) _msg debug "_pages: _last_updated in pages_tpl" if (${debug}) _msg debug "${0:t}_msg_20"
pages_tpl=$( _last_updated ${pages_tpl} ) pages_tpl=$( _last_updated ${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 "${0:t}_msg_21"
pages_title_lower=$( _file_to_lower "${pages_in_array}" ) pages_title_lower=$( _file_to_lower "${pages_in_array}" )
# Clean up unused tags, if any # Clean up unused tags, if any
if (${debug}) _msg debug "_pages: Running _cleanup" if (${debug}) _msg debug "${0:t}_msg_22"
pages_tpl=$( _cleanup "${pages_tpl}" ) pages_tpl=$( _cleanup "${pages_tpl}" )
# Write pages_tpl to disk # Write pages_tpl to disk
@ -524,9 +525,9 @@ function _pages() {
# Insert the blog to the front page is blog_in_index is true and the file in the array is index.file_ext # Insert the blog to the front page is blog_in_index is true and the file in the array is index.file_ext
# and if index.tmp.html exist and is not empty # and if index.tmp.html exist and is not empty
if [[ ${pages_in_array} == "index.${file_ext}" && ${blog_in_index} == "true" && -s "${project_dir}/blog/index.tmp.html" ]]; then if [[ ${pages_in_array} == "index.${file_ext}" && ${blog_in_index} == "true" && -s "${project_dir}/blog/index.tmp.html" ]]; then
if (${debug}) _msg sub "- Parsing ${pages_in_array}" if (${debug}) _msg sub "${0:t}_msg_23" " ${pages_in_array}"
if (${debug}) _msg sub "- blog_in_index = ${blog_in_index}" if (${debug}) _msg sub "${0:t}_msg_24" " ${blog_in_index}"
if (${debug}) _msg sub "- Listing blog temp file:" if (${debug}) _msg sub "${0:t}_msg_25"
if (${debug}) ls -l ${project_dir}/blog/index.tmp.html if (${debug}) ls -l ${project_dir}/blog/index.tmp.html
_add_blog_list_to_index _add_blog_list_to_index
fi fi
@ -539,15 +540,15 @@ function _pages() {
# Insert the blog to the front page is blog_in_index is true and the file in the array is index.file_ext # Insert the blog to the front page is blog_in_index is true and the file in the array is index.file_ext
# and if index.tmp.html exist and is not empty # and if index.tmp.html exist and is not empty
if [[ ${blog_in_index} == "true" && -s "${project_dir}/blog/index.tmp.html" ]]; then if [[ ${blog_in_index} == "true" && -s "${project_dir}/blog/index.tmp.html" ]]; then
_msg std "Updating index.html with new blog posts" _msg std "${0:t}_msg_26"
if (${debug}) _msg sub "- Parsing ${pages_in_array}" if (${debug}) _msg sub "${0:t}_msg_27" " ${pages_in_array}"
if (${debug}) _msg sub "- blog_in_index = ${blog_in_index}" if (${debug}) _msg sub "${0:t}_msg_28" " ${blog_in_index}"
if (${debug}) _msg sub "- Listing blog temp file:" if (${debug}) _msg sub "${0:t}_msg_25"
if (${debug}) ls -l ${project_dir}/blog/index.tmp.html if (${debug}) ls -l ${project_dir}/blog/index.tmp.html
_add_blog_list_to_index _add_blog_list_to_index
fi fi
_msg sub "- No new or updated Pages found" _msg sub "${0:t}_msg_29"
export new_updated_pages=false export new_updated_pages=false
fi fi
@ -560,18 +561,18 @@ function _blogs() {
local debug=${globaldebug:-false} local debug=${globaldebug:-false}
# Running function _list_blogs # Running function _list_blogs
if (${debug}) _msg debug "_blogs: Running function _list_blogs" if (${debug}) _msg debug "${0:t}_msg_1"
_list_blogs _list_blogs
if [[ ${no_blogs_found} == "true" ]]; then if [[ ${no_blogs_found} == "true" ]]; then
_msg sub "* You do not have any blogs *" _msg sub "${0:t}_msg_2"
return return
fi fi
_msg main "Generating Blogs" _msg main "${0:t}_msg_3"
# Running function _blog_cache # Running function _blog_cache
if (${debug}) _msg debug "_blogs: Running function _blog_cache" if (${debug}) _msg debug "${0:t}_msg_4"
_blog_cache _blog_cache
if (( ${#make_blog_array[@]} > 0 )); then if (( ${#make_blog_array[@]} > 0 )); then
@ -584,13 +585,13 @@ function _blogs() {
if [[ -f ${project_dir}/themes/${theme}/blogs.tpl ]]; then if [[ -f ${project_dir}/themes/${theme}/blogs.tpl ]]; then
local blog_tpl=$(<"${project_dir}/themes/${theme}/blogs.tpl") local blog_tpl=$(<"${project_dir}/themes/${theme}/blogs.tpl")
else else
_msg info "Unable to find theme template for Blogs." _msg info "${0:t}_msg_5"
exit exit
fi fi
for blog in "${make_blog_array[@]}"; do for blog in "${make_blog_array[@]}"; do
if (${debug}) _msg debug "_blogs: Processing pre-data for ${blog}" if (${debug}) _msg debug "${0:t}_msg_6" " ${blog}"
local content="$(<"${blog}")" local content="$(<"${blog}")"
local sdate btitle ingress body blog_index blog_dir blog_url local sdate btitle ingress body blog_index blog_dir blog_url
@ -604,12 +605,12 @@ function _blogs() {
do do
# Check for the DATE line # Check for the DATE line
if [[ "${line}" == "DATE "* ]]; then if [[ "${line}" == "DATE "* ]]; then
if (${debug}) _msg debug "_blogs: Looking for DATE: Found" if (${debug}) _msg debug "${0:t}_msg_7"
date_found=true date_found=true
fi fi
# Check for the BLOG_TITLE line # Check for the BLOG_TITLE line
if [[ "${line}" == "BLOG_TITLE "* ]]; then if [[ "${line}" == "BLOG_TITLE "* ]]; then
if (${debug}) _msg debug "_blogs: Looking for BLOG_TITLE: Found" if (${debug}) _msg debug "${0:t}_msg_8"
title_found=true title_found=true
fi fi
# If both DATE and BLOG_TITLE are found, no need to continue checking # If both DATE and BLOG_TITLE are found, no need to continue checking
@ -620,17 +621,15 @@ function _blogs() {
# Check if DATE or BLOG_TITLE metadata is missing and log message # Check if DATE or BLOG_TITLE metadata is missing and log message
if [[ "${date_found}" == false ]]; then if [[ "${date_found}" == false ]]; then
_msg debug "* _blogs: DATE metadata missing in ${blog}." _msg debug "${0:t}_msg_9" " ${blog}."
continue # Skip this file and move to the next continue # Skip this file and move to the next
fi fi
if [[ "${title_found}" == false ]]; then if [[ "${title_found}" == false ]]; then
_msg debug "* _blogs: BLOG_TITLE metadata missing in ${blog}." _msg debug "${0:t}_msg_10" " ${blog}."
continue # Skip this file and move to the next continue # Skip this file and move to the next
fi fi
# Extract blog information # Extract blog information
# sed -i "s/GETDATE/${blogdate}/" ${blog}
# Array sdate = Name day=1, Year=2, Month=3, Number day=4
sdate=( $( echo ${content} | grep DATE | sed "s|DATE\ ||" | sed "s|\-|\ |g" ) ) sdate=( $( echo ${content} | grep DATE | sed "s|DATE\ ||" | sed "s|\-|\ |g" ) )
if [[ ${generator} == "native" ]]; then if [[ ${generator} == "native" ]]; then
while IFS= read -r line; do while IFS= read -r line; do
@ -657,19 +656,19 @@ function _blogs() {
blog_dir="/blog/${sdate[2]}/${sdate[3]:l}/${sdate[4]}" blog_dir="/blog/${sdate[2]}/${sdate[3]:l}/${sdate[4]}"
blog_url="${blog_dir}/${blog_index}.html" blog_url="${blog_dir}/${blog_index}.html"
if (${debug}) _msg debug "_blogs: Adding data for ${blog} to array to export" if (${debug}) _msg debug "${0:t}_msg_11" " ${blog} " "${0:t}_msg_11.1"
# Concatenate all metadata into a single string for the current blog # Concatenate all metadata into a single string for the current blog
local metadata_str="SDATE: ${sdate[@]}||BTITLE: ${btitle}||INGRESS: ${ingress}||URL: ${blog_url}" local metadata_str="SDATE: ${sdate[@]}||BTITLE: ${btitle}||INGRESS: ${ingress}||URL: ${blog_url}"
# Append this metadata string to the array # Append this metadata string to the array
BLOG_META_STR_ARRAY+=("${metadata_str}") BLOG_META_STR_ARRAY+=("${metadata_str}")
if (${debug}) _msg debug "_blogs: Processing ${blog}" if (${debug}) _msg debug "${0:t}_msg_12" " ${blog}"
_msg std "- Generating Blog: ${blog_index}.html" _msg std "${0:t}_msg_13" " ${blog_index}.html"
# Prepare the blog template # Prepare the blog template
if (${debug}) _msg debug "_blogs: Processing substitutes in ${blog}" if (${debug}) _msg debug "${0:t}_msg_14" " ${blog}"
local blog_content=$( local blog_content=$(
echo "${blog_tpl}" | \ echo "${blog_tpl}" | \
perl -pe "\ perl -pe "\
@ -683,21 +682,21 @@ function _blogs() {
blog_content="${blog_content//CALMONTH/${sdate[3]}}" blog_content="${blog_content//CALMONTH/${sdate[3]}}"
blog_content="${blog_content//CALADAY/${sdate[1]}}" blog_content="${blog_content//CALADAY/${sdate[1]}}"
if (${debug}) _msg debug "_blogs: Running function $engine for ${blog}" if (${debug}) _msg debug "${0:t}_msg_15" " ${blog}"
if [[ ${generator} == "native" ]]; then if [[ ${generator} == "native" ]]; then
blog_content=$( ${engine} "${blog_content}" ) blog_content=$( ${engine} "${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 "${0:t}_msg_16"
if [[ $( echo ${blog_content} | grep \#link ) ]]; then if [[ $( echo ${blog_content} | grep \#link ) ]]; then
if (${debug}) _msg debug "_blogs: #link is present, run _link: blog_content" if (${debug}) _msg debug "${0:t}_msg_17"
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: #showimg is present, run _link: blog_content" if (${debug}) _msg debug "${0:t}_msg_18"
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: #ytvideo is present, run _link: blog_content" if (${debug}) _msg debug "${0:t}_msg_19"
blog_content=$(_youtube "${blog_content}") blog_content=$(_youtube "${blog_content}")
fi fi
elif [[ ${generator} == "markdown" ]]; then elif [[ ${generator} == "markdown" ]]; then
@ -705,18 +704,18 @@ function _blogs() {
fi fi
# Replace every #tagline in blog_content # Replace every #tagline in blog_content
if (${debug}) _msg debug "_blogs: Replacing tagline, sitename and pagetitle" if (${debug}) _msg debug "${0:t}_msg_20"
blog_content=$( echo ${blog_content} | perl -pe "s|#tagline|${site_tagline}|gs; s|#sitename|${site_name}|gs; s|#pagetitle|${page_title}|gs" ) blog_content=$( echo ${blog_content} | perl -pe "s|#tagline|${site_tagline}|gs; s|#sitename|${site_name}|gs; s|#pagetitle|${page_title}|gs" )
blog_content=$(_last_updated "${blog_content}") blog_content=$(_last_updated "${blog_content}")
blog_content=$(_cleanup "${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 directory ${www_root}${blog_dir}" if (${debug}) _msg debug "${0:t}_msg_21" " ${www_root}${blog_dir}"
[[ ! -d "${www_root}/${blog_dir}" ]] && mkdir -p "${www_root}/${blog_dir}" [[ ! -d "${www_root}/${blog_dir}" ]] && mkdir -p "${www_root}/${blog_dir}"
# Write to file # Write to file
if (${debug}) _msg debug "_blogs: Writing blog to disk: ${www_root}${blog_url}" if (${debug}) _msg debug "${0:t}_msg_22" " ${www_root}${blog_url}"
echo "${blog_content}" > "${www_root}${blog_url}" echo "${blog_content}" > "${www_root}${blog_url}"
unset sdate btitle ingress body blog_index blog_dir blog_url unset sdate btitle ingress body blog_index blog_dir blog_url
@ -724,18 +723,18 @@ function _blogs() {
done done
# Now BLOG_META_STR_ARRAY contains the metadata string for each blog post # Now BLOG_META_STR_ARRAY contains the metadata string for each blog post
export BLOG_META_STR_ARRAY export BLOG_META_STR_ARRAY
if (${debug}) _msg debug "_blogs: new_updated_blogs=true" if (${debug}) _msg debug "${0:t}_msg_23"
export new_updated_blogs=true export new_updated_blogs=true
else else
_msg sub "- No new or updated Blogs found" _msg sub "${0:t}_msg_24"
export new_updated_blogs=false export new_updated_blogs=false
fi fi
if [[ ${new_updated_blogs} == "true" ]]; then if [[ ${new_updated_blogs} == "true" ]]; then
if (${debug}) _msg sub "* _blogs: Running _blog_idx_for_index" if (${debug}) _msg sub "${0:t}_msg_25"
_blog_idx_for_index _blog_idx_for_index
if (${debug}) _msg sub "* _blogs: Running _blog_index" if (${debug}) _msg sub "${0:t}_msg_26"
_blog_index _blog_index
fi fi
@ -746,21 +745,21 @@ function _blog_idx_for_index() {
local debug=${globaldebug:-false} local debug=${globaldebug:-false}
_msg sub "- Populating ${project_dir}/blog/index.tmp.html" _msg sub "${0:t}_msg_1" " ${project_dir}/blog/index.tmp.html"
if (${debug}) _msg debug "_blog_idx_for_index: Initiating function" if (${debug}) _msg debug "${0:t}_msg_2"
local blog_list_tpl=$(<${project_dir}/themes/${theme}/blog_list.tpl) local blog_list_tpl=$(<${project_dir}/themes/${theme}/blog_list.tpl)
# Truncate file before writing new one # Truncate file before writing new one
: >| "${project_dir}/blog/index.tmp.html" : >| "${project_dir}/blog/index.tmp.html"
if (${debug}) _msg debug "_blog_idx_for_index: BLOG_META_STR_ARRAY: ${BLOG_META_STR_ARRAY[@]}" if (${debug}) _msg debug "${0:t}_msg_3" " ${BLOG_META_STR_ARRAY[@]}"
for meta_str in ${BLOG_META_STR_ARRAY[@]} for meta_str in ${BLOG_META_STR_ARRAY[@]}
do do
if (${debug}) _msg debug "_blog_idx_for_index: meta_str from BLOG_META_STR_ARRAY from _blogs" if (${debug}) _msg debug "${0:t}_msg_4"
if (${debug}) _msg debug "_blog_idx_for_index: ${meta_str}" if (${debug}) _msg debug "${0:t}_msg_5" " ${meta_str}"
# Split meta_str into individual metadata components # Split meta_str into individual metadata components
local -a meta_array=("${(@s/||/)meta_str}") local -a meta_array=("${(@s/||/)meta_str}")
@ -769,7 +768,7 @@ function _blog_idx_for_index() {
local sdate btitle ingress url local sdate btitle ingress url
# Iterate over each component and extract information # Iterate over each component and extract information
if (${debug}) _msg debug "_blog_idx_for_index: Iterate over each component and extract information" if (${debug}) _msg debug "${0:t}_msg_6"
for component in "${meta_array[@]}" for component in "${meta_array[@]}"
do do
case "${component}" in case "${component}" in
@ -803,11 +802,11 @@ function _blog_idx_for_index() {
unset sdate btitle ingress url unset sdate btitle ingress url
if (${debug}) _msg debug "_blog_idx_for_index: Running ${engine} on content to catch QStags in Ingress" if (${debug}) _msg debug "${0:t}_msg_7" " ${engine} " "${0:t}_msg_7.1"
blog_list_content=$( ${engine} ${blog_list_content} ) blog_list_content=$( ${engine} ${blog_list_content} )
if (${debug}) _msg debug "_blog_idx_for_index: Writing _blog_idx_for_index to file: ${project_dir}/blog/index.tmp.html" if (${debug}) _msg debug "${0:t}_msg_8" " ${project_dir}/blog/index.tmp.html"
if (${debug}) _msg debug "_blog_idx_for_index: blog_list_content = ${blog_list_content}" if (${debug}) _msg debug "${0:t}_msg_9" " ${blog_list_content}"
echo ${blog_list_content} >> ${project_dir}/blog/index.tmp.html echo ${blog_list_content} >> ${project_dir}/blog/index.tmp.html
done done
@ -822,26 +821,24 @@ function _blog_index() {
# ${new_updated_blogs} comes from the function _blogs if anything new or updated is detected # ${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 [[ ${blog_in_index} == "false" ]] && [[ ${new_updated_blogs} = "true" ]]; then
if (${debug}) _msg debug "_blog_index: blog_in_index=${blog_in_index}" if (${debug}) _msg debug "${0:t}_msg_1" "${blog_in_index}"
if (${debug}) _msg debug "_blog_index: new_updated_blogs=${new_updated_blogs}" if (${debug}) _msg debug "${0:t}_msg_2" "${new_updated_blogs}"
if (${debug}) _msg debug "_blog_index: Running function _blog_index" if (${debug}) _msg debug "${0:t}_msg_3"
if (${debug}) _msg debug "_blog_index: blog_in_index = ${blog_in_index}" if (${debug}) _msg debug "${0:t}_msg_4" " ${blog_in_index}"
_msg std "- Generating Page: ${www_root}/blog/index.html" _msg std "${0:t}_msg_5" " ${www_root}/blog/index.html"
local blog_index_tpl=$(<${project_dir}/themes/${theme}/blog_index.tpl) local blog_index_tpl=$(<${project_dir}/themes/${theme}/blog_index.tpl)
local blog_index_list=$(<${project_dir}/blog/index.tmp.html) local blog_index_list=$(<${project_dir}/blog/index.tmp.html)
if (${debug}) _msg debug "_blog_index: Replacing sitename and tagline" if (${debug}) _msg debug "${0:t}_msg_6"
local blog_index_content=$(echo "${blog_index_tpl}" | perl -pe "s|#sitename|${site_name}|gs; s|#tagline|${site_tagline}|gs") local blog_index_content=$(echo "${blog_index_tpl}" | perl -pe "s|#sitename|${site_name}|gs; s|#tagline|${site_tagline}|gs")
if (${debug}) _msg debug "_blog_index: Replacing BODY with content of ${project_dir}/blog/index.tmp.html" if (${debug}) _msg debug "${0:t}_msg_7" " ${project_dir}/blog/index.tmp.html"
blog_index_content=$( awk -v new_body="$blog_index_list" '{sub(/BODY/, new_body)} 1' <(echo "${blog_index_content}") ) blog_index_content=$( awk -v new_body="$blog_index_list" '{sub(/BODY/, new_body)} 1' <(echo "${blog_index_content}") )
if (${debug}); then if (${debug}); then
_msg debug "_blog_index: Writing ${www_root}/blog/index.html" _msg debug "${0:t}_msg_8" " ${www_root}/blog/index.html"
_msg debug "_blog_index: Content length of blog_index_content: ${#blog_index_content}" _msg debug "${0:t}_msg_9" " ${#blog_index_content}"
#_msg debug "_blog_index: Content of blog_index_content"
#_msg sub "${blog_index_content}"
fi fi
echo "$blog_index_content" > ${www_root}/blog/index.html echo "$blog_index_content" > ${www_root}/blog/index.html
_f_last_updated ${www_root}/blog/index.html _f_last_updated ${www_root}/blog/index.html
@ -855,7 +852,7 @@ function _add_blog_list_to_index() {
local debug=${globaldebug:-false} local debug=${globaldebug:-false}
# Let's find the file 'index.qst' and add the blog if blog_in_index is true # Let's find the file 'index.qst' and add the blog if blog_in_index is true
if (${debug}) _msg debug "_add_blog_list_to_index: Inserting blog list to index.html" if (${debug}) _msg debug "${0:t}_msg_1"
local blog_index_list=$(<${project_dir}/blog/index.tmp.html) local blog_index_list=$(<${project_dir}/blog/index.tmp.html)
local site_index_file=$(<${www_root}/index.html) local site_index_file=$(<${www_root}/index.html)
echo "${site_index_file}" | awk -v new_body="${blog_index_list}" '{sub(/BLOGINDEX/, new_body)} 1' > "${www_root}/index.html" echo "${site_index_file}" | awk -v new_body="${blog_index_list}" '{sub(/BLOGINDEX/, new_body)} 1' > "${www_root}/index.html"
@ -869,7 +866,7 @@ function _sitemap() {
# Check if sitemap is set to true and if there are updated Blogs or Pages before updating the sitemap.xml file. # Check if sitemap is set to true and if there are updated Blogs or Pages before updating the sitemap.xml file.
if [[ ${sitemap} == "true" ]] && ( [[ ${new_updated_blogs} == "true" ]] || [[ ${new_updated_pages} == "true" ]] ); then if [[ ${sitemap} == "true" ]] && ( [[ ${new_updated_blogs} == "true" ]] || [[ ${new_updated_pages} == "true" ]] ); then
_msg main "Generating Sitemap" _msg main "${0:t}_msg_1"
local sitemap_file="${www_root}/sitemap.xml" local sitemap_file="${www_root}/sitemap.xml"
@ -904,7 +901,7 @@ function _sitemap() {
# End of the XML file # End of the XML file
echo '</urlset>' >> "${sitemap_file}" echo '</urlset>' >> "${sitemap_file}"
if (${debug}); then _msg debug "Sitemap generated at ${sitemap_file}"; fi if (${debug}); then _msg debug "${0:t}_msg_2" " ${sitemap_file}"; fi
fi fi
@ -921,15 +918,15 @@ function _link() {
# Process the content line by line # Process the content line by line
echo "${content}" | while IFS= read -r line; do echo "${content}" | while IFS= read -r line; do
if [[ ${line} == *"#link"* ]]; then if [[ ${line} == *"#link"* ]]; then
if (${debug}) _msg debug "_link: URL_MAIN(line): ${line}" if (${debug}) _msg debug "${0:t}_msg_1" " ${line}"
# Extract the URL and the link text # Extract the URL and the link text
local url_full=$(echo "${line}" | awk -F'#link ' '{print $2}' | awk -F'¤' '{print $1 "¤" $2}') local url_full=$(echo "${line}" | awk -F'#link ' '{print $2}' | awk -F'¤' '{print $1 "¤" $2}')
local url_dest=$(echo "${url_full}" | awk -F'¤' '{print $1}') local url_dest=$(echo "${url_full}" | awk -F'¤' '{print $1}')
local url_txt=$(echo "${url_full}" | awk -F'¤' '{print $2}') local url_txt=$(echo "${url_full}" | awk -F'¤' '{print $2}')
if (${debug}) _msg debug "_link_ URL: ${url_dest}" if (${debug}) _msg debug "${0:t}_msg_2" " ${url_dest}"
if (${debug}) _msg debug "_link: Text: ${url_txt}" if (${debug}) _msg debug "${0:t}_msg_3" " ${url_txt}"
# Form the replacement HTML link # Form the replacement HTML link
local modified_link="<a href=\"${url_dest}\">${url_txt}" local modified_link="<a href=\"${url_dest}\">${url_txt}"
@ -959,7 +956,7 @@ function _image() {
# Process the content line by line # Process the content line by line
echo "${content}" | while IFS= read -r line; do echo "${content}" | while IFS= read -r line; do
if [[ ${line} == *"#showimg"* ]]; then if [[ ${line} == *"#showimg"* ]]; then
if (${debug}) _msg debug "_image: Processing line: ${line}" if (${debug}) _msg debug "${0:t}_msg_1" " ${line}"
# Extract image link and alt text # Extract image link and alt text
local img_link=$(echo "${line}" | awk -F'#showimg ' '{print $2}') local img_link=$(echo "${line}" | awk -F'#showimg ' '{print $2}')
@ -999,7 +996,7 @@ function _youtube() {
# Process the content line by line # Process the content line by line
echo "${content}" | while IFS= read -r line; do echo "${content}" | while IFS= read -r line; do
if [[ ${line} == *"#ytvideo"* ]]; then if [[ ${line} == *"#ytvideo"* ]]; then
if (${debug}) _msg debug "_youtube: Processing line: ${line}" if (${debug}) _msg debug "${0:t}_msg_1" " ${line}"
# Extract YouTube video ID # Extract YouTube video ID
local yt_id=$(echo "${line}" | awk -F'#ytvideo ' '{print $2}') local yt_id=$(echo "${line}" | awk -F'#ytvideo ' '{print $2}')
@ -1023,7 +1020,7 @@ function _cleanup() {
local content="${1}" local content="${1}"
if (${debug}) _msg debug "_cleanup: Cleaning up tags in content" if (${debug}) _msg debug "${0:t}_msg_1"
# Perform the cleanup # Perform the cleanup
# -e "s|BLOGINDEX\ ||g" # -e "s|BLOGINDEX\ ||g"
@ -1046,7 +1043,7 @@ function _html() {
local content="${1}" local content="${1}"
if ${debug}; then if ${debug}; then
_msg debug "_html: Converting QStags in content" _msg debug "${0:t}_msg_1"
fi fi
# Use perl to convert QStags to HTML # Use perl to convert QStags to HTML
@ -1106,7 +1103,7 @@ function _zhtml() {
local content="${1}" local content="${1}"
if ${debug}; then if ${debug}; then
_msg debug "_html: Converting QStags in content" _msg debug "${0:t}_msg_1"
fi fi
# Load regex module # Load regex module