Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting set link text #1021

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,24 @@ Links to the RFC page (external).
#### Settings

***Syntax: `[[setting,setting_name(,args)]]`***
***Syntax: `[[setting_text,setting_name(,text)]]`***

If args is set, it is appended to the display as a setting value. Example:
For the `setting` variant, if args is set, it is appended to the display as a
setting value. Example:

```
# [[setting,foo,5]] results in:
<a href="PATH_TO_FOO_SETTING">foo = 5</a>
```

For the `setting_text` variant, if text is set, it is used as the link text.
Example:

```
# [[setting_text,foo,bar]] results in:
<a href="PATH_TO_FOO_SETTING">bar</a>
```

#### Variable

***Syntax: `[[variable(,section)]]`***
Expand Down
2 changes: 1 addition & 1 deletion docs/core/admin/guides/spam_reporting.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ messages in/out of the Spam mailbox.
**You cannot run scripts anywhere you want.**

Sieve allows you to only run scripts under
[[setting,sieve_&gt;extension&lt;_bin_dir,sieve_pipe_bin_dir]]. You
[[setting_text,sieve_&lt;extension&gt;_bin_dir,sieve_pipe_bin_dir]]. You
can't use `/usr/local/bin/my-sieve-filter.sh`, you have to put the
script under `sieve_pipe_bin_dir` and use `my-sieve-filter.sh` in the
script instead.
Expand Down
2 changes: 1 addition & 1 deletion docs/core/config/auth/userdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ namespace default {
```

The separator setting can be overridden by returning
[[setting,namespace/separator,namespace/default/separator]] extra field.
[[setting_text,namespace/separator,namespace/default/separator]] extra field.

### Examples

Expand Down
5 changes: 3 additions & 2 deletions docs/installation/upgrade/include/2.3-to-2.3.x.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
### v2.3.x to v2.3.14

* Removed autocreate plugin. Use
[[setting,namespace/mailbox/auto,mailbox { auto }]] instead.
[[setting_text,namespace/mailbox/auto,mailbox { auto }]] instead.
* Removed expire plugin. Use
[[setting,namespace/mailbox/autoexpunge,mailbox { autoexpunge }]] instead.
[[setting_text,namespace/mailbox/autoexpunge,mailbox { autoexpunge }]]
instead.
* Removed xz write support from zlib plugin. (Reading xz compressed mails
is still supported.) Use another compression algorithm.

Expand Down
12 changes: 9 additions & 3 deletions lib/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ function dovecot_markdown(md, opts) {
case 'doveadm':
case 'event':
case 'setting':
case 'setting_text':
env.inner = parts[1]
env.args = parts[2] ? parts[2] : undefined;

Expand All @@ -179,16 +180,17 @@ function dovecot_markdown(md, opts) {
break

case 'setting':
case 'setting_text':
/* Settings names can have brackets, so we need to unescape
* input for purposes of searching settings keys. */
const search_str = env.inner.replaceAll('&gt;', '<')
.replaceAll('&lt;', '>')
const search_str = env.inner.replaceAll('&gt;', '>')
.replaceAll('&lt;', '<')

if (!opts.settings[search_str]) {
handle_error('setting link missing: ' + env.inner)
return '<code><a>'
}
page += 's'
page = 'settings'
break
}

Expand Down Expand Up @@ -334,6 +336,9 @@ function dovecot_markdown(md, opts) {
case 'setting':
return env.inner + (env.args ? ' = ' + env.args : '')

case 'setting_text':
return env.args ?? env.inner

case 'variable':
return env.inner

Expand All @@ -357,6 +362,7 @@ function dovecot_markdown(md, opts) {
case 'event':
case 'man':
case 'setting':
case 'setting_text':
case 'variable':
return '</a></code>'

Expand Down
Loading