Exemple #1
0
    def GET(self):
        uid = getuserid()
        result = []
        i = web.input()
        ye = 1
        yeshu = None

        if 'page' in i:
            ye = int(i.page)

        if 'date' in i:
            data = db.query('''select * from notes where date="%s"''' % i.date)
            if data:
                result.append([i.date,data])
                return render.main(result,"index",uid,[None])
            else:
                return render.error("sorry,该页数不存在!")
        else:
            #dates = db.query("select distinct date from notes order by date  desc")

            r = db.query('''select count(distinct date) as nu from notes''')
            yeshu = fenye.getyeshu(r[0].nu)
            minmax  = fenye.getminmax(ye)

            dates = db.query('''select distinct date from notes order by date desc limit %s,%s''' % (minmax[0],minmax[1]))
            for date in dates:
                datas = db.query('''select * from notes where date="%s" order by time desc''' % date.date)
                result.append([date.date,datas])
        return render.main(result,"index",uid,[yeshu,ye,"/?page="])
Exemple #2
0
    def GET(self):
        uid = getuserid()
        result = []
        i = web.input()
        ye = 1

        if "page" in i:
            ye = int(i.page)

        if "search" in i:
            if  "'" in i.search:
                return render.error('''请不要在关键字起中包含“ ''”''')
            r  = db.query('''select count(nid) as nu from notes where text like '%s%s%s' order by date desc''' %("%",i.search,"%"))[0].nu 
            if r != 0:
                yeshu = fenye.getyeshu(r)
                minmax = fenye.getminmax(ye)
                datas = db.query('''select * from notes where text like '%s%s%s' order by date desc limit %s,%s''' %("%",i.search,"%",minmax[0],minmax[1]))

                for j in datas:
                    result.append([j.date,[j]])
                return render.main(result,"index",uid,[yeshu,ye,"/search?search=%s&page=" % i.search])
            else:
                return render.error("sorry,没有找到内容!")
        else:
            raise web.seeother("/")