# Path: _helpers.py
# ONLINE_LAST_MINUTES = 5
# def force_int(value,default=1):
#     def block_code(self,text,lang):
# def fill_with_user(items):
# def fill_with_node(items):
# def fill_object(items,objects,*args,**kwargs):
# def _add_attr(item,objects_dict,arg,kwargs):
# def mark_online(user_id):
# def get_online_users():
# class BleepRenderer(HtmlRenderer,SmartyPants):
# class MaxinObject(object):


from flask import Flask
from _helpers import db,cache,BleepRenderer,login_manager,mark_online
from flask.ext.login import login_required,current_user 
    from views.admin import load_sidebar_notice
    from views.focus import getNodes
    from views import index,topic,account,node,admin,user,notice,focus
import os,codecs
import misaka as m
import datetime

    @app.template_filter('timesince')
    def timesince(value):
        now = datetime.datetime.utcnow()
        delta = now - value
        if delta.days > 365:
            return u'{num}年前'.format(num=delta.days / 365)
        if delta.days > 30:
            return u'{num}个月前'.format(num=delta.days / 30)
        if delta.days > 0:
            return u'{num}天前'.format(num=delta.days)
        if delta.seconds > 3600:
            return u'{num}小时前'.format(num=delta.seconds / 3600)
        if delta.seconds > 60:
            return u'{num}个月前'.format(num=delta.seconds / 60)
        return u'刚刚'

    @app.context_processor
    def register_context():
        return dict(
                load_sidebar_notice=load_sidebar_notice,
                getNodes = getNodes,
                )

def register_routes(app):
    app.register_blueprint(topic.bp,url_prefix='/topic')
    app.register_blueprint(account.bp,url_prefix='/account')
    app.register_blueprint(node.bp,url_prefix='/node')
    app.register_blueprint(admin.bp,url_prefix='/admin')
    app.register_blueprint(user.bp,url_prefix='/user')

# Path: _helpers.py
# ONLINE_LAST_MINUTES = 5
# def force_int(value,default=1):
#     def block_code(self,text,lang):
# def fill_with_user(items):
# def fill_with_node(items):
# def fill_object(items,objects,*args,**kwargs):
# def _add_attr(item,objects_dict,arg,kwargs):
# def mark_online(user_id):
# def get_online_users():
# class BleepRenderer(HtmlRenderer,SmartyPants):
# class MaxinObject(object):


# Path: app.py
from flask import Flask
from _helpers import db,cache,BleepRenderer,login_manager,mark_online
from flask.ext.login import login_required,current_user 
    from views.admin import load_sidebar_notice
    from views.focus import getNodes
    from views import index,topic,account,node,admin,user,notice,focus
import os,codecs
import misaka as m
import datetime


    @app.template_filter('timesince')
    def timesince(value):
        now = datetime.datetime.utcnow()
        delta = now - value
        if delta.days > 365:
            return u'{num}年前'.format(num=delta.days / 365)
        if delta.days > 30:
            return u'{num}个月前'.format(num=delta.days / 30)
        if delta.days > 0:
            return u'{num}天前'.format(num=delta.days)
        if delta.seconds > 3600:
            return u'{num}小时前'.format(num=delta.seconds / 3600)
        if delta.seconds > 60:
            return u'{num}个月前'.format(num=delta.seconds / 60)
        return u'刚刚'

    @app.context_processor
    def register_context():
        return dict(
                load_sidebar_notice=load_sidebar_notice,
                getNodes = getNodes,
                )

def register_routes(app):
    app.register_blueprint(topic.bp,url_prefix='/topic')
    app.register_blueprint(account.bp,url_prefix='/account')
    app.register_blueprint(node.bp,url_prefix='/node')
    app.register_blueprint(admin.bp,url_prefix='/admin')
    app.register_blueprint(user.bp,url_prefix='/user')

    app.register_blueprint(notice.bp,url_prefix='/notice')