3 [ -n "$include_widgets" ] && return 0
6 . "$_EXEC/cgilite/storage.sh"
9 w_refuri="$(URL "$PATH_INFO")?$(HTML "$QUERY_STRING")"
11 w_str_s="$(STRING "$SEARCH")"
12 w_str_f="$(STRING "$FILTER")"
14 c_tags="$_DATA/.index/tags.cache"; c_tagcategories="$_DATA/.index/tagcategories.cache"
15 if [ ! -s "$c_tags" -o ! -s "$c_tagcategories" ] \
16 || [ "$(find "$_DATA/" -path '*/.index/meta' -newer "$c_tags")" ]
20 s;^.*\ttags=([^\t]*)\t.*$;\1;;
23 | sort |uniq -c |sort -rn |sed -E 's;^ *[0-9]+ ;;;' \
25 | sed -E 's;
\;;\n;g; s;\n+;\n;g;'
27 w_tagcategories="$(printf %s "$w_tags" | sed -rn '/:/s;^-?([^:]+):.*$;\1;p' |sort -u )"
28 printf %s "$w_tags" >"$c_tags"
29 printf %s "$w_tagcategories" >"$c_tagcategories"
31 w_tags="$(cat "$c_tags")"
32 w_tagcategories="$(cat "$c_tagcategories")"
36 [ "$ORDER" = Name ] && w_coname=checked
37 [ "$ORDER" = Date ] && w_codate=checked
38 [ "$ORDER" = Length ] && w_colength=checked
39 [ "$ORDER" = Group ] && w_cogroup=checked
43 [ "$w_bmname" ] || w_bmname="$(
44 bm="$_DATA/.index/bookmarks"
45 name="$(grep -m1 -aF " search=${w_str_s} filter=${w_str_f}${CR}" "$bm" 2>&-)"
48 printf '%s' "$name" |cut -f1 |UNSTRING |HTML
50 printf '%s\t%s' "$SEARCH" "$FILTER" \
51 | sed -r '/^\t$/{ s;\t;All;; q;}
54 :x; s;(^|[~^|])([^|^~:]+):;\1;; tx;
55 s;\^; and ;g; s;\|;,;g; s;~;not ;g; q;}' \
59 printf '%s' "$w_bmname"
63 local bm="$_DATA/.index/bookmarks" name='' search='' filter=''
64 [ ! -d "${bm%/*}" ] && return 0
65 [ ! -f "$bm" ] && touch "$bm"
67 grep -qaF " search=$w_str_s filter=${w_str_f}${CR}" "$bm" && name=Update || name=Add
70 [form #bookmarks action=?a=bookmark method=POST
72 [hidden "ref" "${w_refuri}"]
73 [hidden "search" "$(HTML "$SEARCH")"][hidden "filter" "$(HTML "$FILTER")"]
74 [label Name for current page:]
75 [input name="name" value="$(w_bmname)" placeholder="Name" ]
76 [button type="submit" . ${name}]
78 [ "$name" ] && printf ' [submit "delete" "delete" Delete]'
80 sort "$bm" |while read -r name search filter; do
81 search="${search#search=}" filter="${filter#filter=}" filter="${filter%${CR}}"
82 [ "$search" = "${w_str_s}" -a "$filter" = "${w_str_f}" ] && continue
84 name="$(UNSTRING "$name")";
85 search="$(UNSTRING "${search}" |URL)";
86 filter="$(UNSTRING "${filter}" |URL)";
88 [label .link . $(HTML "$name" |sed 's;,\;;&[wbr];g;')]
89 [a .link target=blank href="/?o=Name&s=${search}&f=${filter}" by Name]
90 [a .link target=blank href="/?o=Date&s=${search}&f=${filter}" by Date]
91 [a .link target=blank href="/?o=Length&s=${search}&f=${filter}" by Length]
92 [a .link target=blank href="/?o=Group&s=${search}&f=${filter}" by Group]
100 [form #search method=GET action=./?
101 [select name=o size=1
102 [option disabled=disabled Order By]
103 [option value=Name ${w_coname} Name]
104 [option value=Date ${w_codate} Date]
105 [option value=Length ${w_colength} Length]
106 [option value=Group ${w_cogroup} Group]
108 [input name=s placeholder=Search value="$(HTML "$SEARCH")"]
109 [a #t_avsearch href="#advsearch" Advanced]
117 tm=''; [ "$(COOKIE mode)" = index ] && tm=' '
118 tf=''; [ "$(COOKIE fakemp4)" = yes ] && tf=checked
119 td=''; [ "$(COOKIE downscale)" = yes ] && td=checked
122 [form #prefs method="POST" action="?a=setprefs"
124 [hidden "ref" "${w_refuri}"]
125 [label for=prefs_ps Pagesize]
126 [input #prefs_ps type=number name=pagesize value="${LISTSIZE}"][br]
127 [radio "mode" "browse" ${tm:-checked=checked} #prefs_modebrowse] [label for=prefs_modebrowse Browse Folders][br]
128 [radio "mode" "index" ${tm:+checked=checked} #prefs_modeindex ] [label for=prefs_modeindex View Full Index][br]
129 [checkbox "fakemp4" "yes" ${tf} #prefs_fmp4] [label for=prefs_fmp4 Fake .MP4 file type][br]
130 [checkbox "downscale" "yes" ${td} #prefs_downscale] [label for=prefs_downscale Prefer downscale to 480p][br]
131 [submit "index" "update" Force Index Update][br]
132 [submit "store" "store" Set Cookie]
139 [form #index method="POST" action="?a=spawnindex"
140 [hidden "ref" "${w_refuri}"]
141 [label Set up for Index view: ]
142 [checkbox "recursive" "yes" #spawn_recursive] [label for=spawn_recursive Include subdirectories]
143 [submit "spawn" "spawn" Set up]
150 local n lbid tag category filter f t d
151 filter="$(HTML "${FILTER}^")"
154 [form #advsearch action=./?a=advsearch method=POST
156 [p .help Refine the search further by setting additional search tags using the [strong "+and"] button.]
159 for n in 1 2 3 4 5 6 7 8 9 10; do
160 f="${filter%%^*}"; filter="${filter#*^}"
162 t=''; [ "$f" -a ! "${f%%~*}" ] && t=" "
164 lbid="cat_${n}_(none)"
166 [input .and type=checkbox name=and id="and_${n}" ${f:+checked=checked}][label for="and_${n}" +and
168 [radio "pol_${n}" "pos" .pol ${t:-checked=checked} #pol_pos_${n}"][label for=pol_pos_${n} Any]
169 [radio "pol_${n}" "neg" .pol ${t:+checked=checked} #pol_neg_${n}"][label for=pol_neg_${n} None]
170 [label .head Category:]
174 printf '*\n%s\n$\n' "$w_tagcategories" \
175 | while read -r category; do
176 lbid="cat_${n}_${category}"
179 [ "$category" = '*' -a "${f%%|${category}:*}" ] && t=checked
180 [ "$category" != '*' -a ! "${f%%|${category}:*}" ] && t=checked
181 [ "$category" != '*' -a ! "${f%%|-${category}:*}" ] && t=checked
183 printf '[radio "cat_%i" "%s" .cat %s id="%s"][label for="%s" %s]
185 $n "$category" "$t" "$lbid" "$lbid" "$category"
187 printf '%s\n' "$w_tags" \
188 | { [ "$category" = '*' ] && grep -avF ':' || grep -awF "${category}"; } \
189 | { sed -u 10q; sort; } \
190 | while read -r tag; do
191 [ "$tag" ] || continue
192 t=''; [ ! "${f%%*|${tag}|*}" ] && t=checked
193 d="${tag#-}"; d="${d#*:}"
194 printf '[label [checkbox "tag_%s" "%s" %s] %s]' "$n" "$tag" "$t" "$d"
196 d="${f##*\$:}" d="${d%%\|*}"
197 [ "$category" = \$ ] && printf '[input name="tag_%i" value="%s"]' "$n" "$(HTML "$d")"
204 [fieldset .submit [select name=order
205 [option disabled=disabled Order By]
206 [option value=Name ${w_coname} Name]
207 [option value=Date ${w_codate} Date]
208 [option value=Length ${w_colength} Length]
209 [option value=Group ${w_cogroup} Group]
210 ][button type=submit Apply Filter]]
216 printf '[a href="#multitag" Add Tags / Remove Tags]
217 [div #multitag [input type="hidden" name="ref" value="%s"]
219 [fieldset [legend New:]
220 [submit "op" "filedelete" Delete Files]
228 [a href="#multitag" Add Tags / Remove Tags]
229 [div #multitag [input type="hidden" name="ref" value="${w_refuri}"]
233 printf 'Tags\n%s\n' "$w_tagcategories" \
234 | while read -r category; do
235 [ "$category" ] || continue
236 printf '[fieldset [legend %s:][div .tagselect\n' "$category"
237 printf %s "$w_tags" \
238 | { [ "$category" = 'Tags' ] && grep -avF ':' || grep -awF "${category}"; } \
239 | { sed -u 10q; sort; } \
240 | while read -r tag; do
241 [ "$tag" ] || continue
242 d="${tag#-}"; d="${d#*:}"
243 printf '[label [checkbox "tag" "%s"] %s]\n' "$tag" "$d"
249 [fieldset [legend New:][textarea name=newtag\n]
250 [label [checkbox "makegroup" "true"] Join selected into group]
251 [submit "op" "del" Remove Tags][submit "op" "add" Add Tags]