Skip to content

Commit

Permalink
Add next and previous buttons only when content is available
Browse files Browse the repository at this point in the history
  • Loading branch information
dormant-user committed Jan 10, 2024
1 parent c77fae4 commit 8c738ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pystream/routers/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,10 @@ async def stream_video(request: Request,
)
if pure_path.exists():
prev_, next_ = squire.get_iter(pure_path)
# fixme: perhaps, remove previous and next buttons in template instead of defaulting to #
attrs = {
"request": request, "title": video_path,
"path": f"{config.static.streaming_endpoint}?{config.static.query_param}={urlparse.quote(str(pure_path))}",
"previous": prev_ or "#", "next": next_ or "#"
"previous": prev_, "next": next_
}
# set default to avoid broken image sign in thumbnail
preview_src = os.path.join(pathlib.PurePath(__file__).parent, "blank.jpg")
Expand Down
4 changes: 4 additions & 0 deletions pystream/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,16 @@ <h1>{{title}}</h1>
<a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
</p>
</video>
{% if previous %}
<button class="iter" style="float: left" onclick="window.location='{{ previous }}'" title="{{ previous }}">
<i class="fa fa-backward"></i> Previous
</button>
{% endif %}
{% if next %}
<button class="iter" style="float: right" onclick="window.location='{{ next }}'" title="{{ next }}">
Next <i class="fa fa-forward"></i>
</button>
{% endif %}
<br><br>
</div>
<script>
Expand Down

0 comments on commit 8c738ac

Please sign in to comment.