Ejemplo n.º 1
0
 def get(self):
     query_dict = request.data
     page, number = self.pageinfo
     filter_dict = {'is_hidden': False}
     order_by = ('-created_at', )
     timelines = TimeLine.query.filter_by(**filter_dict).order_by(
         *order_by).paginate(page, number)
     if query_dict.pop('from', None) == 'blog':
         return HTTP.HTML('timeline/macro.html', timelines=timelines)
     return HTTP.HTML('timeline/itemlist.html', timelines=timelines)
Ejemplo n.º 2
0
 def post(self):
     request_data = request.data
     password = request_data.pop('password', '')
     content = request_data.pop('content', '')
     if not password or not content:
         return HTTP.BAD_REQUEST(message="params required.")
     ec = Encrypt(password, current_app.config['SECRET_KEY_SALT'])
     try:
         return HTTP.OK(data=ec.decrypt(content))
     except InvalidToken:
         return HTTP.BAD_REQUEST(message="password is not correct")
Ejemplo n.º 3
0
 def get(self):
     page, number = self.pageinfo
     filter_dict = {'is_hidden': False}
     order_by = ('-created_at', )
     timelines = TimeLine.query.filter_by(**filter_dict).order_by(
         *order_by).paginate(page, number)
     serializer = Serializer(timelines,
                             exclude=['user', 'user_id', 'is_hidden'],
                             extra=['datetime_format'])
     return HTTP.OK(data=serializer.data)
Ejemplo n.º 4
0
    def get(self):
        request_data = request.data
        page, number = self.pageinfo
        kwargs = filter_maybe(
            request_data, {
                "tag": "tags__name",
                "category": "category__name",
                "author": "author__name",
                "title": "title__contains",
                "year": "created_at__year",
                "month": "created_at__month"
            })
        order_by = ("-created_at", )

        ins = Blog.query.filter_by(**kwargs).order_by(*order_by).paginate(
            page, number)
        return HTTP.HTML('blog/itemlist.html', blogs=ins)
Ejemplo n.º 5
0
    def get(self):
        request_data = request.data
        kwargs = filter_maybe(
            request_data, {
                "tag": "tags__name",
                "category": "category__name",
                "author": "author__name",
                "title": "title__contains",
                "year": "created_at__year",
                "month": "created_at__month"
            })
        order_by = ("-created_at", )

        ins = {}
        for blog in Blog.query.filter_by(**kwargs).order_by(*order_by):
            date = blog.created_at.strftime("%Y年%m月")
            ins.setdefault(date, [])
            ins[date].append(blog)
        return HTTP.HTML('blog/archives.html', blogs=ins)
Ejemplo n.º 6
0
 def login():
     user = current_user._get_current_object()
     login_user(user, remember=True)
     return HTTP.OK()
Ejemplo n.º 7
0
 def get(self, pk):
     ins = Blog.query.filter_by(id=pk).first_or_404()
     '''记录用户浏览次数'''
     ins.read_times = 1
     data = {'blog': ins}
     return HTTP.HTML('blog/item.html', **data)
Ejemplo n.º 8
0
 def get(self):
     return HTTP.HTML("index/friends.html")
Ejemplo n.º 9
0
 def get(self):
     return HTTP.HTML("index/about.html")
Ejemplo n.º 10
0
 def get(self):
     return HTTP.HTML("index/index.html")