Esempio n. 1
0
#!/usr/local/bin/python
#coding=utf-8

from Config.config import config as conf 
import datetime
import json
from bson import BSON
from bson import json_util
from lib.kid import Kid
import PyRSS2Gen
import markdown
from categories import Category
from tags import Tag

db = conf.site_config()['db']
conf = conf.site_config()

class Diary(object):
    def __init__(self):
        pass

    @staticmethod
    def get():
        return db.diaries.find(limit=5).sort('publish_time', -1)

    @staticmethod
    def get_detail(_id):
        return db.diaries.find_one({'_id': int(_id)})

    @staticmethod
    def del_diary(_id):
Esempio n. 2
0
#!/usr/local/bin/python
# conding: utf-8
# author: [email protected]

from urls import urls

import tornado.database
import tornado.web
import os
from Config.config import config

config = config.site_config()

SETTINGS = dict(
    template_path=os.path.join(os.path.dirname(__file__), "View"),
    static_path=os.path.join(os.path.dirname(__file__), "static"),
    cookie_secret=config["cookie"],
    db=config["db"],
    title=config["title"],
    url=config["url"],
    keywords=config["keywords"],
    desc=config["description"],
    login_url="/login",
    autoescape=None,
    xsrf_cookies=True,
    debug=config["debug"],
    analytics=config["analytics"],
)
application = tornado.web.Application(handlers=urls, **SETTINGS)
Esempio n. 3
0
#!/usr/local/bin/python
#conding: utf-8

import sys
import os
import re
from fabric.api import *
import datetime
from Config.config import config as conf

conf = conf.site_config()

@task
def deploy():
    execute(lessc)
    execute(compress)
    execute(backup_database)

@task
def test():
    local("python ./runserver.py --port=8000")

@task
def build():
    admins = conf['db'].admins
    kid = conf['db'].kid
    admin = {'user': conf['username'], 'password': conf['password'], 'site_start':datetime.datetime.now().strftime("%Y-%m-%d")}
    admins.save(admin)
    print "Default Admin add Success!"
    kid.save({'k': 0})
    print "Auto uuid add Success!"
Esempio n. 4
0
#!/usr/local/bin/python
# coding=utf-8

from Config.config import config as conf
import datetime
from lib.kid import Kid
from lib.upyun import UpYun, md5, md5file

db = conf.site_config()["db"]
conf = conf.site_config()


class Gallary(object):
    def __init__(self):
        pass

    @staticmethod
    def get_detail(_id):
        return db.gallaries.find_one({"_id": int(_id)})

    @staticmethod
    def get_all():
        return db.gallaries.find().sort("publish_time", -1)

    @staticmethod
    def add(title, desc):
        gallaries = db.gallaries

        galllary = {
            "_id": Kid.kid(),
            "title": title,