Merge pull request #235 from writeas/date-stamps
Add dates to blog posts Resolves T669
This commit is contained in:
commit
659392ac4f
5 changed files with 22 additions and 16 deletions
|
@ -63,6 +63,7 @@ type (
|
||||||
TotalPosts int `json:"total_posts"`
|
TotalPosts int `json:"total_posts"`
|
||||||
Owner *User `json:"owner,omitempty"`
|
Owner *User `json:"owner,omitempty"`
|
||||||
Posts *[]PublicPost `json:"posts,omitempty"`
|
Posts *[]PublicPost `json:"posts,omitempty"`
|
||||||
|
Format *CollectionFormat
|
||||||
}
|
}
|
||||||
DisplayCollection struct {
|
DisplayCollection struct {
|
||||||
*CollectionObj
|
*CollectionObj
|
||||||
|
@ -70,7 +71,6 @@ type (
|
||||||
IsTopLevel bool
|
IsTopLevel bool
|
||||||
CurrentPage int
|
CurrentPage int
|
||||||
TotalPages int
|
TotalPages int
|
||||||
Format *CollectionFormat
|
|
||||||
Suspended bool
|
Suspended bool
|
||||||
}
|
}
|
||||||
SubmittedCollection struct {
|
SubmittedCollection struct {
|
||||||
|
@ -556,6 +556,13 @@ type CollectionPage struct {
|
||||||
CanInvite bool
|
CanInvite bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewCollectionObj(c *Collection) *CollectionObj {
|
||||||
|
return &CollectionObj{
|
||||||
|
Collection: *c,
|
||||||
|
Format: c.NewFormat(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *CollectionObj) ScriptDisplay() template.JS {
|
func (c *CollectionObj) ScriptDisplay() template.JS {
|
||||||
return template.JS(c.Script)
|
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 {
|
func newDisplayCollection(c *Collection, cr *collectionReq, page int) *DisplayCollection {
|
||||||
coll := &DisplayCollection{
|
coll := &DisplayCollection{
|
||||||
CollectionObj: &CollectionObj{Collection: *c},
|
CollectionObj: NewCollectionObj(c),
|
||||||
CurrentPage: page,
|
CurrentPage: page,
|
||||||
Prefix: cr.prefix,
|
Prefix: cr.prefix,
|
||||||
IsTopLevel: isSingleUser,
|
IsTopLevel: isSingleUser,
|
||||||
Format: c.NewFormat(),
|
|
||||||
}
|
}
|
||||||
c.db.GetPostsCount(coll.CollectionObj, cr.isCollOwner)
|
c.db.GetPostsCount(coll.CollectionObj, cr.isCollOwner)
|
||||||
return coll
|
return coll
|
||||||
|
|
|
@ -17,6 +17,16 @@ body {
|
||||||
font-size: 1.6em;
|
font-size: 1.6em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
article {
|
||||||
|
h2#title.dated {
|
||||||
|
margin-bottom: 0.5em;
|
||||||
|
}
|
||||||
|
time.dt-published {
|
||||||
|
display: block;
|
||||||
|
color: #666;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
posts.go
2
posts.go
|
@ -1354,7 +1354,7 @@ func viewCollectionPost(app *App, w http.ResponseWriter, r *http.Request) error
|
||||||
|
|
||||||
// Fetch extra data about the Collection
|
// Fetch extra data about the Collection
|
||||||
// TODO: refactor out this logic, shared in collection.go:fetchCollection()
|
// TODO: refactor out this logic, shared in collection.go:fetchCollection()
|
||||||
coll := &CollectionObj{Collection: *c}
|
coll := NewCollectionObj(c)
|
||||||
owner, err := app.db.GetUserByID(coll.OwnerID)
|
owner, err := app.db.GetUserByID(coll.OwnerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Log the error and just continue
|
// Log the error and just continue
|
||||||
|
|
|
@ -37,16 +37,6 @@ body footer {
|
||||||
}
|
}
|
||||||
body#post header {
|
body#post header {
|
||||||
padding: 1em 1rem;
|
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;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
@ -68,7 +58,7 @@ article time.dt-published {
|
||||||
{{if .Suspended}}
|
{{if .Suspended}}
|
||||||
{{template "user-suspended"}}
|
{{template "user-suspended"}}
|
||||||
{{end}}
|
{{end}}
|
||||||
<article id="post-body" class="{{.Font}} h-entry">{{if .IsScheduled}}<p class="badge">Scheduled</p>{{end}}{{if .Title.String}}<h2 id="title" class="p-name">{{.FormattedDisplayTitle}}</h2>{{end}}{{/* TODO: check format: if .Collection.Format.ShowDates*/}}<time class="dt-published" datetime="{{.Created}}" pubdate itemprop="datePublished" content="{{.Created}}">{{.DisplayDate}}</time><div class="e-content">{{.HTMLContent}}</div></article>
|
<article id="post-body" class="{{.Font}} h-entry">{{if .IsScheduled}}<p class="badge">Scheduled</p>{{end}}{{if .Title.String}}<h2 id="title" class="p-name{{if $.Collection.Format.ShowDates}} dated{{end}}">{{.FormattedDisplayTitle}}</h2>{{end}}{{if $.Collection.Format.ShowDates}}<time class="dt-published" datetime="{{.Created}}" pubdate itemprop="datePublished" content="{{.Created}}">{{.DisplayDate}}</time>{{end}}<div class="e-content">{{.HTMLContent}}</div></article>
|
||||||
|
|
||||||
{{ if .Collection.ShowFooterBranding }}
|
{{ if .Collection.ShowFooterBranding }}
|
||||||
<footer dir="ltr">
|
<footer dir="ltr">
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
{{if .Suspended}}
|
{{if .Suspended}}
|
||||||
{{template "user-suspended"}}
|
{{template "user-suspended"}}
|
||||||
{{end}}
|
{{end}}
|
||||||
<article id="post-body" class="{{.Font}} h-entry {{if not .IsFound}}error-page{{end}}">{{if .IsScheduled}}<p class="badge">Scheduled</p>{{end}}{{if .Title.String}}<h2 id="title" class="p-name">{{.FormattedDisplayTitle}}</h2>{{end}}<div class="e-content">{{.HTMLContent}}</div></article>
|
<article id="post-body" class="{{.Font}} h-entry {{if not .IsFound}}error-page{{end}}">{{if .IsScheduled}}<p class="badge">Scheduled</p>{{end}}{{if .Title.String}}<h2 id="title" class="p-name{{if $.Collection.Format.ShowDates}} dated{{end}}">{{.FormattedDisplayTitle}}</h2>{{end}}{{if $.Collection.Format.ShowDates}}<time class="dt-published" datetime="{{.Created}}" pubdate itemprop="datePublished" content="{{.Created}}">{{.DisplayDate}}</time>{{end}}<div class="e-content">{{.HTMLContent}}</div></article>
|
||||||
|
|
||||||
{{ if .Collection.ShowFooterBranding }}
|
{{ if .Collection.ShowFooterBranding }}
|
||||||
<footer dir="ltr"><hr><nav><p style="font-size: 0.9em">{{localhtml "published with write.as" .Language.String}}</p></nav></footer>
|
<footer dir="ltr"><hr><nav><p style="font-size: 0.9em">{{localhtml "published with write.as" .Language.String}}</p></nav></footer>
|
||||||
|
|
Loading…
Add table
Reference in a new issue