summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-07-17 13:37:55 +0000
committerTed Trask <ttrask01@yahoo.com>2008-07-17 13:37:55 +0000
commitc8a55ba7d09fa091ff64a79b9a8347b6d3191da6 (patch)
tree9f42770bf8ba2129fcf2537221d2c88566adf0a0
parentd6eaceb7368639a4d634b06b2e1f09498c81e1e4 (diff)
downloadacf-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
-rw-r--r--tinydns-model.lua41
-rw-r--r--tinydns-view-html.lsp86
2 files changed, 57 insertions, 70 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 ()
diff --git a/tinydns-view-html.lsp b/tinydns-view-html.lsp
index 8ec8b9e..354b199 100644
--- a/tinydns-view-html.lsp
+++ b/tinydns-view-html.lsp
@@ -19,6 +19,10 @@ require("viewfunctions")
});
}
}
+ function toggleEntry(){
+ $(this).find("table").toggle();
+ $(this).find("pre").toggle();
+ }
function editEntry(){
window.location.href = "edit?" + this.id;
}
@@ -31,6 +35,8 @@ require("viewfunctions")
$("#filter-list").submit(function(){
return false;
}).focus();
+ $("#records pre").hide();
+ $("#records li").not(":has(ul)").click(toggleEntry);
$("#records li").not(":has(ul)").dblclick(editEntry);
$("#locations li").not(":has(ul)").dblclick(editEntry);
});
@@ -49,14 +55,10 @@ io.write("</span>")
</H1>
<H2>Locations</H2>
<DL id="locations">
-<?
-if (view.value) and (view.value['%']) then
- local val = view.value['%'] ?>
- <DT<? if (val.errtxt) then io.write(" class='error'") end ?>><?= val.label ?></DT>
-
- <DD><ul>
- <? local currentloc = ""
- for i,loc in ipairs(val) do
+<ul>
+<? local currentloc = ""
+for i,loc in ipairs(view.value) do
+ if loc.type == '%' then
if currentloc ~= loc[1] then
if currentloc ~= "" then ?>
</ul>
@@ -70,14 +72,13 @@ if (view.value) and (view.value['%']) then
<? if (loc.errtxt) then ?><P CLASS='error'><?= string.gsub(loc.errtxt, "\n", "<BR>") ?></P><? end ?>
</li>
<? end
- if currentloc ~= "" then ?>
- </ul>
- <? end ?>
- </ul>
- </DD>
-<? else ?>
+end ?>
+<? if currentloc == "" then ?>
No locations defined
+<? else ?>
+ </ul>
<? end ?>
+</ul>
</DL>
<?
@@ -111,34 +112,33 @@ end
<H2>Records</H2>
<form id="filter-list">Filter: <input name="filter" id="filter" value="" maxlength="30" size="30" type="text"></form>
<DL id="records">
-<?
-local tags = {".", "&", "=", "+", "@", "'", "^", "C", "Z", ":" }
-for i,entrytype in ipairs(tags) do
- local myview = view.value[entrytype]
- if (myview) then ?>
- <DT><?= myview.label ?></DT>
- <DD><ul>
- <? local indent = {}
- for j,entry in ipairs(myview) do
- indent = doListIndents(entry[1], indent) ?>
- <ul><li STYLE='margin-left:10px;' id='filename=<?= entry.filename ?>;linenumber=<?= entry.linenumber ?>'>
- <IMG SRC='/skins/static/tango/16x16/devices/computer.png' width='16' height='16'><?= tostring(entry[1]) ?><BR>
- <TABLE STYLE='margin-left:<?= tostring(7-#indent) ?>0px;'>
- <? for k=2,#entry do
- local option = entry[k]
- if (option) and option ~= "" then ?>
- <TR><TD WIDTH='160px' STYLE='border:none;'><?= myview.fieldlabels[k] ?>:</TD>
- <TD STYLE='border:none;'><?= option ?></TD></TR>
- <? end
- end ?>
- </TABLE>
- <? if entry.errtxt then ?>
- <P CLASS='error'><?= string.gsub(entry.errtxt, "\n", "<BR>") ?></P>
- <? end ?>
- </li></ul>
- <? end
- doListIndents("", indent) ?>
- </ul></DD>
- <? end
+<ul>
+<? local indent = {}
+for j,entry in ipairs(view.value) do
+ if entry.type ~= '%' then
+ indent = doListIndents(entry[1], indent) ?>
+ <ul><li STYLE='margin-left:10px;' id='filename=<?= entry.filename ?>;linenumber=<?= entry.linenumber ?>'>
+ <IMG SRC='/skins/static/tango/16x16/devices/computer.png' width='16' height='16'><?= entry.label ?><BR>
+ <pre><?= entry.configline ?></pre>
+ <TABLE STYLE='margin-left:<?= tostring(7-#indent) ?>0px;'>
+ <? for k=2,#entry do
+ local option = entry[k]
+ if (option) and option ~= "" then ?>
+ <TR><TD WIDTH='160px' STYLE='border:none;'><?= view.fieldlabels[entry.type][k] ?>:</TD>
+ <TD STYLE='border:none;'><?= option ?></TD></TR>
+ <? end
+ end ?>
+ </TABLE>
+ <? if entry.errtxt then ?>
+ <P CLASS='error'><?= string.gsub(entry.errtxt, "\n", "<BR>") ?></P>
+ <? end ?>
+ </li></ul>
+ <? end
+end
+if #indent == 0 then ?>
+ No records defined
+<? else
+ doListIndents("", indent)
end ?>
+</ul>
</DL>