+++ /dev/null
-#!/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
+++ /dev/null
-#!/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;'
-}
#!/bin/zsh
-# Copyright 2014 Paul Hänsch
+# Copyright 2014,2015 Paul Hänsch
#
# This file is part of Serve0.
#
[ -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
+++ /dev/null
-#!/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
+++ /dev/null
-#!/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
--- /dev/null
+# 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: