Esempio n. 1
0
 def GET(self):
     args = web.input(type="view")
     db = NovelDB()
     if args.type == "view":
         return render_to_response("ajax/top_view", {"toshows": db.get_view_top()})
     elif args.type == "latest":
         return render_to_response("ajax/top_latest", {"toshows": db.get_latest_top()})
     return "ajax ready"
Esempio n. 2
0
 def GET(self):
     args = web.input(type="view")
     db = NovelDB()
     if args.type == "view":
         return render_to_response("ajax/top_view",
                                   {"toshows": db.get_view_top()})
     elif args.type == "latest":
         return render_to_response("ajax/top_latest",
                                   {"toshows": db.get_latest_top()})
     return "ajax ready"
Esempio n. 3
0
 def POST(self, id):
     form = cgform()
     if not form.validates():
         return render_to_response('category/manager_catedit', {
             'form':form,
             'fancybox':False
         })
     categroy = Category(form['name'].get_value(), id=int(id))
     info = categroy.save()
     fancybox = True
     return render_to_response('category/manager_catedit', {'form':form, 
         'fancybox':fancybox,
         })            
Esempio n. 4
0
 def GET(self):
     col_handler = self.col_handler('artical')
     form = articalf()   
     form.inputs = (_.Dropdown("category_id", 
     args=map(lambda i:(i['id'], i['name']), self.col_handler('category').find()), 
     description="Category"),) + form.inputs
     return render_to_response('artical/manager_add_artical', {'form':form})
Esempio n. 5
0
 def POST(self):
     form = novel_form() 
     if not form.validates(web.input(_method="POST")): 
         return render_to_response("admin/add_novel", {
             "form": form,
         })
     else:
         args = web.input(_method="post", rid=None)
         next = "/tuoshui_admin/checkall"
         if args.rid:
             next = "/tuoshui_admin/checkall_recommends"
         del args.rid
         # 获得type
         args.type = get_type_by_url(args.url)
         if not args.type:
             return "type_error"
         ret = self.db.add_novel(args)
         if ret[0] is True:
             rid = web.input(_method="get", rid=None).rid
             # 修改推荐小说的状态
             if rid:
                 self.db.update_recommend_status(rid)
             raise web.seeother(next)
         else:
             return ret
Esempio n. 6
0
    def GET(self, id):
        db = NovelDB()
        novel = db.get_novel_info(id, cache=False)
        if novel is None or novel.status in (0, 100):
            raise web.notfound()
        db.incr_view_count(id)
        # 获得推荐小说
        rd_recommends = db.get_random_recommend(id=id)

        page = web.input(page=1).page
        page_count = db.get_novel_pageinfo(id)
        pager = Paginator(page_count, 1, page)
        try:
            novel_html = open(get_novel_html_path(id, pager.page), "r")
        except:
            return "内容还没准备好,稍等一会哦:)"

        # 访问twisted更新
        temp_date = novel.last_update_time.replace(tzinfo=None)
        if not pager.has_next() and novel.status not in (
                1, 3) and (datetime.datetime.now() - temp_date).seconds > 3600:
            start_work(id)
            novel = db.get_novel_info(id, cache=False)
        novel.tag = db.get_tags_by_id(id)
        novel.view_count = db.get_view_count(id)

        return render_to_response(
            "show_novel", {
                "novel_id": id,
                "novel": novel,
                "novel_html": novel_html,
                "pager": pager,
                "rd_recommends": rd_recommends,
            })
Esempio n. 7
0
 def GET(self, id):
     db = NovelDB()
     novel = db.get_novel_info(id)
     db.incr_view_count(id)
     return render_to_response("novel_info", {
         "novel": novel
     })
Esempio n. 8
0
 def POST(self):
     form = novel_form()
     if not form.validates(web.input(_method="POST")):
         return render_to_response("admin/add_novel", {
             "form": form,
         })
     else:
         args = web.input(_method="post", rid=None)
         next = "/tuoshui_admin/checkall"
         if args.rid:
             next = "/tuoshui_admin/checkall_recommends"
         del args.rid
         # 获得type
         args.type = get_type_by_url(args.url)
         if not args.type:
             return "type_error"
         ret = self.db.add_novel(args)
         if ret[0] is True:
             rid = web.input(_method="get", rid=None).rid
             # 修改推荐小说的状态
             if rid:
                 self.db.update_recommend_status(rid)
             raise web.seeother(next)
         else:
             return ret
Esempio n. 9
0
    def GET(self, id):
        db = NovelDB()
        novel = db.get_novel_info(id, cache=False)
        if novel is None or novel.status in (0, 100):
            raise web.notfound()
        db.incr_view_count(id)
        # 获得推荐小说
        rd_recommends = db.get_random_recommend(id=id)
        
        page = web.input(page=1).page
        page_count = db.get_novel_pageinfo(id)
        pager = Paginator(page_count, 1, page)
        try:
            novel_html = open(get_novel_html_path(id, pager.page), "r")
        except:
            return "内容还没准备好,稍等一会哦:)"

        # 访问twisted更新
        temp_date = novel.last_update_time.replace(tzinfo=None)
        if not pager.has_next() and novel.status not in (1,3) and (datetime.datetime.now() - temp_date).seconds > 3600:
            start_work(id)
            novel = db.get_novel_info(id, cache=False)
        novel.tag = db.get_tags_by_id(id)
        novel.view_count = db.get_view_count(id)
        
        return render_to_response("show_novel", {
            "novel_id": id,
            "novel": novel,
            "novel_html": novel_html,
            "pager": pager,
            "rd_recommends": rd_recommends,
        })
Esempio n. 10
0
 def GET(self):
     id = web.input(id=None).id
     if id.isdigit():
         novel_info = self.db.get_novel_info(id, cache=False)
         novel_info.update(tag=";".join(self.db.get_tags_by_id(id)))
         form = novel_form()
         form.fill(novel_info)
     return render_to_response("admin/edit_novel", {"form": form, "id": id})
Esempio n. 11
0
 def GET(self):
     page = web.input(page=1).page
     
     pager, toshows = self.db.get_novels_by_page(page, self.PERPAGE, all=True, cache=False)
     return render_to_response("admin/checkall", {
         "pager": pager,
         "toshows": toshows
     })
Esempio n. 12
0
 def GET(self):
     page = web.input(page=1).page
     
     pager, toshows = self.db.get_recommends_by_page(page, self.PERPAGE)
     return render_to_response("admin/checkall_recommends", {
         "pager": pager,
         "toshows": toshows
     })
Esempio n. 13
0
    def GET(self):
        page = web.input(page=1).page

        pager, toshows = self.db.get_recommends_by_page(page, self.PERPAGE)
        return render_to_response("admin/checkall_recommends", {
            "pager": pager,
            "toshows": toshows
        })
Esempio n. 14
0
 def GET(self):
     col_handler = self.col_handler('category')
     artical_handler = self.col_handler('artical')
     objs = col_handler.find().sort('id', pymongo.DESCENDING)
     form = cgform()
     return render_to_response('category/manager_category', 
                               {'form':form, 
                                'objs':objs,})
Esempio n. 15
0
 def POST(self, id):
     form = linkform()
     if not form.validates():
         return render_to_response('category/manager_linkedit', {
             'form':form,
             'fancybox':False,
         })
     link = Link(form['link_addr'].get_value(), 
         form['link_name'].get_value(),
         form['friend_name'].get_value(),
         form['description'].get_value(),
         id=int(id))
     info = link.save()
     fancybox = True
     return render_to_response('category/manager_linkedit', {'form':form, 
         'fancybox':fancybox,
         })            
Esempio n. 16
0
    def GET(self):
        db = NovelDB()
        page = web.input(page=1).page

        pager, toshows = db.get_novels_by_page(page, self.PERPAGE, all=False)
        return render_to_response("checkall", {
            "pager": pager,
            "toshows": toshows
        })
Esempio n. 17
0
 def GET(self):
     db = NovelDB()
     page = web.input(page=1).page
     
     pager, toshows = db.get_novels_by_page(page, self.PERPAGE, all=False)
     return render_to_response("checkall", {
         "pager": pager,
         "toshows": toshows
     })        
Esempio n. 18
0
 def GET(self):
     artical_handler = self.col_handler('artical')
     comment_handler = self.col_handler('comment')
     objs = artical_handler.find().sort('id', pymongo.DESCENDING)
     articals = []
     for obj in objs:
         sum = comment_handler.find({'artical_id':obj['id']}).count()
         articals.append([obj, sum])
     return render_to_response('artical/manager_artical', {'articals':articals})
Esempio n. 19
0
 def GET(self):
     form = novel_form()
     args = web.input(_method="get", rid=None)
     if args.rid:
         info = self.db.get_recommend_info(args.rid)
         info.update(update_interval=10)
         form.fill(info)
     return render_to_response("admin/add_novel", {
         "form": form,
     })
Esempio n. 20
0
 def GET(self):
     form = novel_form()
     args = web.input(_method="get", rid=None)
     if args.rid:
         info = self.db.get_recommend_info(args.rid)
         info.update(update_interval=10)
         form.fill(info)
     return render_to_response("admin/add_novel", {
         "form": form,
     })
Esempio n. 21
0
    def GET(self):
        page = web.input(page=1).page

        pager, toshows = self.db.get_novels_by_page(page,
                                                    self.PERPAGE,
                                                    all=True,
                                                    cache=False)
        return render_to_response("admin/checkall", {
            "pager": pager,
            "toshows": toshows
        })
Esempio n. 22
0
 def GET(self):
     id = web.input(id=None).id
     if id.isdigit():
         novel_info = self.db.get_novel_info(id, cache=False)
         novel_info.update(tag=";".join(self.db.get_tags_by_id(id)))
         form = novel_form()
         form.fill(novel_info)
     return render_to_response("admin/edit_novel", {
         "form": form, 
         "id": id
     })
Esempio n. 23
0
 def GET(self):
     args = web.input(keyword="", page=1)
     args.keyword = args.keyword.strip()
     if not args.keyword.strip():
         raise web.seeother(self.env.get("HTTP_REFERER", "/"))
     db = NovelDB()
     pager, toshows = db.search(args.keyword, args.page, self.PERPAGE)
     return render_to_response("search", {
         "keyword": args.keyword,
         "toshows": toshows,
         "pager": pager
     })
Esempio n. 24
0
 def GET(self, id):
     if not id.isdigit():
         return "ID is Wrong!"
     col_handler = self.col_handler('category')
     id = int(id)
     category = col_handler.find_one({'id':id})
     form = cgform()
     form.fill({'id':id, 'name':category['name']})
     fancybox = False
     return render_to_response('category/manager_catedit', {'form':form, 
         'fancybox':fancybox,
     })
Esempio n. 25
0
 def POST(self):
     col_handler = self.col_handler('category')
     objs = col_handler.find().sort('id', pymongo.DESCENDING)
     form = cgform()
     if not form.validates():
         return render_to_response('category/manager_category', {
             'form':form,
             'objs':objs,
         })
     categroy = Category(form['name'].get_value())
     info = categroy.save()
     return web.seeother('/manager/category')
Esempio n. 26
0
 def GET(self):
     args = web.input(keyword="", page=1)
     args.keyword = args.keyword.strip()
     if not args.keyword.strip():
         raise web.seeother(self.env.get("HTTP_REFERER", "/"))
     db = NovelDB()
     pager, toshows = db.search(args.keyword, args.page, self.PERPAGE)
     return render_to_response("search", {
         "keyword": args.keyword,
         "toshows": toshows,
         "pager": pager
     })
Esempio n. 27
0
 def POST(self):
     form = novel_form()
     if not form.validates():
         return render_to_response("admin/edit_novel", {
             "form": form,
         })
     else:
         args = web.input()
         ret = self.db.edit_novel(args.id, args)
         if ret is True:
             raise web.seeother("/tuoshui_admin/checkall")
         else:
             return "修改失败" + ret
Esempio n. 28
0
 def GET(self):
     # 处理source
     source = web.input(source="").source
     if source:
         source = get_real_url(source)
         novel = self.db.get_novel_byurl(source)
         if novel:
             raise web.seeother("/novel/%s" % novel.id)
     tags = self.db.get_index_tags()
     return render_to_response("index", {
         "tags": tags,
         "source": source,
     })
Esempio n. 29
0
 def GET(self):
     # 处理source
     source = web.input(source="").source
     if source:
         source = get_real_url(source)
         novel = self.db.get_novel_byurl(source)
         if novel:
             raise web.seeother("/novel/%s" % novel.id)
     tags = self.db.get_index_tags()
     return render_to_response("index", {
         "tags": tags,
         "source": source,
     })
Esempio n. 30
0
 def POST(self):
     form = novel_form() 
     if not form.validates(): 
         return render_to_response("admin/edit_novel", {
             "form": form,
         })
     else:
         args = web.input()
         ret = self.db.edit_novel(args.id, args)
         if ret is True:
             raise web.seeother("/tuoshui_admin/checkall")
         else:
             return "修改失败" + ret
Esempio n. 31
0
    def POST(self):
        col_handler = self.col_handler('link')
        objs = col_handler.find().sort('id', pymongo.DESCENDING)
        form = linkform()
        if not form.validates():
            return render_to_response('category/manager_link', {
                'form':form,
                'objs':objs,
            })
        link = Link(form['link_addr'].get_value(), 
            form['link_name'].get_value(),
            form['friend_name'].get_value(),
            form['description'].get_value() 
        )
#        print 'aa'
        info = link.save()
        return web.seeother('/manager/link')    
Esempio n. 32
0
 def GET(self, id):
     if not id.isdigit():
         return "ID is Wrong!"
     id = int(id)
     col_handler = self.col_handler('artical')
     artical = col_handler.find_one({'id':id})
     form = articalf()   
     form.inputs = (_.Dropdown("category_id", 
     args=map(lambda i:(i['id'], i['name']), self.col_handler('category').find()), 
     description="Category"),) + form.inputs        
     form.fill({'id':id, 'category_id':artical['category_id'],
                'content':artical['content'], 
                'title':artical['title'],
                'tags':artical['tags'],
                'author':artical['author'],
                })
     
     return render_to_response('artical/manager_add_artical', {'form':form})
Esempio n. 33
0
    def GET(self, id):
        if not id.isdigit():
            return "ID is Wrong!"
        col_handler = self.col_handler('link')
        id = int(id)
        link = col_handler.find_one({'id':id})
        form = linkform()
        form.fill({'id':id, 
            'link_name':link['link_name'], 
            'link_addr':link['link_addr'],
            'friend_name':link['friend_name'],
            'description':link['description'],
            })
#        form = cgform()
        fancybox = False
        return render_to_response('category/manager_linkedit', {'form':form, 
            'fancybox':fancybox,
        })
Esempio n. 34
0
 def POST(self, id):
     col_handler = self.col_handler('artical')    
     form = articalf()
     form.inputs = (_.Dropdown("category_id", 
             args=map(lambda i:(i['id'], i['name']), self.col_handler('category').find()), 
             description="Category"),) + form.inputs        
     if not form.validates():
         return render_to_response('artical/manager_add_artical', {'form':form})
     artical = Artical(
         form['title'].get_value(),
         form['tags'].get_value(),
         form['content'].get_value(),
         form['category_id'].get_value(),
         form['author'].get_value(),
         id=form['id'].get_value()
         )
     artical.save()
     return web.seeother('/manager/artical')        
Esempio n. 35
0
 def GET(self, id):
     if not id.isdigit():
         return "ID is Wrong!"
     id = int(id)
     comment_children = []
     
     artical_handler = self.col_handler('artical')
     comment_handler = self.col_handler('comment')
     
     comments = comment_handler.find({'artical_id':id})
     if comments.count():
         for comment in comments:
             children = get_comments_in_comment(comment['id'])
             comment_children.append([comment, children])
     artical = artical_handler.find_one({'id':id})   
     
     return render_to_response('comment/manager_comment_show', {
                               'artical':artical,
                               'comment_children':comment_children,
                               })
Esempio n. 36
0
 def GET(self):
     return render_to_response("admin/manage_index",
                               {"content": open(INDEX_PATH, "r").read()})
Esempio n. 37
0
 def GET(self):
     return render_to_response("admin/base")
Esempio n. 38
0
 def GET(self, id):
     db = NovelDB()
     novel = db.get_novel_info(id)
     db.incr_view_count(id)
     return render_to_response("novel_info", {"novel": novel})
Esempio n. 39
0
 def GET(self):
     col_handler = self.col_handler('link')
     objs = col_handler.find().sort('id', pymongo.DESCENDING)
     form = linkform()
     return render_to_response('category/manager_link', {'form':form, 'objs':objs})
Esempio n. 40
0
 def GET(self):
     return render_to_response("admin/login")
Esempio n. 41
0
 def GET(self):
     return render_to_response("admin/manage_index", {
         "content": open(INDEX_PATH, "r").read()
     })
Esempio n. 42
0
 def GET(self):
     return render_to_response("admin/base")
Esempio n. 43
0
 def GET(self):
     return render_to_response("admin/login")