Ejemplo n.º 1
0
def signup():
    config.reset(settingdb.select())
    config.kargs['blogTitle'] = "ទំព័រសមាជិក​"
    config.kargs['posts'] = userdb.select(config.kargs['dashboardPostLimit'])
    config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'],
                                               type="user")
    config.kargs['page'] = 1

    return template('dashboard/signup', data=config.kargs)
Ejemplo n.º 2
0
def search(place):
  config.reset(settingdb.select())
  query = request.forms.getunicode('fquery')
  config.kargs['posts'] = postdb.search(query)
  config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'])
  config.kargs['blogTitle'] = "ទំព័រ​ស្វែង​រក"

  if place == "backend":
    return template('dashboard/search', data=config.kargs)
  else:
    return template('search', data=config.kargs)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
def post(name):
    config.reset(settingdb.select())
    config.kargs['blogTitle'] = "ទំព័រសមាជិក"
    config.kargs['post'] = userdb.select(1, author=name)
    config.kargs['posts'] = userdb.select(config.kargs['authorPagePostLimit'])
    config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'], "user")
    config.kargs['page'] = 1
    author = request.get_cookie("logged-in", secret=config.kargs['secretKey'])
    if author:
        config.kargs['showEdit'] = True

    return template('user', data=config.kargs)
Ejemplo n.º 5
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')
Ejemplo n.º 6
0
def post(id):
    config.reset(settingdb.select())
    config.kargs['blogTitle'] = "ទំព័រ​ស្តាទិក"
    config.kargs['post'] = pagedb.select(1, id)
    config.kargs['posts'] = pagedb.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('page', data=config.kargs)
Ejemplo n.º 7
0
def post():
  config.reset(settingdb.select())
  config.kargs['blogTitle'] = "ទំព័រ​ជំពូក"
  config.kargs['posts'] = categorydb.select(config.kargs['dashboardPostLimit'])
  config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'])
  config.kargs['datetime'] = getTimeZone()
  config.kargs['page'] = 1
  author = request.get_cookie("logged-in", secret=config.kargs['secretKey'])
  if author:
    config.kargs['author'] = author
    config.kargs['showEdit'] = True

  return template('dashboard/category', data=config.kargs)
Ejemplo n.º 8
0
def edit(id):
  author = request.get_cookie("logged-in", secret=config.kargs['secretKey'])
  if ((author != "Guest") and categorydb.check(author)):
    config.reset(settingdb.select())
    config.kargs['blogTitle'] = "ទំព័រ​កែ​តំរូវ"
    config.kargs['posts'] = categorydb.select(config.kargs['dashboardPostLimit'])
    config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'])
    config.kargs['post'] = categorydb.select(1, id)
    config.kargs['edit'] = True
    config.kargs['postId'] = id
    config.kargs['page'] = 1
    return template('dashboard/category', data=config.kargs)
  
  redirect('/category')
Ejemplo n.º 9
0
def paginate(place):
    if place == "frontEnd":
        postLimit = config.kargs['frontPagePostLimit']
    elif place == "author":
        postLimit = config.kargs['authorPagePostLimit']
    else:
        postLimit = config.kargs['dashboardPostLimit']

    posts = userdb.select(postLimit, page=config.kargs['page'])

    if posts:
        config.kargs['page'] += 1
        thumbs = lib.getPostThumbs(posts, type='user')
        return {'json': posts, 'thumbs': thumbs}
    else:
        return {'json': 0}
Ejemplo n.º 10
0
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}
Ejemplo n.º 11
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)
Ejemplo n.º 12
0
def paginate(place):
  if place == "backend":
    postLimit = config.kargs['dashboardPostLimit']
  else:
    postLimit = config.kargs['frontPagePostLimit']

  posts = categorydb.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)
    print(posts)
    return {'json':posts, 'thumbs':thumbs}
  else:
    return {'json':0}
Ejemplo n.º 13
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)