- if e ~= '.' then
- local estat = luci.fs.stat( file .. "/" .. e )
-
- if estat.type == "directory" then
- html = html .. string.format(
- '<li><p><a href="%s/%s/">%s/</a> ' ..
- '<small>(directory)</small><br />' ..
- '<small>Changed: %s</small></li>',
- ruri, e, e,
- self.date.to_http( estat.mtime )
- )
- else
- html = html .. string.format(
- '<li><p><a href="%s/%s">%s</a> ' ..
- '<small>(%s)</small><br />' ..
- '<small>Size: %i Bytes | Changed: %s</small></li>',
- ruri, e, e, self.mime.to_mime( e ),
- estat.size, self.date.to_http( estat.mtime )
- )
+ if type(entries) == "table" then
+ for i, e in luci.util.spairs(
+ entries, function(a,b)
+ if entries[a] == '..' then
+ return true
+ elseif entries[b] == '..' then
+ return false
+ else
+ return ( entries[a] < entries[b] )
+ end
+ end
+ ) do
+ if e ~= '.' and ( e == '..' or e:sub(1,1) ~= '.' ) then
+ local estat = luci.fs.stat( file .. "/" .. e )
+
+ if estat.type == "directory" then
+ html = html .. string.format(
+ '<li><p><a href="%s/%s/">%s/</a> ' ..
+ '<small>(directory)</small><br />' ..
+ '<small>Changed: %s</small></li>',
+ ruri, self.proto.urlencode( e ), e,
+ self.date.to_http( estat.mtime )
+ )
+ else
+ html = html .. string.format(
+ '<li><p><a href="%s/%s">%s</a> ' ..
+ '<small>(%s)</small><br />' ..
+ '<small>Size: %i Bytes | ' ..
+ 'Changed: %s</small></li>',
+ ruri, self.proto.urlencode( e ), e,
+ self.mime.to_mime( e ),
+ estat.size, self.date.to_http( estat.mtime )
+ )
+ end