1
0

changelog.htm 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <%#
  2. Copyright 2010 Jo-Philipp Wich <jo@mein.io>
  3. Licensed to the public under the Apache License 2.0.
  4. -%>
  5. <% export("uci_changelog", function(changes) -%>
  6. <div 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 tpl = {
  19. ["add-3"] = "<ins>uci add %0 <strong>%3</strong> # =%2</ins>",
  20. ["set-3"] = "<ins>uci set %0.<strong>%2</strong>=%3</ins>",
  21. ["set-4"] = "<var><ins>uci set %0.%2.%3=<strong>%4</strong></ins></var>",
  22. ["remove-2"] = "<del>uci del %0.<strong>%2</strong></del>",
  23. ["remove-3"] = "<var><del>uci del %0.%2.<strong>%3</strong></del></var>",
  24. ["order-3"] = "<var>uci reorder %0.%2=<strong>%3</strong></var>",
  25. ["list-add-4"] = "<var><ins>uci add_list %0.%2.%3=<strong>%4</strong></ins></var>",
  26. ["list-del-4"] = "<var><del>uci del_list %0.%2.%3=<strong>%4</strong></del></var>",
  27. ["rename-3"] = "<var>uci rename %0.%2=<strong>%3</strong></var>",
  28. ["rename-4"] = "<var>uci rename %0.%2.%3=<strong>%4</strong></var>"
  29. }
  30. local conf, deltas
  31. for conf, deltas in util.kspairs(changes) do
  32. write("<h3># /etc/config/%s</h3>" % conf)
  33. local _, delta, added
  34. for _, delta in pairs(deltas) do
  35. local t = tpl["%s-%d" %{ delta[1], #delta }]
  36. write(t:gsub("%%(%d)", function(n)
  37. if n == "0" then
  38. return conf
  39. elseif n == "2" then
  40. if added and delta[2] == added[1] then
  41. return "@%s[-1]" % added[2]
  42. else
  43. return delta[2]
  44. end
  45. elseif n == "4" then
  46. return util.shellquote(delta[4])
  47. else
  48. return delta[tonumber(n)]
  49. end
  50. end))
  51. if delta[1] == "add" then
  52. added = { delta[2], delta[3] }
  53. end
  54. end
  55. write("<br />")
  56. end
  57. %></div>
  58. </div>
  59. <%- end) %>