From f90de782a758ad1c702e2ae9403e415d8592eac5 Mon Sep 17 00:00:00 2001 From: Xingwang Liao Date: Fri, 29 Mar 2019 17:09:37 +0800 Subject: luci-app-aria2: Refactor, new views and more options This commit contains: * Refactor package code. * Add options for RPC, HTTP/HTTPS and BT. * Improve descriptions for some options. * New views for config files and log files. * Also updated translation for simplified Chinese. Signed-off-by: Xingwang Liao --- .../luasrc/model/cbi/aria2/files.lua | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 applications/luci-app-aria2/luasrc/model/cbi/aria2/files.lua (limited to 'applications/luci-app-aria2/luasrc/model/cbi/aria2/files.lua') diff --git a/applications/luci-app-aria2/luasrc/model/cbi/aria2/files.lua b/applications/luci-app-aria2/luasrc/model/cbi/aria2/files.lua new file mode 100644 index 0000000000..954a4ec5ef --- /dev/null +++ b/applications/luci-app-aria2/luasrc/model/cbi/aria2/files.lua @@ -0,0 +1,39 @@ +-- Copyright 2017-2019 Xingwang Liao +-- Licensed to the public under the MIT License. + +local m, s, o + +local fs = require "nixio.fs" +local util = require "luci.util" +local uci = require "luci.model.uci".cursor() + +local config_dir = uci:get("aria2", "main", "config_dir") or "/var/etc/aria2" +local config_file = "%s/aria2.conf.main" % config_dir +local session_file = "%s/aria2.session.main" % config_dir + +m = SimpleForm("aria2", "%s - %s" % { translate("Aria2"), translate("Files") }, + translate("Here shows the files used by aria2.")) +m.reset = false +m.submit = false + +s = m:section(SimpleSection, nil, translatef("Content of config file: %s", config_file)) + +o = s:option(TextValue, "_config") +o.rows = 20 +o.readonly = true +o.cfgvalue = function() + local v = fs.readfile(config_file) or translate("File does not exist.") + return util.trim(v) ~= "" and v or translate("Empty file.") +end + +s = m:section(SimpleSection, nil, translatef("Content of session file: %s", session_file)) + +o = s:option(TextValue, "_session") +o.rows = 20 +o.readonly = true +o.cfgvalue = function() + local v = fs.readfile(session_file) or translate("File does not exist.") + return util.trim(v) ~= "" and v or translate("Empty file.") +end + +return m -- cgit v1.2.3