diff options
author | Mika Havela <mika.havela@gmail.com> | 2007-11-29 17:20:56 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2007-11-29 17:20:56 +0000 |
commit | 8203efff3c9cf291d78e27fc6d744740aca6b543 (patch) | |
tree | 6efb65db5a9d26b51038f49b66fe5911262451ab | |
parent | 8dd8ee0316f52886e0b1f6bc083eb5531ec28dc0 (diff) | |
download | acf-alpine-baselayout-8203efff3c9cf291d78e27fc6d744740aca6b543.tar.bz2 acf-alpine-baselayout-8203efff3c9cf291d78e27fc6d744740aca6b543.tar.xz |
Sorting logfiles. Small modifications so that header is not inside the table of listed files.v2.0_alpha2
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@387 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | logfiles-controller.lua | 7 | ||||
-rw-r--r-- | logfiles-delete-html.lsp | 2 | ||||
-rw-r--r-- | logfiles-model.lua | 14 | ||||
-rw-r--r-- | logfiles-read-html.lsp | 15 |
5 files changed, 23 insertions, 17 deletions
@@ -1,6 +1,6 @@ APP_NAME=alpine-baselayout PACKAGE=acf-$(APP_NAME) -VERSION=2.0_alpha1 +VERSION=2.0_alpha2 APP_DIST=hostname-controller.lua \ hostname-html.lsp \ diff --git a/logfiles-controller.lua b/logfiles-controller.lua index b6f81d7..1a5ca30 100644 --- a/logfiles-controller.lua +++ b/logfiles-controller.lua @@ -24,7 +24,12 @@ end delete = function (self) local filetodelete = self.clientdata.name or "" - return ({deletedfile = self.model:delete(filetodelete)} ) + local me = ({deletestatus = self.model:delete(filetodelete)}) + if (me.deletestatus.errtxt) then + return me + else + list_redir(self) + end end view = function (self) diff --git a/logfiles-delete-html.lsp b/logfiles-delete-html.lsp index eb7cf88..018b6f0 100644 --- a/logfiles-delete-html.lsp +++ b/logfiles-delete-html.lsp @@ -2,6 +2,6 @@ <html> <body> <h1>Deleted file</h1> -<?= view.deletedfile.value ?> <p class="error"><?= view.deletedfile.errtxt ?></p> +<p class="error"><?= view.deletestatus.errtxt ?></p> </body> </html> diff --git a/logfiles-model.lua b/logfiles-model.lua index 39a3e4f..e0e0888 100644 --- a/logfiles-model.lua +++ b/logfiles-model.lua @@ -46,9 +46,7 @@ end -- Function to list available files for view/delete local function list_files ( ... ) - -- Create a header for the view and create variables - local listed_files = { cfe{inuse="Delete", save="Save", view="View", - size="Size", lastmod="Last Modified", name="File"} } + local listed_files = {} local open_files = {} local files = {} local k,v @@ -60,15 +58,17 @@ local function list_files ( ... ) for k,v in pairs(files) do -- Get info on this specific file and put it in a table local lastmod,size,fileinuseresult,fileinuseurl = file_info(v) - table.insert ( listed_files , cfe{inuse=fileinuseresult, del=fileinuseurl, save="/download?name=" .. v, view="/view?name=" .. v, size=size, lastmod=lastmod, name=v, type="", id=k} ) + table.insert ( listed_files , cfe{inuse=fileinuseresult, del=fileinuseurl, save="/download?name=" .. v, + view="/view?name=" .. v, size=size, lastmod=lastmod, name=v, type="", id=k} ) end + table.sort(listed_files, function (a,b) return (a.name < b.name) end ) return listed_files end -- Function to check if a file is deletable, and if it is, then delete it. local function checkfilefordelete ( filetodelete ) local deletedfile = {} - deletedfile = cfe{value=nil, type="text", option=nil, errtxt="File '" .. filetodelete .. "' has not been deleted!"} + deletedfile = {value=nil, type="text", option=nil, errtxt="File '" .. filetodelete .. "' has not been deleted!"} -- Get a list of files that could be deleted local available_files = get() for k,v in pairs(available_files) do @@ -77,9 +77,9 @@ local function checkfilefordelete ( filetodelete ) if ( available_files[k].del ) then local status, err = os.remove( filetodelete ) if not ( err ) then - deletedfile = cfe{value="File '" .. filetodelete .. "' has been successfully deleted!", type="text", option=nil, errtxt=err} + deletedfile = {value="File '" .. filetodelete .. "' has been successfully deleted!", type="text"} else - deletedfile = cfe{value=nil, type="text", option=nil, errtxt=err} + deletedfile = {value=nil, type="text", option=nil, errtxt=err} end else end diff --git a/logfiles-read-html.lsp b/logfiles-read-html.lsp index 9616b91..5c020e4 100644 --- a/logfiles-read-html.lsp +++ b/logfiles-read-html.lsp @@ -2,17 +2,18 @@ <html> <body> <h1>Available Logfiles</h1> + <TABLE border=0> <TR style="background:#eee;font-weight:bold;"> - <TD "width=55px"><?= view.logfile[1].inuse ?></TD> - <TD "width=55px"><?= view.logfile[1].view ?></TD> - <TD "width=55px"><?= view.logfile[1].save ?></TD> - <TD "width=55px" align="right"><?= view.logfile[1].size ?></TD> - <TD align="right" "width=90px"><?= view.logfile[1].lastmod ?></TD> - <TD style="padding-left:10px"><?= view.logfile[1].name ?></TD> + <TD "width=55px">Delete</TD> + <TD "width=55px">Save</TD> + <TD "width=55px">View</TD> + <TD "width=55px" align="right">Size</TD> + <TD align="right" "width=90px">Last Modified</TD> + <TD style="padding-left:10px">File</TD> </TR> -<? for i = 2, table.maxn(view.logfile) do ?> +<? for i = 1, table.maxn(view.logfile) do ?> <TR > <TD> <? if view.logfile[i].del then ?> |