Ejemplo n.º 1
0
    def get(self, id):
        author = Author.get_author_by_id(id)

        if not author:
            raise HTTPError(404)

        books = Book.get_books_by_author(id)

        self.render("author.html", author=author, books=books)
Ejemplo n.º 2
0
    def get(self, id):
        author = Author.get_author_by_id(id)

        if not author:
            raise HTTPError(404)

        books = Book.get_books_by_author(id)

        self.render("author.html", author=author, books=books)
Ejemplo n.º 3
0
    def get(self, id):
        book = Book.get_book_by_id(id)
        if not book:
            raise HTTPError(404)

        cate = Category.get_cat_by_id(book["category_id"])
        author = Author.get_author_by_id(book["author_id"])

        cover = get_cover(book['id'], book['cover']);

        self.render("book.html", book=book, cover=cover, cate=cate, author=author)
Ejemplo n.º 4
0
    def get(self, id):
        book = Book.get_book_by_id(id)
        if not book:
            raise HTTPError(404)

        cate = Category.get_cat_by_id(book["category_id"])
        author = Author.get_author_by_id(book["author_id"])

        cover = get_cover(book['id'], book['cover'])

        self.render("book.html",
                    book=book,
                    cover=cover,
                    cate=cate,
                    author=author)
Ejemplo n.º 5
0
    def get(self, book_id, id):
        chapter = Chapter.get_chapter_by_id(id)
        if not chapter:
            raise HTTPError(404)

        book = Book.get_book_by_id(chapter.book_id)
        author = Author.get_author_by_id(book["author_id"])
        text = ""
        from tornado.options import options
        filepath = os.path.join(options.txt_path, str(int(book_id) / 1000),
                                book_id, id)
        if os.path.exists(filepath):
            obj_file = open(filepath)
            try:
                text = obj_file.read()
            finally:
                obj_file.close()
        else:
            row = Chapter.get_text_by_id(id)
            if row is not None:
                text = row['text']
                #text = htmlremove(text)
            else:
                text = '正在努力的加载数据...'
        #text = htmlremove(text)

        previous = Chapter.get_previous(book_id, chapter["sort_num"])
        if not previous:
            previous = 'index'
        else:
            previous = previous["id"]
        next = Chapter.get_next(book_id, chapter["sort_num"])
        if not next:
            next = 'index'
        else:
            next = next["id"]

        self.render(
            "chapter.html",
            book=book,
            chapter=chapter,
            text=text,
            author=author,
            previous=previous,
            next=next,
        )
Ejemplo n.º 6
0
 def get(self, id):
     book = Book.get_book_by_id(id)
     if not book:
         raise HTTPError(404)
     a = []
     author = Author.get_author_by_id(book["author_id"])
     volumes = Volume.get_volumes_by_book_id(id)
     chapters = Chapter.get_chapters_by_book_id(id)
     for i, item in enumerate(volumes):
         var = {}
         var['id'] = item.id
         var['title'] = item.title
         var['chs'] = []
         for ch in chapters:
             if ch.volume_id == item.id:
                 var['chs'].append(ch)
         a.append(var)
     self.render("chapters.html", book=book, volumes=a, author=author)
Ejemplo n.º 7
0
 def get(self, id):
     book = Book.get_book_by_id(id)
     if not book:
         raise HTTPError(404)
     a = []
     author = Author.get_author_by_id(book["author_id"])
     volumes = Volume.get_volumes_by_book_id(id)
     chapters = Chapter.get_chapters_by_book_id(id)
     for i,item in enumerate(volumes):
         var ={}
         var['id'] = item.id
         var['title'] = item.title
         var['chs'] = []
         for ch in chapters:
             if ch.volume_id == item.id:
                 var['chs'].append(ch)
         a.append(var)
     self.render("chapters.html", book=book, volumes=a, author=author)
Ejemplo n.º 8
0
    def get(self, book_id, id):
        chapter = Chapter.get_chapter_by_id(id)
        if not chapter:
            raise HTTPError(404)

        book = Book.get_book_by_id(chapter.book_id)
        author = Author.get_author_by_id(book["author_id"])
        text = ""
        from tornado.options import options
        filepath = os.path.join(options.txt_path, str(int(book_id)/1000), book_id, id)
        if os.path.exists(filepath):
            obj_file = open(filepath)
            try:
                text = obj_file.read()
            finally:
                obj_file.close()
        else:
            row = Chapter.get_text_by_id(id)
            if row is not None:
                text = row['text']
                #text = htmlremove(text)
            else:
                text = '正在努力的加载数据...'
        #text = htmlremove(text)

        previous = Chapter.get_previous(book_id, chapter["sort_num"])
        if not previous:
            previous = 'index'
        else:
            previous = previous["id"]
        next = Chapter.get_next(book_id, chapter["sort_num"])
        if not next:
            next = 'index'
        else:
            next = next["id"]

        self.render("chapter.html",
            book=book,
            chapter=chapter,
            text=text,
            author=author,
            previous=previous,
            next=next,
        )