Esempio n. 1
0
def post(pid):
    try:
        p = fromcache("post-%s" % str(pid)) or tocache("post-%s" % str(pid),wordpress.getPost(pid))
    except:
        return abort(404)
    """View that renders a post template"""
    recent_posts = fromcache("recent_posts") or tocache("recent_posts", wordpress.getRecentPosts(
        post_status='publish',
        numberposts=4))
    #Retorna a ultima foto inserida neste album.
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    cmts = fromcache("comentarios%s" % str(pid)) or tocache("comentarios%s" % str(pid),  wordpress.getComments(status='approve',post_id=pid))
    tags = fromcache("tags") or tocache("tags", wordpress.getTagCloud())
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    # live_comment_ = request.cookies.get('live_comment_save')
    return render_template(
        'post.html',
        post=p,
        tags=tags,
        sidebar=wordpress.getSidebar,
        # live_comment_save=live_comment_,
        # picday=picday,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        menu=menus,
        comments=cmts,
        show_comment_form=is_authenticated(),
        recent_posts=recent_posts)
Esempio n. 2
0
def post_slug(slug):
    try:
        post = fromcache("post-%s" % slug) or tocache(
            "post-%s" % slug, wordpress.getPostByPath(slug))
        if not post['id']:
            abort(404)
    except:
        abort(404)

    print '=============================================================================='
    print post
    print '=============================================================================='

    pid = post['id']

    if 'the_date' not in post.keys():
        # post['the_date'] = post['date']['date'].value
        post['the_date'] = datetime.datetime.strptime(
            post['date']['date'].value, '%Y%m%dT%H:%M:%S')
    """View that renders a post template"""
    recent_posts = fromcache("recent_posts") or tocache(
        "recent_posts",
        wordpress.getRecentPosts(post_status='publish', numberposts=4))
    #Retorna a ultima foto inserida neste album.
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)
    menus = fromcache('menuprincipal') or tocache(
        'menuprincipal',
        wordpress.exapi.getMenuItens(menu_slug='menu-principal'))
    # cmts = fromcache("comentarios_post_slug-%s"%slug) or tocache("comentarios_post_slug-%s"%slug, wordpress.getComments(status='approve',post_id=pid))
    tags = fromcache("tags") or tocache("tags", wordpress.getTagCloud())
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    # live_comment_ = request.cookies.get('live_comment_save')
    # if live_comment_:
    #     live_comment_ = live_comment_.replace('<br/>','\n')

    resp = make_response(
        render_template(
            'post.html',
            post=post,
            tags=tags,
            # live_comment_save=live_comment_,
            sidebar=wordpress.getSidebar,
            # picday=picday,
            twitter_hash_cabecalho=twitter_hash_cabecalho,
            menu=menus,
            base_url=app.config['BASE_URL'],
            # comments=cmts,
            show_comment_form=is_authenticated(),
            recent_posts=recent_posts))
    # resp.set_cookie('live_comment_save', "" )
    return resp
Esempio n. 3
0
def post_slug(slug):
    try:
        post = fromcache("post-%s" % slug) or tocache("post-%s" % slug, wordpress.getPostByPath(slug))
        if not post['id']:
            abort(404)
    except:
        abort(404)

    print '=============================================================================='
    print post
    print '=============================================================================='

    pid = post['id']

    if 'the_date' not in post.keys():
        # post['the_date'] = post['date']['date'].value
        post['the_date'] = datetime.datetime.strptime(post['date']['date'].value,'%Y%m%dT%H:%M:%S')

    """View that renders a post template"""
    recent_posts = fromcache("recent_posts") or tocache("recent_posts", wordpress.getRecentPosts(
        post_status='publish',
        numberposts=4))
    #Retorna a ultima foto inserida neste album.
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    # cmts = fromcache("comentarios_post_slug-%s"%slug) or tocache("comentarios_post_slug-%s"%slug, wordpress.getComments(status='approve',post_id=pid))
    tags = fromcache("tags") or tocache("tags", wordpress.getTagCloud())
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    # live_comment_ = request.cookies.get('live_comment_save')
    # if live_comment_:
    #     live_comment_ = live_comment_.replace('<br/>','\n')

    resp = make_response(
     render_template(
        'post.html',
        post=post,
        tags=tags,
        # live_comment_save=live_comment_,
        sidebar=wordpress.getSidebar,
        # picday=picday,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        menu=menus,
        base_url=app.config['BASE_URL'],
        # comments=cmts,
        show_comment_form=is_authenticated(),
        recent_posts=recent_posts)
    )
    # resp.set_cookie('live_comment_save', "" )
    return resp
Esempio n. 4
0
def post(pid):
    try:
        p = fromcache("post-%s" % str(pid)) or tocache("post-%s" % str(pid),
                                                       wordpress.getPost(pid))
    except:
        return abort(404)
    """View that renders a post template"""
    recent_posts = fromcache("recent_posts") or tocache(
        "recent_posts",
        wordpress.getRecentPosts(post_status='publish', numberposts=4))
    #Retorna a ultima foto inserida neste album.
    # picday = wordpress.wpgd.getLastFromGallery(conf.GALLERIA_FOTO_DO_DIA_ID)
    menus = fromcache('menuprincipal') or tocache(
        'menuprincipal',
        wordpress.exapi.getMenuItens(menu_slug='menu-principal'))
    cmts = fromcache("comentarios%s" % str(pid)) or tocache(
        "comentarios%s" % str(pid),
        wordpress.getComments(status='approve', post_id=pid))
    tags = fromcache("tags") or tocache("tags", wordpress.getTagCloud())
    try:
        twitter_hash_cabecalho = twitts()
    except KeyError:
        twitter_hash_cabecalho = ""
    # live_comment_ = request.cookies.get('live_comment_save')
    return render_template(
        'post.html',
        post=p,
        tags=tags,
        sidebar=wordpress.getSidebar,
        # live_comment_save=live_comment_,
        # picday=picday,
        twitter_hash_cabecalho=twitter_hash_cabecalho,
        menu=menus,
        comments=cmts,
        show_comment_form=is_authenticated(),
        recent_posts=recent_posts)