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")"
13 c_tags="$_DATA/.index/tags.cache"; c_tagcategories="$_DATA/.index/tagcategories.cache"
14 if [ ! -s "$c_tags" -o ! -s "$c_tagcategories" ] \
15 || [ "$(find "$_DATA/" -path '*/.index/meta' -newer "$c_tags")" ]
19 s;^.*\ttags=([^\t]*)\t.*$;\1;;
22 | sort |uniq -c |sed -E 's;^ *[0-9]+ ;;;' |sort -rn \
24 | sed -E 's;
\;;\n;g; s;\n+;\n;g;'
26 w_tagcategories="$(printf %s "$w_tags" | sed -rn '/:/s;^-?([^:]+):.*$;\1;p' |sort -u )"
27 printf %s "$w_tags" >"$c_tags"
28 printf %s "$w_tagcategories" >"$c_tagcategories"
30 w_tags="$(cat "$c_tags")"
31 w_tagcategories="$(cat "$c_tagcategories")"
35 [ "$ORDER" = Name ] && w_coname=checked
36 [ "$ORDER" = Date ] && w_codate=checked
37 [ "$ORDER" = Length ] && w_colength=checked
38 [ "$ORDER" = Group ] && w_cogroup=checked
42 [ "$w_bmname" ] || w_bmname="$(
43 bm="$_DATA/.index/bookmarks"
44 name="$(grep -m1 -aF " search=${w_str_s} filter=${w_str_f}${CR}" "$bm" 2>&-)"
47 printf '%s' "$name" |cut -f1 |UNSTRING |HTML
49 printf '%s\t%s' "$SEARCH" "$FILTER" \
50 | sed -r '/^\t$/{ s;\t;All;; q;}
53 :x; s;(^|[~^|])([^|^~:]+):;\1;; tx;
54 s;\^; and ;g; s;\|;,;g; s;~;not ;g; q;}' \
58 printf '%s' "$w_bmname"
62 local bm="$_DATA/.index/bookmarks" name='' search='' filter=''
63 [ ! -d "${bm%/*}" ] && return 0
64 [ ! -f "$bm" ] && touch "$bm"
66 grep -qaF " search=$w_str_s filter=${w_str_f}${CR}" "$bm" && name=Update || name=Add
68 printf '[form #bookmarks action=?a=bookmark method=POST
71 [hidden "search" "%s"][hidden "filter" "%s"]
72 [label Name for current page:]
73 [input name="name" value="%s" placeholder="Name" ]
74 [button type="submit" %s]' \
76 "$(HTML "$SEARCH")" "$(HTML "$FILTER")" \
77 "$(w_bmname)" "${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)";
87 printf '[label .link %s]
88 [a .link target=blank href="/?o=Name&s=%s&f=%s" by Name]
89 [a .link target=blank href="/?o=Date&s=%s&f=%s" by Date]
90 [a .link target=blank href="/?o=Length&s=%s&f=%s" by Length]
91 [a .link target=blank href="/?o=Group&s=%s&f=%s" by Group]
93 "$(HTML "$name" |sed 's;,\;;&[wbr];g;')" \
104 [form #search method=GET action=./?
105 [select name=o size=1
106 [option disabled=disabled Order By]
107 [option value=Name %s Name]
108 [option value=Date %s Date]
109 [option value=Length %s Length]
110 [option value=Group %s Group]
112 [input name=s placeholder=Search value="%s"]
113 [a #t_avsearch href="#advsearch" Advanced]
116 "$w_coname" "$w_codate" "$w_colength" "$w_cogroup" \
123 tm=''; [ "$(COOKIE mode)" = index ] && tm=' '
124 tf=''; [ "$(COOKIE fakemp4)" = yes ] && tf=checked
125 td=''; [ "$(COOKIE downscale)" = yes ] && td=checked
128 [form #prefs method="POST" action="?a=setprefs"
131 [label for=prefs_ps Pagesize]
132 [input #prefs_ps type=number name=pagesize value="%s"][br]
133 [radio "mode" "browse" %s #prefs_modebrowse] [label for=prefs_modebrowse Browse Folders][br]
134 [radio "mode" "index" %s #prefs_modeindex ] [label for=prefs_modeindex View Full Index][br]
135 [checkbox "fakemp4" "yes" %s #prefs_fmp4] [label for=prefs_fmp4 Fake .MP4 file type][br]
136 [checkbox "downscale" "yes" %s #prefs_downscale] [label for=prefs_downscale Prefer downscale to 480p][br]
137 [submit "index" "update" Force Index Update][br]
138 [submit "store" "store" Set Cookie]
141 "$w_refuri" "$LISTSIZE" \
142 "${tm:-checked}" "${tm:+checked}" "$tf" "$td"
147 [form #index method="POST" action="?a=spawnindex"
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}^")"
161 printf '[form #advsearch action=./?a=advsearch method=POST
163 [p .help Select multiple tags from each category by holding down the [strong Ctrl] key on your keyboard.
164 Refine the search further by setting additional search tags using the [strong "+and"] button.]'
166 for n in 1 2 3 4 5 6 7 8 9 10; do
167 f="${filter%%^*}"; filter="${filter#*^}"
169 t=''; [ "$f" -a ! "${f%%~*}" ] && t=" "
171 lbid="cat_${n}_(none)"
172 printf '[input .and type=checkbox name=and id="and_%i" %s][label for="and_%i" +and
174 [radio "pol_%i" "pos" .pol %s #pol_pos_%i"][label for=pol_pos_%i Any]
175 [radio "pol_%i" "neg" .pol %s #pol_neg_%i"][label for=pol_neg_%i None]
176 [label .head Category:]' \
177 $n "${f:+checked}" $n \
178 $n "${t:-checked}" $n $n \
179 $n "${t:+checked}" $n $n
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]
192 # [select name=tag_%s size=10 multiple' \
193 # $n "$category" "$t" "$lbid" "$lbid" "$category" $n
194 printf '[radio "cat_%i" "%s" .cat %s id="%s"][label for="%s" %s]
196 $n "$category" "$t" "$lbid" "$lbid" "$category"
198 printf '%s\n' "$w_tags" \
199 | { [ "$category" = '*' ] && grep -avF ':' || grep -awF "${category}"; } \
200 | { for n in 1 2 3 4 5 6 7 8 9 0; do
201 read -r line && printf '%s\n' "$line" || break;
202 done; # pass 10 lines through without modification
203 sort; # and sort remaining lines
204 } | while read -r tag; do
205 [ "$tag" ] || continue
206 t=''; [ ! "${f%%*|${tag}|*}" ] && t=checked
207 d="${tag#-}"; d="${d#*:}"
208 # printf '[option %s value="%s"\n%s]' "$t" "$tag" "$d"
209 printf '[label [checkbox "tag_%s" "%s" %s] %s]' "$n" "$tag" "$t" "$d"
211 d="${f##*\$:}" d="${d%%\|*}"
212 [ "$category" = \$ ] && printf '[input name="tag_%i" value="%s"]' "$n" "$(HTML "$d")"
218 printf '[fieldset .submit [select name=order
219 [option disabled=disabled Order By]
220 [option value=Name %s Name]
221 [option value=Date %s Date]
222 [option value=Length %s Length]
223 [option value=Group %s Group]
224 ][button type=submit Apply Filter]]
226 "$w_coname" "$w_codate" \
227 "$w_colength" "$w_cogroup"
231 printf '[a href="#multitag" Add Tags / Remove Tags]
232 [div #multitag [input type="hidden" name="ref" value="%s"]
234 [fieldset [legend New:]
235 [submit "op" "filedelete" Delete Files]
241 printf '[a href="#multitag" Add Tags / Remove Tags]
242 [div #multitag [input type="hidden" name="ref" value="%s"]' "$w_refuri"
243 printf '[a href="#" X]'
245 printf 'Tags\n%s\n' "$w_tagcategories" \
246 | while read -r category; do
247 [ "$category" ] || continue
248 # printf '[fieldset [legend %s:][select name=tag size=4 multiple\n' "$category"
249 printf '[fieldset [legend %s:][div .tagselect\n' "$category"
250 printf %s "$w_tags" \
251 | { [ "$category" = 'Tags' ] && grep -avF ':' || grep -awF "${category}"; } \
252 | { for n in 1 2 3 4 5 6 7 8 9 0; do
253 read -r line && printf '%s\n' "$line" || break
256 } | while read -r tag; do
257 [ "$tag" ] || continue
258 d="${tag#-}"; d="${d#*:}"
259 # printf '[option value="%s"\n%s]' "$tag" "$d"
260 printf '[label [checkbox "tag" "%s"] %s]\n' "$tag" "$d"
265 printf '[fieldset [legend New:][textarea name=newtag\n]
266 [submit "op" "del" Remove Tags][submit "op" "add" Add Tags]