]> git.plutz.net Git - serve0/blob - pages/common.sh
new folder browse section
[serve0] / pages / common.sh
1 #!/bin/zsh
2
3 # Copyright 2014, 2015 Paul Hänsch
4 #
5 # This file is part of Serve0.
6
7 # Serve0 is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11
12 # Serve0 is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU Affero General Public License for more details.
16
17 # You should have received a copy of the GNU Affero General Public License
18 # along with Serve0.  If not, see <http://www.gnu.org/licenses/>. 
19
20 filter="${_GET[f]}"
21 search="${_GET[s]}"
22 order="${_GET[o]}" #validated
23 page="${_GET[pn]}" #validated
24 pagesize="${_COOKIE[pagesize]}" #validated
25
26 page_link=''
27 [ -n "$info" ]   && page_link="i=$(urlsafe "$info")&"
28 [ -n "$order" ]  && page_link="${page_link}o=${order}&"
29 [ -n "$search" ] && page_link="${page_link}s=${search}&"
30 [ -n "$filter" ] && page_link="${page_link}f=${filter}&"
31 page_prev="${page_link}pn=$([ "$page" -le "$pagesize" ] && echo 1 || echo $(($page - $pagesize)) )"
32 page_next="${page_link}pn=$(($page + $pagesize))"
33 page_this="${page_link}pn=$page"
34
35 taglist=$(
36   [ -r ${_DATA}/cache/taglist ] && cat ${_DATA}/cache/taglist ||\
37   for each in ${_DATA}/meta/*.meta; do
38     sed -n '2s:|:\n:gp' "$each"
39   done |sort -u |grep -xv '' |tee ${_DATA}/cache/taglist
40 )
41
42 list_categories(){
43   echo none
44   printf %s "$taglist" |sed -rn 's;^([^:]+):.*$;\1;p' |sort -u
45 }
46
47 genthumb(){
48   videofile="$1"
49   thumb="$2"
50
51   nohup nice -10 "${_EXEC}"/helpers/genthumb.sh "$videofile" "$thumb" >/dev/null 2>/dev/null &
52   #printf '%s\n' "${_EXEC}/helpers/genthumb.sh '$videofile' '$thumb' >/dev/null 2>/dev/null" \
53   #| batch
54 }
55 genmeta(){
56   videofile="$1"
57   meta="$2"
58
59   "${_EXEC}"/helpers/genmeta.sh "$videofile" "$meta" >/dev/null
60 }