Skip to content

Commit

Permalink
Added WITH_FUTURE_DATES settings, which if true treats future dated c…
Browse files Browse the repository at this point in the history
…ontent as drafts.
  • Loading branch information
jokull committed Nov 26, 2011
1 parent 082cc2a commit dc22d2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pelican/contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pelican.utils import slugify, truncate_html_words
from pelican.log import *
from pelican.settings import _DEFAULT_CONFIG
from datetime import datetime
from os import getenv
from sys import platform, stdin

Expand All @@ -23,8 +24,6 @@ def __init__(self, content, metadata=None, settings=None, filename=None):
self._content = content
self.translations = []

self.status = "published" # default value

local_metadata = dict(settings.get('DEFAULT_METADATA', ()))
local_metadata.update(metadata)

Expand Down Expand Up @@ -87,7 +86,10 @@ def __init__(self, content, metadata=None, settings=None, filename=None):
# manage status
if not hasattr(self, 'status'):
self.status = settings['DEFAULT_STATUS']

if not settings['WITH_FUTURE_DATES']:
if hasattr(self, 'date') and self.date > datetime.now():
self.status = 'draft'

# set summary
if not hasattr(self, 'summary'):
self.summary = truncate_html_words(self.content, 50)
Expand Down
1 change: 1 addition & 0 deletions pelican/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
'PDF_GENERATOR': False,
'DEFAULT_CATEGORY': 'misc',
'FALLBACK_ON_FS_DATE': True,
'WITH_FUTURE_DATES': True,
'CSS_FILE': 'main.css',
'REVERSE_ARCHIVE_ORDER': False,
'REVERSE_CATEGORY_ORDER': False,
Expand Down

0 comments on commit dc22d2b

Please sign in to comment.