summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-admin-full/luasrc/view/admin_uci/changelog.htm
blob: 4ed4f0a10f7595e7d788c172fdf0e2a6f9d44571 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<%#
 Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
 Licensed to the public under the Apache License 2.0.
-%>

<% export("uci_changelog", function(changes) -%>
<fieldset class="cbi-section">
	<strong><%:Legend:%></strong>
	<div class="uci-change-legend">
		<div class="uci-change-legend-label"><ins>&#160;</ins> <%:Section added%></div>
		<div class="uci-change-legend-label"><del>&#160;</del> <%:Section removed%></div>
		<div class="uci-change-legend-label"><var><ins>&#160;</ins></var> <%:Option changed%></div>
		<div class="uci-change-legend-label"><var><del>&#160;</del></var> <%:Option removed%></div>
		<br style="clear:both" />
	</div>
	<br />

	<div class="uci-change-list"><%
		local util = luci.util
		local ret  = { }

		for r, tbl in pairs(changes) do
			for s, os in pairs(tbl) do
				-- section add
				if os['.type'] and os['.type'] ~= "" then
					ret[#ret+1] = "<ins>%s.%s=<strong>%s</strong>" %{ r, s, os['.type'] }
					for o, v in util.kspairs(os) do
						if o:sub(1,1) ~= "." then
							if type(v) == "table" then
								local i
								for i = 1, #v do
									ret[#ret+1] = "<br />%s.%s.%s+=<strong>%s</strong>"
										%{ r, s, o, util.pcdata(v[i]) }
								end
							else
								ret[#ret+1] = "<br />%s.%s.%s=<strong>%s</strong>"
									%{ r, s, o, util.pcdata(v) }
							end
						end
					end
					ret[#ret+1] = "</ins><br />"

				-- section delete
				elseif os['.type'] and os['.type'] == "" then
					ret[#ret+1] = "<del>%s.<strong>%s</strong></del><br />" %{ r, s }

				-- modifications
				else
					ret[#ret+1] = "<var>%s.%s<br />" %{ r, s }
					for o, v in util.kspairs(os) do
						if o:sub(1,1) ~= "." then
							if v and #v > 0 then
								ret[#ret+1] = "<ins>"
								if type(v) == "table" then
									local i
									for i = 1, #v do
										ret[#ret+1] = "%s.%s.%s+=<strong>%s</strong><br />"
											%{ r, s, o, util.pcdata(v[i]) }
									end
									
								else
									ret[#ret+1] = "%s.%s.%s=<strong>%s</strong><br />"
										%{ r, s, o, util.pcdata(v) }
								end
								ret[#ret+1] = "</ins>"
							else
								ret[#ret+1] = "<del>%s.%s.<strong>%s</strong><br /></del>" %{ r, s, o }
							end
						end
					end
					ret[#ret+1] = "</var><br />"
				end
			end
		end

		write(table.concat(ret))
	%></div>
</fieldset>
<%- end) %>