Ejemplo n.º 1
0
def get_root():
  overwrite = request.query.overwrite or False
  return ''.join((
    get_header(overwrite=overwrite),
    get_index(overwrite=overwrite),
    get_footer(overwrite=overwrite)
  ))
Ejemplo n.º 2
0
def route_post_md(post_id=None):
  req_type = request.query.type

  if req_type == 'json':
    return {'post': get_post_no(post_id)}
  else:
    template  = memcache.get('')
    overwrite = request.query.overwrite or False

    return ''.join((
      get_header(overwrite=overwrite),
      markdown.markdown(
        split_file(get_post_no(post_id, overwrite=overwrite))[1]
      ),
      get_footer(overwrite=overwrite)
    ))
Ejemplo n.º 3
0
def route_posts(fun=get_posts_html, **kw):
  '''Returns a JSON dictionary about current posts'''

  posts = get_posts_time()
  overwrite = request.query.overwrite or False
  kw['overwrite'] = overwrite

  logging.info('overwrite: %s' % overwrite)

  posts = [
    get_post_front_matter(
      post.get('path'),
      overwrite=overwrite
    ) for post in posts
  ]
  
  req_type = request.query.type
  if req_type == 'json':
  
    return {
      'posts': [{
          'id': id_val,
          'time': x.get('time'),
          'last_modified': x.get('time'),
          'title': x.get('title')
        } for id_val, x in enumerate(posts)
      ]}

  else:
    return (
      ''.join((
      get_header(**kw),
      fun(**kw),
      '<ul>%s</ul>' % '\n'.join(
      ["<li><a href='/posts/%s'>%s</a></li>" % 
        (pid, x.get('title')) for pid, x in enumerate(posts)
      ]),
      get_footer(**kw)
    )))