comparison src/lib/Config.luan @ 2:fc2383eb48a9

set config
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 16 Jun 2022 20:52:24 -0600
parents 7c64173643c8
children 94e26bffd4fb
comparison
equal deleted inserted replaced
1:7c64173643c8 2:fc2383eb48a9
1 local Luan = require "luan:Luan.luan" 1 local Luan = require "luan:Luan.luan"
2 local error = Luan.error 2 local error = Luan.error
3 local Db = require "site:/lib/Db.luan"
4
3 5
4 local Config = {} 6 local Config = {}
5 7
6 Config.default_text = [[ 8 Config.default_text = [[
7 local Forum = require "site:/lib/Forum.luan" 9 local Forum = require "site:/lib/Forum.luan"
8 10
9 Forum.title = "Your Forum" 11 Forum.title = "Your Forum"
10 ]] 12 ]]
11 13
12 Config.text = Config.default_text 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 local doc = Db.get_document("type:config") or {type="config"}
19 doc.config = text
20 Db.save(doc)
21 end
13 22
14 return Config 23 return Config