From ec988ea69c7391292777cacdc66f670b513d99f4 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Thu, 8 Oct 2009 16:40:58 +0000 Subject: Fixed bug with adhoc query, display results in a table, example descriptions, bumped to 0.4.7 --- Makefile | 2 +- weblog-adhocquery-html.lsp | 63 +++++++++++++++++++++++++++++++++++----------- weblog-model.lua | 2 +- weblog-status-html.lsp | 6 ++--- 4 files changed, 54 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 9b3333e..476a333 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ APP_NAME=weblog PACKAGE=acf-$(APP_NAME) -VERSION=0.4.6 +VERSION=0.4.7 CRON_FILE=weblogimport diff --git a/weblog-adhocquery-html.lsp b/weblog-adhocquery-html.lsp index e1c79f2..d7aee5c 100644 --- a/weblog-adhocquery-html.lsp +++ b/weblog-adhocquery-html.lsp @@ -2,29 +2,61 @@ require("viewfunctions") %> + + <% if form.value.result then %> -

<%= html.html_escape(form.value.result.label) %>

-
-<% require("html") %> -<%= html.cfe_unpack(form.value.result.value) %> -
- -
Download query result
-
-
+

<%= html.html_escape(form.value.result.label) %>

+ <% if #form.value.result.value == 0 then %> +

No results, try adjusting query

+ <% else %> + + + <% names = {} + for name,val in pairs(form.value.result.value[1]) do + names[#names+1] = name %> + + <% end %> + + <% for i,row in ipairs(form.value.result.value) do + local a,b = math.modf((i/2)) + local mark = '' + if (b == 0) then mark=' class="mark"' end %> + > + <% for j,name in ipairs(names) do %> + + <% end %> + + <% end %> +
<%= html.html_escape(name) %>
<%= html.html_escape(row[name]) %>
+ +
+ +
+
Download query result
+
+
+ <% end %> <% end %>

<%= html.html_escape(form.label) %>

-<% displayformstart(form, page_info) %> -<% displayformitem(form.value.query, "query") %> This form accepts a Postgresql SELECT statement and displays the results. Examples: -The available database tables and descriptions are as follows:
+<% displayformstart(form, page_info) %> +
+<% displayformitem(form.value.query, "query") %> +
<% displayformend(form) %> +
+The available database tables and descriptions are as follows:

PubWeblog and PubBlocklog

These tables contain the combined squid access log and dansguardian log for every access and blocked access respectively. The definition of the table is as follows: @@ -41,6 +73,7 @@ These tables contain the combined squid access log and dansguardian log for ever shortreason text )
+

dbHistLog

This table contains the database history, including such information as which log files were loaded and how many entries they contained. The definition of the table is as follows: @@ -65,6 +98,7 @@ This table contains the list of log file sources. The definition of the table is enabled boolean )
+

Usagestat

This table contains a historical record of pages requested and blocked by hour. The definition of the table is as follows: @@ -76,6 +110,7 @@ This table contains a historical record of pages requested and blocked by hour. numblock integer )
+

Watchlist

This table contains the user watch list. The definition of the table is as follows: diff --git a/weblog-model.lua b/weblog-model.lua index c4d5080..6cd66f5 100644 --- a/weblog-model.lua +++ b/weblog-model.lua @@ -1265,8 +1265,8 @@ function adhocquery(query) result[#result+1] = {} for name,val in pairs(row) do result[#result][name] = val - row = cur:fetch (row, "a") end + row = cur:fetch (row, "a") end -- close everything cur:close() diff --git a/weblog-status-html.lsp b/weblog-status-html.lsp index fae98c0..b1c806b 100644 --- a/weblog-status-html.lsp +++ b/weblog-status-html.lsp @@ -17,15 +17,15 @@ end %> <% if status then %> <%= status.value.status.value %> <% else %> -unknown +Unknown <% end %>
Weblog Database
<% if data.value then %> -present +Present <% else %> -missing +Missing <% if viewlibrary and viewlibrary.dispatch_component then viewlibrary.dispatch_component("createdatabase") end %> -- cgit v1.2.3