From ba50b03bcd5b92412e883b491f0068a1cdc1ed8e Mon Sep 17 00:00:00 2001 From: Nova Date: Tue, 17 Aug 2021 12:27:47 +0000 Subject: [PATCH] mkpage has been rewritten --- CHANGELOG | 13 ++++++----- README.md | 2 +- mkpage | 64 +++++++++++++++++++++++++++++++++++++------------------ 3 files changed, 52 insertions(+), 27 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 225c383..ff92c13 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ -[2021.07.28] - - Added the ability of loading a config.cfg file like 'saait' does - - Renamed generate.sh to gensite - - Renamed create.sh to mkpage - - Implemented UUIDs as filenames and added two more fields on the generated pages (inspired from Logarion) +2021-08-17 Nova + * mkpage has been rewritten, now it supports both HTML and Markdown + +2021-07-28 Nova + * Added the ability of loading a config.cfg file like 'saait' does + * Renamed generate.sh to gensite + * Renamed create.sh to mkpage + * Implemented UUIDs as filenames and added two more fields on the generated pages (inspired from Logarion) diff --git a/README.md b/README.md index 09381fe..6e87acb 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ As well featuring the `gensite` script and the ability to source configuration f Usage ----- -- `mkpage <description> <author>` +- `mkpage <switch> <title> <description> <author>` - `gensite` Features diff --git a/mkpage b/mkpage index b741dbf..8e3641c 100644 --- a/mkpage +++ b/mkpage @@ -1,29 +1,51 @@ #!/bin/sh # Metadata generator for static-site-scripts -# It also creates the associated markdown pages +# It can also generate either the markdown pages or the html pages -# Program's arguments -# $1 = Title -# $2 = Description -# $3 = Author +VERSION=$(git rev-parse --short HEAD) page_id="$(uuidgen)" -cat << EOF > pages/${page_id}.sh -#!/bin/sh -title="$1" -description="$2" -timecreated="$(date +%Y-%m-%d)" -timeupdated="$(date +%Y-%m-%d)" -author="$3" -id="${page_id}" -url="${page_id}.html" -#tags="$6" -#keywords="$7" -#categories="$8" -#timestamp="${timecreated}" -#author="" -#content="custom stuff" +gen_html() { + touch pages/${page_id}.html +} +gen_markdown() { + touch pages/${page_id}.md +} +gen_metadata() { + cat << EOF > pages/${page_id}.sh + #!/bin/sh + title="$2" + description="$3" + timecreated="$(date +%Y-%m-%d)" + timeupdated="$(date +%Y-%m-%d)" + author="$4" + id="${page_id}" + url="${page_id}.html" EOF +} +show_help() { + printf "\t${0}\n" + printf "\tpart of static-site-scripts , version ${VERSION}\n" + printf "\n" + printf "\t-htm <title> <description> <author> \tGenerate metadata + html file\n" + printf "\t-md <title> <description> <author> \tGenerate metadata + markdown file\n" + printf "\t--help\tShow this help page\n" +} -touch pages/${page_id}.md +case "$1" in + -htm) + gen_metadata "$2" "$3" "$4" + gen_html + ;; + -md) + gen_metadata "$2" "$3" "$4" + gen_markdown + ;; + --help) + show_help + ;; + *) + show_help + ;; +esac