Esempio n. 1
0
                          ArticleModel, ArticleContentModel)


class IndexView(views.MethodView):
    '''
        首页
    '''

    def get(self):
        channels = ChannelModel.query.all()
        slides = SlideModel.query.order_by(SlideModel.order).all()
        return render_template('www/index.html', channels=channels,
                                                 slides=slides)


blueprint_www.add_url_rule('/', view_func=IndexView.as_view(b'index'),
                           endpoint='index', methods=['GET'])


class SearchView(views.MethodView):
    '''
        搜索
    '''

    def _search(self, kw):
        channels = (ChannelModel.query
                                .join('_summary')
                                .filter(db.or_(ChannelModel.name.like('%'+kw+'%'),
                                               ChannelSummaryModel.content.like('%'+kw+'%')))
                                .all())
        articles = (ArticleModel.query
                                .join('_content')
Esempio n. 2
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from flask import request, views, render_template

from studio.core.engines import db
from suibe.blueprints import blueprint_www
from suibe.models import AccountModel


class RegisterView(views.MethodView):
    '''
        注册用户
    '''

    def post(self):
        AccountModel
        return render_template('www/register.html')


blueprint_www.add_url_rule('/register', view_func=RegisterView.as_view(b'register'),
                           endpoint='register', methods=['POST'])
Esempio n. 3
0
article_per_page = 10


class ChannelView(views.MethodView):
    '''
        频道页
    '''

    @property
    def page(self):
        try:
            return int(request.args.get('page', 1))
        except ValueError:
            return 1

    def get(self, cid):
        channels = ChannelModel.query.all()
        channel = ChannelModel.query.get(cid)
        pager = Pagination(bs_version=3, page=self.page,
                           total=channel.articles.count())

        return render_template('www/channel.html',
                                channels=channels,
                                channel=channel,
                                pager=pager)


blueprint_www.add_url_rule('/channel/<int:cid>/',
                            view_func=ChannelView.as_view(b'channel'),
                            endpoint='channel', methods=['GET'])
Esempio n. 4
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from flask import views, render_template
from suibe.blueprints import blueprint_www


from suibe.models import ArticleModel


class ArticleView(views.MethodView):
    '''
        文章页
    '''

    def get(self, aid):
        article = ArticleModel.query.get(aid)
        return render_template('www/article.html', article=article)


blueprint_www.add_url_rule('/article/<int:aid>/', view_func=ArticleView.as_view(b'article'),
                           endpoint='article', methods=['GET'])
Esempio n. 5
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from flask import views, render_template
from suibe.blueprints import blueprint_www

from suibe.models import ArticleModel


class ArticleView(views.MethodView):
    '''
        文章页
    '''
    def get(self, aid):
        article = ArticleModel.query.get(aid)
        return render_template('www/article.html', article=article)


blueprint_www.add_url_rule('/article/<int:aid>/',
                           view_func=ArticleView.as_view(b'article'),
                           endpoint='article',
                           methods=['GET'])