Fix i18n problems with freifunk module and meshwizard
[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 = uci:get("freifunk", "community", "name")
16 luci.i18n.loadc("freifunk")
17
18 if community == nil then
19 luci.http.redirect(luci.dispatcher.build_url("admin", "freifunk", "profile_error"))
20 return
21 else
22 community = "/etc/config/profile_" .. community
23 f = SimpleForm("community", translate("Community profile"), translate("You can manually edit the selected community profile here."))
24
25 t = f:field(TextValue, "cop")
26 t.rmempty = true
27 t.rows = 30
28 function t.cfgvalue()
29 return fs.readfile(community) or ""
30 end
31
32 function f.handle(self, state, data)
33 if state == FORM_VALID then
34 if data.cop then
35 fs.writefile(cop, data.rcs:gsub("\r\n", "\n"))
36 end
37 end
38 return true
39 end
40 return f
41 end
42