mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-04 23:40:01 +00:00
add pagination to basic
This commit is contained in:
parent
ae5ccf6e91
commit
458576a141
@ -19,6 +19,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from cps.pagination import Pagination
|
||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
from flask_babel import gettext as _
|
from flask_babel import gettext as _
|
||||||
from flask_babel import get_locale
|
from flask_babel import get_locale
|
||||||
@ -45,14 +46,16 @@ log = logger.create()
|
|||||||
@login_required_if_no_ano
|
@login_required_if_no_ano
|
||||||
def index():
|
def index():
|
||||||
term = request.args.get("query", "") # default to showing all books
|
term = request.args.get("query", "") # default to showing all books
|
||||||
offset = 0
|
limit = 15
|
||||||
|
page = int(request.args.get("page") or 1)
|
||||||
|
off = (page - 1) * limit
|
||||||
order = get_sort_function("stored", "search")
|
order = get_sort_function("stored", "search")
|
||||||
join = db.books_series_link, db.Books.id == db.books_series_link.c.book, db.Series
|
join = db.books_series_link, db.Books.id == db.books_series_link.c.book, db.Series
|
||||||
entries, result_count, pagination = calibre_db.get_search_results(term,
|
entries, result_count, pagination = calibre_db.get_search_results(term,
|
||||||
config,
|
config,
|
||||||
offset,
|
off,
|
||||||
order,
|
order,
|
||||||
None,
|
limit,
|
||||||
*join)
|
*join)
|
||||||
return render_title_template('basic_index.html',
|
return render_title_template('basic_index.html',
|
||||||
searchterm=term,
|
searchterm=term,
|
||||||
|
@ -1,13 +1,23 @@
|
|||||||
{% extends "basic_layout.html" %}
|
{% extends "basic_layout.html" %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
|
||||||
|
<div class="pagination">
|
||||||
<div>
|
<div>
|
||||||
|
{% if pagination.has_prev %}
|
||||||
|
<a href="{{ (pagination.page - 1)|url_for_other_page }}">« {{_('Previous')}}</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{% if pagination.has_next %}
|
||||||
|
<a href="{{ (pagination.page + 1)|url_for_other_page }}">{{_('Next')}} »</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% if entries|length < 1 %}
|
{% if entries|length < 1 %}
|
||||||
<p>{{_('No Results Found')}}</p>
|
<p>{{_('No Results Found')}}</p>
|
||||||
<p>{{_('Search Term:')}} {{adv_searchterm}}</p>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div>
|
|
||||||
{% for entry in entries %}
|
{% for entry in entries %}
|
||||||
{% if entry.Books.authors %}
|
{% if entry.Books.authors %}
|
||||||
{% set author = entry.Books.authors[0].name.replace('|',',')|shortentitle(30) %}
|
{% set author = entry.Books.authors[0].name.replace('|',',')|shortentitle(30) %}
|
||||||
@ -15,10 +25,8 @@
|
|||||||
{% set author = '' %}
|
{% set author = '' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="{{ url_for('basic.show_book', book_id=entry.Books.id) }}">
|
<a href="{{ url_for('basic.show_book', book_id=entry.Books.id) }}">
|
||||||
<p title="{{entry.Books.title}}">{{ author }} - {{entry.Books.title|shortentitle}}</p>
|
<p class="listing" title="{{entry.Books.title}}">{{ author }} - {{entry.Books.title|shortentitle}}</p>
|
||||||
</a>
|
</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -71,6 +71,20 @@ nav > a {
|
|||||||
height: 250px;
|
height: 250px;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.listing {
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 10px 0;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user