files.lua 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. -- Copyright 2017-2019 Xingwang Liao <kuoruan@gmail.com>
  2. -- Licensed to the public under the MIT License.
  3. local m, s, o
  4. local fs = require "nixio.fs"
  5. local util = require "luci.util"
  6. local uci = require "luci.model.uci".cursor()
  7. local config_dir = uci:get("aria2", "main", "config_dir") or "/var/etc/aria2"
  8. local config_file = "%s/aria2.conf.main" % config_dir
  9. local session_file = "%s/aria2.session.main" % config_dir
  10. m = SimpleForm("aria2", "%s - %s" % { translate("Aria2"), translate("Files") },
  11. translate("Here shows the files used by aria2."))
  12. m.reset = false
  13. m.submit = false
  14. s = m:section(SimpleSection, nil, translatef("Content of config file: <code>%s</code>", config_file))
  15. o = s:option(TextValue, "_config")
  16. o.rows = 20
  17. o.readonly = true
  18. o.cfgvalue = function()
  19. local v = fs.readfile(config_file) or translate("File does not exist.")
  20. return util.trim(v) ~= "" and v or translate("Empty file.")
  21. end
  22. s = m:section(SimpleSection, nil, translatef("Content of session file: <code>%s</code>", session_file))
  23. o = s:option(TextValue, "_session")
  24. o.rows = 20
  25. o.readonly = true
  26. o.cfgvalue = function()
  27. local v = fs.readfile(session_file) or translate("File does not exist.")
  28. return util.trim(v) ~= "" and v or translate("Empty file.")
  29. end
  30. return m