Scheduled
{{end}}{{if .Title.String}}diff --git a/account.go b/account.go index d8ea0df..66a3fa0 100644 --- a/account.go +++ b/account.go @@ -21,6 +21,7 @@ import ( "github.com/writeas/web-core/data" "github.com/writeas/web-core/log" "github.com/writeas/writefreely/author" + "github.com/writeas/writefreely/config" "github.com/writeas/writefreely/page" "html/template" "net/http" @@ -58,11 +59,15 @@ func NewUserPage(app *App, r *http.Request, u *User, title string, flashes []str up.Flashes = flashes up.Path = r.URL.Path up.IsAdmin = u.IsAdmin() - up.CanInvite = app.cfg.App.UserInvites != "" && - (up.IsAdmin || app.cfg.App.UserInvites != "admin") + up.CanInvite = canUserInvite(app.cfg, up.IsAdmin) return up } +func canUserInvite(cfg *config.Config, isAdmin bool) bool { + return cfg.App.UserInvites != "" && + (isAdmin || cfg.App.UserInvites != "admin") +} + func (up *UserPage) SetMessaging(u *User) { //up.NeedsAuth = app.db.DoesUserNeedAuth(u.ID) } diff --git a/app.go b/app.go index 6d6a689..68ba7c7 100644 --- a/app.go +++ b/app.go @@ -317,6 +317,8 @@ func pageForReq(app *App, r *http.Request) page.StaticPage { u = getUserSession(app, r) if u != nil { p.Username = u.Username + p.IsAdmin = u != nil && u.IsAdmin() + p.CanInvite = canUserInvite(app.cfg, p.IsAdmin) } } p.CanViewReader = !app.cfg.App.Private || u != nil diff --git a/collections.go b/collections.go index 1a8ceca..0d2549a 100644 --- a/collections.go +++ b/collections.go @@ -525,6 +525,8 @@ type CollectionPage struct { Username string Collections *[]Collection PinnedPosts *[]PublicPost + IsAdmin bool + CanInvite bool } func (c *CollectionObj) ScriptDisplay() template.JS { @@ -737,6 +739,8 @@ func handleViewCollection(app *App, w http.ResponseWriter, r *http.Request) erro IsCustomDomain: cr.isCustomDomain, IsWelcome: r.FormValue("greeting") != "", } + displayPage.IsAdmin = u != nil && u.IsAdmin() + displayPage.CanInvite = canUserInvite(app.cfg, displayPage.IsAdmin) var owner *User if u != nil { displayPage.Username = u.Username @@ -768,7 +772,11 @@ func handleViewCollection(app *App, w http.ResponseWriter, r *http.Request) erro // TODO: fix this mess of collections inside collections displayPage.PinnedPosts, _ = app.db.GetPinnedPosts(coll.CollectionObj) - err = templates["collection"].ExecuteTemplate(w, "collection", displayPage) + collTmpl := "collection" + if app.cfg.App.Chorus { + collTmpl = "chorus-collection" + } + err = templates[collTmpl].ExecuteTemplate(w, "collection", displayPage) if err != nil { log.Error("Unable to render collection index: %v", err) } diff --git a/config/config.go b/config/config.go index d026a74..9a1db52 100644 --- a/config/config.go +++ b/config/config.go @@ -69,6 +69,7 @@ type ( WebFonts bool `ini:"webfonts"` Landing string `ini:"landing"` SimpleNav bool `ini:"simple_nav"` + Chorus bool `ini:"chorus"` // Users SingleUser bool `ini:"single_user"` diff --git a/page/page.go b/page/page.go index 2af5322..15f09a9 100644 --- a/page/page.go +++ b/page/page.go @@ -28,6 +28,8 @@ type StaticPage struct { Values map[string]string Flashes []string CanViewReader bool + IsAdmin bool + CanInvite bool } // SanitizeHost alters the StaticPage to contain a real hostname. This is diff --git a/posts.go b/posts.go index 07902ce..b1ce20f 100644 --- a/posts.go +++ b/posts.go @@ -1345,15 +1345,24 @@ func viewCollectionPost(app *App, w http.ResponseWriter, r *http.Request) error IsPinned bool IsCustomDomain bool PinnedPosts *[]PublicPost + IsAdmin bool + CanInvite bool }{ PublicPost: p, StaticPage: pageForReq(app, r), IsOwner: cr.isCollOwner, IsCustomDomain: cr.isCustomDomain, } + tp.IsAdmin = u != nil && u.IsAdmin() + tp.CanInvite = canUserInvite(app.cfg, tp.IsAdmin) tp.PinnedPosts, _ = app.db.GetPinnedPosts(coll) tp.IsPinned = len(*tp.PinnedPosts) > 0 && PostsContains(tp.PinnedPosts, p) - if err := templates["collection-post"].ExecuteTemplate(w, "post", tp); err != nil { + + postTmpl := "collection-post" + if app.cfg.App.Chorus { + postTmpl = "chorus-collection-post" + } + if err := templates[postTmpl].ExecuteTemplate(w, "post", tp); err != nil { log.Error("Error in collection-post template: %v", err) } } diff --git a/read.go b/read.go index 683f124..fa350fa 100644 --- a/read.go +++ b/read.go @@ -48,6 +48,8 @@ type readPublication struct { CurrentPage int TotalPages int SelTopic string + IsAdmin bool + CanInvite bool } func initLocalTimeline(app *App) { @@ -198,11 +200,16 @@ func showLocalTimeline(app *App, w http.ResponseWriter, r *http.Request, page in } d := &readPublication{ - pageForReq(app, r), - &posts, - page, - ttlPages, - tag, + StaticPage: pageForReq(app, r), + Posts: &posts, + CurrentPage: page, + TotalPages: ttlPages, + SelTopic: tag, + } + if app.cfg.App.Chorus { + u := getUserSession(app, r) + d.IsAdmin = u != nil && u.IsAdmin() + d.CanInvite = canUserInvite(app.cfg, d.IsAdmin) } err := templates["read"].ExecuteTemplate(w, "base", d) diff --git a/templates.go b/templates.go index 7a45c45..6e9a008 100644 --- a/templates.go +++ b/templates.go @@ -64,11 +64,14 @@ func initTemplate(parentDir, name string) { filepath.Join(parentDir, templatesDir, "include", "footer.tmpl"), filepath.Join(parentDir, templatesDir, "base.tmpl"), } - if name == "collection" || name == "collection-tags" { + if name == "collection" || name == "collection-tags" || name == "chorus-collection" { // These pages list out collection posts, so we also parse templatesDir + "include/posts.tmpl" files = append(files, filepath.Join(parentDir, templatesDir, "include", "posts.tmpl")) } - if name == "collection" || name == "collection-tags" || name == "collection-post" || name == "post" { + if name == "chorus-collection" || name == "chorus-collection-post" { + files = append(files, filepath.Join(parentDir, templatesDir, "user", "include", "header.tmpl")) + } + if name == "collection" || name == "collection-tags" || name == "collection-post" || name == "post" || name == "chorus-collection" || name == "chorus-collection-post" { files = append(files, filepath.Join(parentDir, templatesDir, "include", "post-render.tmpl")) } templates[name] = template.Must(template.New("").Funcs(funcMap).ParseFiles(files...)) diff --git a/templates/base.tmpl b/templates/base.tmpl index c1f17ad..41b0f2a 100644 --- a/templates/base.tmpl +++ b/templates/base.tmpl @@ -13,14 +13,38 @@
Scheduled
{{end}}{{if .Title.String}}{{.Description}}
{{end}} + {{/*if not .Public/*}} + + {{/*end*/}} + {{if .PinnedPosts}}This is your new blog.
+Start writing, or customize your blog.
+Check out our writing guide to see what else you can do, and get in touch anytime with questions or feedback.
+