split templates, add static files (bootstrap 5.1.3)
This commit is contained in:
parent
4d98d825bf
commit
7e15835ebd
@ -34,6 +34,7 @@ class MyQuartApp(quart_trio.QuartTrio):
|
||||
def __init__(self, import_name: str, **kwargs) -> None:
|
||||
self.my_config = capport.config.Config.load_default_once()
|
||||
kwargs.setdefault('template_folder', os.path.join(os.path.dirname(__file__), 'templates'))
|
||||
kwargs.setdefault('static_folder', os.path.join(os.path.dirname(__file__), 'static'))
|
||||
cust_templ = os.path.join('custom', 'templates')
|
||||
if os.path.exists(cust_templ):
|
||||
self.custom_loader = jinja2.FileSystemLoader(os.fspath(cust_templ))
|
||||
|
7
src/capport/api/static/bootstrap/bootstrap.bundle.min.js
vendored
Normal file
7
src/capport/api/static/bootstrap/bootstrap.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
src/capport/api/static/bootstrap/bootstrap.min.css
vendored
Normal file
7
src/capport/api/static/bootstrap/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -3,12 +3,21 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>{% block title %}Captive Portal{% endblock %}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<script src="{{ url_for('static', filename='bootstrap/bootstrap.bundle.min.js') }}"></script>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='bootstrap/bootstrap.min.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
{% block content %}{% endblock %}
|
||||
<body class="container">
|
||||
<header class="d-flex justify-content-center py-3">
|
||||
<ul class="nav nav-pills">
|
||||
<li class="nav-item"><a href="#" class="nav-link active" aria-current="page">Home</a></li>
|
||||
</ul>
|
||||
</header>
|
||||
|
||||
{% for message in get_flashed_messages() %}
|
||||
<div class="flash">{{ message }}</div>
|
||||
<div class="alert alert-primary" role="alert">{{ message }}</div>
|
||||
{% endfor %}
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,16 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
{% if not state.mac %}
|
||||
<p>It seems you're accessing this site from outside the network this captive portal is running for.</p>
|
||||
<p>Your clients IP address is {{ state.address }}</p>
|
||||
{% elif state.captive %}
|
||||
To get access to the internet please accept our usage guidelines by clicking this button:
|
||||
<form method="POST" action="/login"><button type="submit">Accept</button></form>
|
||||
{% else %}
|
||||
You already accepted out conditions and are currently granted access to the internet:
|
||||
<form method="POST" action="/login"><button type="submit">Renew session</button></form>
|
||||
<form method="POST" action="/logout"><button type="submit">Close session</button></form>
|
||||
<br>
|
||||
Your current session will last for {{ state.allowed_remaining }} seconds.
|
||||
{% endif %}
|
||||
{% endblock %}
|
14
src/capport/api/templates/index_active.html
Normal file
14
src/capport/api/templates/index_active.html
Normal file
@ -0,0 +1,14 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
You already accepted out conditions and are currently granted access to the internet:
|
||||
|
||||
Your current session will last for {{ state.allowed_remaining }} seconds.
|
||||
<form method="POST" action="/login">
|
||||
<input type="hidden" name="accept" value="1">
|
||||
<button type="submit" class="btn btn-primary mb-3">Extend session</button>
|
||||
</form>
|
||||
<form method="POST" action="/logout">
|
||||
<button type="submit" class="btn btn-danger mb-3">Terminate session</button>
|
||||
</form>
|
||||
<br>
|
||||
{% endblock %}
|
8
src/capport/api/templates/index_inactive.html
Normal file
8
src/capport/api/templates/index_inactive.html
Normal file
@ -0,0 +1,8 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
To get access to the internet please accept our usage guidelines by clicking this button:
|
||||
<form method="POST" action="/login">
|
||||
<input type="hidden" name="accept" value="1">
|
||||
<button type="submit" class="btn btn-primary mb-3">Accept</button>
|
||||
</form>
|
||||
{% endblock %}
|
5
src/capport/api/templates/index_unknown.html
Normal file
5
src/capport/api/templates/index_unknown.html
Normal file
@ -0,0 +1,5 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<p>It seems you're accessing this site from outside the network this captive portal is running for.</p>
|
||||
<p>Your clients IP address is {{ state.address }}</p>
|
||||
{% endblock %}
|
@ -98,7 +98,12 @@ async def user_lookup() -> cptypes.MacPublicState:
|
||||
@app.route('/', methods=['GET'])
|
||||
async def index():
|
||||
state = await user_lookup()
|
||||
return await quart.render_template('index.html', state=state)
|
||||
if not state.mac:
|
||||
return await quart.render_template('index_unknown.html', state=state)
|
||||
elif state.allowed:
|
||||
return await quart.render_template('index_active.html', state=state)
|
||||
else:
|
||||
return await quart.render_template('index_inactive.html', state=state)
|
||||
|
||||
|
||||
@app.route('/login', methods=['POST'])
|
||||
|
Loading…
Reference in New Issue
Block a user