Contact: Add option for privacy policy

This commit is contained in:
Jan-Lukas Else 2021-07-22 14:04:46 +02:00
parent bdbaf9b915
commit 3db1f6b85c
7 changed files with 29 additions and 13 deletions

View File

@ -153,16 +153,17 @@ type configGeoMap struct {
}
type configContact struct {
Enabled bool `mapstructure:"enabled"`
Path string `mapstructure:"path"`
Title string `mapstructure:"title"`
Description string `mapstructure:"description"`
SMTPHost string `mapstructure:"smtpHost"`
SMTPPort int `mapstructure:"smtpPort"`
SMTPUser string `mapstructure:"smtpUser"`
SMTPPassword string `mapstructure:"smtpPassword"`
EmailFrom string `mapstructure:"emailFrom"`
EmailTo string `mapstructure:"emailTo"`
Enabled bool `mapstructure:"enabled"`
Path string `mapstructure:"path"`
Title string `mapstructure:"title"`
Description string `mapstructure:"description"`
PrivacyPolicy string `mapstructure:"privacyPolicy"`
SMTPHost string `mapstructure:"smtpHost"`
SMTPPort int `mapstructure:"smtpPort"`
SMTPUser string `mapstructure:"smtpUser"`
SMTPPassword string `mapstructure:"smtpPassword"`
EmailFrom string `mapstructure:"emailFrom"`
EmailTo string `mapstructure:"emailTo"`
}
type configUser struct {

View File

@ -23,6 +23,7 @@ func (a *goBlog) serveContactForm(w http.ResponseWriter, r *http.Request) {
Data: map[string]interface{}{
"title": cc.Title,
"description": cc.Description,
"privacy": cc.PrivacyPolicy,
},
})
}

View File

@ -220,9 +220,10 @@ blogs:
# Contact form
contact:
enabled: true # Enable a contact form
title: "Contact me!" # (Optional) Title to show above the form
description: "Feel free to send me a message" # (Optional) Description to show above the form
path: /contact # (Optional) Set a custom path (relative to blog path), default is /contact
title: "Contact me!" # (Optional) Title to show above the form
description: "Feel free to send me a message" # (Optional) Description to show above the form, supports markdown
privacyPolicy: "By submitting this form, I agree to the privacy policy." # (Optional) Require agreement to the privacy policy, supports markdown
smtpHost: smtp.example.com # SMTP host
smtpPort: 587 # (Optional) SMTP port, default is 587
smtpUser: mail@example.com # SMTP user

View File

@ -130,6 +130,12 @@ func (a *goBlog) serveSitemap(w http.ResponseWriter, r *http.Request) {
Loc: a.getFullAddress(bc.getRelativePath(defaultIfEmpty(mc.Path, defaultGeoMapPath))),
})
}
// Contact
if cc := bc.Contact; cc != nil && cc.Enabled {
sm.Add(&sitemap.URL{
Loc: a.getFullAddress(bc.getRelativePath(defaultIfEmpty(cc.Path, defaultContactPath))),
})
}
// Custom pages
for _, cp := range bc.CustomPages {
sm.Add(&sitemap.URL{

View File

@ -14,7 +14,12 @@
<input type="url" name="website" placeholder="{{ string .Blog.Lang "websiteopt" }}">
<input type="email" name="email" placeholder="{{ string .Blog.Lang "emailopt" }}">
<textarea name="message" required placeholder="{{ string .Blog.Lang "message" }}"></textarea>
<input type="submit" value="{{ string .Blog.Lang "contactsend" }}">
{{ if .Data.privacy }}
{{ md .Data.privacy }}
<input type="submit" value="{{ string .Blog.Lang "contactagreesend" }}">
{{ else }}
<input type="submit" value="{{ string .Blog.Lang "contactsend" }}">
{{ end }}
</form>
{{ end }}
</main>

View File

@ -5,6 +5,7 @@ comments: "Kommentare"
confirmdelete: "Löschen bestätigen"
connectedviator: "Verbunden über Tor."
connectviator: "Über Tor verbinden."
contactagreesend: "Akzeptieren & Senden"
contactsend: "Senden"
create: "Erstellen"
delete: "Löschen"

View File

@ -10,6 +10,7 @@ comments: "Comments"
confirmdelete: "Confirm deletion"
connectedviator: "Connected via Tor."
connectviator: "Connect via Tor."
contactagreesend: "Accept & Send"
contactsend: "Send"
create: "Create"
delete: "Delete"