summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc/view/cbi/filebrowser.htm
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2014-12-03 15:17:05 +0100
committerJo-Philipp Wich <jow@openwrt.org>2015-01-08 16:26:20 +0100
commit1bb4822dca6113f73e3bc89e2acf15935e6f8e92 (patch)
tree35e16f100466e4e00657199b38bb3d87d52bf73f /modules/luci-base/luasrc/view/cbi/filebrowser.htm
parent9edd0e46c3f880727738ce8ca6ff1c8b85f99ef4 (diff)
Rework LuCI build system
* Rename subdirectories to their repective OpenWrt package names * Make each LuCI module its own standalone package * Deploy a shared luci.mk which is used by each module Makefile Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'modules/luci-base/luasrc/view/cbi/filebrowser.htm')
-rw-r--r--modules/luci-base/luasrc/view/cbi/filebrowser.htm108
1 files changed, 108 insertions, 0 deletions
diff --git a/modules/luci-base/luasrc/view/cbi/filebrowser.htm b/modules/luci-base/luasrc/view/cbi/filebrowser.htm
new file mode 100644
index 0000000000..a79beebba7
--- /dev/null
+++ b/modules/luci-base/luasrc/view/cbi/filebrowser.htm
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Filebrowser - LuCI</title>
+ <style type="text/css">
+ #path, #listing {
+ font-size: 85%;
+ }
+
+ ul {
+ padding-left: 0;
+ list-style-type: none;
+ }
+
+ li img {
+ vertical-align: bottom;
+ margin-right: 0.2em;
+ }
+ </style>
+
+ <script type="text/javascript">
+ function callback(path) {
+ if( window.opener ) {
+ var input = window.opener.document.getElementById('<%=luci.http.formvalue('field')%>');
+ if( input ) {
+ input.value = path;
+ window.close();
+ }
+ }
+ }
+ </script>
+</head>
+<body>
+ <%
+ require("nixio.fs")
+ require("nixio.util")
+ require("luci.http")
+ require("luci.dispatcher")
+
+ local field = luci.http.formvalue('field')
+ local request = luci.dispatcher.context.args
+ local path = { '' }
+
+ for i = 1, #request do
+ if request[i] ~= '..' and #request[i] > 0 then
+ path[#path+1] = request[i]
+ end
+ end
+
+ local filepath = table.concat( path, '/' )
+ local filestat = nixio.fs.stat( filepath )
+ local baseurl = luci.dispatcher.build_url('admin', 'filebrowser')
+
+ if filestat and filestat.type == "reg" then
+ table.remove( path, #path )
+ filepath = table.concat( path, '/' ) .. '/'
+ elseif not ( filestat and filestat.type == "dir" ) then
+ path = { '' }
+ filepath = '/'
+ else
+ filepath = filepath .. '/'
+ end
+
+ local entries = nixio.util.consume((nixio.fs.dir(filepath)))
+ -%>
+ <div id="path">
+ Location:
+ <% for i, dir in ipairs(path) do %>
+ <% if i == 1 then %>
+ <a href="<%=baseurl%>?field=<%=field%>">(root)</a>
+ <% elseif next(path, i) then %>
+ <% baseurl = baseurl .. '/' .. dir %>
+ / <a href="<%=baseurl%>?field=<%=field%>"><%=dir%></a>
+ <% else %>
+ <% baseurl = baseurl .. '/' .. dir %>
+ / <%=dir%>
+ <% end %>
+ <% end %>
+ </div>
+
+ <hr />
+
+ <div id="listing">
+ <ul>
+ <% for _, e in luci.util.vspairs(entries) do
+ local stat = nixio.fs.stat(filepath..e)
+ if stat and stat.type == 'dir' then
+ -%>
+ <li class="dir">
+ <img src="<%=resource%>/cbi/folder.gif" alt="<%:Directory%>" />
+ <a href="<%=baseurl%>/<%=e%>?field=<%=field%>"><%=e%>/</a>
+ </li>
+ <% end end -%>
+
+ <% for _, e in luci.util.vspairs(entries) do
+ local stat = nixio.fs.stat(filepath..e)
+ if stat and stat.type ~= 'dir' then
+ -%>
+ <li class="file">
+ <img src="<%=resource%>/cbi/file.gif" alt="<%:File%>" />
+ <a href="#" onclick="callback('<%=filepath..e%>')"><%=e%></a>
+ </li>
+ <% end end -%>
+ </ul>
+ </div>
+</body>
+</html>