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
|
// Check status
|
||||||
if p.Status == "" {
|
if p.Status == "" {
|
||||||
p.Status = statusPublished
|
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
|
// Cleanup params
|
||||||
for key, value := range p.Parameters {
|
for key, value := range p.Parameters {
|
||||||
|
|
|
@ -155,15 +155,20 @@ func (a *goBlog) postToMfItem(p *post) *microformatItem {
|
||||||
switch p.Status {
|
switch p.Status {
|
||||||
case statusDraft:
|
case statusDraft:
|
||||||
mfStatus = "draft"
|
mfStatus = "draft"
|
||||||
case statusPublished, statusScheduled:
|
case statusPublished, statusScheduled, statusUnlisted, statusPrivate:
|
||||||
mfStatus = "published"
|
mfStatus = "published"
|
||||||
|
case statusPublishedDeleted, statusDraftDeleted, statusPrivateDeleted, statusUnlistedDeleted, statusScheduledDeleted:
|
||||||
|
mfStatus = "deleted"
|
||||||
|
}
|
||||||
|
switch p.Status {
|
||||||
|
case statusDraft, statusScheduled, statusPublished:
|
||||||
mfVisibility = "public"
|
mfVisibility = "public"
|
||||||
case statusUnlisted:
|
case statusUnlisted:
|
||||||
mfStatus = "published"
|
|
||||||
mfVisibility = "unlisted"
|
mfVisibility = "unlisted"
|
||||||
case statusPrivate:
|
case statusPrivate:
|
||||||
mfStatus = "published"
|
|
||||||
mfVisibility = "private"
|
mfVisibility = "private"
|
||||||
|
case statusPublishedDeleted, statusDraftDeleted, statusPrivateDeleted, statusUnlistedDeleted, statusScheduledDeleted:
|
||||||
|
mfVisibility = "deleted"
|
||||||
}
|
}
|
||||||
return µformatItem{
|
return µformatItem{
|
||||||
Type: []string{"h-entry"},
|
Type: []string{"h-entry"},
|
||||||
|
|
Loading…
Reference in New Issue