[WIP] Initial commit for qsgen3
This commit is contained in:
101
docs/zsdoc/data/bodies/qsgen2
Normal file
101
docs/zsdoc/data/bodies/qsgen2
Normal file
@ -0,0 +1,101 @@
|
||||
|
||||
|
||||
VERSION="0.4.3"
|
||||
QSGEN="Quick Site Generator 2"
|
||||
globaldebug=false
|
||||
fpath=(${HOME}/bin/include/common ${HOME}/bin/include/qsgen2/lang $fpath)
|
||||
autoload include
|
||||
autoload zini
|
||||
include common/colors
|
||||
|
||||
echo "${magenta}${blue_bg} ${QSGEN} ${end}${bold_white}${blue_bg}${VERSION} ${end}"
|
||||
if [[ -f $(pwd)/config ]]; then
|
||||
if (${globaldebug}); then echo "${red}Config file found and sourced${end}\n${yellow} - $(pwd)/config${end}"; fi
|
||||
zini $(pwd)/config
|
||||
else
|
||||
echo "${red}Cannot find configuration file.${end}"
|
||||
echo "${yellow} - Please create the file 'config' in your project directory.${end}"
|
||||
echo "${yellow} - See 'config.example' in the git source tree.${end}"
|
||||
exit
|
||||
fi
|
||||
typeset -A qsgenlang
|
||||
lang_found=false
|
||||
for dir in $fpath; do
|
||||
if [[ -f "${dir}/${config[project_lang]}" ]]; then
|
||||
source "${dir}/${config[project_lang]}"
|
||||
lang_found=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ ${lang_found} == "false" ]]; then
|
||||
echo "Defined language, ${config[project_lang]}, not found. Using en_US."
|
||||
source "${HOME}/bin/include/qsgen2/lang/en_US"
|
||||
fi
|
||||
|
||||
if (${globaldebug}); then
|
||||
qsconfig=$( cat $(pwd)/config | grep -v \# | awk '{print substr($0, index($0, " ") + 1)}' )
|
||||
echo "Content of Config file"
|
||||
for qslines in ${qsconfig}
|
||||
do
|
||||
echo "${yellow}${qslines}${end}"
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ "$1" == "version" || "$1" == "-v" || "$1" == "--version" ]]; then
|
||||
_version ${0:t}
|
||||
elif [[ "$1" == "help" || "$1" == "-h" || "$1" == "--help" ]]; then
|
||||
_help ${0:t}
|
||||
fi
|
||||
blog_cache_file="${config[project_root]}/.blog_cache"
|
||||
pages_cache_file="${config[project_root]}/.pages_cache"
|
||||
if [[ ! ${config[project_generator]} ]] || [[ -d $(pwd)/.git ]]; then
|
||||
_msg debug "_qsgen2_msg_3"
|
||||
exit
|
||||
fi
|
||||
if [[ ${config[project_generator]} == "native" ]]; then
|
||||
engine=_qstags
|
||||
export file_ext="qst"
|
||||
elif [[ ${config[project_generator]} == "markdown" ]]; then
|
||||
if [[ ! -f /usr/local/bin/pandoc ]]; then
|
||||
_msg other "_qsgen2_msg_4"
|
||||
_msg other "https://github.com/jgm/pandoc/releases"
|
||||
exit
|
||||
else
|
||||
engine="/usr/local/bin/pandoc"
|
||||
engine_opts=
|
||||
export file_ext="md"
|
||||
fi
|
||||
else
|
||||
_msg debug "_qsgen2_msg_5"
|
||||
exit
|
||||
fi
|
||||
|
||||
if (${globaldebug}); then _msg debug "_qsgen2_msg_6"; fi
|
||||
|
||||
builtin cd ${config[project_root]}
|
||||
zmodload zsh/files
|
||||
zmodload zsh/datetime
|
||||
zmodload zsh/regex
|
||||
export today=$(strftime "%Y-%m-%d - %T")
|
||||
export blogdate=$(strftime "%a-%Y-%b-%d")
|
||||
|
||||
|
||||
case ${1} in
|
||||
force)
|
||||
_msg sub "_qsgen2_msg_2"
|
||||
: >| "$blog_cache_file"
|
||||
: >| "$pages_cache_file"
|
||||
;;
|
||||
sitemap)
|
||||
_msg sub "Updating sitemaps"
|
||||
export sitemap_force=true
|
||||
_sitemap
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
_blogs
|
||||
_pages
|
||||
_sitemap
|
Reference in New Issue
Block a user