Browse Source

Fix Microformats query for post, schedule post if it's posted without status and published time is in the future

master
Jan-Lukas Else 2 weeks ago
parent
commit
db6c54f3bf
  1. 10
      postsDb.go
  2. 11
      postsFuncs.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 {

11
postsFuncs.go

@ -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 &microformatItem{
Type: []string{"h-entry"},

Loading…
Cancel
Save