Merge pull request #18 from UniversityRadioYork/michaelg-bits

Not Overwhelming the Log Pages
This commit is contained in:
Matthew Stratford 2021-05-17 22:10:35 +01:00 committed by GitHub
commit 26a6f72cf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 21 deletions

View file

@ -1,4 +1,5 @@
# BAPSicle # BAPSicle
### a.k.a. The Next-Gen BAPS server ### a.k.a. The Next-Gen BAPS server
!["BAPSicle logo, a pink melting ice lolly."](docs/images/logo.png "BAPSicle Logo") !["BAPSicle logo, a pink melting ice lolly."](docs/images/logo.png "BAPSicle Logo")
@ -11,12 +12,13 @@ Just want to install BAPSicle?
### Windows ### Windows
Currently there's just a batch script. Simply run ``install.bat`` as administrator. If you've just built BAPSicle yourself, it'll be in the ``/install`` folder. Currently there's just a batch script. Simply run `install.bat` as administrator. If you've just built BAPSicle yourself, it'll be in the `/install` folder.
This will: This will:
* Copy BAPSicle into ``C:\Program Files\BAPSicle``
* Install BAPSicle.exe as a Windows Service with NSSM. - Copy BAPSicle into `C:\Program Files\BAPSicle`
* If all goes well, open [http://localhost:13500](localhost:13500) for the server UI. - Install BAPSicle.exe as a Windows Service with NSSM.
- If all goes well, open [http://localhost:13500](localhost:13500) for the server UI.
### Linux ### Linux
@ -24,7 +26,7 @@ Installed service for linux is coming soon. Testing is primarily on Ubuntu 20.04
### MacOS ### MacOS
Currently there's no installer for MacOS, so you'll have to move the ``build/output/BAPSicle.app`` you've built and make it start automatically (if you want). Currently there's no installer for MacOS, so you'll have to move the `build/output/BAPSicle.app` you've built and make it start automatically (if you want).
Starting and stopping the server, as well as UI links, are available in the System Menu once opening the app. Starting and stopping the server, as well as UI links, are available in the System Menu once opening the app.
@ -35,29 +37,32 @@ Starting and stopping the server, as well as UI links, are available in the Syst
### Requirements ### Requirements
On all platforms: On all platforms:
* Python 3.7 - 3.9 Tested (macOS 3.7 may be iffy)
* Git (Obviously) - Python 3.8 - 3.9 Tested
- Git (Obviously)
On MacOS: On MacOS:
* Homebrew (To install command line Platypus)
- Homebrew (To install command line Platypus)
### Running ### Running
To just run the server standaline without installing, run ``python ./launch_standalone.py``.
To just run the server standaline without installing, run `python ./launch.py`.
## Building ## Building
### Windows ### Windows
To build a ``BAPSicle.exe``, run ``build\build-exe.bat``. The resulting file will appear in ``build\output``. You can then use the install instructions above to install it, or just run it standalone. To build a `BAPSicle.exe`, run `build\build-exe.bat`. The resulting file will appear in `build\output`. You can then use the install instructions above to install it, or just run it standalone.
### Linux ### Linux
To build a ``BAPSicle`` executable, run ``build/build-linux.sh``. The resulting file will appear in ``build/output``. To build a `BAPSicle` executable, run `build/build-linux.sh`. The resulting file will appear in `build/output`.
### MacOS ### MacOS
To build a ``BAPSicle.app``, run ``build/build-macos.sh``. The resulting file will appear in ``build/output``. To build a `BAPSicle.app`, run `build/build-macos.sh`. The resulting file will appear in `build/output`.
### Other bits ### Other bits
Provided is a VScode debug config to let you debug live, as well as ``dev\install-githook.{bat,sh}`` that will help git to clean your code up as you're committing! Provided is a VScode debug config to let you debug live, as well as `dev\install-githook.{bat,sh}` that will help git to clean your code up as you're committing!

View file

@ -1,11 +1,34 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block content_inner %} {% block content_inner %}
{% if data %} {% if data %}
{% for log in data.logs %} <div>
<code> {% if data.page != 1 %}
{{log}} <a href="?page={{data.page-1}}" class="float-left">
</code> <<< Previous Page
<br> </a>
{% endfor %} {% endif %}
<a href="?page={{data.page+1}}" class="float-right">
Next Page >>>
</a>
</div>
<br>
{% for log in data.logs %}
<code>
{{log}}
</code>
<br>
{% endfor %}
<br>
<div>
{% if data.page != 1 %}
<a href="?page={{data.page-1}}" class="float-left">
<<< Previous Page
</a>
{% endif %}
<a href="?page={{data.page+1}}" class="float-right">
Next Page >>>
</a>
</div>
<br>
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View file

@ -141,11 +141,18 @@ def ui_logs_list(request):
@app.route("/logs/<path:path>") @app.route("/logs/<path:path>")
def ui_logs_render(request, path): def ui_logs_render(request, path):
page = request.args.get("page")
if not page:
return redirect(f"/logs/{path}?page=1")
page = int(page)
assert page >= 1
log_file = open("logs/{}.log".format(path)) log_file = open("logs/{}.log".format(path))
data = { data = {
"logs": log_file.read().splitlines(), "logs": log_file.read().splitlines()[-300*page:(-300*(page-1) if page > 1 else None)][::-1],
"ui_page": "logs", "ui_page": "logs",
"ui_title": "Logs - {}".format(path), "ui_title": "Logs - {}".format(path),
"page": page
} }
log_file.close() log_file.close()
return render_template("log.html", data=data) return render_template("log.html", data=data)
@ -306,7 +313,8 @@ async def audio_file(request, type: str, id: int):
# Static Files # Static Files
app.static("/favicon.ico", resolve_local_file_path("ui-static/favicon.ico"), name="ui-favicon") app.static("/favicon.ico", resolve_local_file_path("ui-static/favicon.ico"), name="ui-favicon")
app.static("/static", resolve_local_file_path("ui-static"), name="ui-static") app.static("/static", resolve_local_file_path("ui-static"), name="ui-static")
app.static("/presenter/", resolve_local_file_path("presenter-build/index.html"), strict_slashes=True, name="presenter-index") app.static("/presenter/", resolve_local_file_path("presenter-build/index.html"),
strict_slashes=True, name="presenter-index")
app.static("/presenter/", resolve_local_file_path("presenter-build")) app.static("/presenter/", resolve_local_file_path("presenter-build"))