diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | dansguardian-category-html.lsp | 23 | ||||
-rw-r--r-- | dansguardian-controller.lua | 2 | ||||
-rw-r--r-- | dansguardian-model.lua | 17 |
4 files changed, 37 insertions, 6 deletions
@@ -5,6 +5,7 @@ VERSION=0.1 APP_DIST=dansguardian-controller.lua \ dansguardian-model.lua \ dansguardian-general-html.lsp \ + dansguardian-category-html.lsp \ dansguardian-advanced-html.lsp \ dansguardian-edit-html.lsp \ dansguardian-plain-html.lsp \ diff --git a/dansguardian-category-html.lsp b/dansguardian-category-html.lsp index 32ef877..bbe1a20 100644 --- a/dansguardian-category-html.lsp +++ b/dansguardian-category-html.lsp @@ -44,16 +44,29 @@ until you restart the service.</p> <h1>Categories</h1> <p><pre class=error><? io.write( service.cfgerr ) ?></pre></p> -<h2>Delete Category</h2> +<h2>Add Category</h2> +<p> +To add a category, or to add a file to an existing category, please fill in the corresponding information below. +(Due to a limitation with DansGuardian, all categories must be lowercase.) +</p> +<dl><dt>Category name</dt><dd><input type="text" name="newcat" value=""></dd></dl> +<dl><dt>Category files</dt><dd><input type="checkbox" name="cattype" value="w">weighted <input type="checkbox" name="cattype" value="b">banned <input type="checkbox" name="cattype" value="e">exception</dd></dl> +<dl><dt>Action</dt><dd><input class="submit" type="submit" name="cmd" value="add"></dd></dl> +<p></p> +<h2>Delete Category</h2> +<p> +Select the categories you wish to delete. Please note that this deletes the category, but does not +delete the link in the corresponding phraselist above. You will also need to edit the phraselist file +above if you delete a category. +</p> <form action="" method="POST"> -<table> +<dl><dt>Categories available</dt><dd>(please check the ones you want to delete)</dd></dl> <? for k,v in ipairs( config ) do - io.write( "<tr><td><input type=\"checkbox\" name=\"cats\" value=\"" .. v .. "\"> " .. v .. "</td></tr>\n" ) + io.write( "<dl><dt></dt><dd><input type=\"checkbox\" name=\"cats\" value=\"" .. v .. "\"> " .. v .. "</dd></dl>\n" ) end ?> -<tr><td><input class="submit" type="submit" name="cmd" value="delete"></td></tr> -</table> +<dl><dt>Action</dt><dd><input class="submit" type="submit" name="cmd" value="delete"></dd></dl> </form> diff --git a/dansguardian-controller.lua b/dansguardian-controller.lua index 0d6c7e8..8160131 100644 --- a/dansguardian-controller.lua +++ b/dansguardian-controller.lua @@ -169,7 +169,7 @@ category = function( self ) extra = "" } - local service = { message="", status="", config="" } + local service = { message="", status="", config="", cfgerr="" } service.config = self.model.get_categories() diff --git a/dansguardian-model.lua b/dansguardian-model.lua index 1abec68..63694e2 100644 --- a/dansguardian-model.lua +++ b/dansguardian-model.lua @@ -352,3 +352,20 @@ is_valid_configfile = function( name ) return retval end +get_categories = function() + + local retval = {} + local entries = posix.dir( "/etc/dansguardian/phraselists" ) + local k = "" + local v = "" + + for k,v in ipairs( entries ) do + local attrs = posix.stat( "/etc/dansguardian/phraselists/" .. v ) + if attrs.type == "directory" and v ~= "." and v ~= ".." then + table.insert( retval, v ) + end + end + + return retval +end + |