Commit 93477ab9 authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt

extend functionality of suggest-content feature

* inject labelled type into template
* fallback to address if no name has been provided
* guarantee title variable
parent 5a607c8e
......@@ -121,12 +121,23 @@ network connection you’re advised to use WebSockets if you can.
It’s hard and time-intensive to write proper descriptions for recordings.
In the spirit of open participation users can submit content via mail.
`suggestContent.address`:
The email address the suggestion is send to.
`suggestContent.name`:
The name displayed in the frontend where content can be suggested.
Falls back to `suggestContent.address` if not provided.
`suggestContent.address`:
The email address the suggestion is send to.
`suggestContent.subjectTemplate`:
A template for the message subject. Variables are interpolated
within curly brackets. Guaranteed variables are `title` and `type`.
See the example for a better understanding.
`suggestContent.typeMapping`:
A simple key-value mapping for a type key (one of `broadcast `,
`recording`, `series`, and `tag`) to a label. This is used
to inject a localized `type` variable into the subject template
(see option above).
### User OS Integration
......@@ -235,9 +246,14 @@ experience on various platforms.
}
},
"suggestContent": {
"subject": "Beschreibungsvorschlag für \"{title}\"",
"name": "musik@lohro.de",
"address": "musik@lohro.de"
"address": "musik@lohro.de",
"subjectTemplate": "Beschreibungsvorschlag für {type} \"{title}\"",
"typeMapping": {
"broadcast": "die Sendung",
"recording": "den Beitrag",
"series": "die Sendereihe",
"tag": "das Schlagwort"
}
},
"integration": {
"splashBackground": "#fff",
......
......@@ -13,15 +13,17 @@
export default {
props: {
missingTextTranslationKey: String,
context: Object
context: Object,
type: String
},
computed: {
suggestData () {
const { suggestContent: suggest } = this.env
if (suggest) {
const subject = renderSimpleTemplateString(suggest.subject, this.context)
const type = suggest.typeMapping ? suggest.typeMapping[this.type] || this.type : this.type
const subject = renderSimpleTemplateString(suggest.subjectTemplate, { ...this.context, type })
return {
suggest_name: suggest.name,
suggest_name: suggest.name || suggest.address,
suggest_address: `mailto:${suggest.address}?subject=${encodeURIComponent(subject)}`
}
}
......
......@@ -18,7 +18,7 @@
<div class="mb-2">
<app-markdown v-if="recording.description">{{ recording.description }}</app-markdown>
<SuggestContent v-else missing-text-translation-key="recording_page.missing_description"
:context="recording"/>
:context="recording" type="recording"/>
</div>
<app-field>
<ul class="d-inline hyphens ma-0 pa-0 opaque-7">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment