applications/ffwizard: Massive changes to the ffwizard to make it more generic. Also...
[project/luci.git] / modules / freifunk / luasrc / model / cbi / freifunk / profile_expert.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 httc://www.apache.org/licenses/LICENSE-2.0
11 ]]--
12
13 local fs = require "nixio.fs"
14 local uci = require "luci.model.uci".cursor()
15 local community = "/etc/config/profile_" .. uci:get("freifunk", "community", "name")
16
17 f = SimpleForm("community", translate("Community profile"), translate("This is the complete content of the selected community profile."))
18
19 t = f:field(TextValue, "cop")
20 t.rmempty = true
21 t.rows = 30
22 function t.cfgvalue()
23 return fs.readfile(community) or ""
24 end
25
26 function f.handle(self, state, data)
27 if state == FORM_VALID then
28 if data.cop then
29 fs.writefile(cop, data.rcs:gsub("\r\n", "\n"))
30 end
31 end
32 return true
33 end
34
35 return f
36