コード例 #1
0
def post(id):
  config.reset(settingdb.select())
  config.kargs['blogTitle'] = "ទំព័រ​ការផ្សាយ"
  config.kargs['post'] = postdb.select(1, id)
  config.kargs['posts'] = postdb.select(config.kargs['frontPagePostLimit'])
  config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'])
  config.kargs['page'] = 1
  author = request.get_cookie("logged-in", secret=config.kargs['secretKey'])
  if author:
    config.kargs['showEdit'] = True

  return template('post', data=config.kargs)
コード例 #2
0
def edit(id):
  author = request.get_cookie("logged-in", secret=config.kargs['secretKey'])
  if ((author != "Guest") and postdb.check(author)):
    config.reset(settingdb.select())
    config.kargs['blogTitle'] = "ទំព័រ​កែ​តំរូវ"
    config.kargs['posts'] = postdb.select(config.kargs['dashboardPostLimit'])
    config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'])
    config.kargs['categories'] = categorydb.select(amount="all")
    config.kargs['post'] = postdb.select(1, id)
    config.kargs['edit'] = True
    config.kargs['postId'] = id
    config.kargs['page'] = 1
    return template('dashboard/home', data=config.kargs)
  
  redirect('/login')
コード例 #3
0
ファイル: category.py プロジェクト: Sokhavuth/kwblog
def category(name):
  config.reset(settingdb.select())
  config.kargs['blogTitle'] = "ទំព័រ​ជំពូក"
  config.kargs['category'] = name
  config.kargs['posts'] = postdb.select(config.kargs['categoryPostLimit'], category=name)
  config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'])
  config.kargs['page'] = 1
  author = request.get_cookie("logged-in", secret=config.kargs['secretKey'])
  if author:
    config.kargs['showEdit'] = True

  return template('categories', data=config.kargs)
コード例 #4
0
def edit():
    author = request.get_cookie("logged-in", secret=config.kargs['secretKey'])
    if ((author != "Guest") and userdb.checkAdmin(author)):
        config.kargs['blogTitle'] = "ទំព័រ​កែ​តំរូវ"
        config.kargs['posts'] = postdb.select(
            config.kargs['dashboardPostLimit'])
        config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'])
        config.kargs['post'] = settingdb.select()
        config.kargs['page'] = 1
        return template('dashboard/setting', data=config.kargs)

    redirect('/login')
コード例 #5
0
ファイル: category.py プロジェクト: Sokhavuth/kwblog
def paginate(category):
  posts = postdb.select(config.kargs['categoryPostLimit'], category=category, page=config.kargs['page'])
  
  def toString(post):
    post[3] = post[3].strftime('%d-%m-%Y')
    post[4] = post[4].strftime('%H:%M:%S')

  if posts:
    config.kargs['page'] += 1
    posts = [list(obj) for obj in posts ]

    [toString(obj) for obj in posts]
    thumbs = lib.getPostThumbs(posts)
    print(posts)
    return {'json':posts, 'thumbs':thumbs}
  else:
    return {'json':0}
コード例 #6
0
def login():
    user = userdb.createTable()
    username = request.get_cookie("logged-in",
                                  secret=config.kargs['secretKey'])
    if not user:
        return template('dashboard/signup', data=config.kargs)
    elif username:
        config.reset(settingdb.select())
        config.kargs['author'] = username
        config.kargs['blogTitle'] = "ទំព័រ​គ្រប់គ្រង"
        config.kargs['datetime'] = getTimeZone()
        config.kargs['posts'] = postdb.select(
            config.kargs['dashboardPostLimit'])
        config.kargs['categories'] = categorydb.select(amount="all")
        config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'])
        config.kargs['page'] = 1
        return template('dashboard/home', data=config.kargs)
    else:
        return template('login', data=config.kargs)
コード例 #7
0
def paginate(place):
  if place == "frontEnd":
    postLimit = config.kargs['frontPagePostLimit']
  elif place == 'home':
    postLimit = config.kargs['homePagePostLimit']
  else:
    postLimit = config.kargs['dashboardPostLimit']

  posts = postdb.select(postLimit, page=config.kargs['page'])
  
  def toString(post):
    post[3] = post[3].strftime('%d-%m-%Y')
    post[4] = post[4].strftime('%H:%M:%S')

  if posts:
    config.kargs['page'] += 1
    posts = [list(obj) for obj in posts ]

    [toString(obj) for obj in posts]
    thumbs = lib.getPostThumbs(posts)
  
    return {'json':posts, 'thumbs':thumbs}
  else:
    return {'json':0}
コード例 #8
0
def main():
  config.reset(settingdb.select())
  config.kargs['posts'] = postdb.select(config.kargs['homePagePostLimit'])
  config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'])
  config.kargs['page'] = 1
  return template('home', data=config.kargs)