summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-10-21 17:23:10 +0000
committerTed Trask <ttrask01@yahoo.com>2008-10-21 17:23:10 +0000
commit83f91021bea9203fa8fe0877846a299c296df97d (patch)
tree725c9e70a7b69da2ea655ebb4df511288286db98
parent5484e1fff4c4a8c9c2ae557a5c322f50299aae60 (diff)
downloadacf-tinydns-83f91021bea9203fa8fe0877846a299c296df97d.tar.bz2
acf-tinydns-83f91021bea9203fa8fe0877846a299c296df97d.tar.xz
Modified TinyDNS to include more intelligence. Changed listfiles and newfile to not display / require directory. Made edit function in controller to allow control independent from expert. Modified edit to limit entries to the domain indicated by the file name.
git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@1557 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--tinydns-controller.lua4
-rw-r--r--tinydns-edit-html.lsp24
-rw-r--r--tinydns-listfiles-html.lsp12
-rw-r--r--tinydns-model.lua5
-rw-r--r--tinydns-view-html.lsp2
5 files changed, 35 insertions, 12 deletions
diff --git a/tinydns-controller.lua b/tinydns-controller.lua
index aa85efc..bcaffa4 100644
--- a/tinydns-controller.lua
+++ b/tinydns-controller.lua
@@ -37,6 +37,10 @@ function listfiles(self)
return cfe({ type="list", value=config, label="Config files" })
end
+function edit(self)
+ return editfile(self)
+end
+
function editfile(self)
config = controllerfunctions.handle_form(self, function()
return self.model.get_filedetails(self, self.clientdata.filename, sessiondata.userinfo.userid)
diff --git a/tinydns-edit-html.lsp b/tinydns-edit-html.lsp
index ddb4ae4..a4754e1 100644
--- a/tinydns-edit-html.lsp
+++ b/tinydns-edit-html.lsp
@@ -1,7 +1,7 @@
<% local form, viewlibrary, page_info = ... %>
<% require("viewfunctions") %>
-<% form = viewlibrary.dispatch_component(page_info.prefix .. page_info.controller .. "/editfile", form, true) %>
+<% local domain = string.gsub(form.value.filename.value, "^.*/", "") %>
<script type="text/javascript" src="/js/jquery-latest.js"></script>
<script type="text/javascript">
var editEntry = '<td> \
@@ -32,8 +32,15 @@
entryTypes[11]=new Entry("%","Client location",2,"Location","IP prefix");
function finishForm(entry){
- var entrytext = entry.find("select").val() + entry.find("input").map(function(){
- return $(this).val();
+ var entrytext = entry.find("select").val() + entry.find("input:not(.submit)").map(function(){
+ if (this.name == "fixme") {
+ if ($(this).val() != "")
+ return $(this).val() + ".<%= domain %>";
+ else
+ return "<%= domain %>";
+ } else {
+ return $(this).val();
+ }
}).get().join(":");
entry.empty().append(entrytext);
}
@@ -62,15 +69,22 @@
}
for (i=0; i<entryType.num; i++){
if (entries[i] === null) { entries[i] = ""; }
- form = form + '<dt>' + entryType.descriptions[i] + '</dt><dd><input type="text" value="' + entries[i] + '"></dd>';
+ if (entryType.descriptions[i] == "Domain" || entryType.descriptions[i] == "Alias" || entryType.descriptions[i] == "Host" )
+ form = form + '<dt>' + entryType.descriptions[i] + '</dt><dd><input type="text" value="' + entries[i].replace(/\.?<%= string.gsub(domain, "[\\%[%]%.%*%?%+%{%^%$]", "\\%1") %>$/i, "") + '" name="fixme"> . <%= domain %></dd>';
+ else
+ form = form + '<dt>' + entryType.descriptions[i] + '</dt><dd><input type="text" value="' + entries[i] + '"></dd>';
}
- form = form + "</dl>";
+ form = form + '\n<DT></DT><DD><input class="submit" type="submit" value="<%= form.option %>"></DD>';
+ form = form + "\n</dl>";
entry.empty().append(form);
entry.find("select").change(function(){
var entry = $(this).parent();
finishForm(entry);
createForm(entry);
});
+ entry.find("input.submit").click(function() {
+ $("input[name='<%= form.option %>']").click();
+ });
}
function editLine(){
var parent = $(this).parent();
diff --git a/tinydns-listfiles-html.lsp b/tinydns-listfiles-html.lsp
index 21bc652..0046d91 100644
--- a/tinydns-listfiles-html.lsp
+++ b/tinydns-listfiles-html.lsp
@@ -23,14 +23,16 @@ io.write("</span>")
<% for i,file in ipairs(form.value) do %>
<TR>
<TD style="padding-right:20px;white-space:nowrap;">
- <% io.write(html.link{value = "delete?filename=" .. file.value.filename.value, label="Delete " }) %>
- <% io.write(html.link{value = "view?filename=" .. file.value.filename.value, label="View " }) %>
- <% io.write(html.link{value = "edit?filename=" .. file.value.filename.value, label="Edit " }) %>
- <% io.write(html.link{value = "editfile?filename=" .. file.value.filename.value, label="Expert " }) %>
+ <%
+ if session.permissions.tinydns.delete then io.write(html.link{value = "delete?filename=" .. file.value.filename.value, label="Delete " }) end
+ io.write(html.link{value = "view?filename=" .. file.value.filename.value, label="View " })
+ if session.permissions.tinydns.edit then io.write(html.link{value = "edit?filename=" .. file.value.filename.value, label="Edit " }) end
+ if session.permissions.tinydns.editfile then io.write(html.link{value = "editfile?filename=" .. file.value.filename.value, label="Expert " }) end
+ %>
</TD>
<TD style="padding-right:20px;white-space:nowrap;text-align:right;"><%= file.value.filesize.value %></TD>
<TD style="padding-right:20px;white-space:nowrap;"><%= file.value.mtime.value %></TD>
- <TD style="white-space:nowrap;" width="90%"><%= file.value.filename.value %></TD>
+ <TD style="white-space:nowrap;" width="90%"><%= string.gsub(file.value.filename.value, "^.*/", "") %></TD>
</TR>
<% end %>
</TABLE>
diff --git a/tinydns-model.lua b/tinydns-model.lua
index 95e5f4f..dcbe9da 100644
--- a/tinydns-model.lua
+++ b/tinydns-model.lua
@@ -269,13 +269,16 @@ end
function getnewconfigfile()
local options = {}
- options.filename = cfe({ value=configdir.."/", label="File Name" })
+ options.filename = cfe({ label="File Name" })
return cfe({ type="group", value=options, label="New config file" })
end
function createconfigfile(self, configfile, userid)
configfile.errtxt = "Failed to create file"
local path = configfile.value.filename.value
+ if not string.find(path, "/") then
+ path = configdir .. "/" .. path
+ end
if validator.is_valid_filename(path,configdir) then
if (fs.is_file(path)) then
configfile.value.filename.errtxt = "File already exists"
diff --git a/tinydns-view-html.lsp b/tinydns-view-html.lsp
index e851569..b163ce5 100644
--- a/tinydns-view-html.lsp
+++ b/tinydns-view-html.lsp
@@ -51,7 +51,7 @@ io.write("</span>")
%>
<H1>DNS Entries
-<% if view.filename then io.write(" for "..view.filename) end %>
+<% if view.filename then io.write(" for "..string.gsub(view.filename, "^.*/", "")) end %>
</H1>
<H2>Locations</H2>
<DL id="locations">