annotate src/lib/Config.luan @ 10:de0cbf515ef5

remove author_id
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 30 Jun 2022 11:11:00 -0600
parents fc2383eb48a9
children 94e26bffd4fb
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)
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
18 local doc = Db.get_document("type:config") or {type="config"}
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
19 doc.config = text
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
20 Db.save(doc)
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
21 end
1
7c64173643c8 start config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22
7c64173643c8 start config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 return Config