Skip to content
Browse files

добавил DRAFT в сабжекте как маркер черновиков

  • Loading branch information...
1 parent fc3b3e1 commit 5d22fbb070e4d838d6bc0d75e6b18c0f7ff7010e @bobuk committed Apr 22, 2012
Showing with 28 additions and 11 deletions.
  1. +28 −11 blogit
View
39 blogit
@@ -102,7 +102,8 @@ class MarkDownEntry(Entry):
title, rest = self.content.split('\n', 1)
self.title = title
self.content = rest
- self.content = markdown.markdown(self.content)#.replace('\n','')
+ self.draft = 'draft' in self.title or 'DRAFT' in self.title
+ self.content = markdown.markdown(self.content)
self.result = os.path.join(config['local']['results']['posts'],
self.page, 'index.html')
self.permalink = config['site'] + config['local']['results']['site'] + self.page
@@ -128,6 +129,8 @@ class Archive:
def do(self, template):
items = []
for x in reversed(self.idx['idx']):
+ if 'draft' in self.idx[x] and self.idx[x]['draft']:
+ continue
items.append({
'fname': self.idx[x]['permalink'],
'subtitle': self.idx[x]['title'],
@@ -152,6 +155,8 @@ class RSS:
url=config['site'][:-1] if config['site'].endswith('/') else config['site'],
author=config['author'])
for x in list(reversed(self.idx['idx']))[:10]:
+ if 'draft' in self.idx[x] and self.idx[x]['draft']:
+ continue
page = MarkDownEntry(x)
feed.add(title=self.idx[x]['title'],
content= page.content,
@@ -208,21 +213,33 @@ def gen(page=current_date, force=False):
if page in idx and os.path.getmtime(fpath) <= idx[page]['cdate']:
return
entry = MarkDownEntry(page)
- with Index(ro=True) as idx:
- if (page not in idx['idx']) or (idx['idx'][-1] == page):
- entry.is_index = True
- entry.do(config['local']['templates']['post'])
- sys.stdout.write('File %s writen\n' % entry.result)
- if entry.is_index:
- entry.do_to(config['local']['templates']['post'],
- config['local']['results']['path'] + 'index.html')
- sys.stdout.write('Page ' + page + ' also is index\n')
+ if entry.draft:
+ sys.stdout.write('Page '+ page + ' drafted.\n' )
+ else:
+ with Index(ro=True) as idx:
+ if page not in idx['idx']:
+ entry.is_index = True
+ else:
+ last = None
+ for x in reversed(idx['idx']):
+ if 'draft' not in idx[x] or idx[x]['draft'] == False:
+ last = x
+ break
+ if x == page:
+ entry.is_index = True
+ entry.do(config['local']['templates']['post'])
+ sys.stdout.write('File %s writen\n' % entry.result)
+ if entry.is_index:
+ entry.do_to(config['local']['templates']['post'],
+ config['local']['results']['path'] + 'index.html')
+ sys.stdout.write('Page ' + page + ' also is index\n')
with Index() as idx:
idx[page] = dict(
permalink = entry.permalink,
title = entry.title,
cdate = entry.cdate,
- fdate = entry.fdate
+ fdate = entry.fdate,
+ draft = entry.draft,
)
if page not in idx['idx']:
idx['idx'].append(page)

0 comments on commit 5d22fbb

Please sign in to comment.
Something went wrong with that request. Please try again.