diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-06-24 15:25:39 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-06-24 15:25:39 +0000 |
commit | e5b81fd75226b70136264addc95e30cecffce444 (patch) | |
tree | cc724394d5202125af7340a256fd5f201af6f6e3 /tinydns-model.lua | |
parent | bc4c53f27f100f3f0280d4d8d5c2d02e4bc3cfd0 (diff) | |
download | acf-tinydns-e5b81fd75226b70136264addc95e30cecffce444.tar.bz2 acf-tinydns-e5b81fd75226b70136264addc95e30cecffce444.tar.xz |
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
Diffstat (limited to 'tinydns-model.lua')
-rw-r--r-- | tinydns-model.lua | 73 |
1 files changed, 39 insertions, 34 deletions
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 () |