changelog.htm 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <%#
  2. Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
  3. Licensed to the public under the Apache License 2.0.
  4. -%>
  5. <% export("uci_changelog", function(changes) -%>
  6. <fieldset class="cbi-section">
  7. <strong><%:Legend:%></strong>
  8. <div class="uci-change-legend">
  9. <div class="uci-change-legend-label"><ins>&#160;</ins> <%:Section added%></div>
  10. <div class="uci-change-legend-label"><del>&#160;</del> <%:Section removed%></div>
  11. <div class="uci-change-legend-label"><var><ins>&#160;</ins></var> <%:Option changed%></div>
  12. <div class="uci-change-legend-label"><var><del>&#160;</del></var> <%:Option removed%></div>
  13. <br style="clear:both" />
  14. </div>
  15. <br />
  16. <div class="uci-change-list"><%
  17. local util = luci.util
  18. local ret = { }
  19. for r, tbl in pairs(changes) do
  20. for s, os in pairs(tbl) do
  21. -- section add
  22. if os['.type'] and os['.type'] ~= "" then
  23. ret[#ret+1] = "<ins>%s.%s=<strong>%s</strong>" %{ r, s, os['.type'] }
  24. for o, v in util.kspairs(os) do
  25. if o:sub(1,1) ~= "." then
  26. if type(v) == "table" then
  27. local i
  28. for i = 1, #v do
  29. ret[#ret+1] = "<br />%s.%s.%s+=<strong>%s</strong>"
  30. %{ r, s, o, util.pcdata(v[i]) }
  31. end
  32. else
  33. ret[#ret+1] = "<br />%s.%s.%s=<strong>%s</strong>"
  34. %{ r, s, o, util.pcdata(v) }
  35. end
  36. end
  37. end
  38. ret[#ret+1] = "</ins><br />"
  39. -- section delete
  40. elseif os['.type'] and os['.type'] == "" then
  41. ret[#ret+1] = "<del>%s.<strong>%s</strong></del><br />" %{ r, s }
  42. -- modifications
  43. else
  44. ret[#ret+1] = "<var>%s.%s<br />" %{ r, s }
  45. for o, v in util.kspairs(os) do
  46. if o:sub(1,1) ~= "." then
  47. if v and #v > 0 then
  48. ret[#ret+1] = "<ins>"
  49. if type(v) == "table" then
  50. local i
  51. for i = 1, #v do
  52. ret[#ret+1] = "%s.%s.%s+=<strong>%s</strong><br />"
  53. %{ r, s, o, util.pcdata(v[i]) }
  54. end
  55. else
  56. ret[#ret+1] = "%s.%s.%s=<strong>%s</strong><br />"
  57. %{ r, s, o, util.pcdata(v) }
  58. end
  59. ret[#ret+1] = "</ins>"
  60. else
  61. ret[#ret+1] = "<del>%s.%s.<strong>%s</strong><br /></del>" %{ r, s, o }
  62. end
  63. end
  64. end
  65. ret[#ret+1] = "</var><br />"
  66. end
  67. end
  68. end
  69. write(table.concat(ret))
  70. %></div>
  71. </fieldset>
  72. <%- end) %>