1
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
2
|
3 local Db = require "site:/lib/Db.luan"
|
|
4
|
1
|
5
|
|
6 local Config = {}
|
|
7
|
|
8 Config.default_text = [[
|
|
9 local Forum = require "site:/lib/Forum.luan"
|
|
10
|
|
11 Forum.title = "Your Forum"
|
|
12 ]]
|
|
13
|
2
|
14 local doc = Db.get_document("type:config")
|
|
15 Config.text = doc and doc.config or Config.default_text
|
|
16
|
|
17 function Config.set(text)
|
18
|
18 Db.run_in_transaction( function()
|
|
19 local doc = Db.get_document("type:config") or {type="config"}
|
|
20 doc.config = text
|
|
21 Db.save(doc)
|
|
22 end )
|
2
|
23 end
|
1
|
24
|
|
25 return Config
|