コード例 #1
0
ファイル: index.py プロジェクト: five3/weblog
 def comment(self):
     userInput= self.getInput()
     cmsObj = model.cms()
     cmsId = userInput['cmsId']
     condition = {'status':1,'id':cmsId}
     atl = cmsObj.getOne('*',condition)
     if atl == None:
         return self.error('文章不存在')
     from web import form
     validList=(
         form.Textbox("name",form.regexp(r".{3,100}$", '姓名需为3~100个字符')),
         form.Textbox("content",form.regexp(r".{1,100}$", '评论内容需为3~100个字符')),
         form.Textbox("email", form.regexp(r".*@.*", '邮箱格式错误')),
         form.Textbox("email",form.regexp(r".{5,100}$", '邮箱需为5~100个字符')),
         )
     if not self.validates(validList):
         return self.error(self.errorMessage)
     date = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
     HTTP_X_REAL_IP =  web.ctx.env.get('HTTP_X_REAL_IP')
     ip=HTTP_X_REAL_IP if HTTP_X_REAL_IP else web.ctx.ip
     data={
         'cmsId':cmsId,
         'content':userInput['content'],
         'name':userInput['name'],
         'email':userInput['email'],
         'createTime':date,
         'ip':ip,
         'status':1
     }
     model.comment().insert(data)
     data = {'commentCount':atl['commentCount']+1}
     model.cms().update(data,condition)
     return self.success('评论成功',self.referer)
コード例 #2
0
ファイル: index.py プロジェクト: 5alt/0CTF2015Final0cms
 def comment(self):
     userInput= self.getInput()
     cmsObj = model.cms()
     cmsId = userInput['cmsId']
     condition = {'status':1,'id':cmsId}
     atl = cmsObj.getOne('*',condition)
     if atl == None:
         return self.error('not exist')
     from web import form
     validList=(
         form.Textbox("name",form.regexp(r".{3,100}$", 'name length 3-100')),
         form.Textbox("content",form.regexp(r".{1,200}$", 'comment length 1-200')),
         form.Textbox("email", form.regexp(r".*@.*", 'error email format')),
         form.Textbox("email",form.regexp(r".{5,100}$", 'email length 5-100')),
         )
     if not self.validates(validList):
         return self.error(self.errorMessage)
     date = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
     ip=web.ctx.ip
     data={
         'cmsId':cmsId,
         'content':userInput['content'],
         'name':userInput['name'],
         'email':userInput['email'],
         'createTime':date,
         'ip':ip,
         'status':1
     }
     commentid = model.comment().insert(data)
     data = {'commentCount':atl['commentCount']+1}
     model.cms().update(data,condition)
     return self.success('comment success, comment id '+str(commentid)+'~',self.referer)
コード例 #3
0
ファイル: index.py プロジェクト: five3/weblog
 def comment(self):
     userInput = self.getInput()
     cmsObj = model.cms()
     cmsId = userInput['cmsId']
     condition = {'status': 1, 'id': cmsId}
     atl = cmsObj.getOne('*', condition)
     if atl == None:
         return self.error('文章不存在')
     from web import form
     validList = (
         form.Textbox("name", form.regexp(r".{3,100}$", '姓名需为3~100个字符')),
         form.Textbox("content", form.regexp(r".{1,100}$",
                                             '评论内容需为3~100个字符')),
         form.Textbox("email", form.regexp(r".*@.*", '邮箱格式错误')),
         form.Textbox("email", form.regexp(r".{5,100}$", '邮箱需为5~100个字符')),
     )
     if not self.validates(validList):
         return self.error(self.errorMessage)
     date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
     HTTP_X_REAL_IP = web.ctx.env.get('HTTP_X_REAL_IP')
     ip = HTTP_X_REAL_IP if HTTP_X_REAL_IP else web.ctx.ip
     data = {
         'cmsId': cmsId,
         'content': userInput['content'],
         'name': userInput['name'],
         'email': userInput['email'],
         'createTime': date,
         'ip': ip,
         'status': 1
     }
     model.comment().insert(data)
     data = {'commentCount': atl['commentCount'] + 1}
     model.cms().update(data, condition)
     return self.success('评论成功', self.referer)
コード例 #4
0
ファイル: index.py プロジェクト: five3/weblog
    def index(self):
        settings = self.getSettings()
        count = settings.PER_PAGE_COUNT
        inputParams = self.getPars()
        page = int(inputParams['page']) if inputParams.has_key('page') else 1
        offset= (page-1)*count if page > 0 else 0
        cmsObj = model.cms()
        condition = {'status':1}
        if 'category' in inputParams:
            condition['category'] = inputParams['category']            
        listData = cmsObj.getOne('COUNT(*) AS `total`',condition)
        totalCount = listData['total']
        cmsList = cmsObj.getList('*',condition,'orders desc,createTime desc',str(offset)+','+str(count))
        self.assign('cmsList',cmsList)
        path = web.ctx.env['PATH_INFO'] if web.ctx.env['PATH_INFO'].strip('/') else '/index/index'
        pageString = self.getPageStr(path, page,count,totalCount)
        self.assign('pageString',pageString)
#         commentObj=model.comment()
#         commentList = commentObj.getList('*',{'status':1},'id desc',str(offset)+','+str(count))
#         self.assign('commentList', commentList)  ##评论内容列表 
        unioObj = model.unio() 
        topHotList = unioObj.fetchAll('select id,name,preview_image_src from cms order by views desc limit 0,10')
        self.assign('topHotList', topHotList)  ##最热文章列表 
        categoryArtList = unioObj.fetchAll('select category.id, category.name, count(cms.id) as num from cms,category where category.id=cms.category GROUP BY cms.category order by num desc limit 0,10')
        self.assign('categoryArtList', categoryArtList)  ##分类归档列表  
        tagArtList = []
        self.assign('tagArtList', tagArtList)  ##标签归档列表  
        lastCommentList = unioObj.fetchAll('select cms.id, `comment`.content as name, cms.preview_image_src from cms, `comment` where cms.id=`comment`.cmsId order by `comment`.createTime desc limit 0,10') 
        self.assign('lastCommentList', lastCommentList)  ##最新评论列表  
        return self.display('index')
コード例 #5
0
ファイル: cms.py プロジェクト: five3/weblog
 def edit(self):
     inputParams = self.getPars()
     if not inputParams.has_key('id') :
         return self.error('文章不存在')
     id=inputParams['id']
     condition={'id':str(id)}
     atl=model.cms().getOne('*',condition)
     self.assign('atl',atl)
     return self.display('cmsEdit')
コード例 #6
0
ファイル: cms.py プロジェクト: jatter/pywebtest
 def edit(self):
     inputParams = self.getInput()
     if not inputParams.has_key('id') :
         return self.error('文章不存在')
     id=inputParams['id']
     condition={'id':str(id)}
     atl=model.cms().getOne('*',condition)
     self.assign('atl',atl)
     return self.display('cmsEdit')
コード例 #7
0
 def delete(self):
     inputParams = self.getInput()
     if not inputParams.has_key('id'):
         return self.error('not exist')
     id = inputParams['id']
     condition = {'id': str(id)}
     result = model.cms().delete(condition)
     if result:
         return self.success('delete success', self.makeUrl('cms', 'list'))
     else:
         return self.error('delete failed')
コード例 #8
0
ファイル: cms.py プロジェクト: jatter/pywebtest
 def delete(self):
     inputParams = self.getInput()
     if not inputParams.has_key('id') :
         return self.error('文章不存在')
     id=inputParams['id']
     condition={'id':str(id)}
     result=model.cms().delete(condition)
     if result:
         return self.success('删除成功',self.makeUrl('cms','list'))
     else:
         return self.error('删除失败')
コード例 #9
0
ファイル: cms.py プロジェクト: five3/weblog
 def delete(self):
     inputParams = self.getPars()
     if not inputParams.has_key('id') :
         return self.error('文章不存在')
     id=inputParams['id']
     condition={'id':str(id)}
     result=model.cms().delete(condition)
     if result:
         return self.success('删除成功',self.makeUrl('cms','list'))
     else:
         return self.error('删除失败')
コード例 #10
0
ファイル: cms.py プロジェクト: jatter/pywebtest
 def modify(self):
     userInput= self.getInput()
     data={
         'content':self.htmlunquote(userInput['content']),
         'name':userInput['name'],
         'status':userInput['status'],
         'orders':userInput['orders'],
     }
     condition = {'id':userInput['id']}
     status = model.cms().update(data,condition)
     if status:
         return self.success('修改成功',self.makeUrl('cms','list'))
     else:
         return self.error('修改失败')
コード例 #11
0
 def modify(self):
     userInput = self.getInput()
     data = {
         'content': self.htmlunquote(userInput['content']),
         'name': userInput['name'],
         'status': userInput['status'],
         'orders': userInput['orders'],
     }
     condition = {'id': userInput['id']}
     status = model.cms().update(data, condition)
     if status:
         return self.success('修改成功', self.makeUrl('cms', 'list'))
     else:
         return self.error('修改失败')
コード例 #12
0
ファイル: index.py プロジェクト: ver007/0CTF2015Final0cms
 def comment(self):
     userInput = self.getInput()
     cmsObj = model.cms()
     cmsId = userInput['cmsId']
     condition = {'status': 1, 'id': cmsId}
     atl = cmsObj.getOne('*', condition)
     if atl == None:
         return self.error('not exist')
     from web import form
     validList = (
         form.Textbox("name", form.regexp(r".{3,100}$",
                                          'name length 3-100')),
         form.Textbox("content",
                      form.regexp(r".{1,200}$", 'comment length 1-200')),
         form.Textbox("email", form.regexp(r".*@.*", 'error email format')),
         form.Textbox("email",
                      form.regexp(r".{5,100}$", 'email length 5-100')),
     )
     if not self.validates(validList):
         return self.error(self.errorMessage)
     date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
     ip = web.ctx.ip
     data = {
         'cmsId': cmsId,
         'content': userInput['content'],
         'name': userInput['name'],
         'email': userInput['email'],
         'createTime': date,
         'ip': ip,
         'status': 1
     }
     commentid = model.comment().insert(data)
     data = {'commentCount': atl['commentCount'] + 1}
     model.cms().update(data, condition)
     return self.success(
         'comment success, comment id ' + str(commentid) + '~',
         self.referer)
コード例 #13
0
ファイル: cms.py プロジェクト: jatter/pywebtest
 def list(self):
     inputParams = self.getInput()
     page = int(inputParams['page']) if inputParams.has_key('page') else 1
     settings = self.getSettings()
     count = settings.PER_PAGE_COUNT
     offset= (page-1)*count if page > 0 else 0
     cmsObj = model.cms()
     condition = {}
     listData = cmsObj.getOne('COUNT(*) AS `total`',condition)
     totalCount = listData['total']
     cmsList = cmsObj.getList('*',condition,'id desc',str(offset)+','+str(count))
     self.assign('cmsList',cmsList)
     pageString = self.getPageStr(self.makeUrl('cms','list'),page,count,totalCount)
     self.assign('pageString',pageString)
     return self.display('cmsList')
コード例 #14
0
ファイル: cms.py プロジェクト: five3/weblog
 def list(self):
     inputParams = self.getPars()
     page = int(inputParams['page']) if inputParams.has_key('page') else 1
     settings = self.getSettings()
     count = settings.PER_PAGE_COUNT
     offset= (page-1)*count if page > 0 else 0
     cmsObj = model.cms()
     condition = {}
     listData = cmsObj.getOne('COUNT(*) AS `total`',condition)
     totalCount = listData['total']
     cmsList = cmsObj.getList('*',condition,'id desc',str(offset)+','+str(count))
     self.assign('cmsList',cmsList)
     pageString = self.getPageStr(self.makeUrl('cms','list'),page,count,totalCount)
     self.assign('pageString',pageString)
     return self.display('cmsList')
コード例 #15
0
ファイル: cms.py プロジェクト: jatter/pywebtest
 def save(self):
     userInput= self.getInput()
     date = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
     data={
         'content':self.htmlunquote(userInput['content']),
         'name':userInput['name'],
         'createTime':date,
         'status':userInput['status'],
         'orders':userInput['orders'],
         'views':0,
         'commentCount':0
     }
     status = model.cms().insert(data)
     if status:
         return self.success('保存成功',self.makeUrl('cms','list'))
     else:
         return self.error('保存失败')
コード例 #16
0
 def save(self):
     userInput = self.getInput()
     date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
     data = {
         'content': self.htmlunquote(userInput['content']),
         'name': userInput['name'],
         'createTime': date,
         'status': userInput['status'],
         'orders': userInput['orders'],
         'views': 0,
         'commentCount': 0
     }
     status = model.cms().insert(data)
     if status:
         return self.success('保存成功', self.makeUrl('cms', 'list'))
     else:
         return self.error('保存失败')
コード例 #17
0
ファイル: cms.py プロジェクト: 5alt/0CTF2015Final0cms
 def save(self):
     userInput= self.getInput()
     date = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
     data={
         'content':userInput['content'],
         'name':userInput['name'],
         'createTime':date,
         'status':userInput['status'],
         'orders':userInput['orders'],
         'views':0,
         'commentCount':0
     }
     status = model.cms().insert(data)
     if status:
         return self.success('save success, post id '+str(status)+'~', self.makeUrl('cms','list'))
     else:
         return self.error('save failed')
コード例 #18
0
    def up(self):
        rt = {'errorCode': 0, 'message': ''}
        inputParams = self.getPars()
#         print inputParams  
        if not inputParams.has_key('id') :
            rt['errorCode'] = -1000
            rt['message'] = '参数错误'
            return rt
        id=inputParams['id']
        result=model.cms().execute('update cms set up=up+1 where id=%s;' % id)
        if result:
            rt['message'] = '点赞成功!'
        else:
            rt['errorCode'] = -1001
            rt['message'] = '点赞失败'
        rt['id'] = id
        return rt
コード例 #19
0
ファイル: index.py プロジェクト: 5alt/0CTF2015Final0cms
 def index(self):
     settings = self.getSettings()
     count = settings.PER_PAGE_COUNT
     inputParams = self.getInput()
     page = int(inputParams['page']) if inputParams.has_key('page') else 1
     offset= (page-1)*count if page > 0 else 0
     cmsObj = model.cms()
     condition = {'status':1}
     listData = cmsObj.getOne('COUNT(*) AS `total`',condition)
     totalCount = listData['total']
     cmsList = cmsObj.getList('*',condition,'orders desc,createTime desc',str(offset)+','+str(count))
     self.assign('cmsList',cmsList)
     pageString = self.getPageStr(self.makeUrl('index','index'),page,count,totalCount)
     self.assign('pageString',pageString)
     commentObj=model.comment()
     commentList = commentObj.getList('*',{'status':1},'id desc',str(offset)+','+str(count))
     self.assign('commentList',commentList)
     return self.display('index')
コード例 #20
0
 def save(self):
     userInput = self.getInput()
     date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
     data = {
         'content': userInput['content'],
         'name': userInput['name'],
         'createTime': date,
         'status': userInput['status'],
         'orders': userInput['orders'],
         'views': 0,
         'commentCount': 0
     }
     status = model.cms().insert(data)
     if status:
         return self.success('save success, post id ' + str(status) + '~',
                             self.makeUrl('cms', 'list'))
     else:
         return self.error('save failed')
コード例 #21
0
ファイル: index.py プロジェクト: five3/weblog
 def show(self):
     inputParams = self.getPars()
     if not inputParams.has_key('id'):
         settings = self.getSettings()
         web.seeother(settings.WEB_URL)
     id = inputParams['id']
     cmsObj = model.cms()
     condition = {'status': 1, 'id': str(id)}
     atl = cmsObj.getOne('*', condition)
     #         print atl
     if not atl:
         raise web.notfound('not found')
     atl['views'] += 1
     updateData = {'views': (atl['views'])}
     #view count
     cmsObj.update(updateData, condition)
     commentList = model.comment().getList('*', {
         'status': 1,
         'cmsId': int(id)
     })
     atl['categoryList'] = self.getCate()
     atl['tags'] = atl['tags'].split(u',')
     self.assign('atl', atl)
     self.assign('commentList', commentList)
     self.assignSEO(atl['name'], atl['keywords'], atl['description'])
     if atl['category']:
         cate_id = atl['category']
         cate_name = self.tplData['categoryList'].get(cate_id)
         self.assign('webTitle',
                     '%s_%s' % (self.tplData['webTitle'], cate_name))
     unioObj = model.unio()
     topNewList = unioObj.fetchAll(
         'select cms.id, cms.name, cms.preview_image_src from cms order by createTime desc limit 0,10'
     )
     self.assign('topNewList', topNewList)  ##最新文章列表
     categoryArtList = unioObj.fetchAll(
         'select category.id, category.name, count(cms.id) as num from cms,category where category.id=cms.category GROUP BY cms.category order by num desc limit 0,10'
     )
     self.assign('categoryArtList', categoryArtList)  ##分类归档列表
     tagArtList = []
     self.assign('tagArtList', tagArtList)  ##标签归档列表
     dateArtList = []
     self.assign('dateArtList', dateArtList)  ##日期归档列表
     return self.display('show')
コード例 #22
0
ファイル: index.py プロジェクト: 5alt/0CTF2015Final0cms
 def show(self):
     inputParams = self.getInput()
     if not inputParams.has_key('id') :
         settings = self.getSettings()
         web.seeother(settings.WEB_URL)
     id = inputParams['id']
     cmsObj = model.cms()
     condition = {'status':1,'id':str(id)}
     atl = cmsObj.getOne('*',condition)
     if atl == None:
         raise web.notfound('not found')
     atl['views']+=1
     updateData = {'views':(atl['views'])}
     #view count incr
     cmsObj.update(updateData,condition)
     commentList=model.comment().getList('*',{'status':1,'cmsId':int(id)})
     self.assign('atl',atl)
     self.assign('commentList',commentList)
     return self.display('show')
コード例 #23
0
    def list(self):
        inputParams = self.getInput()
        page = int(inputParams['page']) if inputParams.has_key('page') else 1
        settings = self.getSettings()
        count = settings.PER_PAGE_COUNT
        offset= (page-1)*count if page > 0 else 0
        commentObj = model.comment()
        condition = {}
        listData = commentObj.getOne('COUNT(*) AS `total`',condition)
        totalCount = listData['total']
        commentList = commentObj.getList('*',condition,'id desc',str(offset)+','+str(count))
        cmsObj = model.cms()
        for k,v in enumerate(commentList):
            atl=cmsObj.getOne('name,id',{'id':v['cmsId']})
            commentList[k]['atl'] =atl

        self.assign('commentList',commentList)
        pageString = self.getPageStr(self.makeUrl('comment','list'),page,count,totalCount)
        self.assign('pageString',pageString)
        return self.display('commentList')
コード例 #24
0
ファイル: cms.py プロジェクト: five3/weblog
 def modify(self):
     userInput= self.getInput()
     data={
         'content':self.htmlunquote(userInput['content']).replace("'", "\\'"),
         'name':userInput['name'],
         'keywords':userInput['keywords'],
         'description':userInput['description'],
         'category':userInput['category'],
         'tags':userInput['tags'].replace(',', u','),
         'status':userInput['status'],
         'orders':userInput['orders'],
         'preview_image_src':userInput['preview_image_src'],
         'direct_buy_url':userInput['direct_buy_url'],
     }
     condition = {'id':userInput['id']}
     status = model.cms().update(data,condition)
     if status:
         return self.success('修改成功',self.makeUrl('cms','list'))
     else:
         return self.error('修改失败')
コード例 #25
0
ファイル: comment.py プロジェクト: jatter/pywebtest
    def list(self):
        inputParams = self.getInput()
        page = int(inputParams['page']) if inputParams.has_key('page') else 1
        settings = self.getSettings()
        count = settings.PER_PAGE_COUNT
        offset= (page-1)*count if page > 0 else 0
        commentObj = model.comment()
        condition = {}
        listData = commentObj.getOne('COUNT(*) AS `total`',condition)
        totalCount = listData['total']
        commentList = commentObj.getList('*',condition,'id desc',str(offset)+','+str(count))
        cmsObj = model.cms()
        for k,v in enumerate(commentList):
            atl=cmsObj.getOne('name,id',{'id':v['cmsId']})
            commentList[k]['atl'] =atl

        self.assign('commentList',commentList)
        pageString = self.getPageStr(self.makeUrl('comment','list'),page,count,totalCount)
        self.assign('pageString',pageString)
        return self.display('commentList')
コード例 #26
0
ファイル: index.py プロジェクト: ver007/0CTF2015Final0cms
 def index(self):
     settings = self.getSettings()
     count = settings.PER_PAGE_COUNT
     inputParams = self.getInput()
     page = int(inputParams['page']) if inputParams.has_key('page') else 1
     offset = (page - 1) * count if page > 0 else 0
     cmsObj = model.cms()
     condition = {'status': 1}
     listData = cmsObj.getOne('COUNT(*) AS `total`', condition)
     totalCount = listData['total']
     cmsList = cmsObj.getList('*', condition, 'orders desc,createTime desc',
                              str(offset) + ',' + str(count))
     self.assign('cmsList', cmsList)
     pageString = self.getPageStr(self.makeUrl('index', 'index'), page,
                                  count, totalCount)
     self.assign('pageString', pageString)
     commentObj = model.comment()
     commentList = commentObj.getList('*', {'status': 1}, 'id desc',
                                      str(offset) + ',' + str(count))
     self.assign('commentList', commentList)
     return self.display('index')
コード例 #27
0
ファイル: index.py プロジェクト: ver007/0CTF2015Final0cms
 def show(self):
     inputParams = self.getInput()
     if not inputParams.has_key('id'):
         settings = self.getSettings()
         web.seeother(settings.WEB_URL)
     id = inputParams['id']
     cmsObj = model.cms()
     condition = {'status': 1, 'id': str(id)}
     atl = cmsObj.getOne('*', condition)
     if atl == None:
         raise web.notfound('not found')
     atl['views'] += 1
     updateData = {'views': (atl['views'])}
     #view count incr
     cmsObj.update(updateData, condition)
     commentList = model.comment().getList('*', {
         'status': 1,
         'cmsId': int(id)
     })
     self.assign('atl', atl)
     self.assign('commentList', commentList)
     return self.display('show')
コード例 #28
0
ファイル: index.py プロジェクト: five3/weblog
    def tag(self):
        settings = self.getSettings()
        count = settings.PER_PAGE_COUNT
        inputParams = self.getPars()
        if 'name' not in inputParams:
            raise web.notfound(u"您的访问已超出本府管辖范围!")
        name = inputParams['name']
        page = int(inputParams['page']) if inputParams.has_key('page') else 1
        offset= (page-1)*count if page > 0 else 0
        cmsObj = model.cms()
        condition = u''' status=1 and tags like '%''' +name+'''%' '''
        sql = u'select COUNT(*) AS `total` from cms where '  + condition
#         print sql
        listData = cmsObj.fetchOne(sql)
        totalCount = listData['total']
        sql = u'select * from cms where ' + condition + ' ORDER BY  orders desc,createTime desc limit ' + str(offset)+','+str(count)
#         print sql 
        cmsList = cmsObj.fetchAll(sql)
        self.assign('cmsList',cmsList)
        pageString = self.getPageStr(self.makeUrl('index','index'),page,count,totalCount)
        self.assign('pageString',pageString)
        return self.display('index')
コード例 #29
0
ファイル: index.py プロジェクト: five3/weblog
 def index(self):
     settings = self.getSettings()
     count = settings.PER_PAGE_COUNT
     inputParams = self.getPars()
     page = int(inputParams['page']) if inputParams.has_key('page') else 1
     offset = (page - 1) * count if page > 0 else 0
     cmsObj = model.cms()
     condition = {'status': 1}
     if 'category' in inputParams:
         condition['category'] = inputParams['category']
     listData = cmsObj.getOne('COUNT(*) AS `total`', condition)
     totalCount = listData['total']
     cmsList = cmsObj.getList('*', condition, 'orders desc,createTime desc',
                              str(offset) + ',' + str(count))
     self.assign('cmsList', cmsList)
     path = web.ctx.env['PATH_INFO'] if web.ctx.env['PATH_INFO'].strip(
         '/') else '/index/index'
     pageString = self.getPageStr(path, page, count, totalCount)
     self.assign('pageString', pageString)
     #         commentObj=model.comment()
     #         commentList = commentObj.getList('*',{'status':1},'id desc',str(offset)+','+str(count))
     #         self.assign('commentList', commentList)  ##评论内容列表
     unioObj = model.unio()
     topHotList = unioObj.fetchAll(
         'select id,name,preview_image_src from cms order by views desc limit 0,10'
     )
     self.assign('topHotList', topHotList)  ##最热文章列表
     categoryArtList = unioObj.fetchAll(
         'select category.id, category.name, count(cms.id) as num from cms,category where category.id=cms.category GROUP BY cms.category order by num desc limit 0,10'
     )
     self.assign('categoryArtList', categoryArtList)  ##分类归档列表
     tagArtList = []
     self.assign('tagArtList', tagArtList)  ##标签归档列表
     lastCommentList = unioObj.fetchAll(
         'select cms.id, `comment`.content as name, cms.preview_image_src from cms, `comment` where cms.id=`comment`.cmsId order by `comment`.createTime desc limit 0,10'
     )
     self.assign('lastCommentList', lastCommentList)  ##最新评论列表
     return self.display('index')
コード例 #30
0
ファイル: cms.py プロジェクト: five3/weblog
 def save(self):
     userInput= self.getInput()
     date = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
     data={
         'content':self.htmlunquote(userInput['content']).replace("'", "\\'"),
         'name':userInput['name'],
         'keywords':userInput['keywords'],
         'description':userInput['description'],
         'category':userInput['category'],
         'tags':userInput['tags'].replace(',', u','),
         'createTime':date,
         'status':userInput['status'],
         'orders':userInput['orders'],
         'preview_image_src':userInput['preview_image_src'],
         'direct_buy_url':userInput['direct_buy_url'],
         'views': 0,
         'commentCount':0
     }
     status = model.cms().insert(data)
     if status:
         return self.success('保存成功',self.makeUrl('cms','list'))
     else:
         return self.error('保存失败')
コード例 #31
0
ファイル: index.py プロジェクト: five3/weblog
 def tag(self):
     settings = self.getSettings()
     count = settings.PER_PAGE_COUNT
     inputParams = self.getPars()
     if 'name' not in inputParams:
         raise web.notfound(u"您的访问已超出本府管辖范围!")
     name = inputParams['name']
     page = int(inputParams['page']) if inputParams.has_key('page') else 1
     offset = (page - 1) * count if page > 0 else 0
     cmsObj = model.cms()
     condition = u''' status=1 and tags like '%''' + name + '''%' '''
     sql = u'select COUNT(*) AS `total` from cms where ' + condition
     #         print sql
     listData = cmsObj.fetchOne(sql)
     totalCount = listData['total']
     sql = u'select * from cms where ' + condition + ' ORDER BY  orders desc,createTime desc limit ' + str(
         offset) + ',' + str(count)
     #         print sql
     cmsList = cmsObj.fetchAll(sql)
     self.assign('cmsList', cmsList)
     pageString = self.getPageStr(self.makeUrl('index', 'index'), page,
                                  count, totalCount)
     self.assign('pageString', pageString)
     return self.display('index')
コード例 #32
0
ファイル: index.py プロジェクト: five3/weblog
    def show(self):
        inputParams = self.getPars()
        if not inputParams.has_key('id') :
            settings = self.getSettings()
            web.seeother(settings.WEB_URL)
        id=inputParams['id']
        cmsObj = model.cms()
        condition = {'status':1,'id':str(id)}
        atl = cmsObj.getOne('*',condition)
#         print atl
        if not atl:
            raise web.notfound('not found')
        atl['views']+=1
        updateData = {'views':(atl['views'])}
        #view count 
        cmsObj.update(updateData,condition)
        commentList=model.comment().getList('*',{'status':1,'cmsId':int(id)})
        atl['categoryList'] = self.getCate()
        atl['tags'] = atl['tags'].split(u',')
        self.assign('atl',atl)
        self.assign('commentList',commentList)
        self.assignSEO(atl['name'], atl['keywords'], atl['description'])
        if atl['category']:
            cate_id = atl['category']
            cate_name = self.tplData['categoryList'].get(cate_id)
            self.assign('webTitle', '%s_%s' % (self.tplData['webTitle'], cate_name)) 
        unioObj = model.unio() 
        topNewList = unioObj.fetchAll('select cms.id, cms.name, cms.preview_image_src from cms order by createTime desc limit 0,10')
        self.assign('topNewList', topNewList)  ##最新文章列表 
        categoryArtList = unioObj.fetchAll('select category.id, category.name, count(cms.id) as num from cms,category where category.id=cms.category GROUP BY cms.category order by num desc limit 0,10')
        self.assign('categoryArtList', categoryArtList)  ##分类归档列表 
        tagArtList = []
        self.assign('tagArtList', tagArtList)  ##标签归档列表 
        dateArtList = []
        self.assign('dateArtList', dateArtList)  ##日期归档列表 
        return self.display('show')  
コード例 #33
0
ファイル: rss.py プロジェクト: 5alt/0CTF2015Final0cms
 def index(self):
     cmsList = model.cms().getList('*',{},'id desc')
     self.assign('cmsList',cmsList)
     return self.display('rss')
コード例 #34
0
 def index(self):
     cmsList = model.cms().getList('*', {}, 'id desc')
     self.assign('cmsList', cmsList)
     return self.display('rss')