3 [ -n "$include_widgets" ] && return 0
6 . "$_EXEC/cgilite/storage.sh"
8 w_refuri="$(URL "$PATH_INFO")?$(HTML "$QUERY_STRING")"
11 s-0-0-g; s-1-1-g; s-2-2-g; s-3-3-g; s-4-4-g; s-5-5-g;
12 s-6-6-g; s-7-7-g; s-8-8-g; s-9-9-g;
13 s-A-A-g; s-B-B-g; s-C-C-g; s-D-D-g; s-E-E-g; s-F-F-g;
14 s-G-G-g; s-H-H-g; s-I-I-g; s-J-J-g; s-K-K-g; s-L-L-g;
15 s-M-M-g; s-N-N-g; s-O-O-g; s-P-P-g; s-Q-Q-g; s-R-R-g;
16 s-S-S-g; s-T-T-g; s-U-U-g; s-V-V-g; s-W-W-g; s-X-X-g;
17 s-Y-Y-g; s-Z-Z-g;
18 s-a-a-g; s-b-b-g; s-c-c-g; s-d-d-g; s-e-e-g; s-f-f-g;
19 s-g-g-g; s-h-h-g; s-i-i-g; s-j-j-g; s-k-k-g; s-l-l-g;
20 s-m-m-g; s-n-n-g; s-o-o-g; s-p-p-g; s-q-q-g; s-r-r-g;
21 s-s-s-g; s-t-t-g; s-u-u-g; s-v-v-g; s-w-w-g; s-x-x-g;
22 s-y-y-g; s-z-z-g;
23 s---\--g; s-/-/-g; s-/-/-g; s-:-:-g; s-=-=-g; s-@-@-g;
24 s-_-_-g; s-~-~-g; s- - -g; s-^-^-g; s-|-|-g;
27 w_tags="$_DATA/.index/tags.cache"; w_tagcategories="$_DATA/.index/tagcategories.cache"
28 if [ ! -f "$w_tags" -o ! -f "$w_tagcategories" ] \
29 || [ "$(find "$_DATA/" -path '*/.index/meta' -newer "$w_tags")" ]
31 w_tags="$( { local cn=1
32 find "$_DATA/" -path '*/.index/meta' -print0 \
34 s;^.*\t.*\t.*\ttags=(.*)\tcomment=.*\t.*\r$;\1;;
35 s;,;\n;g;'"$UNSTRING" \
36 | { sort; printf '\n'; } \
37 | while read -r tag; do
38 [ "$tag" = "$otag" ] \
41 printf "%i %s\n" "$cn" "$otag"
46 } |sort -rn |cut -f2- |HTML |sed "$w_ascii s- -\n-g; s;\n\n;\n;g;" |tee "$w_tags" )"
47 w_tagcategories="$(printf %s "$w_tags" \
48 | cut -sd: -f1 |sort -u \
49 | tee "$w_tagcategories" )"
51 w_tags="$(cat "$w_tags")"
52 w_tagcategories="$(cat "$w_tagcategories")"
56 [ "$ORDER" = Name ] && w_coname=checked
57 [ "$ORDER" = Date ] && w_codate=checked
58 [ "$ORDER" = Length ] && w_colength=checked
61 local name='' cf='' cs='' bm="$_DATA/.index/bookmarks" proposed_name=''
62 [ ! -d "${bm%/*}" ] && return 0
63 [ ! -f "$bm" ] && touch "$bm"
65 [ "$SEARCH" ] && cs="$(STRING "$SEARCH")"
66 [ "$FILTER" ] && cf="$(STRING "$FILTER")"
68 name="$(grep -m1 -aF " search=$cs filter=$cf${CR}" "$bm" |cut -f1 |UNSTRING)"
69 [ ! "$name" ] && proposed_name="$(
70 printf '%s\t%s' "$SEARCH" "$FILTER" \
71 |sed -r '/^\t$/{ s;\t;All;; q;}
74 :x; s;(^|[~^|])([^|^~:]+):;\1;; tx;
75 s;\^; and ;g; s;\|;,;g; s;~;not ;g; q;}'
78 printf '[form #bookmarks action=?a=bookmark method=POST
81 [hidden "search" "%s"][hidden "filter" "%s"]
82 [label Name for current page:]
83 [input name="name" value="%s" placeholder="Name" ]
84 [button type="submit" %s]' \
86 "$(HTML "$SEARCH")" "$(HTML "$FILTER")" \
87 "$(HTML "${name:-${proposed_name}}")" \
88 "${name:+Update}${proposed_name:+Add}"
89 [ "$name" ] && printf ' [submit "delete" "delete" Delete]'
91 sort "$bm" |while read -r name search filter; do
92 search="${search#search=}" filter="${filter#filter=}" filter="${filter%${CR}}"
93 [ "$search" = "${cs}" -a "$filter" = "${cf}" ] && continue
95 name="$(UNSTRING "$name")";
96 search="$(UNSTRING "${search}" |URL)";
97 filter="$(UNSTRING "${filter}" |URL)";
98 printf '[label .link %s]
99 [a .link target=blank href="?o=Name&s=%s&f=%s" by Name]
100 [a .link target=blank href="?o=Date&s=%s&f=%s" by Date]
101 [a .link target=blank href="?o=Length&s=%s&f=%s" by Length]
103 "$(HTML "$name" |sed 's;,\;;&[wbr];g;')" \
104 "$search" "$filter" \
105 "$search" "$filter" \
113 [form #search method=GET action=?
114 [select name=o size=1
115 [option disabled=disabled Order By]
116 [option value=Name %s Name]
117 [option value=Date %s Date]
118 [option value=Length %s Length]
120 [input name=s placeholder=Search value="%s"]
123 "$w_coname" "$w_codate" "$w_colength" \
130 tm=''; [ "$(COOKIE mode)" = index ] && tm=' '
131 tf=''; [ "$(COOKIE fakemp4)" = yes ] && tf=checked
132 td=''; [ "$(COOKIE downscale)" = yes ] && td=checked
135 [form #prefs method="POST" action="?a=setprefs"
138 [label for=prefs_ps Pagesize]
139 [input #prefs_ps type=number name=pagesize value="%s"][br]
140 [radio "mode" "browse" %s #prefs_modebrowse] [label for=prefs_modebrowse Browse Folders][br]
141 [radio "mode" "index" %s #prefs_modeindex ] [label for=prefs_modeindex View Full Index][br]
142 [checkbox "fakemp4" "yes" %s #prefs_fmp4] [label for=prefs_fmp4 Fake .MP4 file type][br]
143 [checkbox "downscale" "yes" %s #prefs_downscale] [label for=prefs_downscale Prefer downscale to 480p][br]
144 [submit "index" "update" Force Index Update][br]
145 [submit "store" "store" Set Cookie]
148 "$w_refuri" "$LISTSIZE" \
149 "${tm:-checked}" "${tm:+checked}" "$tf" "$td"
154 [form #index method="POST" action="?a=spawnindex"
156 [label Set up for Index view: ]
157 [checkbox "recursive" "yes" #spawn_recursive] [label for=spawn_recursive Include subdirectories]
158 [submit "spawn" "spawn" Set up]
165 local n lbid tag category filter f t
166 filter="$(HTML "${FILTER}^" |sed "$w_ascii")"
168 printf '[form #advsearch action=?a=advsearch method=POST
170 [p .help Select multiple tags from each category by holding down the [strong Ctrl] key on your keyboard.[br]
171 Refine the search further by setting additional search tags using the [strong "+and"] button.]'
173 for n in 1 2 3 4 5 6 7 8 9 10; do
174 f="${filter%%^*}"; filter="${filter#*^}"
176 t=''; [ "$f" -a ! "${f%%~*}" ] && t=" "
178 lbid="cat_${n}_(none)"
179 printf '[input .and type=checkbox name=and id="and_%i" %s][label for="and_%i" +and
181 [radio "pol_%i" "pos" .pol %s #pol_pos_%i"][label for=pol_pos_%i Any]
182 [radio "pol_%i" "neg" .pol %s #pol_neg_%i"][label for=pol_neg_%i None]
183 [label .head Category:]' \
184 $n "${f:+checked}" $n \
185 $n "${t:-checked}" $n $n \
186 $n "${t:+checked}" $n $n
189 printf '*\n%s\n' "$w_tagcategories" \
190 | while read -r category; do
191 lbid="cat_${n}_${category}"
194 [ "$category" = '*' -a "${f%%|${category}:*}" ] && t=checked
195 [ "$category" != '*' -a ! "${f%%|${category}:*}" ] && t=checked
197 printf '[radio "cat_%i" "%s" .cat %s id="%s"][label for="%s" %s]
198 [select name=tag_%s size=10 multiple' \
199 $n "$category" "$t" "$lbid" "$lbid" "$category" $n
201 printf '%s\n' "$w_tags" \
202 | { [ "$category" = '*' ] && grep -avF ':' || grep -awF "${category}"; } \
203 | { for n in 1 2 3 4 5 6 7 8 9 0; do
204 read -r line && printf '%s\n' "$line" || break;
205 done; # path 10 lines through without modification
206 sort; # and sort remaining lines
207 } | while read -r tag; do
208 [ "$tag" ] || continue
209 t=''; [ ! "${f%%*|${tag}|*}" ] && t=checked
210 printf '[option %s value="%s"\n%s]' "$t" "$tag" "${tag#*:}"
217 printf '[fieldset .submit [select name=order
218 [option disabled=disabled Order By]
219 [option value=Name %s Name]
220 [option value=Date %s Date]
221 [option value=Length %s Length]
222 ][button type=submit Apply Filter]]
231 printf '[a href="#multitag" Add Tags / Remove Tags]
232 [div #multitag [input type="hidden" name="ref" value="%s"]' "$w_refuri"
233 printf '[a href="#" Hide][br]'
235 printf 'Tags\n%s\n' "$w_tagcategories" \
236 | while read -r category; do
237 [ "$category" ] || continue
238 printf '[fieldset [legend %s:][select name=tag size=4 multiple\n' "$category"
239 printf %s "$w_tags" \
240 | { [ "$category" = 'Tags' ] && grep -avF ':' || grep -awF "${category}"; } \
241 | { for n in 1 2 3 4 5 6 7 8 9 0; do
242 read -r line && printf '%s\n' "$line" || break
245 } | while read -r tag; do
246 [ "$tag" ] || continue
247 printf '[option value="%s"\n%s]' "$tag" "${tag#*:}"
252 printf '[fieldset [legend New:][textarea name=newtag\n]
253 [submit "op" "del" Remove Tags][submit "op" "add" Add Tags]