diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-07-17 13:37:55 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-07-17 13:37:55 +0000 |
commit | c8a55ba7d09fa091ff64a79b9a8347b6d3191da6 (patch) | |
tree | 9f42770bf8ba2129fcf2537221d2c88566adf0a0 /tinydns-model.lua | |
parent | d6eaceb7368639a4d634b06b2e1f09498c81e1e4 (diff) | |
download | acf-tinydns-c8a55ba7d09fa091ff64a79b9a8347b6d3191da6.tar.bz2 acf-tinydns-c8a55ba7d09fa091ff64a79b9a8347b6d3191da6.tar.xz |
Modifed tinydns view to combine all record types, except for locations, and display together.
git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@1313 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'tinydns-model.lua')
-rw-r--r-- | tinydns-model.lua | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/tinydns-model.lua b/tinydns-model.lua index 193af6e..7a0f411 100644 --- a/tinydns-model.lua +++ b/tinydns-model.lua @@ -187,58 +187,45 @@ function getconfigobjects(file_name, filter_type) 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 - + filecontent_table.filename = filename + filecontent_table.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 + for mt in string.gmatch(filecontent_table[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, ".") + filecontent_table.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) + table.insert(configobjects, filecontent_table) end end end end - -- Sort each of the tables by domain name (entry 1) - for type,entries in pairs(configobjects) do - table.sort(entries, function(a,b) + -- Sort the table by domain name (entry 1) + table.sort(configobjects, function(a,b) if a == b then - return false; + return false elseif a.sort ~= b.sort then return a.sort < b.sort - end - for i in ipairs(a) do - if a[i] ~= b[i] then - return a[i] < b[i] - end + elseif a.configline ~= b.configline then + return a.configline < b.configline end a.errtxt = "Duplicate entry" b.errtxt = "Duplicate entry" return false end) - for i,entry in ipairs(entries) do - entry.sort = nil - end + for i,entry in ipairs(configobjects) do + entry.sort = nil end - return cfe({ type="structure", value=configobjects, label="DNS Entries", filename=file_name }) + return cfe({ type="structure", value=configobjects, label="DNS Entries", filename=file_name, fieldlabels=descr.fieldlabels }) end function getfilelist () |