コード例 #1
0
ファイル: blog.py プロジェクト: Stonelinks/stonelinks.org
def make_blog(p):
  blog = blog_dict(p)
  
  blog_entries = []
  blog_indexes = []
  for k in reversed(sorted(blog.iterkeys())):
    blog_entries.append(blog[k])
  
  i = 0
  for j in range(0, len(blog_entries), config.blog_entries_per_page):
    segment = blog_entries[j:j + config.blog_entries_per_page]
    
    s = ''
    sidebar = '<h3>Other Posts</h3>'
    sidebar += '<ul class="nav nav-list">'

    for c, summary in segment:
      s += summary
      sidebar += '<li>%s</li>' % (utils.page_link(c))
    sidebar += '<li class="divider"></li>'
    sidebar += '<li><a href="{{wr}}blog/archives.html"><b>All Entries &rarr;</b></a></li>'
    sidebar += '<li class="divider"></li>'
    sidebar += '<li><a onclick="goBack()"><b>&larr; Go Back</b></a></li>'
    sidebar += '</ul>'
    
    for c, _ in segment:
      c.sidebar = sidebar.replace('<li><a href="%s">%s</a></li>' % (c.address(), c.human_name), \
                  '<li class="active"><a href="%s">%s</a></li>' % (c.address(), c.human_name))
    
    n = objects.page()
    n.human_name = 'Blog'
    n.name = 'index'
    if i > 0:
      n.name += str(i)
      n.human_name = 'Page ' + str(i + 1)
    i += 1
    n.level = p.level + 1
    n.path = os.path.join(p.path, 'blog')
    n.destination = os.path.join(p.destination, 'blog')
    n.omit_sidebar = False
    n.sidebar = sidebar
    n.content = s
    n.enable_comments = False
    p.children.append(n)
    blog_indexes.append(n)
  
  pagination(blog_entries, blog_indexes)
  p.children.append(full_archive(p, blog_entries))
コード例 #2
0
ファイル: blog.py プロジェクト: Stonelinks/stonelinks.org
def full_archive(p, blog_entries):
  full_archives = objects.page()
  full_archives.human_name = 'Full Archives'
  full_archives.name = 'archives'
  full_archives.level = p.level + 1
  full_archives.path = os.path.join(p.path, 'blog')
  full_archives.destination = os.path.join(p.destination, 'blog')
  full_archives.omit_sidebar = False
  full_archives.enable_comments = False
  full_archives.sidebar = '<h3>Archives</h3>'
  full_archives.sidebar += '<ul class="nav nav-list">'
  for c, summary in blog_entries:
    full_archives.content += summary
    full_archives.sidebar += '<li><a href="%s">%s</a></li>' % (c.address(), c.human_name)
  full_archives.sidebar += '</ul>'
  return full_archives