]> git.plutz.net Git - serve0/commitdiff
moved cgi components to different repository
authorpaul <paul@plutz.net>
Sat, 13 Jun 2015 14:15:12 +0000 (14:15 +0000)
committerpaul <paul@plutz.net>
Sat, 13 Jun 2015 14:15:12 +0000 (14:15 +0000)
svn path=/trunk/; revision=51

action.sh [deleted file]
cgi.sh [deleted file]
constants.sh
index.cgi [deleted file]
page.sh [deleted file]
templates/download.html.sh [new file with mode: 0755]

diff --git a/action.sh b/action.sh
deleted file mode 100755 (executable)
index 0077575..0000000
--- a/action.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/zsh
-
-# Copyright 2014 Paul Hänsch
-#
-# This file is part of Serve0.
-# 
-# Serve0 is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# Serve0 is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Affero General Public License for more details.
-# 
-# You should have received a copy of the GNU Affero General Public License
-# along with Serve0.  If not, see <http://www.gnu.org/licenses/>. 
-
-ACTION="$(echo "$_GET[\"action\"]" |egrep '^[a-zA-Z0-9_-]+$')"
-ACTION="${_EXEC}/actions/${ACTION}.sh"
-[ -x "$ACTION" ] || echo -n "Location: http://$HTTP_HOST/?page=error\n\n"
-
-. $ACTION
diff --git a/cgi.sh b/cgi.sh
deleted file mode 100755 (executable)
index c70c4d2..0000000
--- a/cgi.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/bin/zsh
-
-# Copyright 2014 Paul Hänsch
-#
-# This file is part of Serve0.
-# 
-# Serve0 is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# Serve0 is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Affero General Public License for more details.
-# 
-# You should have received a copy of the GNU Affero General Public License
-# along with Serve0.  If not, see <http://www.gnu.org/licenses/>. 
-
-declare -A _GET
-declare -A _POST
-declare -A _REF
-
-cgi_get() {  # parse HTTP GET string
-  echo "$QUERY_STRING" |tr '&' '\n' |while read query; do
-    key="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\1:')"
-    val="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\2:')"
-    _GET["$key"]="$(echo -e "$(echo "$val" |sed 's:+: :g;s:%:\\x:g')")"
-  done
-}
-
-cgi_post() {  # parse HTTP POST string
-  sed -u 1q |tr '&' '\n' |while read query; do
-    key="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\1:')"
-    val="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\2:')"
-    value="$(echo -e "$(echo "$val" |sed 's:+: :g;s:%:\\x:g')")"
-    if [ -n "$_POST[\"$key\"]" ]; then
-      n=0
-      while [ -n "$_POST[\"$key$n\"]" ]; do n=$(($n + 1)); done
-      _POST["$key$n"]="$value"
-    else
-      _POST["$key"]="$value"
-    fi
-    #debug "_POST[$key] => $value"
-  done
-}
-
-cgi_refdata() { # Parse GET data from referer
-  echo "$HTTP_REFERER" |cut -d'?' -f2- |tr '&' '\n' |while read query; do
-    key="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\1:')"
-    val="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\2:')"
-    _REF["$key"]="$(echo -e "$(echo "$val" |sed 's:+: :g;s:%:\\x:g')")"
-  done
-}
-
-urlsave(){
-  echo -E "$*" |sed 's:%:\%25:g;s:\?:\%3F:g;s:&:\%26:g;s:'\'':\%27:g;s: :\%20:g;s:!:\%21:g;s:(:\%28:g;s:):\%29:g;s:":\%22:g;'
-}
index 36c85bca7caa1b01f35bebd662815a699f33374d..727952d4de8d0a6db296146472a647a9dfe922b9 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/zsh
 
-# Copyright 2014 Paul Hänsch
+# Copyright 2014,2015 Paul Hänsch
 #
 # This file is part of Serve0.
 # 
@@ -21,3 +21,5 @@ alias _wiki="stx2any --no-template --link-abbrevs --quote -T html"
 [ -z "$_GET[\"page\"]" ] && _GET["page"]=list
 pagesize=100
 file_pattern='^.*(mov|ts|mpg|mpeg|mp4|m4v|avi|mkv|flv|sfv|wmv|ogm|webm|iso|rmvb)$'
+
+data_dirs cache meta mp4 videos thumbs trash by_length transcoded
diff --git a/index.cgi b/index.cgi
deleted file mode 100755 (executable)
index 40b67f1..0000000
--- a/index.cgi
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/zsh
-
-# Copyright 2014 Paul Hänsch
-#
-# This file is part of Serve0.
-# 
-# Serve0 is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# Serve0 is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Affero General Public License for more details.
-# 
-# You should have received a copy of the GNU Affero General Public License
-# along with Serve0.  If not, see <http://www.gnu.org/licenses/>. 
-
-export LC_ALL=C
-
-# basic functions
-die() {
-  echo "$*" >/dev/stderr
-  exit 1
-}
-debug() { #change to false to disable debugging
-  #true && echo "$*" >>debug
-  true && [ -n "$*" ] && echo -E "$*" >>/dev/stderr
-  true && [ -z "$*" ] && tee /dev/stderr
-}
-
-# this program is supposed to be symlinked into a http root directory
-# we will use the http root as object storage (data directory) and call sub
-# programs from the directory in which the real executable resides
-# therefore we need to identify the code and data directories _EXEC and _DATA
-call="$0"
-real="$(readlink -f $call)"
-_EXEC="$(dirname "$real")"  #execution directory
-_DATA="$(dirname "$call")"  #storage directory
-
-[ -w "$_DATA" ] && [ -d "$_DATA" ] || die "storage directory must be writable"
-
-# create directories for object storage
-for each in "$_DATA"/{cache,meta,mp4,videos,thumbs,trash,by_length,transcoded}; do
-  [ ! -e "$each" ] && mkdir "$each"
-  [ -w "$each" ] && [ -d "$each" ] || die "storage $each must be a writable directory"
-done
-
-# create htaccess file
-[ -f .htaccess ] || cat >.htaccess <<EOF
-Options                +ExecCGI
-AddHandler     cgi-script .cgi
-DirectoryIndex index.cgi
-EOF
-[ -f .htaccess ] || die "no htaccess file present and unable to create one"
-
-. "$_EXEC/cgi.sh"
-
-cgi_get
-
-. "$_EXEC/constants.sh"
-
-if [ -n "$_GET[\"action\"]" ]; then
-  . "$_EXEC/action.sh"
-elif [ -n "$_GET[\"export\"]" ]; then
-  . "$_EXEC/export.sh"
-else
-  . "$_EXEC/page.sh"
-fi
diff --git a/page.sh b/page.sh
deleted file mode 100755 (executable)
index fce83fb..0000000
--- a/page.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/zsh
-
-# Copyright 2014 Paul Hänsch
-#
-# This file is part of Serve0.
-# 
-# Serve0 is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# Serve0 is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Affero General Public License for more details.
-# 
-# You should have received a copy of the GNU Affero General Public License
-# along with Serve0.  If not, see <http://www.gnu.org/licenses/>. 
-
-echo -n "Content-Type: text/html;charset=utf-8\n\n"
-
-PAGE="$(echo "$_GET[\"page\"]" |egrep '^[a-zA-Z0-9_-]+$')"
-PAGE="${_EXEC}/pages/${PAGE}.sh"
-[ -x "$PAGE" ] || PAGE="${_EXEC}/pages/error.sh"
-
-NAVIGATION() {
-  for each in "${_EXEC}"/pages/*.sh; do
-    link="$(echo "$each" |sed -r "s:^.*/([^/]*)\.sh$:\1:")"
-    title="$($each title)"
-    [ -n "$title" ] && echo "/?page=$link $title"
-  done
-}
-
-. ${_EXEC}/templates/frame.html.sh
diff --git a/templates/download.html.sh b/templates/download.html.sh
new file mode 100755 (executable)
index 0000000..0bc4dbf
--- /dev/null
@@ -0,0 +1,69 @@
+# Copyright 2015 Paul Hänsch
+#
+# This file is part of Serve0
+# 
+# Serve0 is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# Serve0 is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with Serve0  If not, see <http://www.gnu.org/licenses/>. 
+
+cat <<EOF
+  <form class="panel" id="advfilter" style="display: none;"
+        action="?action=filter" method="post" accept-charset="UTF-8">
+    <input disabled type="text" name="s" value="$search" placeholder="Search">
+    <label for="o2" class="order">Order by:</label>
+    <select disabled class="order" size="1" name="o" id="o2">
+      <option>Name</option>
+      <option>Date</option>
+      <option>Length</option>
+    </select>
+    <input disabled type="submit" name="submit" value="Find">
+
+    <a class="panel clearsearch" href="?">Clear All</a>
+    <a class="panel advanced hide" href="#" 
+     onclick="javascript:hide('advfilter');$(for n in {1..9}; do echo "hide('filter$n');"; done)show_block('search')"
+    >Hide</a>
+    <hr>
+
+    <p class="help">Up to <strong>10</strong> filter boxes will appear as you start selecting tags. You can select <strong>multiple</strong> tags in each box by holding down the <strong>Ctrl</strong>-key. Click the "<strong>Filter!</strong>" button when you are ready.</p>
+
+    <p class="filter final">
+      <label for="o3" class="order">Order by:</label>
+      <select class="edit order" size="1" name="o" id="o3">
+        <option>Name</option>
+        <option>Date</option>
+        <option>Length</option>
+      </select>
+      <input type="submit" value="Filter!">
+    </p>
+
+    <p class="quicklinks">
+      <label class="quicklinks">Most recent</label>
+      $(output=''
+        tac ${_DATA}/meta/recent |while [ "$(echo "$output" |wc -l)" -lt 10 ] && read line; do
+          line="<a href="$line">$line</a>"
+          echo "$output" |grep -qF "$line" || output="$output$line\n"
+        done
+        echo $output
+      )
+    </p>
+  </form>
+
+
+  <form action="?action=multitag&${page_this}" method="post" accept-charset="UTF-8">
+    <ul id="thumblist">
+      $(thumblist)
+    </ul>
+    $(tagger)
+  </form>
+EOF
+
+# vi:set filetype=html: