aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSomasis <somasissounds@gmail.com>2014-02-15 02:21:13 -0500
committerSomasis <somasissounds@gmail.com>2014-02-15 02:21:13 -0500
commit5a56246bc1b11976774f4f9fb1a17b507ae95a71 (patch)
tree4e46effdf43afb920aaeee2dce4ee3fef5d5ae26
parentdd04d85c1c9540841abe2405b762f6b08db4d4fc (diff)
downloadraspui-5a56246bc1b11976774f4f9fb1a17b507ae95a71.tar.gz
raspui-5a56246bc1b11976774f4f9fb1a17b507ae95a71.tar.xz
raspui-5a56246bc1b11976774f4f9fb1a17b507ae95a71.zip
included some of the resources that are used
-rw-r--r--.gitignore41
-rw-r--r--config.example.sh0
l---------css1
l---------fonts1
-rw-r--r--functions.sh132
-rwxr-xr-xindex.sh46
l---------js1
7 files changed, 222 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3d852a0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,41 @@
+dirlisting.css
+# Compiled source #
+###################
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+
+# Packages #
+############
+# it's better to unpack these files and commit the raw source
+# git has its own built in compression methods
+*.7z
+*.dmg
+*.gz
+*.iso
+*.jar
+*.rar
+*.tar
+*.zip
+
+# Logs and databases #
+######################
+*.log
+*.sql
+*.sqlite
+
+# OS generated files #
+######################
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+ehthumbs.db
+Thumbs.db
+config.sh
+jqueryFileTree.css
+jqueryFileTree.js
diff --git a/config.example.sh b/config.example.sh
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/config.example.sh
diff --git a/css b/css
new file mode 120000
index 0000000..3ab895a
--- /dev/null
+++ b/css
@@ -0,0 +1 @@
+/srv/http/css/ \ No newline at end of file
diff --git a/fonts b/fonts
new file mode 120000
index 0000000..9b03dd3
--- /dev/null
+++ b/fonts
@@ -0,0 +1 @@
+/srv/http/fonts/ \ No newline at end of file
diff --git a/functions.sh b/functions.sh
new file mode 100644
index 0000000..a51b6ce
--- /dev/null
+++ b/functions.sh
@@ -0,0 +1,132 @@
+#!/bin/bash
+
+OLDIFS="$IFS"
+IFS=$'\n'
+for release_line in $(</etc/os-release);do
+ eval "RELEASE_$release_line"
+done
+IFS="$OLDIFS"
+
+if [[ "$HTTPS" == "on" ]];then
+ PROTOCOL=https
+else
+ PROTOCOL=http
+fi
+
+DEBUG=0
+STDIN=$(</dev/stdin)
+if [[ -n "${STDIN}" ]]; then
+ QUERY_STRING="${STDIN}&${QUERY_STRING}"
+fi
+
+# Handle GET and POST requests... (the QUERY_STRING will be set)
+if [[ -n "${QUERY_STRING}" ]]; then
+ # name=value params, separated by either '&' or ';'
+ if echo "${QUERY_STRING}" | grep '=' >/dev/null ; then
+ for Q in $(echo "${QUERY_STRING}" | tr ";&" "\012") ; do
+ name=
+ value=
+ tmpvalue=
+ name="${Q%%=*}"
+ name=$(echo "${name}" | sed -e 's/%\(\)/\\\x/g' | tr "+" " ")
+ name=$(echo "${name}" | tr -d ".-")
+ name=$(printf "${name}")
+ tmpvalue="${Q#*=}"
+ tmpvalue=$(echo "${tmpvalue}" | sed -e 's/%\(..\)/\\\x\1 /g')
+ for i in ${tmpvalue}; do
+ g=$(printf "${i}")
+ value="${value}${g}"
+ done
+ eval "export ${name}='${value}'"
+ done
+ else
+ Q=$(echo "${QUERY_STRING}" | tr '+' ' ')
+ eval "export KEYWORDS='${Q}'"
+ fi
+fi
+
+if [[ -n "${HTTP_COOKIE}" ]]; then
+ for Q in ${HTTP_COOKIE}; do
+ name=
+ value=
+ tmpvalue=
+
+ Q="${Q%;}"
+
+ name="${Q%%=*}"
+ name=$(echo "${name}" | sed -e 's/%\(\)/\\\x/g' | tr "+" " ")
+ name=$(echo "${name}" | tr -d ".-")
+ name=$(printf "${name}")
+
+ tmpvalue="${Q#*=}"
+ tmpvalue=$(echo "${tmpvalue}" | sed -e 's/%\(..\)/\\\x\1 /g')
+
+ for i in ${tmpvalue}; do
+ g=$(printf "${i}")
+ value="${value}${g}"
+ done
+ eval "export cookie_${name}='${value}'"
+ done
+fi
+
+
+cookie() {
+ if [[ "$#" -eq 1 ]]; then
+ name="$1"
+ name=$(echo "${name}" | sed -e 's/cookie_//')
+ value=$(env | grep "^cookie_${name}" | sed -e 's/cookie_//' | cut -d= -f2-)
+ elif [[ $# -gt 1 ]]; then
+ name=$1
+ shift
+ eval "export 'cookie_${name}=$*'"
+ else
+ value=$(env | grep '^cookie_' | sed -e 's/cookie_//' | cut -d= -f1)
+ fi
+ echo ${value}
+ unset name
+ unset value
+}
+
+# keywords returns a list of keywords. This is only set when the script is
+# called with an ISINDEX form (these are pretty rare nowadays).
+keywords() {
+ echo "${KEYWORDS}"
+}
+
+set_cookie() {
+ name="$1"
+ shift
+ value="$*"
+ bashlib_cookies="${bashlib_cookies}; ${name}=${value}"
+ bashlib_cookies="${bashlib_cookies#;}"
+ cookie "$name" "$value"
+}
+
+send_redirect() {
+ if [[ "$#" -eq 1 ]]; then
+ uri="$1"
+ else
+ uri="$PROTOCOL://${SERVER_NAME}/${SCRIPT_NAME}"
+ fi
+ echo "Location: ${uri}"
+ echo
+}
+
+content_type() {
+ case "$1" in
+ html)
+ content_type="text/html"
+ ;;
+ text)
+ content_type="text/plain"
+ ;;
+ css)
+ content_type="text/css"
+ ;;
+ js)
+ content_type="application/javascript"
+ ;;
+ esac
+ echo "Content-type: $content_type"
+ echo
+} \ No newline at end of file
diff --git a/index.sh b/index.sh
new file mode 100755
index 0000000..0937f94
--- /dev/null
+++ b/index.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+version=".1"
+
+. /srv/http/functions.sh
+title="$HOSTNAME - running $RELEASE_PRETTY_NAME"
+time=$(date +'%r')
+date=$(date +'%B %d, %Y')
+pretty_time="It's currently $time, on $date."
+content_type html
+
+cat <<EOF
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>$title</title>
+ <!-- Bootstrap -->
+ <link href="/css/bootstrap.min.css" rel="stylesheet">
+ <link href="/css/bootstrap-theme.min.css" rel="stylesheet">
+ <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
+ <!-- WARNING: Respond.js does not work if you view the page via file:// -->
+ <!--[if lt IE 9]>
+ <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
+ <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
+ <![endif]-->
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
+ <script src="/js/bootstrap.min.js"></script>
+ </head>
+ <body>
+ <div class='container'>
+ <header class='page-header'>
+ <h1>$HOSTNAME <small>running $RELEASE_PRETTY_NAME</small></h1>
+ <h4>$pretty_time <small>raspui v$version</small></h4>
+ </header>
+ <div class="row">
+ <div class="col-md-4">.col-md-4</div>
+ <div class="col-md-4">.col-md-4</div>
+ <div class="col-md-4">.col-md-4</div>
+ </div>
+ </div>
+ </body>
+</html>
+EOF \ No newline at end of file
diff --git a/js b/js
new file mode 120000
index 0000000..908d169
--- /dev/null
+++ b/js
@@ -0,0 +1 @@
+/srv/http/js/ \ No newline at end of file