annotate src/lib/Config.luan @ 22:d87a8f9f43d7

tinymce work
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 17 Jul 2022 21:47:55 -0600
parents 94e26bffd4fb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
7c64173643c8 start config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
7c64173643c8 start config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
2
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
3 local Db = require "site:/lib/Db.luan"
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
4
1
7c64173643c8 start config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5
7c64173643c8 start config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local Config = {}
7c64173643c8 start config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7
7c64173643c8 start config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 Config.default_text = [[
7c64173643c8 start config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local Forum = require "site:/lib/Forum.luan"
7c64173643c8 start config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10
7c64173643c8 start config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 Forum.title = "Your Forum"
7c64173643c8 start config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 ]]
7c64173643c8 start config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13
2
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
14 local doc = Db.get_document("type:config")
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
15 Config.text = doc and doc.config or Config.default_text
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
16
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
17 function Config.set(text)
18
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
18 Db.run_in_transaction( function()
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
19 local doc = Db.get_document("type:config") or {type="config"}
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
20 doc.config = text
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
21 Db.save(doc)
94e26bffd4fb UI work
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
22 end )
2
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
23 end
1
7c64173643c8 start config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24
7c64173643c8 start config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 return Config