1
0
mirror of https://github.com/writeas/writefreely synced 2025-01-09 06:20:17 +01:00
writefreely/pages.go
Matt Baer bdc4f270f8 Support editing About and Privacy pages from Admin panel
This allows admin to edit these pages from the web, using Markdown. It
also dynamically loads information on those pages now, and makes loading
`pages` templates a little easier to find in the code / more explicit.

It requires this new schema change:

CREATE TABLE IF NOT EXISTS `appcontent` (
  `id` varchar(36) NOT NULL,
  `content` mediumtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

This closes T533
2018-11-18 21:58:50 -05:00

40 lines
1.5 KiB
Go

package writefreely
import (
"time"
)
func getAboutPage(app *app) (string, error) {
c, _, err := app.db.GetDynamicContent("about")
if err != nil {
return "", err
}
if c == "" {
if app.cfg.App.Federation {
c = `_` + app.cfg.App.SiteName + `_ is an interconnected place for you to write and publish, powered by WriteFreely and ActivityPub.`
} else {
c = `_` + app.cfg.App.SiteName + `_ is a place for you to write and publish, powered by WriteFreely.`
}
}
return c, nil
}
func getPrivacyPage(app *app) (string, *time.Time, error) {
c, updated, err := app.db.GetDynamicContent("privacy")
if err != nil {
return "", nil, err
}
if c == "" {
c = `[Write Freely](https://writefreely.org), the software that powers this site, is built to enforce your right to privacy by default.
It retains as little data about you as possible, not even requiring an email address to sign up. However, if you _do_ give us your email address, it is stored encrypted in our database. We salt and hash your account's password.
We store log files, or data about what happens on our servers. We also use cookies to keep you logged in to your account.
Beyond this, it's important that you trust whoever runs **` + app.cfg.App.SiteName + `**. Software can only do so much to protect you -- your level of privacy protections will ultimately fall on the humans that run this particular service.`
defaultTime := time.Date(2018, 11, 8, 12, 0, 0, 0, time.Local)
updated = &defaultTime
}
return c, updated, nil
}