mirror of https://github.com/jlelse/GoBlog
Fix Microformats query for post, schedule post if it's posted without status and published time is in the future
This commit is contained in:
parent
337392112b
commit
db6c54f3bf
10
postsDb.go
10
postsDb.go
|
@ -37,6 +37,16 @@ func (a *goBlog) checkPost(p *post) (err error) {
|
|||
// Check status
|
||||
if p.Status == "" {
|
||||
p.Status = statusPublished
|
||||
if p.Published != "" {
|
||||
// If published time is in the future, set status to scheduled
|
||||
publishedTime, err := dateparse.ParseLocal(p.Published)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if publishedTime.After(time.Now()) {
|
||||
p.Status = statusScheduled
|
||||
}
|
||||
}
|
||||
}
|
||||
// Cleanup params
|
||||
for key, value := range p.Parameters {
|
||||
|
|
|
@ -155,15 +155,20 @@ func (a *goBlog) postToMfItem(p *post) *microformatItem {
|
|||
switch p.Status {
|
||||
case statusDraft:
|
||||
mfStatus = "draft"
|
||||
case statusPublished, statusScheduled:
|
||||
case statusPublished, statusScheduled, statusUnlisted, statusPrivate:
|
||||
mfStatus = "published"
|
||||
case statusPublishedDeleted, statusDraftDeleted, statusPrivateDeleted, statusUnlistedDeleted, statusScheduledDeleted:
|
||||
mfStatus = "deleted"
|
||||
}
|
||||
switch p.Status {
|
||||
case statusDraft, statusScheduled, statusPublished:
|
||||
mfVisibility = "public"
|
||||
case statusUnlisted:
|
||||
mfStatus = "published"
|
||||
mfVisibility = "unlisted"
|
||||
case statusPrivate:
|
||||
mfStatus = "published"
|
||||
mfVisibility = "private"
|
||||
case statusPublishedDeleted, statusDraftDeleted, statusPrivateDeleted, statusUnlistedDeleted, statusScheduledDeleted:
|
||||
mfVisibility = "deleted"
|
||||
}
|
||||
return µformatItem{
|
||||
Type: []string{"h-entry"},
|
||||
|
|
Loading…
Reference in New Issue