From 563bd9812b0eb73ae4e49de012e0f67ed836faaf Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 28 Apr 2015 19:02:44 +0000 Subject: [PATCH] split up in distinct pages svn path=/trunk/; revision=46 --- actions/watch.sh | 2 +- constants.sh | 2 +- pages/{videoview.sh => common.sh} | 59 ++----------- .../videoview.html.sh => pages/filter.sh | 31 ++++--- pages/list.sh | 32 +++++++ pages/view.sh | 43 +++++++++ templates/{videoview.css.sh => common.css.sh} | 2 + .../{filterdiag.html.sh => filter.html.sh} | 66 +++++++------- templates/list.html.sh | 87 +++++++++++++++++++ templates/tagger.html.sh | 46 ---------- templates/view.html.sh | 67 ++++++++++++-- 11 files changed, 285 insertions(+), 152 deletions(-) rename pages/{videoview.sh => common.sh} (78%) rename templates/videoview.html.sh => pages/filter.sh (62%) create mode 100755 pages/list.sh create mode 100755 pages/view.sh rename templates/{videoview.css.sh => common.css.sh} (98%) rename templates/{filterdiag.html.sh => filter.html.sh} (73%) create mode 100755 templates/list.html.sh delete mode 100755 templates/tagger.html.sh diff --git a/actions/watch.sh b/actions/watch.sh index 65bfecd..8b0ee46 100755 --- a/actions/watch.sh +++ b/actions/watch.sh @@ -14,4 +14,4 @@ watch_link='' [ -n "$filter" ] && watch_link="${watch_link}f=${filter}&" [ -n "$page" ] && watch_link="${watch_link}p=${page}" -echo -n "Location: ?${watch_link}\n\n" +echo -n "Location: ?page=view&${watch_link}\n\n" diff --git a/constants.sh b/constants.sh index 98dc1de..36c85bc 100755 --- a/constants.sh +++ b/constants.sh @@ -18,6 +18,6 @@ # along with Serve0. If not, see . alias _wiki="stx2any --no-template --link-abbrevs --quote -T html" -_GET["page"]=videoview +[ -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)$' diff --git a/pages/videoview.sh b/pages/common.sh similarity index 78% rename from pages/videoview.sh rename to pages/common.sh index 913b15b..aad9769 100755 --- a/pages/videoview.sh +++ b/pages/common.sh @@ -1,6 +1,6 @@ #!/bin/zsh -# Copyright 2014 Paul Hänsch +# Copyright 2014, 2015 Paul Hänsch # # This file is part of Serve0. # @@ -17,7 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with Serve0. If not, see . -info="$_GET[\"i\"]" filter="$_GET[\"f\"]" search="$_GET[\"s\"]" order=$(echo -E "$_GET[\"o\"]" |egrep '^(Name|Date|Length)$') @@ -33,68 +32,40 @@ page_prev="${page_link}p=$([ "$page" = 0 ] && echo 0 || echo $(($page - 1)) )" page_next="${page_link}p=$(($page + 1))" page_this="${page_link}p=$page" - taglist=$( [ -r ${_DATA}/cache/taglist ] && cat ${_DATA}/cache/taglist ||\ for each in ${_DATA}/meta/*.meta; do sed -n '2s:|:\n:gp' "$each" done |sort -u |grep -xv '' |tee ${_DATA}/cache/taglist ) - -filterdiag() { - . ${_EXEC}/templates/filterdiag.html.sh -} - -tagger() { - n=foot - hideall="$(sed -rn "s;^([^:]+):.*$;hide_inline('${n}_\\1')\\;;p" <<<"$taglist" |sort -u)hide_inline('${n}_none');" - - . ${_EXEC}/templates/tagger.html.sh -} - -view() { - if [ -n "$info" ]; then - meta="${_DATA}/meta/$info.meta" - video="${_DATA}/videos/$info" - #reenc="${_DATA}/vp8/$(sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:\1:' <<<"$info" )" - #[ -f "$reenc.mp4" ] && reenc="$reenc.mp4" || reenc="$reenc.mkv" - tags="$(sed -n '2p' "$meta")" - description="$(sed -n '3,$p' "$meta")" - length=0; width=0; height=0; - eval $(mplayer -noconsolecontrols -input file=/dev/null -slave -really-quiet -identify -frames 0 -ao null -vo null "$video" 2>/dev/null\ - | sed -rn 's:ID_VIDEO_WIDTH=(.*):width=\1:p;s:ID_VIDEO_HEIGHT=(.*):height=\1:p;s:ID_LENGTH=(.*)(\..*)$:length=\1:p;') - - video="videos/$info" - . ${_EXEC}/templates/view.html.sh - fi -} _printVideo(){ info="$1" cache="${_DATA}/cache/$info.cache" - video="${_DATA}/videos/$info" meta="${_DATA}/meta/$info.meta" + if [ "$cache" -nt "$meta" ]; then cat "$cache" else - tags="$(sed -n 2p "$meta")" + videofile="${_DATA}/videos/$info" thumb="${_DATA}/thumbs/$info.jpg" + [ -r "$meta" ] || ${_EXEC}/helpers/genmeta.sh "$videofile" "$meta" + [ -r "$thumb" ] || ${_EXEC}/helpers/genthumb.sh "$videofile" "$thumb" + head -n1 "$meta" |read length width height filename [ -z "$length" ] && length=0 - [ -z "$width" ] && width=0 + [ -z "$width" ] && width=0 [ -z "$height" ] && height=0 - [ -r "$meta" ] || ". ${_EXEC}/helpers/genmeta.sh" "$video" "$meta" - [ -r "$thumb" ] || ". ${_EXEC}/helpers/genthumb.sh" "$video" "$thumb" + tags="$(sed -n 2p "$meta")" video="$(urlsave "videos/$info")" thumb="$(urlsave "thumbs/$info.jpg")" + linkinfo="$(urlsave "$info")" [ "$(($length % 60))" -lt 10 ] &&\ minutes="$(($length / 60)):0$(($length % 60))" ||\ minutes="$(($length / 60)):$(($length % 60))" - linkinfo="$(urlsave "$info")" - rpiaddr="$(host pfostenpanne |sed -r 's;^.* ([0-9\.]+)$;\1;')" rpidull="http://${rpiaddr}/?path=http://jupiter:8000/${video}" rpicgi="http://${rpiaddr}/?path=$(urlsave "http://jupiter:8000/?action=transcode&i=${linkinfo}&t=480")" @@ -168,15 +139,3 @@ thumblist() { _printVideo "$line" done } - -case "$1" in - title) - echo "Videos" - ;; - css) - . ${_EXEC}/templates/videoview.css.sh - ;; - body) - . ${_EXEC}/templates/videoview.html.sh - ;; -esac diff --git a/templates/videoview.html.sh b/pages/filter.sh similarity index 62% rename from templates/videoview.html.sh rename to pages/filter.sh index 5d50119..629a08f 100755 --- a/templates/videoview.html.sh +++ b/pages/filter.sh @@ -1,6 +1,8 @@ -# Copyright 2014 Paul Hänsch +#!/bin/zsh + +# Copyright 2014, 2015 Paul Hänsch # -# This file is part of Serve0 +# 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 @@ -13,17 +15,18 @@ # 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 . +# along with Serve0. If not, see . -cat < -
    - $(thumblist) -
- $(tagger) - -EOF +. $_EXEC/pages/common.sh -# vi:set filetype=html: +case "$1" in + title) + echo "Videos" + ;; + css) + . ${_EXEC}/templates/common.css.sh + ;; + body) + . ${_EXEC}/templates/filter.html.sh + ;; +esac diff --git a/pages/list.sh b/pages/list.sh new file mode 100755 index 0000000..34b4339 --- /dev/null +++ b/pages/list.sh @@ -0,0 +1,32 @@ +#!/bin/zsh + +# Copyright 2014, 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 . + +. $_EXEC/pages/common.sh + +case "$1" in + title) + echo "Videos" + ;; + css) + . ${_EXEC}/templates/common.css.sh + ;; + body) + . ${_EXEC}/templates/list.html.sh + ;; +esac diff --git a/pages/view.sh b/pages/view.sh new file mode 100755 index 0000000..8bbd434 --- /dev/null +++ b/pages/view.sh @@ -0,0 +1,43 @@ +#!/bin/zsh + +# Copyright 2014, 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 . + +. $_EXEC/pages/common.sh + +info="$_GET[\"i\"]" + +meta="${_DATA}/meta/$info.meta" +video="${_DATA}/videos/$info" +tags="$(sed -n '2p' "$meta")" +description="$(sed -n '3,$p' "$meta")" +length=0; width=0; height=0; +eval $(mplayer -noconsolecontrols -input file=/dev/null -slave -really-quiet -identify -frames 0 -ao null -vo null "$video" 2>/dev/null\ +| sed -rn 's:ID_VIDEO_WIDTH=(.*):width=\1:p;s:ID_VIDEO_HEIGHT=(.*):height=\1:p;s:ID_LENGTH=(.*)(\..*)$:length=\1:p;') +video="videos/$info" + +case "$1" in + title) + echo "Videos" + ;; + css) + . ${_EXEC}/templates/common.css.sh + ;; + body) + . ${_EXEC}/templates/view.html.sh + ;; +esac diff --git a/templates/videoview.css.sh b/templates/common.css.sh similarity index 98% rename from templates/videoview.css.sh rename to templates/common.css.sh index cb45dc2..0c3d51a 100755 --- a/templates/videoview.css.sh +++ b/templates/common.css.sh @@ -101,6 +101,7 @@ a.clearsearch, a.advanced, a.tagger, .pagination_nav { } #thumblist { + width: 100%; padding: .5em 0 3em 0; text-align: center; } @@ -134,6 +135,7 @@ a.clearsearch, a.advanced, a.tagger, .pagination_nav { .footer { position: fixed; + min-height: 2em; bottom: 0px; border-style: solid none none none; } diff --git a/templates/filterdiag.html.sh b/templates/filter.html.sh similarity index 73% rename from templates/filterdiag.html.sh rename to templates/filter.html.sh index ec2dee5..70ee4b4 100755 --- a/templates/filterdiag.html.sh +++ b/templates/filter.html.sh @@ -1,30 +1,22 @@ -#!/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 . -cat < - - - - - - - Clear All - Advanced - -
- - << - $(($page + 1)) - >> -
- - -