]> git.plutz.net Git - serve0/blob - actions/meta.sh
styling for pagination links
[serve0] / actions / meta.sh
1 #!/bin/zsh
2 # Copyright 2014 - 2016 Paul Hänsch
3 #
4 # This file is part of Serve0
5 #
6 # Serve0 is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Serve0 is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU Affero General Public License for more details.
15 #
16 # You should have received a copy of the GNU Affero General Public License
17 # along with Serve0  If not, see <http://www.gnu.org/licenses/>.
18
19 cgi_refdata
20
21   info="${_GET[i]:-$_REF[i]}"
22  order="${_GET[o]}"
23 search="${_GET[s]}"
24 filter="${_GET[f]}"
25   page="${_GET[pn]}"
26 file="${_DATA}/meta/$info.meta"
27
28 length="${_POST[length]}"
29  width="${_POST[width]}"
30 height="${_POST[height]}"
31  trash="${_POST[trash]}"
32 cancel="${_POST[cancel]}"
33 tagacc="${_POST[tag]}"
34 tags="$(htmlsafe "${_POST[tags]}" |sed -r 's:\t: :g;s:^!|[\r\$\^\|]::g;' |tr '\n' '|')"
35 description="$(htmlsafe "${_POST[description]}")"
36
37 n=0; while [ -n "${_POST[tag$n]}" ]; do
38   tagacc="$(htmlsafe ${_POST[tag$n]} |sed -r '2,$d;s:\t| :_:g;s:^!|\r|\$|\^::g;')|$tagacc"
39   n=$(($n + 1))
40 done
41
42 [ -z "$cancel" -a -n "$info" ] && if [ -n "$trash" ]; then
43   rm "${_DATA}/thumbs/$info.jpg" 2>/dev/null
44   mv "${_DATA}/videos/$info" "${_DATA}/meta/$info.meta" "${_DATA}/trash/" 2>/dev/null
45   rm "${_DATA}/cache/$info.cache" 2>/dev/null
46   rm ${_DATA}/cache/\?* 2>/dev/null
47 else
48   cat >$file <<EOF
49 ${length}       ${width}        ${height}       ${info}
50 ${tagacc}|${tags}
51 ${description}
52 EOF
53   rm "${_DATA}/cache/$info.cache" 2>/dev/null
54   rm ${_DATA}/cache/\?* 2>/dev/null
55   rm ${_DATA}/cache/taglist_set ${_DATA}/cache/taglist_filter 2>/dev/null
56 fi
57
58 redirect "${_POST[referrer]:-?i=&pn=${page}&s=${search}&f=${filter}&o=${order}#${info}}"