Rework LuCI build system
[project/luci.git] / modules / luci-mod-admin-full / luasrc / view / admin_uci / changelog.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9         http://www.apache.org/licenses/LICENSE-2.0
10
11 $Id$
12
13 -%>
14
15 <% export("uci_changelog", function(changes) -%>
16 <fieldset class="cbi-section">
17         <strong><%:Legend:%></strong>
18         <div class="uci-change-legend">
19                 <div class="uci-change-legend-label"><ins>&#160;</ins> <%:Section added%></div>
20                 <div class="uci-change-legend-label"><del>&#160;</del> <%:Section removed%></div>
21                 <div class="uci-change-legend-label"><var><ins>&#160;</ins></var> <%:Option changed%></div>
22                 <div class="uci-change-legend-label"><var><del>&#160;</del></var> <%:Option removed%></div>
23                 <br style="clear:both" />
24         </div>
25         <br />
26
27         <div class="uci-change-list"><%
28                 local util = luci.util
29                 local ret  = { }
30
31                 for r, tbl in pairs(changes) do
32                         for s, os in pairs(tbl) do
33                                 -- section add
34                                 if os['.type'] and os['.type'] ~= "" then
35                                         ret[#ret+1] = "<ins>%s.%s=<strong>%s</strong>" %{ r, s, os['.type'] }
36                                         for o, v in util.kspairs(os) do
37                                                 if o:sub(1,1) ~= "." then
38                                                         if type(v) == "table" then
39                                                                 local i
40                                                                 for i = 1, #v do
41                                                                         ret[#ret+1] = "<br />%s.%s.%s+=<strong>%s</strong>"
42                                                                                 %{ r, s, o, util.pcdata(v[i]) }
43                                                                 end
44                                                         else
45                                                                 ret[#ret+1] = "<br />%s.%s.%s=<strong>%s</strong>"
46                                                                         %{ r, s, o, util.pcdata(v) }
47                                                         end
48                                                 end
49                                         end
50                                         ret[#ret+1] = "</ins><br />"
51
52                                 -- section delete
53                                 elseif os['.type'] and os['.type'] == "" then
54                                         ret[#ret+1] = "<del>%s.<strong>%s</strong></del><br />" %{ r, s }
55
56                                 -- modifications
57                                 else
58                                         ret[#ret+1] = "<var>%s.%s<br />" %{ r, s }
59                                         for o, v in util.kspairs(os) do
60                                                 if o:sub(1,1) ~= "." then
61                                                         if v and #v > 0 then
62                                                                 ret[#ret+1] = "<ins>"
63                                                                 if type(v) == "table" then
64                                                                         local i
65                                                                         for i = 1, #v do
66                                                                                 ret[#ret+1] = "%s.%s.%s+=<strong>%s</strong><br />"
67                                                                                         %{ r, s, o, util.pcdata(v[i]) }
68                                                                         end
69                                                                         
70                                                                 else
71                                                                         ret[#ret+1] = "%s.%s.%s=<strong>%s</strong><br />"
72                                                                                 %{ r, s, o, util.pcdata(v) }
73                                                                 end
74                                                                 ret[#ret+1] = "</ins>"
75                                                         else
76                                                                 ret[#ret+1] = "<del>%s.%s.<strong>%s</strong><br /></del>" %{ r, s, o }
77                                                         end
78                                                 end
79                                         end
80                                         ret[#ret+1] = "</var><br />"
81                                 end
82                         end
83                 end
84
85                 write(table.concat(ret))
86         %></div>
87 </fieldset>
88 <%- end) %>