Mercurial Hosting > freedit
diff 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 |
line wrap: on
line diff
--- a/src/lib/Config.luan Wed Jun 15 20:59:13 2022 -0600 +++ b/src/lib/Config.luan Thu Jun 16 20:52:24 2022 -0600 @@ -1,5 +1,7 @@ local Luan = require "luan:Luan.luan" local error = Luan.error +local Db = require "site:/lib/Db.luan" + local Config = {} @@ -9,6 +11,13 @@ Forum.title = "Your Forum" ]] -Config.text = Config.default_text +local doc = Db.get_document("type:config") +Config.text = doc and doc.config or Config.default_text + +function Config.set(text) + local doc = Db.get_document("type:config") or {type="config"} + doc.config = text + Db.save(doc) +end return Config