just pushing the old code.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
########################################
|
||||
# CONFIGURATION FILE FOR THE BASH BLOG #
|
||||
########################################
|
||||
BLOGNAME="The Bash Blog"
|
||||
URL="example.com"
|
||||
POSTSPERPAGE="8"
|
||||
BLOGDESCRIPTION="This is a blog in Bash CGI."
|
||||
BLOGKEYWORDS="bash, cgi, blog"
|
||||
BLOGAUTHOR="a guy in a room, being"
|
||||
@@ -0,0 +1,2 @@
|
||||
echo "<p class=\"center\">© MMXXII, ${URL}</p>"
|
||||
echo "</body></html>";
|
||||
@@ -0,0 +1,11 @@
|
||||
echo "<!DOCTYPE html>";
|
||||
echo "<html><head>";
|
||||
[ -v TITLE ] && echo "<title>${BLOGNAME}: ${TITLE}</title>" || echo "<title>${BLOGNAME}</title>"
|
||||
echo "<meta charset=\"utf-8\" />";
|
||||
echo "<meta name=\"description\" content=\"${BLOGDESCRIPTION}\" />";
|
||||
echo "<meta name=\"keywords\" content=\"${BLOGKEYWORDS}\" />";
|
||||
echo "<meta name=\"author\" content=\"${BLOGAUTHOR}\" />";
|
||||
echo "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />";
|
||||
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />";
|
||||
echo "</head><body>";
|
||||
[ -v TITLE ] && echo "<h1>${BLOGNAME}: ${TITLE}</h1>" || echo "<h1>${BLOGNAME}</h1>"
|
||||
@@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
printf "Content-type: text/html\n\n"
|
||||
|
||||
saveIFS=$IFS
|
||||
IFS='=&'
|
||||
parm=($QUERY_STRING)
|
||||
IFS=$saveIFS
|
||||
|
||||
declare -A ARGUMENTS
|
||||
for ((i=0; i<${#parm[@]}; i+=2))
|
||||
do
|
||||
ARGUMENTS[${parm[i]}]=${parm[i+1]}
|
||||
done
|
||||
|
||||
source config
|
||||
source header.include
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
ARR=(posts/*)
|
||||
TOTALPOSTS="${#ARR[@]}"
|
||||
NUMPAGES=$(($TOTALPOSTS/$POSTSPERPAGE))
|
||||
PAGE=${ARGUMENTS[page]}
|
||||
|
||||
if [[ ! $PAGE =~ ^[0-9]+$ ]]; then
|
||||
PAGE=1
|
||||
elif [[ $PAGE -lt 0 ]] || [[ $PAGE -gt $NUMPAGES ]]; then
|
||||
PAGE=1
|
||||
fi
|
||||
|
||||
MIN=0
|
||||
MAX=$(( ${#ARR[@]} - 1 ))
|
||||
while [[ $MIN -lt $MAX ]]; do
|
||||
X="${ARR[$MIN]}"
|
||||
ARR[$MIN]="${ARR[$MAX]}"
|
||||
ARR[$MAX]="$X"
|
||||
(( MIN++, MAX-- ))
|
||||
done
|
||||
|
||||
if [[ $PAGE -gt 1 ]]; then
|
||||
SUB=$(( $PAGE - 1 ))
|
||||
TOSUB=$(($SUB*$POSTSPERPAGE))
|
||||
ARR=( ${ARR[@]:$TOSUB} )
|
||||
echo "<p>Page $PAGE of $NUMPAGES</p>"
|
||||
fi
|
||||
|
||||
for (( I=0; I<$POSTSPERPAGE; I++)); do
|
||||
POST=${ARR[$I]}
|
||||
FILENAME=$(echo ${POST/^posts\///})
|
||||
printf "<div class=\"post\"><p><a href=\"posts.cgi?post=$FILENAME&page=$PAGE\">$(egrep '^# ' $POST | cut -f2- -d' ')</a> ⇢ $(egrep -v "^#" $POST | egrep -v "^$" | head -n1 | cut -c1-255 | markdown) </div>";
|
||||
done
|
||||
|
||||
printf "<br /><p class=\"center\">";
|
||||
for (( NUM = 1; NUM <= $NUMPAGES; NUM++ )); do
|
||||
if [ $NUM -lt $NUMPAGES ]; then
|
||||
printf "<a href=\"index.cgi?page=$NUM\"><b>$NUM</b></a> | "
|
||||
else
|
||||
printf "<a href=\"index.cgi?page=$NUM\"><b>$NUM</b></a></p><br />"
|
||||
fi
|
||||
done
|
||||
|
||||
source footer.include
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
printf "Content-type: text/html\n\n"
|
||||
|
||||
saveIFS=$IFS
|
||||
IFS='=&'
|
||||
parm=($QUERY_STRING)
|
||||
IFS=$saveIFS
|
||||
|
||||
declare -A ARGUMENTS
|
||||
for ((i=0; i<${#parm[@]}; i+=2))
|
||||
do
|
||||
ARGUMENTS[${parm[i]}]=${parm[i+1]}
|
||||
done
|
||||
|
||||
POST="${ARGUMENTS[post]}"
|
||||
PAGE="${ARGUMENTS[page]}"
|
||||
TITLE=$(egrep '^# ' $POST | cut -f2- -d' ')
|
||||
|
||||
source config
|
||||
source header.include
|
||||
|
||||
egrep -v "^# " $POST | egrep -v "^tags: "| markdown
|
||||
|
||||
echo " <p><a href=\"index.cgi?page=$PAGE\">⇠ back</a></p>";
|
||||
|
||||
source footer.include
|
||||
@@ -0,0 +1,6 @@
|
||||
# TITLE
|
||||
|
||||
## 20210122
|
||||
|
||||
The text all goes down here and such!
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
html, body {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
h1, h2 {
|
||||
font-family: monospace, monospace;
|
||||
}
|
||||
|
||||
code {
|
||||
color: #9cf;
|
||||
background-color:#036;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
code, pre {
|
||||
font-family: monospace;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color:#036;
|
||||
color:#9cf;
|
||||
overflow: auto;
|
||||
line-height:1.5;
|
||||
}
|
||||
|
||||
.post {
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 99vw;
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
p.center { text-align: center; clear: both; width: 100%; }
|
||||
Reference in New Issue
Block a user