<%# Copyright 2010 Jo-Philipp Wich <jo@mein.io> 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) %>