Ejemplo n.º 1
0
def feed_folder(folder):
    if folder.split('/')[0] != 'admin':
        folder = Folder.query.filter(guid=folder).one()
        if folder:
            posts = Post.query.filter(folder_id=folder.id,
                                      status='published',
                                      type='post').order_by('created').limit(
                                          20, 0, array=True)

            feed = AtomFeed(g.options['name'] + ' • ' + folder.name,
                            subtitle=folder.seo_content,
                            feed_url=request.url_root + 'feed/',
                            url=request.url_root,
                            generator=None)

            for post in posts:
                feed.add(post.title,
                         post.content,
                         content_type='html',
                         author=post.user.nicename,
                         url=request.url_root + post.guid,
                         updated=post.modified,
                         published=post.created)

            response = feed.get_response()
            response.headers["Content-Type"] = 'application/xml'

            return response
        else:
            return is_404()
    else:
        return is_admin_404()
Ejemplo n.º 2
0
def is_folder(slug):
    if slug.split('/')[0] != 'admin':
        folder = Folder.query.filter(guid=slug).one()
        if folder:
            folder.is_folder = True
            folder.pages = Post.query.filter(
                folder_id=folder.id, status='published',
                type='page').order_by('created').all(array=True)
            folder.index = Post.query.filter(folder_id=folder.id,
                                             slug='index',
                                             status='published',
                                             type='page').one()
            folder.posts = Paginator(
                query=Post.query.filter(folder_id=folder.id,
                                        status='published',
                                        type='post').order_by('created'),
                page=request.args.get('page'),
                per_page=5)

            return render_template(get_template('folder.html', config),
                                   this=folder)
        else:
            return is_404()
    else:
        return is_admin_404()
Ejemplo n.º 3
0
def feed_folder(folder):
    if folder.split('/')[0] != 'admin':
        folder = Folder.query.filter(guid=folder).one()
        if folder:
            posts = Post.query.filter(folder_id=folder.id, status='published', type='post').order_by('created').limit(20, 0, array=True)

            feed = AtomFeed(
                g.options['name']+' • ' + folder.name,
                subtitle=folder.seo_content,
                feed_url=request.url_root+'feed/',
                url=request.url_root,
                generator=None
            )

            for post in posts:
                feed.add(
                    post.title, 
                    post.content,
                    content_type='html',
                    author=post.user.nicename,
                    url=request.url_root+post.guid,
                    updated=post.modified,
                    published=post.created
                )


            response = feed.get_response()
            response.headers["Content-Type"] = 'application/xml'

            return response
        else:
            return is_404()
    else:
        return is_admin_404()
Ejemplo n.º 4
0
def is_folder(slug):
    if slug.split('/')[0] != 'admin':
        folder = Folder.query.filter(guid=slug).one()
        if folder:
            folder.is_folder    = True
            folder.pages        = Post.query.filter(folder_id=folder.id, status='published', type='page').order_by('created').all(array=True)
            folder.index        = Post.query.filter(folder_id=folder.id, slug='index', status='published', type='page').one()
            folder.posts        = Paginator(
                query    = Post.query.filter(folder_id=folder.id, status='published', type='post').order_by('created'),
                page     = request.args.get('page'),
                per_page = 5
            )

            return render_template(get_template('folder.html', config), this=folder)
        else:
            return is_404()
    else:
        return is_admin_404()
Ejemplo n.º 5
0
def is_folder(slug):
    if slug.split('/')[0] != 'admin':
        folder = Folder.get(Folder.guid == slug)
        if folder:
            folder.is_folder = True
            folder.pages = Post.filter(Post.id_folder == folder.id, Post.status == 'published', Post.type == 'page').order_by(Post.created).all()
            folder.index = Post.filter(Post.id_folder == folder.id, Post.slug == 'index', Post.status == 'published', Post.type == 'page').one()
            folder.posts = Paginator(
                query=Post.filter(Post.id_folder == folder.id, Post.status == 'published', Post.type == 'post').order_by(Post.created),
                page=request.args.get('page'),
                theme='bootstrap',
                per_page=4
            )

            return render_template(Theme.get_template('folder.html'), this=folder)
        else:
            return is_404()
    else:
        return is_admin_404()