From e5b81fd75226b70136264addc95e30cecffce444 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Tue, 24 Jun 2008 15:25:39 +0000 Subject: Updated tinydns as follows: Renames status to view and basicstatus to status. Added ability to view individual config file / domain. Added link from view to edit actual line. Modified view. Updated jQuery to latest 1.2.6 git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@1253 ab2d0c66-481e-0410-8bed-d214d4d58bed --- tinydns-basicstatus-html.lsp | 16 ----- tinydns-config-html.lsp | 2 +- tinydns-controller.lua | 9 ++- tinydns-edit-html.lsp | 45 ++++++++------ tinydns-listfiles-html.lsp | 15 ++--- tinydns-model.lua | 73 ++++++++++++---------- tinydns-status-html.lsp | 134 ++++------------------------------------ tinydns-view-html.lsp | 144 +++++++++++++++++++++++++++++++++++++++++++ tinydns.menu | 3 +- tinydns.roles | 2 +- 10 files changed, 234 insertions(+), 209 deletions(-) delete mode 100644 tinydns-basicstatus-html.lsp create mode 100644 tinydns-view-html.lsp diff --git a/tinydns-basicstatus-html.lsp b/tinydns-basicstatus-html.lsp deleted file mode 100644 index d0eae68..0000000 --- a/tinydns-basicstatus-html.lsp +++ /dev/null @@ -1,16 +0,0 @@ - - - - -

SYSTEM INFO

-
- -
diff --git a/tinydns-config-html.lsp b/tinydns-config-html.lsp index 4c56ea3..1119a50 100755 --- a/tinydns-config-html.lsp +++ b/tinydns-config-html.lsp @@ -10,7 +10,7 @@ io.write("") ?>

CONFIGURATION

diff --git a/tinydns-controller.lua b/tinydns-controller.lua index b0f4272..c97bca2 100644 --- a/tinydns-controller.lua +++ b/tinydns-controller.lua @@ -1,4 +1,5 @@ module(..., package.seeall) +require("validator") -- ################################################################################ -- LOCAL FUNCTIONS @@ -8,12 +9,12 @@ module(..., package.seeall) default_action = "status" -function basicstatus(self) +function status(self) return self.model.getstatus(self) end -function status(self) - return self.model.getconfigobjects(self) +function view(self) + return self.model.getconfigobjects(self.clientdata.filename) end function startstop(self) @@ -107,6 +108,8 @@ function edit(self) config = self.model.get_filedetails(self.clientdata.filename) config.descr = "Saved file" end + elseif validator.is_integer(self.clientdata.linenumber) then + config.value.filecontent.linenumber = self.clientdata.linenumber end config.type = "form" diff --git a/tinydns-edit-html.lsp b/tinydns-edit-html.lsp index 6a19c65..95b2fa0 100644 --- a/tinydns-edit-html.lsp +++ b/tinydns-edit-html.lsp @@ -16,21 +16,19 @@ this.descriptions[0]=descr0;this.descriptions[1]=descr1;this.descriptions[2]=descr2;this.descriptions[3]=descr3;this.descriptions[4]=descr4;this.descriptions[5]=descr5;this.descriptions[6]=descr6;this.descriptions[7]=descr7;this.descriptions[8]=descr8;this.descriptions[9]=descr9;this.descriptions[10]=descr10; } - var entryTypes = new Array(14); - entryTypes[0]=new Entry("","Empty line",0); - entryTypes[1]=new Entry(";","Comment line",1,"Comment"); - entryTypes[2]=new Entry("#","Comment line",1,"Comment"); - entryTypes[3]=new Entry(".","Name server",6,"Domain","IP address","Name server","Time to live","Timestamp","Location"); - entryTypes[4]=new Entry("&","Delegate subdomain",6,"Domain","IP address","Name server","Time to live","Timestamp","Location"); - entryTypes[5]=new Entry("=","Host",5,"Host","IP address","Time to live","Timestamp","Location"); - entryTypes[6]=new Entry("+","Alias",5,"Alias","IP address","Time to live","Timestamp","Location"); - entryTypes[7]=new Entry("@","Mail exchanger",7,"Domain","IP address","Mail exchanger","Distance","Time to live","Timestamp","Location"); - entryTypes[8]=new Entry("'","Text record",5,"Domain","Text Record","Time to live","Timestamp","Location"); - entryTypes[9]=new Entry("^","Reverse record",5,"PTR","Domain name","Time to live","Timestamp","Location"); - entryTypes[10]=new Entry("C","Canonical name",5,"Domain","Canonical name","Time to live","Timestamp","Location"); - entryTypes[11]=new Entry("Z","SOA record",11,"Domain","Primary name server","Contact address","Serial number","Refresh time","Retry time","Expire time","Minimum time","Time to live","Timestamp","Location"); - entryTypes[12]=new Entry(":","Generic record",6,"Domain","Record type","Record data","Time to live","Timestamp","Location"); - entryTypes[13]=new Entry("%","Client location",2,"Location","IP prefix"); + var entryTypes = new Array(12); + entryTypes[0]=new Entry("","Comment line",1,"Comment"); + entryTypes[1]=new Entry(".","Name server",6,"Domain","IP address","Name server","Time to live","Timestamp","Location"); + entryTypes[2]=new Entry("&","Delegate subdomain",6,"Domain","IP address","Name server","Time to live","Timestamp","Location"); + entryTypes[3]=new Entry("=","Host",5,"Host","IP address","Time to live","Timestamp","Location"); + entryTypes[4]=new Entry("+","Alias",5,"Alias","IP address","Time to live","Timestamp","Location"); + entryTypes[5]=new Entry("@","Mail exchanger",7,"Domain","IP address","Mail exchanger","Distance","Time to live","Timestamp","Location"); + entryTypes[6]=new Entry("'","Text record",5,"Domain","Text Record","Time to live","Timestamp","Location"); + entryTypes[7]=new Entry("^","Reverse record",5,"PTR","Domain name","Time to live","Timestamp","Location"); + entryTypes[8]=new Entry("C","Canonical name",5,"Domain","Canonical name","Time to live","Timestamp","Location"); + entryTypes[9]=new Entry("Z","SOA record",11,"Domain","Primary name server","Contact address","Serial number","Refresh time","Retry time","Expire time","Minimum time","Time to live","Timestamp","Location"); + entryTypes[10]=new Entry(":","Generic record",6,"Domain","Record type","Record data","Time to live","Timestamp","Location"); + entryTypes[11]=new Entry("%","Client location",2,"Location","IP prefix"); function finishForm(entry){ var entrytext = entry.find("select").val() + entry.find("input").map(function(){ @@ -44,17 +42,23 @@ var form = '
"; - entrytext = entrytext.substring(1,entrytext.length) + "::::::::::"; - var entries = entrytext.split(":"); + var entries; + if (entryType.entryType == ""){ + entries = new Array(1); + entries[0] = entrytext; + } else { + entrytext = entrytext.substring(1,entrytext.length) + "::::::::::"; + entries = entrytext.split(":"); + } for (i=0; i' + entryType.descriptions[i] + '
'; @@ -110,6 +114,9 @@ $(function(){ addLinks($("#entries").find("tr")); $("input.submit").click(submitFile); + + $("#entries tr:eq()").find("a:eq(2)").click().parent().next().focus(); + }); diff --git a/tinydns-listfiles-html.lsp b/tinydns-listfiles-html.lsp index f61ce25..c2407e2 100644 --- a/tinydns-listfiles-html.lsp +++ b/tinydns-listfiles-html.lsp @@ -9,12 +9,8 @@ io.write("") --]] ?> - -

CONFIGURATION

-

Edit/View existing config files

+

Edit/View existing Domains

@@ -26,8 +22,9 @@ end ?> @@ -38,12 +35,8 @@ end ?> -

Create new config file

+

Create new Domain

- - diff --git a/tinydns-model.lua b/tinydns-model.lua index e75f937..43bf8ea 100644 --- a/tinydns-model.lua +++ b/tinydns-model.lua @@ -89,7 +89,7 @@ local function split_config_items(orgitem) local output = {} output = format.string_to_table(string.sub(orgitem,2),delimiter) output.type = string.sub(orgitem,1,1) - output.label = descr['prefix'][output.type] or "unknown" + output.label = descr['prefix'][output.type] return output end @@ -199,42 +199,47 @@ end -- If you enter 'filter_type' (this should be one of the options found in local function check_signs() ) then -- the output will be filtered to only contain this type of data. -function getconfigobjects(self, filter_type) +function getconfigobjects(file_name, filter_type) local configobjects = {} --Loop through all available configfiles for i,filename in pairs(configfiles) do - local filecontent, fileresult - fileresult, filecontent = get_value_from_file(filename) - for j,configline in pairs(filecontent) do - local domaindetails = {} - local filecontent_table = split_config_items(configline) - filecontent_table.configline = configline - - -- Use only configs that has a valid prefix - -- If function is called with some filter options... then show only the filtered values - if ( not (filter_type) or ((filter_type) and (filter_type == filecontent_table.type)) ) - and (filecontent_table.label) - then - local entry = {} - for i,value in ipairs(filecontent_table) do - entry[i] = value + if not file_name or file_name == filename then + local filecontent = fs.read_file_as_array(filename) + for linenumber,configline in ipairs(filecontent) do + local domaindetails = {} + local filecontent_table = split_config_items(configline) + filecontent_table.configline = configline + + -- Use only configs that has a valid prefix + -- If function is called with some filter options... then show only the filtered values + if ( not (filter_type) or ((filter_type) and (filter_type == filecontent_table.type)) ) + and (filecontent_table.label) + then + local entry = {} + for i,value in ipairs(filecontent_table) do + entry[i] = value + end + -- add in the filename and line number + entry.filename = filename + entry.linenumber = linenumber + + -- we're gonna add a reverse domain name to make it easier to sort + local domain = {} + for mt in string.gmatch(entry[1], "([^.]+)") do + table.insert(domain, mt) + end + local reversedomain = {} + for i=#domain,1,-1 do + table.insert(reversedomain, domain[i]) + end + entry.sort = table.concat(reversedomain, ".") + + -- add it to the table + if not configobjects[filecontent_table.type] then + configobjects[filecontent_table.type] = {label=filecontent_table.label, fieldlabels=descr.fieldlabels[filecontent_table.type]} + end + table.insert(configobjects[filecontent_table.type], entry) end - -- we're gonna add a reverse domain name to make it easier to sort - local domain = {} - for mt in string.gmatch(entry[1], "([^.]+)") do - table.insert(domain, mt) - end - local reversedomain = {} - for i=#domain,1,-1 do - table.insert(reversedomain, domain[i]) - end - entry.sort = table.concat(reversedomain, ".") - - -- add it to the table - if not configobjects[filecontent_table.type] then - configobjects[filecontent_table.type] = {label=filecontent_table.label, fieldlabels=descr.fieldlabels[filecontent_table.type]} - end - table.insert(configobjects[filecontent_table.type], entry) end end end @@ -261,7 +266,7 @@ function getconfigobjects(self, filter_type) end end - return configobjects + return cfe({ type="structure", value=configobjects, label="DNS Entries", filename=file_name }) end function getfilelist () diff --git a/tinydns-status-html.lsp b/tinydns-status-html.lsp index ca0ddf4..d0eae68 100644 --- a/tinydns-status-html.lsp +++ b/tinydns-status-html.lsp @@ -1,128 +1,16 @@ - - - - - -DEBUGGING

DEBUG INFO: CFE

") -io.write(html.cfe_unpack(view)) -io.write("
") ---]] -?> - - + + + -

PROGRAM SPECIFIC OPTIONS/INFORMATION

-

Locations

+

SYSTEM INFO

- > - -
- - - -

-

") ?>

- -
- -
- -\n") - end - for j=1,starting do - io.write("
  • ") - io.write(table.concat(newentry, ".", #newentry-(i+j-2), #newentry)) - io.write("\n") - end - return revnewentry -end +displayitem(data.value.status) +displayitem(data.value.version) +displayitem(data.value.autostart) +displayitem(data.value.configdir) +displayitem(data.value.listen) ?> - -

    Records

    -
    Filter: -
    - -
    -
      - -

      • -
Action
+ - +
- - - - -
:
- -

") ?>

- - - - -
diff --git a/tinydns-view-html.lsp b/tinydns-view-html.lsp new file mode 100644 index 0000000..8ec8b9e --- /dev/null +++ b/tinydns-view-html.lsp @@ -0,0 +1,144 @@ + + + + + +DEBUGGING

DEBUG INFO: CFE

") +io.write(html.cfe_unpack(view)) +io.write("
") +--]] +?> + +

DNS Entries + +

+

Locations

+
+ + > + +
    + +
+ +
  • +
      + +
    • + +

      ") ?>

      +
    • + +
    + + +
    + + No locations defined + +
    + +\n") + end + for j=1,starting do + io.write("