3 [ -n "$include_widgets" ] && return 0
6 . "$_EXEC/cgilite/storage.sh"
8 w_refuri="$(URL "$PATH_INFO")?$(HTML "$QUERY_STRING")"
10 w_str_s="$(STRING "$SEARCH")"
11 w_str_f="$(STRING "$FILTER")"
14 s-0-0-g; s-1-1-g; s-2-2-g; s-3-3-g; s-4-4-g; s-5-5-g;
15 s-6-6-g; s-7-7-g; s-8-8-g; s-9-9-g;
16 s-A-A-g; s-B-B-g; s-C-C-g; s-D-D-g; s-E-E-g; s-F-F-g;
17 s-G-G-g; s-H-H-g; s-I-I-g; s-J-J-g; s-K-K-g; s-L-L-g;
18 s-M-M-g; s-N-N-g; s-O-O-g; s-P-P-g; s-Q-Q-g; s-R-R-g;
19 s-S-S-g; s-T-T-g; s-U-U-g; s-V-V-g; s-W-W-g; s-X-X-g;
20 s-Y-Y-g; s-Z-Z-g;
21 s-a-a-g; s-b-b-g; s-c-c-g; s-d-d-g; s-e-e-g; s-f-f-g;
22 s-g-g-g; s-h-h-g; s-i-i-g; s-j-j-g; s-k-k-g; s-l-l-g;
23 s-m-m-g; s-n-n-g; s-o-o-g; s-p-p-g; s-q-q-g; s-r-r-g;
24 s-s-s-g; s-t-t-g; s-u-u-g; s-v-v-g; s-w-w-g; s-x-x-g;
25 s-y-y-g; s-z-z-g;
26 s---\--g; s-/-/-g; s-/-/-g; s-:-:-g; s-=-=-g; s-@-@-g;
27 s-_-_-g; s-~-~-g; s- - -g; s-^-^-g; s-|-|-g;
30 w_tags="$_DATA/.index/tags.cache"; w_tagcategories="$_DATA/.index/tagcategories.cache"
31 if [ ! -f "$w_tags" -o ! -f "$w_tagcategories" ] \
32 || [ "$(find "$_DATA/" -path '*/.index/meta' -newer "$w_tags")" ]
34 w_tags="$( { local cn=1
35 find "$_DATA/" -path '*/.index/meta' -print0 \
37 s;^.*\t.*\t.*\ttags=(.*)\tcomment=.*\t.*\r$;\1;;
38 s;,;\n;g;'"$UNSTRING" \
39 | { sort; printf '\n'; } \
40 | while read -r tag; do
41 [ "$tag" = "$otag" ] \
44 printf "%i %s\n" "$cn" "$otag"
49 } |sort -rn |cut -f2- |HTML |sed "$w_ascii s- -\n-g; s;\n\n;\n;g;" |tee "$w_tags" )"
50 w_tagcategories="$(printf %s "$w_tags" \
51 | sed -rn '/:/s;^-?([^:]+):.*$;\1;p' |sort -u \
52 | tee "$w_tagcategories" )"
54 w_tags="$(cat "$w_tags")"
55 w_tagcategories="$(cat "$w_tagcategories")"
59 [ "$ORDER" = Name ] && w_coname=checked
60 [ "$ORDER" = Date ] && w_codate=checked
61 [ "$ORDER" = Length ] && w_colength=checked
62 [ "$ORDER" = Group ] && w_cogroup=checked
66 [ "$w_bmname" ] || w_bmname="$(
67 bm="$_DATA/.index/bookmarks"
68 name="$(grep -m1 -aF " search=${w_str_s} filter=${w_str_f}${CR}" "$bm" 2>&-)"
71 printf '%s' "$name" |cut -f1 |UNSTRING |HTML
73 printf '%s\t%s' "$SEARCH" "$FILTER" \
74 | sed -r '/^\t$/{ s;\t;All;; q;}
77 :x; s;(^|[~^|])([^|^~:]+):;\1;; tx;
78 s;\^; and ;g; s;\|;,;g; s;~;not ;g; q;}' \
82 printf '%s' "$w_bmname"
86 local bm="$_DATA/.index/bookmarks" name='' search='' filter=''
87 [ ! -d "${bm%/*}" ] && return 0
88 [ ! -f "$bm" ] && touch "$bm"
90 grep -qaF " search=$w_str_s filter=${w_str_f}${CR}" "$bm" && name=Update || name=Add
92 printf '[form #bookmarks action=?a=bookmark method=POST
95 [hidden "search" "%s"][hidden "filter" "%s"]
96 [label Name for current page:]
97 [input name="name" value="%s" placeholder="Name" ]
98 [button type="submit" %s]' \
100 "$(HTML "$SEARCH")" "$(HTML "$FILTER")" \
101 "$(w_bmname)" "${name}"
102 [ "$name" ] && printf ' [submit "delete" "delete" Delete]'
104 sort "$bm" |while read -r name search filter; do
105 search="${search#search=}" filter="${filter#filter=}" filter="${filter%${CR}}"
106 [ "$search" = "${w_str_s}" -a "$filter" = "${w_str_f}" ] && continue
108 name="$(UNSTRING "$name")";
109 search="$(UNSTRING "${search}" |URL)";
110 filter="$(UNSTRING "${filter}" |URL)";
111 printf '[label .link %s]
112 [a .link target=blank href="/?o=Name&s=%s&f=%s" by Name]
113 [a .link target=blank href="/?o=Date&s=%s&f=%s" by Date]
114 [a .link target=blank href="/?o=Length&s=%s&f=%s" by Length]
115 [a .link target=blank href="/?o=Group&s=%s&f=%s" by Group]
117 "$(HTML "$name" |sed 's;,\;;&[wbr];g;')" \
118 "$search" "$filter" \
119 "$search" "$filter" \
120 "$search" "$filter" \
128 [form #search method=GET action=./?
129 [select name=o size=1
130 [option disabled=disabled Order By]
131 [option value=Name %s Name]
132 [option value=Date %s Date]
133 [option value=Length %s Length]
134 [option value=Group %s Group]
136 [input name=s placeholder=Search value="%s"]
139 "$w_coname" "$w_codate" "$w_colength" "$w_cogroup" \
146 tm=''; [ "$(COOKIE mode)" = index ] && tm=' '
147 tf=''; [ "$(COOKIE fakemp4)" = yes ] && tf=checked
148 td=''; [ "$(COOKIE downscale)" = yes ] && td=checked
151 [form #prefs method="POST" action="?a=setprefs"
154 [label for=prefs_ps Pagesize]
155 [input #prefs_ps type=number name=pagesize value="%s"][br]
156 [radio "mode" "browse" %s #prefs_modebrowse] [label for=prefs_modebrowse Browse Folders][br]
157 [radio "mode" "index" %s #prefs_modeindex ] [label for=prefs_modeindex View Full Index][br]
158 [checkbox "fakemp4" "yes" %s #prefs_fmp4] [label for=prefs_fmp4 Fake .MP4 file type][br]
159 [checkbox "downscale" "yes" %s #prefs_downscale] [label for=prefs_downscale Prefer downscale to 480p][br]
160 [submit "index" "update" Force Index Update][br]
161 [submit "store" "store" Set Cookie]
164 "$w_refuri" "$LISTSIZE" \
165 "${tm:-checked}" "${tm:+checked}" "$tf" "$td"
170 [form #index method="POST" action="?a=spawnindex"
172 [label Set up for Index view: ]
173 [checkbox "recursive" "yes" #spawn_recursive] [label for=spawn_recursive Include subdirectories]
174 [submit "spawn" "spawn" Set up]
181 local n lbid tag category filter f t d
182 filter="$(HTML "${FILTER}^" |sed "$w_ascii")"
184 printf '[form #advsearch action=?a=advsearch method=POST
186 [p .help Select multiple tags from each category by holding down the [strong Ctrl] key on your keyboard.[br]
187 Refine the search further by setting additional search tags using the [strong "+and"] button.]'
189 for n in 1 2 3 4 5 6 7 8 9 10; do
190 f="${filter%%^*}"; filter="${filter#*^}"
192 t=''; [ "$f" -a ! "${f%%~*}" ] && t=" "
194 lbid="cat_${n}_(none)"
195 printf '[input .and type=checkbox name=and id="and_%i" %s][label for="and_%i" +and
197 [radio "pol_%i" "pos" .pol %s #pol_pos_%i"][label for=pol_pos_%i Any]
198 [radio "pol_%i" "neg" .pol %s #pol_neg_%i"][label for=pol_neg_%i None]
199 [label .head Category:]' \
200 $n "${f:+checked}" $n \
201 $n "${t:-checked}" $n $n \
202 $n "${t:+checked}" $n $n
205 printf '*\n%s\n' "$w_tagcategories" \
206 | while read -r category; do
207 lbid="cat_${n}_${category}"
210 [ "$category" = '*' -a "${f%%|${category}:*}" ] && t=checked
211 [ "$category" != '*' -a ! "${f%%|${category}:*}" ] && t=checked
212 [ "$category" != '*' -a ! "${f%%|-${category}:*}" ] && t=checked
214 printf '[radio "cat_%i" "%s" .cat %s id="%s"][label for="%s" %s]
215 [select name=tag_%s size=10 multiple' \
216 $n "$category" "$t" "$lbid" "$lbid" "$category" $n
218 printf '%s\n' "$w_tags" \
219 | { [ "$category" = '*' ] && grep -avF ':' || grep -awF "${category}"; } \
220 | { for n in 1 2 3 4 5 6 7 8 9 0; do
221 read -r line && printf '%s\n' "$line" || break;
222 done; # pass 10 lines through without modification
223 sort; # and sort remaining lines
224 } | while read -r tag; do
225 [ "$tag" ] || continue
226 t=''; [ ! "${f%%*|${tag}|*}" ] && t=checked
227 d="${tag#-}"; d="${d#*:}"
228 printf '[option %s value="%s"\n%s]' "$t" "$tag" "$d"
235 printf '[fieldset .submit [select name=order
236 [option disabled=disabled Order By]
237 [option value=Name %s Name]
238 [option value=Date %s Date]
239 [option value=Length %s Length]
240 [option value=Group %s Group]
241 ][button type=submit Apply Filter]]
243 "$w_coname" "$w_codate" \
244 "$w_colength" "$w_cogroup"
248 printf '[a href="#multitag" Add Tags / Remove Tags]
249 [div #multitag [input type="hidden" name="ref" value="%s"]
250 [a href="#" Hide][br]
251 [fieldset [legend New:]
252 [submit "op" "filedelete" Delete Files]
258 printf '[a href="#multitag" Add Tags / Remove Tags]
259 [div #multitag [input type="hidden" name="ref" value="%s"]' "$w_refuri"
260 printf '[a href="#" Hide][br]'
262 printf 'Tags\n%s\n' "$w_tagcategories" \
263 | while read -r category; do
264 [ "$category" ] || continue
265 printf '[fieldset [legend %s:][select name=tag size=4 multiple\n' "$category"
266 printf %s "$w_tags" \
267 | { [ "$category" = 'Tags' ] && grep -avF ':' || grep -awF "${category}"; } \
268 | { for n in 1 2 3 4 5 6 7 8 9 0; do
269 read -r line && printf '%s\n' "$line" || break
272 } | while read -r tag; do
273 [ "$tag" ] || continue
274 d="${tag#-}"; d="${d#*:}"
275 printf '[option value="%s"\n%s]' "$tag" "$d"
280 printf '[fieldset [legend New:][textarea name=newtag\n]
281 [submit "op" "del" Remove Tags][submit "op" "add" Add Tags]