- Implemented UUIDs as filenames and added two more fields on the generated pages

This commit is contained in:
Nova 2021-07-28 14:32:29 -03:00
parent 7159d2e6c1
commit bbd47ff48d
3 changed files with 34 additions and 27 deletions

View File

@ -2,3 +2,4 @@
- Added the possibility 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

33
gensite
View File

@ -2,17 +2,17 @@
if ! [ -f "$PWD/config.cfg" ];then
cat << EOF > config.cfg
sitetitle=""
sitelang=""
sitedomain=""
siteurlrel=""
siteurlfull=""
sitekeywords=""
sitedescription=""
sitemail=""
siteauthor=""
siteupdated=$(date +%Y-%m-%dT%H:%M:%SZ)
siteprojects=""
sitetitle=""
sitelang=""
sitedomain=""
siteurlrel=""
siteurlfull=""
sitekeywords=""
sitedescription=""
sitemail=""
siteauthor=""
siteupdated="$(date +%Y-%m-%d)"
siteprojects=""
EOF
else
source $PWD/config.cfg
@ -28,12 +28,12 @@ markdown="smu"
#gnudate(fmt,date)
gnudate() {
date "+$1" -d "$2" >/dev/null 2&>1
date "+$1" -d "$2" >/dev/null
}
#bsddate(fmt,date)
bsddate() {
date -j "+$1" "$(printf '%s' "$2" | tr -Cd '[:digit:]')" >/dev/null 2&>1
date -j "+$1" "$(printf '%s' "$2" | tr -Cd '[:digit:]')" >/dev/null
}
# added for compatibility with GNU and BSD date.
@ -96,7 +96,10 @@ pageread() {
content=$("${markdown}" "${filename}")
fi
fi
authors="<strong>Authors:</strong> ${author}<br/>"
created="<strong>Created on:</strong> ${datecreated}<br/>"
uuid="<strong>UUID:</strong> ${id}<br/>"
if test "${datecreated}" != "${dateupdated}"; then
created="${created}<strong>Last update on:</strong> ${dateupdated}<br/>"
fi
@ -130,7 +133,7 @@ pageheader() {
<div id="menu">
<span id="links">
<a href="index.html" title="Main page">Index</a> |
<a href="${siteprojects}" title="Some of my projects">Projects</a>
<a href="${siteprojects}" title="Some of my projects">Projects</a> |
<a href="http://validator.w3.org/check?uri=${siteurlfull}">Valid XHTML 1.1</a>
</span>
<span id="links-contact">
@ -151,7 +154,9 @@ pagecontent() {
pageheader
cat <<!__EOF__
<h1><a href="">${title}</a></h1>
<em>${authors}</em>
<em>${created}</em>
<em>${uuid}</em>
${content}
!__EOF__
pagefooter

27
mkpage
View File

@ -3,20 +3,21 @@
# It also creates the associated markdown pages
# Program's arguments
# $1 = Filename
# $2 = Title
# $3 = Description
# $4 = Author
# $1 = Title
# $2 = Description
# $3 = Author
cat << EOF > pages/$1.sh
page_id="$(uuidgen)"
cat << EOF > pages/${page_id}.sh
#!/bin/sh
title="$2"
description="$3"
timecreated="$(date +%Y-%m-%d %T)"
timeupdated="$(date +%Y-%m-%d %T)"
author="$4"
#id="$5"
#url="${id}.html"
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"
@ -25,4 +26,4 @@ author="$4"
#content="custom stuff"
EOF
touch pages/$1.md
touch pages/${page_id}.md