summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-minidlna/luasrc/model
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2012-04-09 12:35:49 +0000
committerJo-Philipp Wich <jow@openwrt.org>2012-04-09 12:35:49 +0000
commit76b51196f57e89bd66b7cc20011f69db21ed9662 (patch)
treeeede2ec72159cf2f86b09e0c720a050ae0059e41 /applications/luci-minidlna/luasrc/model
parente0ff8c39fab66b1f046b30726800f23309b10ba5 (diff)
pplications/luci-minidlna: rework cbi model to use iface widget for interfaces and dynamic list for album art, introduce general and advanced tabs, sync translations
Diffstat (limited to 'applications/luci-minidlna/luasrc/model')
-rw-r--r--applications/luci-minidlna/luasrc/model/cbi/minidlna.lua115
1 files changed, 85 insertions, 30 deletions
diff --git a/applications/luci-minidlna/luasrc/model/cbi/minidlna.lua b/applications/luci-minidlna/luasrc/model/cbi/minidlna.lua
index 820569261f..7c9f4dee19 100644
--- a/applications/luci-minidlna/luasrc/model/cbi/minidlna.lua
+++ b/applications/luci-minidlna/luasrc/model/cbi/minidlna.lua
@@ -12,6 +12,8 @@ You may obtain a copy of the License at
$Id$
]]--
+local m, s, o
+
m = Map("minidlna", translate("miniDLNA"),
translate("MiniDLNA is server software with the aim of being fully compliant with DLNA/UPnP-AV clients."))
@@ -21,7 +23,10 @@ s = m:section(TypedSection, "minidlna", "miniDLNA Settings")
s.addremove = false
s.anonymous = true
-o = s:option(Flag, "enabled", translate("Enable:"))
+s:tab("general", translate("General Settings"))
+s:tab("advanced", translate("Advanced Settings"))
+
+o = s:taboption("general", Flag, "enabled", translate("Enable:"))
o.rmempty = false
function o.cfgvalue(self, section)
@@ -40,75 +45,125 @@ function o.write(self, section, value)
return Flag.write(self, section, value)
end
-port = s:option(Value, "port", translate("Port:"),
+o = s:taboption("general", Value, "port", translate("Port:"),
translate("Port for HTTP (descriptions, SOAP, media transfer) traffic."))
-port.datatype = "port"
-port.default = 8200
+o.datatype = "port"
+o.default = 8200
+
+
+o = s:taboption("general", Value, "interface", translate("Interfaces:"),
+ translate("Network interfaces to serve."))
+
+o.template = "cbi/network_ifacelist"
+o.widget = "checkbox"
+o.nocreate = true
+
+function o.cfgvalue(self, section)
+ local rv = { }
+ local val = Value.cfgvalue(self, section)
+ if val then
+ local ifc
+ for ifc in val:gmatch("[^,%s]+") do
+ rv[#rv+1] = ifc
+ end
+ end
+ return rv
+end
+
+function o.write(self, section, value)
+ local rv = { }
+ local ifc
+ for ifc in luci.util.imatch(value) do
+ rv[#rv+1] = ifc
+ end
+ Value.write(self, section, table.concat(rv, ","))
+end
-s:option(Value, "interface", translate("Interfaces:"),
- translate("Network interfaces to serve, comma delimited list."))
-o = s:option(Value, "friendly_name", translate("Friendly name:"),
+o = s:taboption("general", Value, "friendly_name", translate("Friendly name:"),
translate("Set this if you want to customize the name that shows up on your clients."))
-o.optional = true
+o.rmempty = true
o.placeholder = "OpenWrt DLNA Server"
-o = s:option(Value, "db_dir", translate("Database directory:"),
+o = s:taboption("advanced", Value, "db_dir", translate("Database directory:"),
translate("Set this if you would like to specify the directory where you want MiniDLNA to store its database and album art cache."))
-o.optional = true
+o.rmempty = true
o.placeholder = "/var/cache/minidlna"
-o = s:option(Value, "log_dir", translate("Log directory:"),
+o = s:taboption("advanced", Value, "log_dir", translate("Log directory:"),
translate("Set this if you would like to specify the directory where you want MiniDLNA to store its log file."))
-o.optional = true
+o.rmempty = true
o.placeholder = "/var/log"
-s:option(Flag, "inotify", translate("Enable inotify:"),
+s:taboption("advanced", Flag, "inotify", translate("Enable inotify:"),
translate("Set this to enable inotify monitoring to automatically discover new files."))
-s:option(Flag, "enable_tivo", translate("Enable TIVO:"),
+s:taboption("advanced", Flag, "enable_tivo", translate("Enable TIVO:"),
translate("Set this to enable support for streaming .jpg and .mp3 files to a TiVo supporting HMO."))
-o.optional = true
+o.rmempty = true
-o = s:option(Flag, "strict_dlna", translate("Strict to DLNA standard:"),
+o = s:taboption("advanced", Flag, "strict_dlna", translate("Strict to DLNA standard:"),
translate("Set this to strictly adhere to DLNA standards. This will allow server-side downscaling of very large JPEG images, which may hurt JPEG serving performance on (at least) Sony DLNA products."))
-o.optional = true
+o.rmempty = true
-o = s:option(Value, "presentation_url", translate("Presentation URL:"))
-o.optional = true
+o = s:taboption("advanced", Value, "presentation_url", translate("Presentation URL:"))
+o.rmempty = true
o.placeholder = "http://192.168.1.1/"
-o = s:option(Value, "notify_interval", translate("Notify interval:"),
+o = s:taboption("advanced", Value, "notify_interval", translate("Notify interval:"),
translate("Notify interval in seconds."))
o.datatype = "uinteger"
o.placeholder = 900
-o = s:option(Value, "serial", translate("Announced serial number:"),
+o = s:taboption("advanced", Value, "serial", translate("Announced serial number:"),
translate("Serial number the miniDLNA daemon will report to clients in its XML description."))
o.placeholder = "12345678"
-s:option(Value, "model_number", translate("Announced model number:"),
+s:taboption("advanced", Value, "model_number", translate("Announced model number:"),
translate("Model number the miniDLNA daemon will report to clients in its XML description."))
o.placholder = "1"
-o = s:option(Value, "minissdpsocket", translate("miniSSDP socket:"),
+o = s:taboption("advanced", Value, "minissdpsocket", translate("miniSSDP socket:"),
translate("Specify the path to the MiniSSDPd socket."))
-o.optional = true
+o.rmempty = true
o.placeholder = "/var/run/minissdpd.sock"
-o = s:option(ListValue, "root_container", translate("Root container:"))
+o = s:taboption("general", ListValue, "root_container", translate("Root container:"))
o:value(".", translate("Standard container"))
o:value("B", translate("Browse directory"))
o:value("M", translate("Music"))
o:value("V", translate("Video"))
o:value("P", translate("Pictures"))
-o = s:option(Value, "album_art_names", translate("Album art names:"),
- translate("This is a list of file names to check for when searching for album art. Note: names must be delimited with a forward slash '/'"))
-o.optional = true
-o.placeholder = "Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg"
-s:option(DynamicList, "media_dir", translate("Media directories:"),
+s:taboption("general", DynamicList, "media_dir", translate("Media directories:"),
translate("Set this to the directory you want scanned. If you want to restrict the directory to a specific content type, you can prepend the type ('A' for audio, 'V' for video, 'P' for images), followed by a comma, to the directory (eg. media_dir=A,/mnt/media/Music). Multiple directories can be specified."))
+
+o = s:taboption("general", DynamicList, "album_art_names", translate("Album art names:"),
+ translate("This is a list of file names to check for when searching for album art."))
+o.rmempty = true
+o.placeholder = "Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg"
+
+function o.cfgvalue(self, section)
+ local rv = { }
+ local val = Value.cfgvalue(self, section)
+ if type(val) == "table" then val = table.concat(val, "/") end
+ local file
+ for file in val:gmatch("[^/%s]+") do
+ rv[#rv+1] = file
+ end
+ return rv
+end
+
+function o.write(self, section, value)
+ local rv = { }
+ local file
+ for file in luci.util.imatch(value) do
+ rv[#rv+1] = file
+ end
+ Value.write(self, section, table.concat(rv, "/"))
+end
+
+
return m