From 6ec0353201435e0d0d7d32820d8ba600b4ca7b5b Mon Sep 17 00:00:00 2001 From: "Daniel F. Dickinson" Date: Thu, 2 Aug 2018 09:39:48 -0400 Subject: modules: Make luci-base sufficient to use luci apps Per the discussion in https://github.com/openwrt/luci/issues/869, make luci-base sufficient to login, logout, and review and apply or revert uci changes. This allows most luci-app-xxx to work without having luci-mod-admin-full installed. It has been tested with some apps and not luci-mod-admin-full, as well as with luci-mod-admin-full (to make sure the usual case doesn't break). Instead of creating a new module namespace (e.g. 'Base') we reduce the opportunities for breakage by having luci-base take over the 'shell' of the 'Administration' (admin/....) namespace. Since admin is assumed by all current building LuCI components (including Freifunk), this doesn't introduce the 'Administration' tab into any situation where it would not already be present (but includes it where it was before). We also add a "Component not installed" page to avoid fatal errors and backtrace when e.g. luci-mod-admin-full is not installed. Signed-off-by: Daniel F. Dickinson --- .../luasrc/view/admin_uci/changelog.htm | 66 ---------------------- .../luasrc/view/admin_uci/changes.htm | 45 --------------- .../luasrc/view/admin_uci/revert.htm | 33 ----------- 3 files changed, 144 deletions(-) delete mode 100644 modules/luci-mod-admin-full/luasrc/view/admin_uci/changelog.htm delete mode 100644 modules/luci-mod-admin-full/luasrc/view/admin_uci/changes.htm delete mode 100644 modules/luci-mod-admin-full/luasrc/view/admin_uci/revert.htm (limited to 'modules/luci-mod-admin-full/luasrc/view') diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_uci/changelog.htm b/modules/luci-mod-admin-full/luasrc/view/admin_uci/changelog.htm deleted file mode 100644 index 8a162c88b6..0000000000 --- a/modules/luci-mod-admin-full/luasrc/view/admin_uci/changelog.htm +++ /dev/null @@ -1,66 +0,0 @@ -<%# - Copyright 2010 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - -<% export("uci_changelog", function(changes) -%> -
- <%:Legend:%> -
-
  <%:Section added%>
-
  <%:Section removed%>
-
  <%:Option changed%>
-
  <%:Option removed%>
-
-
-
- -
<% - local util = luci.util - local tpl = { - ["add-3"] = "uci add %0 %3 # =%2", - ["set-3"] = "uci set %0.%2=%3", - ["set-4"] = "uci set %0.%2.%3=%4", - ["remove-2"] = "uci del %0.%2", - ["remove-3"] = "uci del %0.%2.%3", - ["order-3"] = "uci reorder %0.%2=%3", - ["list-add-4"] = "uci add_list %0.%2.%3=%4", - ["list-del-4"] = "uci del_list %0.%2.%3=%4", - ["rename-3"] = "uci rename %0.%2=%3", - ["rename-4"] = "uci rename %0.%2.%3=%4" - } - - local conf, deltas - for conf, deltas in util.kspairs(changes) do - write("

# /etc/config/%s

" % conf) - - local _, delta, added - for _, delta in pairs(deltas) do - local t = tpl["%s-%d" %{ delta[1], #delta }] - - write(t:gsub("%%(%d)", function(n) - if n == "0" then - return conf - elseif n == "2" then - if added and delta[2] == added[1] then - return "@%s[-1]" % added[2] - else - return delta[2] - end - elseif n == "4" then - return util.shellquote(delta[4]) - else - return delta[tonumber(n)] - end - end)) - - if delta[1] == "add" then - added = { delta[2], delta[3] } - end - end - - write("
") - end - %>
-
-<%- end) %> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_uci/changes.htm b/modules/luci-mod-admin-full/luasrc/view/admin_uci/changes.htm deleted file mode 100644 index 43bd7c23fb..0000000000 --- a/modules/luci-mod-admin-full/luasrc/view/admin_uci/changes.htm +++ /dev/null @@ -1,45 +0,0 @@ -<%# - Copyright 2008 Steven Barth - Copyright 2008-2018 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - -<%+header%> - -<%- - local node, redir_url = luci.dispatcher.lookup(luci.http.formvalue("redir")) - export("redirect", redir_url or url("admin/uci/changes")) - - include("admin_uci/changelog") --%> - -

<%:Configuration%> / <%:Changes%>

- -<% if changes then %> - <%- uci_changelog(changes) -%> -<% else %> -

<%:There are no pending changes!%>

-<% end %> - - - -
- <% if redir_url then %> -
- -
- <% end %> - -
"> - - " /> - -
-
"> - - " /> - -
-
- -<%+footer%> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_uci/revert.htm b/modules/luci-mod-admin-full/luasrc/view/admin_uci/revert.htm deleted file mode 100644 index d8fd3de01e..0000000000 --- a/modules/luci-mod-admin-full/luasrc/view/admin_uci/revert.htm +++ /dev/null @@ -1,33 +0,0 @@ -<%# - Copyright 2008 Steven Barth - Copyright 2008-2018 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - -<%+header%> - -<%- - local node, redir_url = luci.dispatcher.lookup(luci.http.formvalue("redir")) - export("redirect", redir_url or url("admin/uci/changes")) - - include("admin_uci/changelog") --%> - -

<%:Configuration%> / <%:Revert%>

- -<% if changes then %> -

<%:The following changes have been reverted%>:

- <%- uci_changelog(changes) -%> -<% else %> -

<%:There are no pending changes to revert!%>

-<% end %> - -<% if redir_url then %> -
-
- -
-
-<% end %> - -<%+footer%> -- cgit v1.2.3