2018-12-24 18:45:15 +01:00
/ *
2022-11-11 05:49:16 +01:00
* Copyright © 2018 - 2019 , 2021 Musing Studio LLC .
2018-12-24 18:45:15 +01:00
*
* This file is part of WriteFreely .
*
* WriteFreely is free software : you can redistribute it and / or modify
* it under the terms of the GNU Affero General Public License , included
* in the LICENSE file in this source code package .
* /
2018-12-31 07:05:26 +01:00
2018-11-19 03:58:50 +01:00
package writefreely
import (
2019-04-11 19:56:07 +02:00
"database/sql"
2021-04-06 23:24:07 +02:00
"github.com/writefreely/writefreely/config"
2018-11-19 03:58:50 +01:00
"time"
)
2019-04-06 19:23:22 +02:00
var defaultPageUpdatedTime = time . Date ( 2018 , 11 , 8 , 12 , 0 , 0 , 0 , time . Local )
2019-05-12 22:55:30 +02:00
func getAboutPage ( app * App ) ( * instanceContent , error ) {
2019-04-06 19:23:22 +02:00
c , err := app . db . GetDynamicContent ( "about" )
2018-11-19 03:58:50 +01:00
if err != nil {
2019-04-06 19:23:22 +02:00
return nil , err
2018-11-19 03:58:50 +01:00
}
2019-04-06 19:23:22 +02:00
if c == nil {
c = & instanceContent {
ID : "about" ,
2019-04-11 19:56:07 +02:00
Type : "page" ,
2019-04-06 19:23:22 +02:00
Content : defaultAboutPage ( app . cfg ) ,
2018-11-19 03:58:50 +01:00
}
}
2019-04-11 19:56:07 +02:00
if ! c . Title . Valid {
c . Title = defaultAboutTitle ( app . cfg )
}
2018-11-19 03:58:50 +01:00
return c , nil
}
2019-04-11 19:56:07 +02:00
func defaultAboutTitle ( cfg * config . Config ) sql . NullString {
return sql . NullString { String : "About " + cfg . App . SiteName , Valid : true }
}
2023-09-22 18:37:15 +02:00
func getContactPage ( app * App ) ( * instanceContent , error ) {
c , err := app . db . GetDynamicContent ( "contact" )
if err != nil {
return nil , err
}
if c == nil {
c = & instanceContent {
ID : "contact" ,
Type : "page" ,
Content : defaultContactPage ( app ) ,
}
}
if ! c . Title . Valid {
c . Title = defaultContactTitle ( )
}
return c , nil
}
func defaultContactTitle ( ) sql . NullString {
return sql . NullString { String : "Contact Us" , Valid : true }
}
2019-05-12 22:55:30 +02:00
func getPrivacyPage ( app * App ) ( * instanceContent , error ) {
2019-04-06 19:23:22 +02:00
c , err := app . db . GetDynamicContent ( "privacy" )
2018-11-19 03:58:50 +01:00
if err != nil {
2019-04-06 19:23:22 +02:00
return nil , err
}
if c == nil {
c = & instanceContent {
ID : "privacy" ,
2019-04-11 19:56:07 +02:00
Type : "page" ,
2019-04-06 19:23:22 +02:00
Content : defaultPrivacyPolicy ( app . cfg ) ,
Updated : defaultPageUpdatedTime ,
}
}
2019-04-11 19:56:07 +02:00
if ! c . Title . Valid {
c . Title = defaultPrivacyTitle ( )
}
2019-04-06 19:23:22 +02:00
return c , nil
}
2019-04-11 19:56:07 +02:00
func defaultPrivacyTitle ( ) sql . NullString {
return sql . NullString { String : "Privacy Policy" , Valid : true }
}
2019-04-06 19:23:22 +02:00
func defaultAboutPage ( cfg * config . Config ) string {
if cfg . App . Federation {
2019-08-02 04:04:09 +02:00
return ` _ ` + cfg . App . SiteName + ` _ is an interconnected place for you to write and publish, powered by [WriteFreely](https://writefreely.org) and ActivityPub. `
2018-11-19 03:58:50 +01:00
}
2019-08-02 04:04:09 +02:00
return ` _ ` + cfg . App . SiteName + ` _ is a place for you to write and publish, powered by [WriteFreely](https://writefreely.org). `
2019-04-06 19:23:22 +02:00
}
2023-09-22 18:37:15 +02:00
func defaultContactPage ( app * App ) string {
c , err := app . db . GetCollectionByID ( 1 )
if err != nil {
return ""
}
return ` _ ` + app . cfg . App . SiteName + ` _ is administered by: [** ` + c . Alias + ` **](/ ` + c . Alias + ` / ) .
Contact them at this email address : _EMAIL GOES HERE_ .
You can also reach them here ... `
}
2019-04-06 19:23:22 +02:00
func defaultPrivacyPolicy ( cfg * config . Config ) string {
2019-04-12 03:33:33 +02:00
return ` [ WriteFreely ] ( https : //writefreely.org), the software that powers this site, is built to enforce your right to privacy by default.
2018-11-19 03:58:50 +01:00
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 .
2023-03-05 08:14:51 +01:00
We store log files , or data about what happens on our servers . We also use cookies to keep you logged into your account .
2018-11-19 03:58:50 +01:00
2019-04-06 19:23:22 +02:00
Beyond this , it ' s important that you trust whoever runs * * ` + 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 . `
2018-11-19 03:58:50 +01:00
}
2019-06-27 23:06:37 +02:00
func getLandingBanner ( app * App ) ( * instanceContent , error ) {
c , err := app . db . GetDynamicContent ( "landing-banner" )
if err != nil {
return nil , err
}
if c == nil {
c = & instanceContent {
ID : "landing-banner" ,
Type : "section" ,
Content : defaultLandingBanner ( app . cfg ) ,
Updated : defaultPageUpdatedTime ,
}
}
return c , nil
}
2019-06-28 04:22:21 +02:00
func getLandingBody ( app * App ) ( * instanceContent , error ) {
2019-06-27 23:06:37 +02:00
c , err := app . db . GetDynamicContent ( "landing-body" )
if err != nil {
return nil , err
}
if c == nil {
c = & instanceContent {
ID : "landing-body" ,
Type : "section" ,
Content : defaultLandingBody ( app . cfg ) ,
Updated : defaultPageUpdatedTime ,
}
}
return c , nil
}
func defaultLandingBanner ( cfg * config . Config ) string {
if cfg . App . Federation {
return "# Start your blog in the fediverse"
}
return "# Start your blog"
}
func defaultLandingBody ( cfg * config . Config ) string {
if cfg . App . Federation {
return ` # # Join the Fediverse
The fediverse is a large network of platforms that all speak a common language . Imagine if you could reply to Instagram posts from Twitter , or interact with your favorite Medium blogs from Facebook -- federated alternatives like [ PixelFed ] ( https : //pixelfed.org), [Mastodon](https://joinmastodon.org), and WriteFreely enable you to do these types of things.
< div style = "text-align:center" >
< iframe style = "width: 560px; height: 315px; max-width: 100%;" sandbox = "allow-same-origin allow-scripts" src = "https://video.writeas.org/videos/embed/cc55e615-d204-417c-9575-7b57674cc6f3" frameborder = "0" allowfullscreen > < / iframe >
< / div >
# # Write More Socially
WriteFreely can communicate with other federated platforms like Mastodon , so people can follow your blogs , bookmark their favorite posts , and boost them to their followers . Sign up above to create a blog and join the fediverse . `
}
return ""
}
2019-08-09 17:16:38 +02:00
func getReaderSection ( app * App ) ( * instanceContent , error ) {
c , err := app . db . GetDynamicContent ( "reader" )
if err != nil {
return nil , err
}
if c == nil {
c = & instanceContent {
ID : "reader" ,
Type : "section" ,
Content : defaultReaderBanner ( app . cfg ) ,
Updated : defaultPageUpdatedTime ,
}
}
if ! c . Title . Valid {
c . Title = defaultReaderTitle ( app . cfg )
}
return c , nil
}
func defaultReaderTitle ( cfg * config . Config ) sql . NullString {
return sql . NullString { String : "Reader" , Valid : true }
}
func defaultReaderBanner ( cfg * config . Config ) string {
return "Read the latest posts from " + cfg . App . SiteName + "."
}