]> git.plutz.net Git - lobster/commitdiff
page skeleton and rough component framework
authorpaul <paul@plutz.net>
Tue, 30 Jul 2013 19:41:14 +0000 (19:41 +0000)
committerpaul <paul@plutz.net>
Tue, 30 Jul 2013 19:41:14 +0000 (19:41 +0000)
svn path=/trunk/; revision=4

ifcomponent/frame.sh [new file with mode: 0755]
ifcomponent/page_attendees.sh [new file with mode: 0755]
ifcomponent/page_courses.sh [new file with mode: 0755]
ifcomponent/page_email.sh [new file with mode: 0755]
ifcomponent/page_error.sh [new file with mode: 0755]
ifcomponent/view_attendee.sh [new file with mode: 0755]
ifcomponent/view_course.sh [new file with mode: 0755]
index.cgi
page.sh [new file with mode: 0755]

diff --git a/ifcomponent/frame.sh b/ifcomponent/frame.sh
new file mode 100755 (executable)
index 0000000..fa04fd6
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/zsh
+
+cat <<EOF
+<!Doctype HTML>
+
+<html>
+  <head>
+    <title>$TITLE</title>
+    <style type="text/css">
+    <!--
+
+
+    $($PAGE css)
+    -->
+    </style>
+  </head>
+  <body>
+    <div class="NAVIGATION">
+      $(NAVIGATION |sed -r 's:^([^ ]+) (.+)$:<a href="\1">\2</a>:g')
+    </div>
+    <div class="MAIN">
+      $($PAGE body)
+    </div>
+  </body>
+</html>
+EOF
diff --git a/ifcomponent/page_attendees.sh b/ifcomponent/page_attendees.sh
new file mode 100755 (executable)
index 0000000..e4b8cd9
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+case "$1" in
+  title)
+    echo "Teilnehmende"
+  ;;
+  css)
+  ;;
+  body)
+  ;;
+esac
+  
diff --git a/ifcomponent/page_courses.sh b/ifcomponent/page_courses.sh
new file mode 100755 (executable)
index 0000000..1c69c66
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+case "$1" in
+  title)
+    echo "Kurse"
+  ;;
+  css)
+  ;;
+  body)
+  ;;
+esac
+  
diff --git a/ifcomponent/page_email.sh b/ifcomponent/page_email.sh
new file mode 100755 (executable)
index 0000000..b37b62a
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+case "$1" in
+  title)
+   echo "Email"
+  ;;
+  css)
+  ;;
+  body)
+  ;;
+esac
+  
diff --git a/ifcomponent/page_error.sh b/ifcomponent/page_error.sh
new file mode 100755 (executable)
index 0000000..d5f6053
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+case "$1" in
+  title)
+  ;;
+  css)
+  ;;
+  body)
+cat <<EOF
+Page not found or nevermore<br />
+Quoth the server: 404
+EOF
+  ;;
+esac
+  
diff --git a/ifcomponent/view_attendee.sh b/ifcomponent/view_attendee.sh
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/ifcomponent/view_course.sh b/ifcomponent/view_course.sh
new file mode 100755 (executable)
index 0000000..e69de29
index 45602fcfc2895ab1785759c56afbe622766f8e8a..4d050e8700c19407fc2c85a8082109077a958d7a 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -46,3 +46,4 @@ EOF
 cgi_get
 debug "$_GET"
 
+. "$_EXEC/page.sh"
diff --git a/page.sh b/page.sh
new file mode 100755 (executable)
index 0000000..ef1cf4d
--- /dev/null
+++ b/page.sh
@@ -0,0 +1,19 @@
+#!/bin/zsh
+
+echo "Content-Type: text/html\n\n"
+
+PAGE="$(echo "$_GET['page']" |egrep '^[a-zA-Z0-9_-]+$')"
+PAGE="${_EXEC}/ifcomponent/page_${PAGE}.sh"
+[ -x "$PAGE" ] || PAGE="${_EXEC}/ifcomponent/page_error.sh"
+
+TITLE=$($PAGE title)
+
+NAVIGATION() {
+  for each in "${_EXEC}/ifcomponent"/page_*.sh; do
+    link="$(echo "$each" |sed -r "s:^.*page_(.*)\.sh$:\1:")"
+    title="$($each title)"
+    echo "/?page=$link $title"
+  done
+}
+
+. ${_EXEC}/ifcomponent/frame.sh