Skip to content

Commit 4def109

Browse files
slusarzcmouse
authored andcommitted
lua: Add ability to incorporate Dovecot settings in a Lua function argument entry
1 parent fc79dd7 commit 4def109

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

components/LuaFunctionComponent.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function buildFunctionSignature(k, v) {
7878
<td><code>{{ k2 }}</code></td>
7979
<td><em>{{ v2.type }}</em></td>
8080
<td>
81-
<span v-html="v2.text" />
81+
<div class="lua-function-description" v-html="v2.text" />
8282
<span v-if="v2.default">(Default: <code>{{ v2.default }}</code>)</span>
8383
</td>
8484
</tr>
@@ -104,4 +104,7 @@ function buildFunctionSignature(k, v) {
104104
margin: 15px auto;
105105
width: 75%;
106106
}
107+
.lua-function-description :deep(p) {
108+
margin: 0;
109+
}
107110
</style>

data/lua.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ export const lua_functions = [
99
// List of function arguments
1010
args: {
1111
text: {
12+
// If this argument is set, the 'text (w/default)' and
13+
// 'values' information from the Dovecot setting is used if it
14+
// does NOT otherwise exist in this config.
15+
// dovecot_setting: 'dovecot_setting_name',
16+
1217
// If true, this argument appears inside a Lua hash table
1318
// instead of as a standalone argument.
1419
// hash_arg: false,

lib/data/lua.data.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,32 @@ async function normalizeLuaConstants(lua) {
2222

2323
async function normalizeLuaFunctions(lua) {
2424
const md = await getVitepressMd()
25+
let set = false
2526
const out = {}
2627

2728
for (const v of lua.values()) {
2829
if (v.args) {
2930
for (const [k2, v2] of Object.entries(v.args)) {
30-
v2.text = md.renderInline(v2.text)
31+
/* Merge information from Dovecot settings. */
32+
if (v2.dovecot_setting) {
33+
if (!set) {
34+
set = structuredClone(loadData('settings').settings)
35+
}
36+
37+
if (!v2.type) {
38+
v2.type = set[v2.dovecot_setting].values?.label
39+
}
40+
41+
if (!v2.text) {
42+
v2.text = set[v2.dovecot_setting].text.trim()
43+
}
44+
45+
if (v2.default === undefined) {
46+
v2.default = set[v2.dovecot_setting].default
47+
}
48+
}
49+
50+
v2.text = md.render(v2.text)
3151
}
3252
}
3353

0 commit comments

Comments
 (0)