local util = require("util") local data = util.merge({notification=''},{ opts = app.opts }) data.plugins = "" function pluginInput(opt) local html = "" html = html .. [[ ]] html = html .. opt.title html = html .. [[ ]] if type(opt.values) == 'table' then html = html .. util.template('\n" else html = html .. util.template('',{ key = opt.key, value = app.opts[key] }) end html = html .. util.template([[ ${info} ]],opt) return html end function pluginUI(name,plugin) local plugindata = util.flatten(plugin,"plugin") plugindata.opts = "" foreach(plugin.opts, function(k,opt) plugindata.opts = plugindata.opts .. pluginInput(opt) end) print_r(plugindata) data.plugins = data.plugins .. util.template( LoadAsset('/page/admin/plugin.html'), plugindata) end function saveData() if GetMethod() == 'POST' then local params = GetParams() local saveconfig = false foreach(params, function(k,v) if v[1]:match("^opts.") then app.opts[ v[1]:gsub("^opts.","") ] = v[2] -- update saveconfig = true end end) if saveconfig then app.set('app.opts', app.opts ) data.notification = '
updated
' else data.notification = '
no changes detected
' end end end foreach( app.plugin, pluginUI ) saveData() local html = util.template( LoadAsset("page/admin/index.html"),data) SetStatus(200) SetHeader('Content-Type', 'text/html; charset=utf-8') Write( html )