bug fixes and navigation improvement

fixed bugs with postgresql group by statement replacing it with the over statement
added buttons to go to the next and previous episodes in the episode viewer
improved pagination so that it will only show a few previous and next pages instead of all of them
and added a next and previous page button
This commit is contained in:
Matthew Welch 2020-03-28 12:37:11 -07:00
parent 1d2a28032b
commit 8b2e43b41d
8 changed files with 74 additions and 19 deletions

View File

@ -112,7 +112,7 @@ def comic_viewer(publisher, series, series_year, issue):
series_parsed = parse.quote(series)
page_number = int(request.args.get("pageNumber"))
meta = database.db_get_comic(publisher, series, series_year, issue)
page_count = int(meta.pageCount)
page_count = int(meta.pagecount)
prev_page = page_number - 1
next_page = page_number + 1
@ -122,7 +122,7 @@ def comic_viewer(publisher, series, series_year, issue):
prev_page = page_count - 1
prev_url = "/comics/{}?series={}&seriesYear={}&issue={}&pageNumber={}".format(publisher_parsed, series_parsed, series_year, issue, prev_page)
next_url = "/comics/{}?series={}&seriesYear={}&issue={}&pageNumber={}".format(publisher_parsed, series_parsed, series_year, issue, next_page)
title = "Comics: "+meta.series+": #"+meta.issueText+" "+(meta.title or "")
title = "Comics: "+meta.series+": #"+meta.issuetext+" "+(meta.title or "")
return render_template("comics/comicView.html", title=title, on_mobile=on_mobile, prev_url=prev_url, next_url=next_url, comic=meta, page_number=page_number)
except Exception as e:
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
@ -135,8 +135,8 @@ def comic_gallery(publisher, series, series_year, issue):
max_items = request.args.get("max_items", 30, type=int)
meta = database.db_get_comic(publisher, series, series_year, issue)
start = (max_items*(page-1))
end = meta.pageCount if meta.pageCount < max_items*page else max_items*page
return render_template("comics/comicGallery.html", title="Comics", comic=meta, start=start, end=end, page=page, max_items=max_items, item_count=meta.pageCount)
end = meta.pagecount if meta.pagecount < max_items*page else max_items*page
return render_template("comics/comicGallery.html", title="Comics", comic=meta, start=start, end=end, page=page, max_items=max_items, item_count=meta.pagecount)
except Exception as e:
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
return str(type(e)) + " " + str(e)

View File

@ -1,10 +1,10 @@
{% for i in range(start, end) %}
<div class="col-3" style="padding: 10px">
<a href="/comics/{{ publisher_series[i].publisher|urlencode }}?series={{ publisher_series[i].series|urlencode }}&seriesYear={{ publisher_series[i].seriesYear }}">
<a href="/comics/{{ publisher_series[i].publisher|urlencode }}?series={{ publisher_series[i].series|urlencode }}&seriesYear={{ publisher_series[i].seriesyear }}">
<div class="card">
<img class="card-img" src="/comics/get_comic/{{ publisher_series[i]['id'] }}/0/thumbnail" onerror="this.src='/static/images/default.png'">
<div class="card-body">
{{ publisher_series[i].series }} {{ publisher_series[i].seriesYear }}
{{ publisher_series[i].series }} {{ publisher_series[i].seriesyear }}
</div>
</div>
</a>

View File

@ -8,9 +8,9 @@
<div class="comic-grid">
{% for page_number in range(start, end) %}
<div style="margin: auto" class="comic-thumbnail card bg-dark text-white">
<a href="/comics/{{ comic.publisher|urlencode }}?series={{ comic.series|urlencode }}&seriesYear={{ comic.seriesYear }}&issue={{ comic.issue|urlencode }}&pageNumber={{ page_number }}">
<a href="/comics/{{ comic.publisher|urlencode }}?series={{ comic.series|urlencode }}&seriesYear={{ comic.seriesyear }}&issue={{ comic.issue|urlencode }}&pageNumber={{ page_number }}">
<img src="/comics/get_comic/{{ comic.id }}/{{ page_number }}/thumbnail" alt="" style="display: inline" onerror="this.src='/static/images/default.png'">
<p class="card-text">{{ 1+page_number }}/{{ comic.pageCount }}</p>
<p class="card-text">{{ 1+page_number }}/{{ comic.pagecount }}</p>
</a>
</div>
{% endfor %}

View File

@ -1,6 +1,6 @@
{% for i in range(start, end) %}
<div class="col-3" style="padding: 10px">
<a href="/comics/{{ comics[i].publisher|urlencode }}?series={{ comics[i].series|urlencode }}&seriesYear={{ comics[i].seriesYear }}&issue={{ comics[i].issue|urlencode }}">
<a href="/comics/{{ comics[i].publisher|urlencode }}?series={{ comics[i].series|urlencode }}&seriesYear={{ comics[i].seriesyear }}&issue={{ comics[i].issue|urlencode }}">
<div class="card">
<img class="card-img" src="/comics/get_comic/{{ comics[i]['id'] }}/0/thumbnail" onerror="this.src='/static/images/default.png'">
<div class="card-body">

View File

@ -443,7 +443,7 @@ def db_get_all_comics():
def db_get_series_by_publisher(publisher):
session = Session()
result = session.query(Comic).filter(Comic.publisher == publisher).group_by(Comic.publisher, Comic.series, Comic.seriesyear).order_by(Comic.series, Comic.seriesyear).all()
result = [i[0] for i in session.query(Comic, over(func.rank(), partition_by=[Comic.publisher, Comic.series, Comic.seriesyear], order_by=[Comic.series, Comic.seriesyear])).filter(Comic.publisher == publisher).all()]
series = result
return series
@ -580,7 +580,9 @@ def db_get_movie_by_imdb_id(imdb_id, extended=False, directors_cut=False):
def get_all_tv_shows():
session = Session()
result = session.query(TvShow).order_by(TvShow.title, TvShow.year).all()
return result
email = current_user.email
shows = [(i, session.execute("SELECT rpiwebapp.is_tv_show_finished('{}', '{}')".format(i.imdb_id, email)).first()[0]) for i in result]
return shows
def get_tv_show_episodes_by_imdb_id(imdb_id):

View File

@ -5,12 +5,42 @@
{% for key in request.args.keys() %}
{% if key != "page" %}<input type="hidden" name="{{ key }}" value="{{ request.args.get(key) }}">{% endif %}
{% endfor %}
{% with %}
{% set min = 1+page-6 %}
{% set max = page+6 %}
{% set prev = page-1 %}
{% set next = page+1 %}
{% if min <= 1 %}{% set min = 2 %}{% endif %}
{% if max >= page_count %}{% set max = page_count %}{% endif %}
<ul class="pagination">
{% for i in range(1, page_count+1) %}
{% if prev > 0 %}
<li class="page-item">
<button name="page" value="{{ prev }}" class="page-link"><img src="/static/svg/chevron-left.svg"></button>
</li>
{% endif %}
<li class="page-item{% if page == 1 %} active{% endif %}">
<button name="page" value="1" class="page-link">1</button>
</li>
{% if min >2 %}...{% endif %}
{% for i in range(min, max) %}
<li class="page-item{% if page == i %} active{% endif %}">
<button name="page" value="{{ i }}" class="page-link">{{ i }}</button>
</li>
{% endfor %}
{% if max < page_count %}...{% endif %}
<li class="page-item{% if page == page_count %} active{% endif %}">
<button name="page" value="{{ page_count }}" class="page-link">{{ page_count }}</button>
</li>
{% if next < page_count+1 %}
<li class="page-item">
<button name="page" value="{{ next }}" class="page-link"><img src="/static/svg/chevron-right.svg"></button>
</li>
{% endif %}
{% endwith %}
</ul>
</form>
</nav>

View File

@ -11,7 +11,25 @@
<a href='https://videojs.com/html5-video-support/' target='_blank'>supports HTML5 video</a>
</p>
</video>
<h1>{{ episode.title }}</h1>
{% for episode in episodes %}
{% if episode.season == season_num and episode.episode == episode_num %}
{% if loop.index0 - 1 >= 0 %}
<form style="display: inline-block; float: left; margin-top: 5px" action="" method="get">
<input name="season" value="{{ episodes[loop.index0 - 1].season }}" hidden>
<input name="episode" value="{{ episodes[loop.index0 - 1].episode }}" hidden>
<button type="submit">Prev</button>
</form>
{% endif %}
<h1 style="display: inline-block">Episode {{ episode.episode }}: {{ episode.title }}</h1>
{% if loop.index0 + 1 < episodes|length %}
<form style="display: inline-block; float: right; margin-top: 5px" action="" method="get">
<input name="season" value="{{ episodes[loop.index0 + 1].season }}" hidden>
<input name="episode" value="{{ episodes[loop.index0 + 1].episode }}" hidden>
<button type="submit">Next</button>
</form>
{% endif %}
{% endif %}
{% endfor %}
<p style="text-align: left">{{ episode.description }}</p>
<a class="btn btn-primary" href="{{ url_for("tv.index") }}/get_episode/{{ episode.imdb_id }}" download="{{ episode.title }}">Download</a>
@ -45,7 +63,7 @@
<div class="w3-display-bottommiddle w3-container w3-round" style="background: rgba(105,105,105,0.61);color: white">{{ episode.title }}</div>
{% for data in user_tv_show_data %}
{% if data.imdb_id == episode.imdb_id and data.finished %}
<div class="w3-display-topright w3-container w3-round">
<div class="w3-display-topright w3-container" style="background: rgba(105,105,105,0.61); border-radius: 5px 0 0 5px">
<img src="/static/svg/verified.svg" >
</div>
{% endif %}

View File

@ -1,11 +1,16 @@
{% for i in range(start, end) %}
<div class="col-4" style="padding: 10px">
<a href="/tv/{{ tv_shows[i].imdb_id }}">
<div class="card">
<img class="card-img" src="https://image.tmdb.org/t/p/original{{ tv_shows[i].poster_path }}" alt="" onerror="this.src='/static/images/default.png'">
<a href="/tv/{{ tv_shows[i][0].imdb_id }}">
<div class="card w3-display-container">
<img class="card-img" src="https://image.tmdb.org/t/p/original{{ tv_shows[i][0].poster_path }}" alt="" onerror="this.src='/static/images/default.png'">
<div class="card-body">
{{ tv_shows[i].title }} ({{ tv_shows[i].year }})
{{ tv_shows[i][0].title }} ({{ tv_shows[i][0].year }})
</div>
{% if tv_shows[i][1] %}
<div class="w3-display-topright w3-container" style="background: rgba(105,105,105,0.61); border-radius: 5px 0 0 5px">
<img src="/static/svg/verified.svg" >
</div>
{% endif %}
</div>
</a>
</div>