# Path: maple/default.py
# SITE = {
#     'title': _('honmaple'),
#     'subtitle': _('风落花语风落天，花落风雨花落田.'),
#     "author": "lin.jiang",
#     "header": "https://static.honmaple.com/images/header/header.png?type=mini"
# }
# 
# Path: maple/utils.py
# class MethodView(_MethodView):
#     cache_time = 180
# 
#     def dispatch_request(self, *args, **kwargs):
#         f = super(MethodView, self).dispatch_request
#         if self.cache_time and request.method in ["GET", "HEAD"]:
#             return cache.cached(
#                 timeout=self.cache_time,
#                 key_prefix=cache_key,
#             )(f)(*args, **kwargs)
#         return f(*args, **kwargs)
# 
# def filter_maybe(request_data, columns, params=None):
#     if params is None:
#         params = dict()
#     is_dict = isinstance(columns, dict)
#     for column in columns:
#         value = request_data.get(column)
#         if not value:
#             continue
#         key = column if not is_dict else columns.get(column, column)
# 
#         if key in ["created_at__gte", "created_at__lte"]:
#             value = datetime.strptime(value, '%Y-%m-%d')
#         params.update({key: value})
#     return params
# 
# Path: maple/blog/db.py
# class Article(db.Model, ModelUserMixin):
#     __tablename__ = 'article'
# 
#     CONTENT_TYPE_MARKDOWN = 0
#     CONTENT_TYPE_ORGMODE = 1
# 
#     CONTENT_TYPE = ((0, 'markdown'), (1, 'org-mode'))
# 
#     id = db.Column(db.Integer, primary_key=True)
#     title = db.Column(db.String(50), nullable=False)
#     content = db.Column(db.Text, nullable=False)
#     content_type = db.Column(
#         db.Integer, nullable=False, default=CONTENT_TYPE_MARKDOWN)
# 
#     category_id = db.Column(
#         db.Integer,
#         db.ForeignKey('category.id', ondelete="CASCADE"),
#         nullable=False)
#     category = db.relationship(
#         'Category',
#         backref=db.backref(
#             'articles', cascade='all,delete-orphan', lazy='dynamic'),
#         uselist=False,
#         lazy='joined')
# 
#     __mapper_args__ = {"order_by": text("created_at desc")}
# 
#     def __repr__(self):
#         return "<Article %r>" % self.title
# 
#     def __str__(self):
#         return self.title
# 
#     def to_json(self):
#         return {
#             'id': self.id,
#             'title': self.title,
#             'category': self.category.name,
#             'tags': ','.join([tag.name for tag in self.tags]),
#         }
# 
#     def to_html(self, length=None, truncate=False):
#         length = length or current_app.config.get("SUMMARY_MAX_LENGTH")
#         if not truncate:
#             length = None
#         if self.content_type == self.CONTENT_TYPE_MARKDOWN:
#             return markdown_to_html(self.content, length)
#         return orgmode_to_html(self.content, length)
# 
#     @property
#     def htmlcontent(self):
#         return self.to_html()
# 
#     @property
#     def next_article(self):
#         return Article.query.filter_by(id__lt=self.id).order_by("-id").first()
# 
#     @property
#     def previous_article(self):
#         return Article.query.filter_by(id__gt=self.id).order_by("id").first()
# 
#     @property
#     def read_times(self):
#         return Count.get('article:{}'.format(self.id))
# 
#     @read_times.setter
#     def read_times(self, value):
#         Count.set('article:{}'.format(self.id))
# 
# class TimeLine(db.Model, ModelUserMixin):
#     __tablename__ = 'timeline'
# 
#     id = db.Column(db.Integer, primary_key=True)
#     content = db.Column(db.Text, nullable=False)
#     is_hidden = db.Column(db.Boolean, nullable=True, default=False)
# 
#     __mapper_args__ = {"order_by": text("created_at desc")}
# 
#     def __repr__(self):
#         return "<TimeLine %r>" % self.content[:10]
# 
#     def __str__(self):
#         return self.content[:10]
# 
#     @property
#     def datetime_format(self):
#         return format_datetime(self.created_at, 'Y-M-d H:M')
# 
#     def to_json(self):
#         return {'id': self.id, 'content': self.content, 'hide': self.hide}


from collections import OrderedDict
from urllib.parse import urljoin
from flask import request, url_for
from flask_maple.response import HTTP
from maple.default import SITE
from maple.utils import MethodView, filter_maybe
from werkzeug.contrib.atom import AtomFeed
from .db import Article, TimeLine
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ********************************************************************************
# Copyright © 2019 jianglin
# File Name: router.py
# Author: jianglin
# Email: mail@honmaple.com
# Created: 2019-05-24 18:43:30 (CST)
# Last Update: Thursday 2019-07-11 18:06:49 (CST)
#          By:
# Description:
# ********************************************************************************




class ArticleListView(MethodView):
    per_page = 10

    def get(self):
        data = request.data
        page, number = self.pageinfo

# Path: maple/default.py
# SITE = {
#     'title': _('honmaple'),
#     'subtitle': _('风落花语风落天，花落风雨花落田.'),
#     "author": "lin.jiang",
#     "header": "https://static.honmaple.com/images/header/header.png?type=mini"
# }
# 
# Path: maple/utils.py
# class MethodView(_MethodView):
#     cache_time = 180
# 
#     def dispatch_request(self, *args, **kwargs):
#         f = super(MethodView, self).dispatch_request
#         if self.cache_time and request.method in ["GET", "HEAD"]:
#             return cache.cached(
#                 timeout=self.cache_time,
#                 key_prefix=cache_key,
#             )(f)(*args, **kwargs)
#         return f(*args, **kwargs)
# 
# def filter_maybe(request_data, columns, params=None):
#     if params is None:
#         params = dict()
#     is_dict = isinstance(columns, dict)
#     for column in columns:
#         value = request_data.get(column)
#         if not value:
#             continue
#         key = column if not is_dict else columns.get(column, column)
# 
#         if key in ["created_at__gte", "created_at__lte"]:
#             value = datetime.strptime(value, '%Y-%m-%d')
#         params.update({key: value})
#     return params
# 
# Path: maple/blog/db.py
# class Article(db.Model, ModelUserMixin):
#     __tablename__ = 'article'
# 
#     CONTENT_TYPE_MARKDOWN = 0
#     CONTENT_TYPE_ORGMODE = 1
# 
#     CONTENT_TYPE = ((0, 'markdown'), (1, 'org-mode'))
# 
#     id = db.Column(db.Integer, primary_key=True)
#     title = db.Column(db.String(50), nullable=False)
#     content = db.Column(db.Text, nullable=False)
#     content_type = db.Column(
#         db.Integer, nullable=False, default=CONTENT_TYPE_MARKDOWN)
# 
#     category_id = db.Column(
#         db.Integer,
#         db.ForeignKey('category.id', ondelete="CASCADE"),
#         nullable=False)
#     category = db.relationship(
#         'Category',
#         backref=db.backref(
#             'articles', cascade='all,delete-orphan', lazy='dynamic'),
#         uselist=False,
#         lazy='joined')
# 
#     __mapper_args__ = {"order_by": text("created_at desc")}
# 
#     def __repr__(self):
#         return "<Article %r>" % self.title
# 
#     def __str__(self):
#         return self.title
# 
#     def to_json(self):
#         return {
#             'id': self.id,
#             'title': self.title,
#             'category': self.category.name,
#             'tags': ','.join([tag.name for tag in self.tags]),
#         }
# 
#     def to_html(self, length=None, truncate=False):
#         length = length or current_app.config.get("SUMMARY_MAX_LENGTH")
#         if not truncate:
#             length = None
#         if self.content_type == self.CONTENT_TYPE_MARKDOWN:
#             return markdown_to_html(self.content, length)
#         return orgmode_to_html(self.content, length)
# 
#     @property
#     def htmlcontent(self):
#         return self.to_html()
# 
#     @property
#     def next_article(self):
#         return Article.query.filter_by(id__lt=self.id).order_by("-id").first()
# 
#     @property
#     def previous_article(self):
#         return Article.query.filter_by(id__gt=self.id).order_by("id").first()
# 
#     @property
#     def read_times(self):
#         return Count.get('article:{}'.format(self.id))
# 
#     @read_times.setter
#     def read_times(self, value):
#         Count.set('article:{}'.format(self.id))
# 
# class TimeLine(db.Model, ModelUserMixin):
#     __tablename__ = 'timeline'
# 
#     id = db.Column(db.Integer, primary_key=True)
#     content = db.Column(db.Text, nullable=False)
#     is_hidden = db.Column(db.Boolean, nullable=True, default=False)
# 
#     __mapper_args__ = {"order_by": text("created_at desc")}
# 
#     def __repr__(self):
#         return "<TimeLine %r>" % self.content[:10]
# 
#     def __str__(self):
#         return self.content[:10]
# 
#     @property
#     def datetime_format(self):
#         return format_datetime(self.created_at, 'Y-M-d H:M')
# 
#     def to_json(self):
#         return {'id': self.id, 'content': self.content, 'hide': self.hide}


# Path: maple/blog/router.py
from collections import OrderedDict
from urllib.parse import urljoin
from flask import request, url_for
from flask_maple.response import HTTP
from maple.default import SITE
from maple.utils import MethodView, filter_maybe
from werkzeug.contrib.atom import AtomFeed
from .db import Article, TimeLine

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ********************************************************************************
# Copyright © 2019 jianglin
# File Name: router.py
# Author: jianglin
# Email: mail@honmaple.com
# Created: 2019-05-24 18:43:30 (CST)
# Last Update: Thursday 2019-07-11 18:06:49 (CST)
#          By:
# Description:
# ********************************************************************************




class ArticleListView(MethodView):
    per_page = 10

    def get(self):
        data = request.data
        page, number = self.pageinfo

        params = filter_maybe(