aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorU-AD\carlsoan <carlsoan@gophersjos7275.ad.uc.edu>2017-03-22 09:22:21 -0400
committerU-AD\carlsoan <carlsoan@gophersjos7275.ad.uc.edu>2017-03-22 09:22:21 -0400
commitb5c65aee8bdb2e0415230f4baf1bec306976bb86 (patch)
treecfeb452da6840626555f3ad1c6650e882c83a3a0
parent976db7fba6c15c412f5a9d4f2ae80ee3b670c5be (diff)
test gitignore
-rw-r--r--Makefile7
-rwxr-xr-xbin/siting.sh68
-rwxr-xr-xdb/content.dbbin0 -> 24576 bytes
-rw-r--r--site.m42
4 files changed, 48 insertions, 29 deletions
diff --git a/Makefile b/Makefile
index 1a94bdf..6a0df0b 100644
--- a/Makefile
+++ b/Makefile
@@ -27,8 +27,11 @@ build/site.xml: tmp/pages.m4 tmp/top.m4 tmp/bottom.m4 build
tmp/pages.m4: $(contentdb) tmp
echo "define(\`PAGEOBJECTS',\`" > tmp/pages.m4
- $(shell ls /usr/bin/sqlite* | head -n1) $(contentdb) 'SELECT value FROM elements WHERE name="homepage";' | awk 'BEGIN { FS="|" } { printf "<homepage>\n<section>\n%s</section>\n</homepage>\n",$$1 }' >> tmp/page.m4
- $(shell ls /usr/bin/sqlite* | head -n1) $(contentdb) 'SELECT title,label,content FROM pages;' | awk 'BEGIN { FS="|" } { printf "<page>\n<title>%s</title>\n<label>%s</label>\n<section>\n%s\n</section>\n</page>\n",$$1,$$2,$$3 }' >> tmp/pages.m4
+ printf "<homepage>\n<section>\n" >> tmp/pages.m4
+ $(shell ls /usr/bin/sqlite* | head -n1) $(contentdb) 'SELECT value FROM elements WHERE name="homepage";' | openssl enc -base64 -d >> tmp/pages.m4
+ printf "\n</section>\n</homepage>" >> tmp/pages.m4
+ $(shell ls /usr/bin/sqlite* | head -n1) $(contentdb) 'SELECT title,label FROM pages;' | awk 'BEGIN { FS="|" } { printf "<page>\n<title>%s</title>\n<label>%s</label>\n",$$1,$$2, }' >> tmp/pages.m4
+ $(shell ls /usr/bin/sqlite* | head -n1) $(contentdb) '
$(shell ls /usr/bin/sqlite* | head -n1) $(contentdb) 'SELECT title,label,content FROM subpages;' | awk 'BEGIN { FS="|" } { printf "<page>\n<title>%s</title>\n<label>%s</label>\n<section>\n%s\n</section>\n</page>\n",$$1,$$2,$$3 }' >> tmp/pages.m4
echo "')" >> tmp/pages.m4
diff --git a/bin/siting.sh b/bin/siting.sh
index db7c6b5..790965b 100755
--- a/bin/siting.sh
+++ b/bin/siting.sh
@@ -10,12 +10,20 @@ sqlite_binary() {
newpage() {
while true; do
exec 3>&1
- PAGEDATA=$(dialog --ok-label "Save Page" --backtitle "Create a New Page" --form "Page Information" 15 50 0 "Title:" 1 1 "" 1 10 15 0 "Content:" 2 1 "" 2 10 1000 0 2>&1 1>&3)
+ PAGETITLE=$(dialog --inputbox "Enter Page Title" 10 40 2>&1 1>&3)
exec 3>&-
- TITLE=$(echo "$PAGEDATA" | head -n1)
- LABEL=$(echo "$TITLE" | tr '[:upper:]' '[:lower:]' | sed 's/[ \t]//g')
- CONTENT=$(echo "$PAGEDATA" | head -n3 | tail -n1)
+ LABEL=$(echo "$PAGETITLE" | tr '[:upper:]' '[:lower:]' | sed 's/[ \t]//g')
+ if [ -n "$($(sqlite_binary) $CONTENTDB 'SELECT * FROM pages WHERE label="'"$LABEL"'";')" ]; then
+ dialog --msgbox "Page '$PAGETITLE' already exists" 5 30
+ continue
+ fi
+
+ [[ -f /tmp/$LABEL ]] && rm /tmp/$LABEL
+ vim /tmp/$LABEL
+ CONTENT="$(cat /tmp/$LABEL | openssl enc -base64)"
+ rm /tmp/$LABEL
+
if [ -z "$(cat <<<$PAGEDATA | grep -v '^[ \t]*$')" ]; then
break
elif [ $(cat <<<$PAGEDATA | grep -v '^[ \t]*$' | wc -l) -eq 2 ]; then
@@ -32,13 +40,15 @@ editpage() {
PAGEID=$($(sqlite_binary) $CONTENTDB 'SELECT id,label FROM pages;' | sed 's/|/ /g' | tr '\n' ' ' | dialog --menu "Select Page" 15 40 10 $(cat -) 2>&1 1>&3)
exec 3>&-
- CONTENT=$($(sqlite_binary) $CONTENTDB 'SELECT content FROM pages WHERE id='"$PAGEID"';')
- PAGETITLE=$($(sqlite_binary) $CONTENTDB 'SELECT title FROM pages WHERE id='"$PAGEID"';')
+
+ PAGELABEL=$($(sqlite_binary) $CONTENTDB 'SELECT label FROM pages WHERE id='"$PAGEID"';')
+ [[ -f /tmp/$PAGELABEL ]] && rm /tmp/$PAGELABEL
+ $(sqlite_binary) $CONTENTDB 'SELECT content FROM pages WHERE id='"$PAGEID"';' | openssl enc -base64 -d > /tmp/$PAGELABEL
while true; do
- exec 3>&1
- PAGEDATA=$(dialog --ok-label "Save $PAGETITLE" --backtitle "Edit Page" --form "Edit" 15 50 0 "Content:" 2 1 "$CONTENT" 2 10 1000 0 2>&1 1>&3)
- exec 3>&-
+ vim /tmp/$PAGELABEL
+ PAGEDATA=$(cat /tmp/$PAGELABEL | openssl enc -base64)
+ rm /tmp/$PAGELABEL
if [ -n "$PAGEDATA" ]; then
$(sqlite_binary) $CONTENTDB 'UPDATE pages SET content="'"$PAGEDATA"'" WHERE id='"$PAGEID"';'
@@ -52,13 +62,21 @@ editpage() {
newsubpage() {
while true; do
exec 3>&1
- PAGEDATA=$(dialog --ok-label "Save Subpage" --backtitle "Create a New Subpage" --form "Subpage Information" 15 50 0 "Title:" 1 1 "" 1 10 15 0 "Content:" 3 1 "" 3 10 1000 0 2>&1 1>&3)
+ PAGETITLE=$(dialog --inputbox "Enter Page Title" 10 40 2>&1 1>&3)
exec 3>&-
- TITLE=$(echo "$PAGEDATA" | head -n1)
- LABEL=$(echo "$TITLE" | tr '[:upper:]' '[:lower:]' | sed 's/[ \t]//g')
- CONTENT=$(echo "$PAGEDATA" | head -n3 | tail -n1)
- if [ -z "$(cat <<<$PAGEDATA | grep -v '^[ \t]*$')" ]; then
+ LABEL=$(echo "$PAGETITLE" | tr '[:upper:]' '[:lower:]' | sed 's/[ \t]//g')
+ if [ -n "$($(sqlite_binary) $CONTENTDB 'SELECT * FROM pages WHERE label="'"$LABEL"'";')" ]; then
+ dialog --msgbox "Page '$PAGETITLE' already exists" 5 30
+ continue
+ fi
+
+ [[ -f /tmp/$LABEL ]] && rm /tmp/$LABEL
+ vim /tmp/$LABEL
+ CONTENT="$(cat /tmp/$LABEL | openssl enc -base64)"
+ rm /tmp/$LABEL
+
+ if [ -z "$(cat <<<$PAGEDATA | grep -v '^[ \t]*$')" ]; then
break
elif [ $(cat <<<$PAGEDATA | grep -v '^[ \t]*$' | wc -l) -eq 2 ]; then
$(sqlite_binary) $CONTENTDB 'INSERT INTO subpages(title,label,content) VALUES("'"$TITLE"'","'"$LABEL"'","'"$CONTENT"'");'
@@ -74,13 +92,14 @@ editsubpage() {
PAGEID=$($(sqlite_binary) $CONTENTDB 'SELECT id,label FROM subpages;' | sed 's/|/ /g' | tr '\n' ' ' | dialog --menu "Select Subpage" 15 40 10 $(cat -) 2>&1 1>&3)
exec 3>&-
- CONTENT=$($(sqlite_binary) $CONTENTDB 'SELECT content FROM subpages WHERE id='"$PAGEID"';')
- PAGETITLE=$($(sqlite_binary) $CONTENTDB 'SELECT title FROM subpages WHERE id='"$PAGEID"';')
+ PAGELABEL=$($(sqlite_binary) $CONTENTDB 'SELECT label FROM subpages WHERE id='"$PAGEID"';')
+ [[ -f /tmp/$PAGELABEL ]] && rm /tmp/$PAGELABEL
+ $(sqlite_binary) $CONTENTDB 'SELECT content FROM pages WHERE id='"$PAGEID"';' | openssl enc -base64 -d > /tmp/$PAGELABEL
while true; do
- exec 3>&1
- PAGEDATA=$(dialog --ok-label "Save $PAGETITLE" --backtitle "Edit Subpage" --form "Edit" 15 50 0 "Content:" 2 1 "$CONTENT" 2 10 1000 0 2>&1 1>&3)
- exec 3>&-
+ vim /tmp/$PAGELABEL
+ PAGEDATA=$(cat /tmp/$PAGELABEL | openssl enc -base64)
+ rm /tmp/$PAGELABEL
if [ -n "$PAGEDATA" ]; then
$(sqlite_binary) $CONTENTDB 'UPDATE subpages SET content="'"$PAGEDATA"'" WHERE id='"$PAGEID"';'
@@ -107,12 +126,11 @@ editelement() {
exec 3>&-
if [ -n "$ELEMID" ]; then
- ELVAL=$($(sqlite_binary) $CONTENTDB 'SELECT value FROM elements WHERE id='"$ELEMID"';')
- ELNAME=$($(sqlite_binary) $CONTENTDB 'SELECT name FROM elements WHERE id='"$ELEMID"';')
-
- exec 3>&1
- NEWVAL=$(dialog --ok-label "Save $ELNAME" --backtitle "Edit Site Element" --form "Edit $ELNAME" 15 50 0 "Value:" 2 1 "$ELVAL" 2 10 1000 0 2>&1 1>&3)
- exec 3>&-
+ [[ -f /tmp/$ELEMID ]] && rm /tmp/$ELEMID
+ $(sqlite_binary) $CONTENTDB 'SELECT value FROM elements WHERE id='"$ELEMID"';' | openssl enc -base64 -d > /tmp/$ELEMID
+ vim /tmp/$ELEMID
+ NEWVAL=$(cat /tmp/$ELEMID | openssl enc -base64)
+ rm /tmp/$ELEMID
$(sqlite_binary) $CONTENTDB 'UPDATE elements SET value="'"$NEWVAL"'" WHERE id='"$ELEMID"';'
fi
diff --git a/db/content.db b/db/content.db
new file mode 100755
index 0000000..1b8130c
--- /dev/null
+++ b/db/content.db
Binary files differ
diff --git a/site.m4 b/site.m4
index a84a91c..ca868f9 100644
--- a/site.m4
+++ b/site.m4
@@ -10,5 +10,3 @@
<belowpage>
BELOWPAGEHTML
</belowpage>
- PAGEOBJECTS
-</site>