]> git.plutz.net Git - serve0/blob - actions/meta.sh
added licence headers, coding style improvements
[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 cgi_post
29 length="${_POST[length]}"
30  width="${_POST[width]}"
31 height="${_POST[height]}"
32  trash="${_POST[trash]}"
33 cancel="${_POST[cancel]}"
34 tagacc="${_POST[tag]}"
35 tags="$(htmlsafe "${_POST[tags]}" |sed -r 's:\t| :_:g;s:^!|\r|\$|\^::g;' |tr '\n' '|')"
36 description="$(htmlsafe "${_POST[description]}")"
37
38 n=0; while [ -n "${_POST[tag$n]}" ]; do
39   tagacc="$(htmlsafe ${_POST[tag$n]} |sed -r '2,$d;s:\t| :_:g;s:^!|\r|\$|\^::g;')|$tagacc"
40   n=$(($n + 1))
41 done
42
43 [ -z "$cancel" -a -n "$info" ] && if [ -n "$trash" ]; then
44   rm "${_DATA}/thumbs/$info.jpg" 2>/dev/null
45   mv "${_DATA}/videos/$info" "${_DATA}/meta/$info.meta" "${_DATA}/trash/" 2>/dev/null
46   rm "${_DATA}/cache/$info.cache" 2>/dev/null
47   rm ${_DATA}/cache/\?* 2>/dev/null
48 else
49   cat >$file <<EOF
50 ${length}       ${width}        ${height}       ${info}
51 ${tagacc}|${tags}
52 ${description}
53 EOF
54   rm "${_DATA}/cache/$info.cache" 2>/dev/null
55   rm ${_DATA}/cache/*[0-9]\?* 2>/dev/null
56   rm ${_DATA}/cache/taglist 2>/dev/null
57 fi
58
59 redirect "?i=&pn=${page}&s=${search}&f=${filter}&o=${order}#${info}"