mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Fixed bug where previous searches, and orders were not respected by
paging
This commit is contained in:
@@ -21,7 +21,7 @@ from interface import views
|
|||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
path("", views.index, name="index"),
|
path("", views.index, name="index"),
|
||||||
path("/<query>", views.index, name="index"),
|
path("home", views.home, name="index"),
|
||||||
path("sort/<_order>", views.index, name="index"),
|
path("sort/<_order>", views.index, name="index"),
|
||||||
path("download/<pk>", views.download, name="download"),
|
path("download/<pk>", views.download, name="download"),
|
||||||
path("favorite/<pk>", views.favorite, name="favorite"),
|
path("favorite/<pk>", views.favorite, name="favorite"),
|
||||||
@@ -29,6 +29,8 @@ urlpatterns = [
|
|||||||
path("share/<pk>", views.info, name="info"),
|
path("share/<pk>", views.info, name="info"),
|
||||||
path("prev_page/<bookset>", views.prev_page, name="prev_page"),
|
path("prev_page/<bookset>", views.prev_page, name="prev_page"),
|
||||||
path("next_page/<bookset>", views.next_page, name="next_page"),
|
path("next_page/<bookset>", views.next_page, name="next_page"),
|
||||||
|
path("prev_page/<bookset>/<_order>", views.prev_page, name="prev_page"),
|
||||||
|
path("next_page/<bookset>/<_order>", views.next_page, name="next_page"),
|
||||||
path("search/", views.index, name="search"),
|
path("search/", views.index, name="search"),
|
||||||
path("search/<query>", views.index, name="search"),
|
path("search/<query>", views.index, name="search"),
|
||||||
path("search/<query>/<_set>", views.index, name="search"),
|
path("search/<query>/<_set>", views.index, name="search"),
|
||||||
|
|||||||
4
src/interface/static/js/pyshelf_ux.js
vendored
4
src/interface/static/js/pyshelf_ux.js
vendored
@@ -81,10 +81,8 @@ $(document).ready(function(){
|
|||||||
window.location.href="/"+valueSelected
|
window.location.href="/"+valueSelected
|
||||||
});
|
});
|
||||||
$('#btn-home').on("click", function(){
|
$('#btn-home').on("click", function(){
|
||||||
console.log('Home Pressed');
|
|
||||||
_location = $(this).attr('data-location');
|
_location = $(this).attr('data-location');
|
||||||
$('#_order').val(null);
|
|
||||||
$('#_search').val(null);
|
|
||||||
window.location.href=_location;
|
window.location.href=_location;
|
||||||
});
|
});
|
||||||
|
$('#search_string').html("<i> "+$('#_search').val().substr(0,15)+"</i>")
|
||||||
});
|
});
|
||||||
|
|||||||
8
src/interface/templates/index.html
vendored
8
src/interface/templates/index.html
vendored
@@ -39,7 +39,7 @@
|
|||||||
<h1 class="app_hdr" id="hdr_branding">pyShelf {{Version}}</h1>
|
<h1 class="app_hdr" id="hdr_branding">pyShelf {{Version}}</h1>
|
||||||
<div class="hdr_nav" id="hdr_nav_center">
|
<div class="hdr_nav" id="hdr_nav_center">
|
||||||
<ul id="tab_nav_menu">
|
<ul id="tab_nav_menu">
|
||||||
<li class="nav_menu_tab active_tab" id="btn-home" data-location="/?query=0"><i class="fas fa-home"></i> Home</li>
|
<li class="nav_menu_tab active_tab" id="btn-home" data-location="/home"><i class="fas fa-home"></i> Home</li>
|
||||||
<li class="nav_menu_tab"><i class="fas fa-layer-group"></i> Collections</li>
|
<li class="nav_menu_tab"><i class="fas fa-layer-group"></i> Collections</li>
|
||||||
<li class="nav_menu_tab"><i class="fas fa-star"></i> Favorites</li>
|
<li class="nav_menu_tab"><i class="fas fa-star"></i> Favorites</li>
|
||||||
<li class="nav_menu_tab"><i class="fas fa-bug"></i> Bug report</li>
|
<li class="nav_menu_tab"><i class="fas fa-bug"></i> Bug report</li>
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="horiz_nav_main">
|
<div id="horiz_nav_main">
|
||||||
<div id="horiz_nav_left">
|
<div id="horiz_nav_left">
|
||||||
<i class="fas fa-arrow-circle-left nav_icon prev_page" onclick="window.location.href = '/prev_page/{{ Set }}'"></i>
|
<i class="fas fa-arrow-circle-left nav_icon prev_page" onclick="window.location.href = '/prev_page/{{ Set }}/{{ Order }}'"></i>
|
||||||
sort <i class="fas fa-sort nav_icon"></i>
|
sort <i class="fas fa-sort nav_icon"></i>
|
||||||
<select id = "sortlist">
|
<select id = "sortlist">
|
||||||
<option valie = "" id="empty-sort"></option>
|
<option valie = "" id="empty-sort"></option>
|
||||||
@@ -62,11 +62,11 @@
|
|||||||
<i class="fas fa-sort-alpha-down nav_icon"></i>
|
<i class="fas fa-sort-alpha-down nav_icon"></i>
|
||||||
<i class="fas fa-sort-alpha-up nav_icon"></i>
|
<i class="fas fa-sort-alpha-up nav_icon"></i>
|
||||||
<input class="nav_search input_box" type="text" size="40" value="search by Title, Author, Tags, or Collections">
|
<input class="nav_search input_box" type="text" size="40" value="search by Title, Author, Tags, or Collections">
|
||||||
<i class="fas fa-search search_submit search_button" onclick="window.location.href = '/prev_page/{{ Set }}'">search</i>
|
<i class="fas fa-search search_submit search_button" id="search_string" onclick="window.location.href = '/prev_page/{{ Set }}'"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="horiz_nav_stats">
|
<div class="horiz_nav_stats">
|
||||||
<i class="fas fa-book nav_icon"></i> {{ NowShowing }} of {{ BookStats }}
|
<i class="fas fa-book nav_icon"></i> {{ NowShowing }} of {{ BookStats }}
|
||||||
<i class="fas fa-arrow-circle-right nav_icon next_page" onclick="window.location.href = '/next_page/{{ Set }}'"></i>
|
<i class="fas fa-arrow-circle-right nav_icon next_page" onclick="window.location.href = '/next_page/{{ Set }}/{{ Order }}'"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -28,6 +28,16 @@ def index(request, query=None, _set=1, _limit=None, _order='title'):
|
|||||||
_payload
|
_payload
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def home(request, query=None, _set=1, _limit=None, _order='title'):
|
||||||
|
"""
|
||||||
|
Reset Search Queries & Return Home
|
||||||
|
"""
|
||||||
|
_payload = payload(request, query, _set, _limit, _order, reset='1')
|
||||||
|
return render(
|
||||||
|
request,
|
||||||
|
"index.html",
|
||||||
|
_payload
|
||||||
|
)
|
||||||
def show_collection(request, _collection, _colset):
|
def show_collection(request, _collection, _colset):
|
||||||
try:
|
try:
|
||||||
_set = int(_colset) + 1
|
_set = int(_colset) + 1
|
||||||
@@ -225,7 +235,6 @@ def menu(which, _set=1, parent=None):
|
|||||||
return _collections
|
return _collections
|
||||||
elif which == "nav_lvl_0":
|
elif which == "nav_lvl_0":
|
||||||
navigation_list = Navigation.objects.all()
|
navigation_list = Navigation.objects.all()
|
||||||
breakpoint()
|
|
||||||
return navigation_list
|
return navigation_list
|
||||||
|
|
||||||
def collections_list():
|
def collections_list():
|
||||||
@@ -235,39 +244,49 @@ def collections_list():
|
|||||||
collection_key.append(i.collection)
|
collection_key.append(i.collection)
|
||||||
return json.dumps(list(set(collection_key)))
|
return json.dumps(list(set(collection_key)))
|
||||||
|
|
||||||
def payload(request, query, _set, _limit, _order):
|
def payload(request, query, _set, _limit, _order, **kwargs):
|
||||||
"""
|
"""
|
||||||
Return formatted data to template
|
Return formatted data to template
|
||||||
"""
|
"""
|
||||||
breakpoint()
|
try:
|
||||||
_set = int(_set)
|
if kwargs['reset']:
|
||||||
if _set < 1: _set = 1
|
|
||||||
if _limit is None: _limit = 20
|
|
||||||
_set_max = int(_set) * _limit
|
|
||||||
_set_min = _set_max - _limit
|
|
||||||
_now_showing = "%s-%s"%(_set_min, _set_max)
|
|
||||||
if query:
|
|
||||||
if query != request.session.get('cached_query'):
|
|
||||||
request.session['cached_query'] = query
|
request.session['cached_query'] = query
|
||||||
_results = Books().generic_search(query)
|
if _set < 1: _set = 1
|
||||||
_r, _r_len = \
|
if _limit is None: _limit = 20
|
||||||
_results[_set_min:_set_max],\
|
_set_max = int(_set) * _limit
|
||||||
_results.count()
|
_set_min = _set_max - _limit
|
||||||
elif query == request.session.get('cached_query'):
|
_now_showing = "%s-%s"%(_set_min, _set_max)
|
||||||
_results = Books().generic_search(query)
|
|
||||||
_r, _r_len = \
|
|
||||||
_results.order_by(_order)[_set_min:_set_max],\
|
|
||||||
_results.count()
|
|
||||||
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
query = request.session['cached_query']
|
|
||||||
_results = Books().generic_search(query)
|
|
||||||
_r, _r_len = \
|
|
||||||
_results.order_by(_order)[_set_min:_set_max],\
|
|
||||||
_results.count()
|
|
||||||
except KeyError:
|
|
||||||
_r, _r_len, _search = book_set(_order, _limit, _set), None, None
|
_r, _r_len, _search = book_set(_order, _limit, _set), None, None
|
||||||
|
except KeyError:
|
||||||
|
_set = int(_set)
|
||||||
|
if _set < 1: _set = 1
|
||||||
|
if _limit is None: _limit = 20
|
||||||
|
_set_max = int(_set) * _limit
|
||||||
|
_set_min = _set_max - _limit
|
||||||
|
_now_showing = "%s-%s"%(_set_min, _set_max)
|
||||||
|
if query:
|
||||||
|
if query != request.session.get('cached_query'):
|
||||||
|
request.session['cached_query'] = query
|
||||||
|
_results = Books().generic_search(query)
|
||||||
|
_r, _r_len = \
|
||||||
|
_results[_set_min:_set_max],\
|
||||||
|
_results.count()
|
||||||
|
elif query == request.session.get('cached_query'):
|
||||||
|
_results = Books().generic_search(query)
|
||||||
|
_r, _r_len = \
|
||||||
|
_results.order_by(_order)[_set_min:_set_max],\
|
||||||
|
_results.count()
|
||||||
|
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
query = request.session['cached_query']
|
||||||
|
if query == None: raise KeyError
|
||||||
|
_results = Books().generic_search(query)
|
||||||
|
_r, _r_len = \
|
||||||
|
_results.order_by(_order)[_set_min:_set_max],\
|
||||||
|
_results.count()
|
||||||
|
except KeyError:
|
||||||
|
_r, _r_len, _search = book_set(_order, _limit, _set), None, None
|
||||||
|
|
||||||
_bookstats, _collectionstats, _collectionobject = \
|
_bookstats, _collectionstats, _collectionobject = \
|
||||||
Books.objects.all().count, Collections.objects.all().count, \
|
Books.objects.all().count, Collections.objects.all().count, \
|
||||||
|
|||||||
Reference in New Issue
Block a user