Exemplo n.º 1
0
def tag_tail(tag, page):

    paths = Tag.get_path_by_tag(tag)
    length = len(paths)

    begin, end, pages = Page.get_index(total=length, per=30, page=page)

    infos = paths[begin:end]
    lines = []
    for info in infos:

        l = info.split('/')
        book = l[-1].split('.')[0]
        category = l[-2]
        finish = l[-3]

        lines.append((finish, category, book))

    page_list = Page.get_list(page=page, echo=5, pages=pages)

    last_page = max(1, page - 1)
    next_page = min(pages, page + 1)

    return render_template('/tags/tag.html',
                           lines=lines,
                           page_list=page_list,
                           last_page=last_page,
                           next_page=next_page,
                           tag=tag,
                           current_page=page,
                           pages=pages)
Exemplo n.º 2
0
def result(page):
    # data=session.get('search')
    data = temp
    result = data[0]
    search_keyword = data[1]
    total = len(result)
    begin, end, pages = Page.get_index(page=page, total=total, per=20)
    page_result = result[begin:end]

    page_list = Page.get_list(pages=pages, page=page, echo=5)

    jinja_list = []
    for d in page_result:

        filepath = d.get('filepath')
        keyword = d.get('keyword')
        keyword_str = u','.join(keyword)
        l = filepath.split('/')
        book = l[-1].split('.')[0]
        category = l[-2]
        finish = l[-3]
        jinja_list.append([finish, category, book, keyword_str])

    next_page = min(pages, page + 1)
    last_page = max(1, page - 1)

    return render_template('search/result.html',current_page=page,total=total,keyword=search_keyword,page_list=page_list,pages=pages,last_page=last_page,\
                                                next_page=next_page,jinja_list=jinja_list,)
Exemplo n.º 3
0
def folders(category, page):

    info = folder_dict.get(category)

    if not info:
        ##路径不存在,拒绝访问
        return redirect('/')

    else:

        folders = info.get('folders')

        length = len(folders)

        begin, end, pages = Page.get_index(total=length, per=30, page=page)

        inner_folders = folders[begin:end]

        page_list = Page.get_list(page=page, pages=pages, echo=5)

        last_page = max(1, page - 1)
        next_page = min(pages, page + 1)

        category_echo = category_dict.get(category)


        return render_template('mm/folder.html',category=category,page_list=page_list,category_echo=category_echo,\
                                                    folders=inner_folders,current_page=page,last_page=last_page,next_page=next_page,pages=pages)
Exemplo n.º 4
0
def book(path, category, page):

    filenames = BOOK.book_dict.get(path).get(category)

    length = len(filenames)

    begin, end, pages = Page.get_index(page=page, total=length, per=30)

    current_filenames = filenames[begin:end]

    page_list = Page.get_list(pages=pages, page=page, echo=5)

    next_page = min(pages, page + 1)
    last_page = max(1, page - 1)

    books = [filename.rsplit('.', 1)[0] for filename in current_filenames]



    return render_template('/books/book.html',category=category,last_page=last_page,books=books,pages=pages,\
                                            current_page=page,next_page=next_page,path=path,page_list=page_list)