From 812136357e9ee2bf4aa940f64b3ebcfeed9a06e7 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Thu, 9 Jan 2020 16:48:22 -0500 Subject: [PATCH 1/2] Move Format from DisplayCollection to CollectionObj --- collections.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/collections.go b/collections.go index 66ad7a0..5c9a1b7 100644 --- a/collections.go +++ b/collections.go @@ -63,6 +63,7 @@ type ( TotalPosts int `json:"total_posts"` Owner *User `json:"owner,omitempty"` Posts *[]PublicPost `json:"posts,omitempty"` + Format *CollectionFormat } DisplayCollection struct { *CollectionObj @@ -70,7 +71,6 @@ type ( IsTopLevel bool CurrentPage int TotalPages int - Format *CollectionFormat Suspended bool } SubmittedCollection struct { @@ -556,6 +556,13 @@ type CollectionPage struct { CanInvite bool } +func NewCollectionObj(c *Collection) *CollectionObj { + return &CollectionObj{ + Collection: *c, + Format: c.NewFormat(), + } +} + func (c *CollectionObj) ScriptDisplay() template.JS { return template.JS(c.Script) } @@ -705,11 +712,10 @@ func checkUserForCollection(app *App, cr *collectionReq, r *http.Request, isPost func newDisplayCollection(c *Collection, cr *collectionReq, page int) *DisplayCollection { coll := &DisplayCollection{ - CollectionObj: &CollectionObj{Collection: *c}, + CollectionObj: NewCollectionObj(c), CurrentPage: page, Prefix: cr.prefix, IsTopLevel: isSingleUser, - Format: c.NewFormat(), } c.db.GetPostsCount(coll.CollectionObj, cr.isCollOwner) return coll From 9958a1122bac318f9f2f6f1dfeddec607d0ef602 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Thu, 9 Jan 2020 16:50:02 -0500 Subject: [PATCH 2/2] Show published date on post pages if Blog Dates now display on blog post pages if the collection's chosen display format is "Blog". It updates the chorus-collection-post template to now respect this value (previously, it always showed the date). Ref T669 --- less/post-temp.less | 10 ++++++++++ posts.go | 2 +- templates/chorus-collection-post.tmpl | 12 +----------- templates/collection-post.tmpl | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/less/post-temp.less b/less/post-temp.less index 3ec682d..8173864 100644 --- a/less/post-temp.less +++ b/less/post-temp.less @@ -17,6 +17,16 @@ body { font-size: 1.6em; } } + article { + h2#title.dated { + margin-bottom: 0.5em; + } + time.dt-published { + display: block; + color: #666; + margin-bottom: 1em; + } + } } } diff --git a/posts.go b/posts.go index 21ed1a1..d2fbcca 100644 --- a/posts.go +++ b/posts.go @@ -1354,7 +1354,7 @@ func viewCollectionPost(app *App, w http.ResponseWriter, r *http.Request) error // Fetch extra data about the Collection // TODO: refactor out this logic, shared in collection.go:fetchCollection() - coll := &CollectionObj{Collection: *c} + coll := NewCollectionObj(c) owner, err := app.db.GetUserByID(coll.OwnerID) if err != nil { // Log the error and just continue diff --git a/templates/chorus-collection-post.tmpl b/templates/chorus-collection-post.tmpl index b9df8ad..0e1164b 100644 --- a/templates/chorus-collection-post.tmpl +++ b/templates/chorus-collection-post.tmpl @@ -37,16 +37,6 @@ body footer { } body#post header { padding: 1em 1rem; -} -article time.dt-published { - display: block; - color: #666; -} -body#post article h2#title{ - margin-bottom: 0.5em; -} -article time.dt-published { - margin-bottom: 1em; } @@ -68,7 +58,7 @@ article time.dt-published { {{if .Suspended}} {{template "user-suspended"}} {{end}} -
{{if .IsScheduled}}

Scheduled

{{end}}{{if .Title.String}}

{{.FormattedDisplayTitle}}

{{end}}{{/* TODO: check format: if .Collection.Format.ShowDates*/}}
{{.HTMLContent}}
+
{{if .IsScheduled}}

Scheduled

{{end}}{{if .Title.String}}

{{.FormattedDisplayTitle}}

{{end}}{{if $.Collection.Format.ShowDates}}{{end}}
{{.HTMLContent}}
{{ if .Collection.ShowFooterBranding }}