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")"
16 s;^.*\ttags=([^\t]*)\t.*$;\1;;
19 | sort |uniq -c |sort -rn |sed -E 's;^ *[0-9]+ ;;;' \
21 | sed -E 's;
\;;\n;g; s;\n+;\n;g;'
26 | sed -rn '/:/s;^-?([^:]+):.*$;\1;p' \
30 c_tags="$_DATA/.index/tags.cache";
31 if [ ! -s "$c_tags" ]; then
33 mv "$c_tags.$$" "$c_tags"
35 w_tags="$(cat "$c_tags")"
37 c_tagcategories="$_DATA/.index/tagcategories.cache"
38 if [ ! -s "$c_tagcategories" ]; then
39 tclist "$w_tags" >"$c_tagcategories.$$"
40 mv "$c_tagcategories.$$" "$c_tagcategories"
42 w_tagcategories="$(cat "$c_tagcategories")"
44 [ "$ORDER" = Name ] && w_coname=checked
45 [ "$ORDER" = Date ] && w_codate=checked
46 [ "$ORDER" = Length ] && w_colength=checked
47 [ "$ORDER" = Group ] && w_cogroup=checked
51 [ "$w_bmname" ] || w_bmname="$(
52 bm="$_DATA/.index/bookmarks"
53 name="$(grep -m1 -aF " search=${w_str_s} filter=${w_str_f}${CR}" "$bm" 2>&-)"
56 printf '%s' "$name" |cut -f1 |UNSTRING |HTML
58 printf '%s\t%s' "$SEARCH" "$FILTER" \
59 | sed -r '/^\t$/{ s;\t;All;; q;}
62 :x; s;(^|[~^|])([^|^~:]+):;\1;; tx;
63 s;\^; and ;g; s;\|;,;g; s;~;not ;g; q;}' \
67 printf '%s' "$w_bmname"
71 local bm="$_DATA/.index/bookmarks" name='' search='' filter=''
72 [ ! -d "${bm%/*}" ] && return 0
73 [ ! -f "$bm" ] && touch "$bm"
75 grep -qaF " search=$w_str_s filter=${w_str_f}${CR}" "$bm" && name=Update || name=Add
78 [form #bookmarks action=?a=bookmark method=POST
80 [hidden "ref" "${w_refuri}"]
81 [hidden "search" "$(HTML "$SEARCH")"][hidden "filter" "$(HTML "$FILTER")"]
82 [label Name for current page:]
83 [input name="name" value="$(w_bmname)" placeholder="Name" ]
84 [button type="submit" . ${name}]
86 [ "$name" ] && printf ' [submit "delete" "delete" Delete]'
88 sort "$bm" |while read -r name search filter; do
89 search="${search#search=}" filter="${filter#filter=}" filter="${filter%${CR}}"
90 [ "$search" = "${w_str_s}" -a "$filter" = "${w_str_f}" ] && continue
92 name="$(UNSTRING "$name")";
93 search="$(UNSTRING "${search}" |URL)";
94 filter="$(UNSTRING "${filter}" |URL)";
96 [label .link . $(HTML "$name" |sed 's;,\;;&[wbr];g;')]
97 [a .link target=blank href="/?o=Name&s=${search}&f=${filter}" by Name]
98 [a .link target=blank href="/?o=Date&s=${search}&f=${filter}" by Date]
99 [a .link target=blank href="/?o=Length&s=${search}&f=${filter}" by Length]
100 [a .link target=blank href="/?o=Group&s=${search}&f=${filter}" by Group]
108 [form #search method=GET action=./?
109 [select name=o size=1
110 [option disabled=disabled Order By]
111 [option value=Name ${w_coname} Name]
112 [option value=Date ${w_codate} Date]
113 [option value=Length ${w_colength} Length]
114 [option value=Group ${w_cogroup} Group]
116 [input name=s placeholder=Search value="$(HTML "$SEARCH")"]
117 [a #t_avsearch href="#advsearch" Advanced]
125 tm=''; [ "$(COOKIE mode)" = browse ] && tm=' '
126 tf=''; [ "$(COOKIE fakemp4)" = yes ] && tf=checked
127 td=''; [ "$(COOKIE downscale)" = yes ] && td=checked
130 [form #prefs method="POST" action="?a=setprefs"
132 [hidden "ref" "${w_refuri}"]
133 [label for=prefs_ps Pagesize]
134 [input #prefs_ps type=number name=pagesize value="${LISTSIZE}"][br]
135 [radio "mode" "browse" ${tm:+checked=checked} #prefs_modebrowse] [label for=prefs_modebrowse Browse Folders][br]
136 [radio "mode" "index" ${tm:-checked=checked} #prefs_modeindex ] [label for=prefs_modeindex View Full Index][br]
137 [checkbox "fakemp4" "yes" ${tf} #prefs_fmp4] [label for=prefs_fmp4 Fake .MP4 file type][br]
138 [checkbox "downscale" "yes" ${td} #prefs_downscale] [label for=prefs_downscale Prefer downscale to 480p][br]
139 [submit "index" "update" Force Index Update][br]
140 [submit "store" "store" Set Cookie]
147 [form #index method="POST" action="?a=spawnindex"
148 [hidden "ref" "${w_refuri}"]
149 [label Set up for Index view: ]
150 [checkbox "recursive" "yes" #spawn_recursive] [label for=spawn_recursive Include subdirectories]
151 [submit "spawn" "spawn" Set up]
158 local n lbid tag category filter f t d
159 filter="$(HTML "${FILTER}^")"
162 [form #advsearch action=./?a=advsearch method=POST
164 [p .help Refine the search further by setting additional search tags using the [strong "+and"] button.]
167 for n in 1 2 3 4 5 6 7 8 9 10; do
168 f="${filter%%^*}"; filter="${filter#*^}"
170 t=''; [ "$f" -a ! "${f%%~*}" ] && t=" "
172 lbid="cat_${n}_(none)"
174 [input .and type=checkbox name=and id="and_${n}" ${f:+checked=checked}][label for="and_${n}" +and
176 [radio "pol_${n}" "pos" .pol ${t:-checked=checked} #pol_pos_${n}"][label for=pol_pos_${n} Any]
177 [radio "pol_${n}" "neg" .pol ${t:+checked=checked} #pol_neg_${n}"][label for=pol_neg_${n} None]
178 [label .head Category:]
182 printf '*\n%s\n$\n' "$w_tagcategories" \
183 | while read -r category; do
184 lbid="cat_${n}_${category}"
187 [ "$category" = '*' -a "${f%%|${category}:*}" ] && t=checked
188 [ "$category" != '*' -a ! "${f%%|${category}:*}" ] && t=checked
189 [ "$category" != '*' -a ! "${f%%|-${category}:*}" ] && t=checked
191 printf '[radio "cat_%i" "%s" .cat %s id="%s"][label for="%s" %s]
193 $n "$category" "$t" "$lbid" "$lbid" "$category"
195 printf '%s\n' "$w_tags" \
196 | { [ "$category" = '*' ] && grep -avF ':' || grep -awF "${category}"; } \
197 | { sed -u 10q; sort; } \
198 | while read -r tag; do
199 [ "$tag" ] || continue
200 t=''; [ ! "${f%%*|${tag}|*}" ] && t=checked
201 d="${tag#-}"; d="${d#*:}"
202 printf '[label [checkbox "tag_%s" "%s" %s] %s]' "$n" "$tag" "$t" "$d"
204 d="${f##*\$:}" d="${d%%\|*}"
205 [ "$category" = \$ ] && printf '[input name="tag_%i" value="%s"]' "$n" "$(HTML "$d")"
212 [fieldset .submit [select name=order
213 [option disabled=disabled Order By]
214 [option value=Name ${w_coname} Name]
215 [option value=Date ${w_codate} Date]
216 [option value=Length ${w_colength} Length]
217 [option value=Group ${w_cogroup} Group]
218 ][button type=submit Apply Filter]]
224 printf '[a href="#multitag" Add Tags / Remove Tags]
225 [div #multitag [input type="hidden" name="ref" value="%s"]
227 [fieldset [legend New:]
228 [submit "op" "filedelete" Delete Files]
236 [a href="#multitag" Add Tags / Remove Tags]
237 [div #multitag [input type="hidden" name="ref" value="${w_refuri}"]
241 printf 'Tags\n%s\n' "$w_tagcategories" \
242 | while read -r category; do
243 [ "$category" ] || continue
244 printf '[fieldset [legend %s:][div .tagselect\n' "$category"
245 printf %s "$w_tags" \
246 | { [ "$category" = 'Tags' ] && grep -avF ':' || grep -awF "${category}"; } \
247 | { sed -u 10q; sort; } \
248 | while read -r tag; do
249 [ "$tag" ] || continue
250 d="${tag#-}"; d="${d#*:}"
251 printf '[label [checkbox "tag" "%s"] %s]\n' "$tag" "$d"
257 [fieldset [legend New:][textarea name=newtag\n]
258 [label [checkbox "makegroup" "true"] Join selected into group]
259 [submit "op" "del" Remove Tags][submit "op" "add" Add Tags]