A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

199 行
5.7 KiB

  1. /*
  2. * Copyright © 2018-2019, 2021 Musing Studio LLC.
  3. *
  4. * This file is part of WriteFreely.
  5. *
  6. * WriteFreely is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License, included
  8. * in the LICENSE file in this source code package.
  9. */
  10. package writefreely
  11. import (
  12. "database/sql"
  13. "github.com/writefreely/writefreely/config"
  14. "time"
  15. )
  16. var defaultPageUpdatedTime = time.Date(2018, 11, 8, 12, 0, 0, 0, time.Local)
  17. func getAboutPage(app *App) (*instanceContent, error) {
  18. c, err := app.db.GetDynamicContent("about")
  19. if err != nil {
  20. return nil, err
  21. }
  22. if c == nil {
  23. c = &instanceContent{
  24. ID: "about",
  25. Type: "page",
  26. Content: defaultAboutPage(app.cfg),
  27. }
  28. }
  29. if !c.Title.Valid {
  30. c.Title = defaultAboutTitle(app.cfg)
  31. }
  32. return c, nil
  33. }
  34. func defaultAboutTitle(cfg *config.Config) sql.NullString {
  35. return sql.NullString{String: "About " + cfg.App.SiteName, Valid: true}
  36. }
  37. func getContactPage(app *App) (*instanceContent, error) {
  38. c, err := app.db.GetDynamicContent("contact")
  39. if err != nil {
  40. return nil, err
  41. }
  42. if c == nil {
  43. c = &instanceContent{
  44. ID: "contact",
  45. Type: "page",
  46. Content: defaultContactPage(app),
  47. }
  48. }
  49. if !c.Title.Valid {
  50. c.Title = defaultContactTitle()
  51. }
  52. return c, nil
  53. }
  54. func defaultContactTitle() sql.NullString {
  55. return sql.NullString{String: "Contact Us", Valid: true}
  56. }
  57. func getPrivacyPage(app *App) (*instanceContent, error) {
  58. c, err := app.db.GetDynamicContent("privacy")
  59. if err != nil {
  60. return nil, err
  61. }
  62. if c == nil {
  63. c = &instanceContent{
  64. ID: "privacy",
  65. Type: "page",
  66. Content: defaultPrivacyPolicy(app.cfg),
  67. Updated: defaultPageUpdatedTime,
  68. }
  69. }
  70. if !c.Title.Valid {
  71. c.Title = defaultPrivacyTitle()
  72. }
  73. return c, nil
  74. }
  75. func defaultPrivacyTitle() sql.NullString {
  76. return sql.NullString{String: "Privacy Policy", Valid: true}
  77. }
  78. func defaultAboutPage(cfg *config.Config) string {
  79. if cfg.App.Federation {
  80. return `_` + cfg.App.SiteName + `_ is an interconnected place for you to write and publish, powered by [WriteFreely](https://writefreely.org) and ActivityPub.`
  81. }
  82. return `_` + cfg.App.SiteName + `_ is a place for you to write and publish, powered by [WriteFreely](https://writefreely.org).`
  83. }
  84. func defaultContactPage(app *App) string {
  85. c, err := app.db.GetCollectionByID(1)
  86. if err != nil {
  87. return ""
  88. }
  89. return `_` + app.cfg.App.SiteName + `_ is administered by: [**` + c.Alias + `**](/` + c.Alias + `/).
  90. Contact them at this email address: _EMAIL GOES HERE_.
  91. You can also reach them here...`
  92. }
  93. func defaultPrivacyPolicy(cfg *config.Config) string {
  94. return `[WriteFreely](https://writefreely.org), the software that powers this site, is built to enforce your right to privacy by default.
  95. 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.
  96. We store log files, or data about what happens on our servers. We also use cookies to keep you logged in to your account.
  97. 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.`
  98. }
  99. func getLandingBanner(app *App) (*instanceContent, error) {
  100. c, err := app.db.GetDynamicContent("landing-banner")
  101. if err != nil {
  102. return nil, err
  103. }
  104. if c == nil {
  105. c = &instanceContent{
  106. ID: "landing-banner",
  107. Type: "section",
  108. Content: defaultLandingBanner(app.cfg),
  109. Updated: defaultPageUpdatedTime,
  110. }
  111. }
  112. return c, nil
  113. }
  114. func getLandingBody(app *App) (*instanceContent, error) {
  115. c, err := app.db.GetDynamicContent("landing-body")
  116. if err != nil {
  117. return nil, err
  118. }
  119. if c == nil {
  120. c = &instanceContent{
  121. ID: "landing-body",
  122. Type: "section",
  123. Content: defaultLandingBody(app.cfg),
  124. Updated: defaultPageUpdatedTime,
  125. }
  126. }
  127. return c, nil
  128. }
  129. func defaultLandingBanner(cfg *config.Config) string {
  130. if cfg.App.Federation {
  131. return "# Start your blog in the fediverse"
  132. }
  133. return "# Start your blog"
  134. }
  135. func defaultLandingBody(cfg *config.Config) string {
  136. if cfg.App.Federation {
  137. return `## Join the Fediverse
  138. 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.
  139. <div style="text-align:center">
  140. <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>
  141. </div>
  142. ## Write More Socially
  143. 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.`
  144. }
  145. return ""
  146. }
  147. func getReaderSection(app *App) (*instanceContent, error) {
  148. c, err := app.db.GetDynamicContent("reader")
  149. if err != nil {
  150. return nil, err
  151. }
  152. if c == nil {
  153. c = &instanceContent{
  154. ID: "reader",
  155. Type: "section",
  156. Content: defaultReaderBanner(app.cfg),
  157. Updated: defaultPageUpdatedTime,
  158. }
  159. }
  160. if !c.Title.Valid {
  161. c.Title = defaultReaderTitle(app.cfg)
  162. }
  163. return c, nil
  164. }
  165. func defaultReaderTitle(cfg *config.Config) sql.NullString {
  166. return sql.NullString{String: "Reader", Valid: true}
  167. }
  168. func defaultReaderBanner(cfg *config.Config) string {
  169. return "Read the latest posts from " + cfg.App.SiteName + "."
  170. }