diff --git a/CONTROL/control b/CONTROL/control
index ae803f6..1dd2eda 100644
--- a/CONTROL/control
+++ b/CONTROL/control
@@ -1,7 +1,7 @@
Package: webif
Priority: optional
Section: web
-Version: 0.8.5-1
+Version: 0.8.6
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: mongoose(>=3.0-2),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.4-1),jim-oo,jim-pack,service-control,busybox(>=1.19.3-1),lsof,epg(>=1.0.8),hmt(>=1.1.2),ssmtp,anacron
diff --git a/var/mongoose/cgi-bin/browse.jim b/var/mongoose/cgi-bin/browse.jim
index 5785612..9010e10 100755
--- a/var/mongoose/cgi-bin/browse.jim
+++ b/var/mongoose/cgi-bin/browse.jim
@@ -8,6 +8,7 @@ puts "Content-Type: text/html"
puts ""
set nicesplice [system pkginst nicesplice]
+set flatten [system pkginst flatten]
set ignore {.nts .thm .hmt .hmi}
set include {.ts .avi .mpg .mpeg .wmv .mkv .mp3 .mp4 .mov}
@@ -15,8 +16,10 @@ set include {.ts .avi .mpg .mpeg .wmv .mkv .mp3 .mp4 .mov}
cgi_input
#cgi_dump
-#set env(REQUEST_URI) ''
-#set _cgi(dir) "/media/My Video/\[Don't Die Young\]"
+if {![dict exists env REQUEST_URI]} {
+ set env(REQUEST_URI) ''
+ set _cgi(dir) "/media/My Video/"
+}
if {![dict exists $env QUERY_STRING]} { set env(QUERY_STRING) "root" }
@@ -28,6 +31,8 @@ if {$order eq "-"} {
}
proc directory {file bfile} {
+ global flatten
+
regsub -all " +" $bfile "" tbfile
puts "
"
puts "
"
puts "$bfile
"
- puts "
+
+ set noflat 0
+ if $flatten {
+ if {[string match {\[*\]} [file tail $file]]} { set noflat 1 }
+ if {[file exists "$file/.noflatten"]} {
+ set noflat 1
+ }
+
+ if $noflat {
+ puts "
"
+ }
+ }
+
+ puts -nonewline "
-
+ "
+
+ puts "
"
puts "
"
@@ -196,6 +220,13 @@ puts {
diff --git a/var/mongoose/cgi-bin/browse/browse.js b/var/mongoose/cgi-bin/browse/browse.js
index e133dfd..5044b1c 100755
--- a/var/mongoose/cgi-bin/browse/browse.js
+++ b/var/mongoose/cgi-bin/browse/browse.js
@@ -217,6 +217,17 @@ function preparemenu(el, menu)
}
+function preparedmenu(el, menu)
+{
+ if (el.attr('noflat') != undefined)
+ {
+ if (el.attr('noflat') > 0)
+ $(menu).changeContextMenuItem('#flat', 'Allow Flatten');
+ else
+ $(menu).changeContextMenuItem('#flat',
+ 'Prevent Flatten');
+ }
+}
$(document).ready(function() {
@@ -328,6 +339,12 @@ var dmenuclick = function(action, el, pos)
$('#drenameform').dialog('open');
break;
+ case 'flat':
+ var url = '/cgi-bin/browse/flat.jim?file=' +
+ encodeURIComponent(file);
+ $.get(url, function() { window.location.reload(true); });
+ break;
+
default:
alert('Unhandled action: ' + action);
break;
@@ -347,7 +364,8 @@ var dmenuclick = function(action, el, pos)
$('img.dopt').contextMenu(
{
menu: 'doptmenu',
- leftButton: true
+ leftButton: true,
+ beforeShow: preparedmenu
},
dmenuclick
);
diff --git a/var/mongoose/cgi-bin/browse/flat.jim b/var/mongoose/cgi-bin/browse/flat.jim
new file mode 100755
index 0000000..3b83219
--- /dev/null
+++ b/var/mongoose/cgi-bin/browse/flat.jim
@@ -0,0 +1,28 @@
+#!/mod/bin/jimsh
+
+package require cgi
+source /mod/var/mongoose/lib/ts.class
+
+puts "Content-Type: text/html"
+puts ""
+
+cgi_input
+#cgi_dump
+
+set dir [cgi_get file]
+if {![file isdirectory $dir]} { exit }
+set noflat 0
+if {[string match {\[*\]} [file tail $dir]]} {
+ set ndir [string range [file tail $dir] 1 end-1]
+ file rename $dir "[file dirname $dir]/$ndir"
+ puts "Unflagged directory as noflatten."
+ exit
+}
+if {[file exists "$dir/.noflatten"]} {
+ file delete "$dir/.noflatten"
+ puts "Unflagged directory as noflatten."
+} else {
+ close [open "$dir/.noflatten" w]
+ puts "Flagged directory as noflatten."
+}
+
diff --git a/var/mongoose/html/img/flat-tyre.png b/var/mongoose/html/img/flat-tyre.png
new file mode 100644
index 0000000..560fb48
Binary files /dev/null and b/var/mongoose/html/img/flat-tyre.png differ