Add base HTML template & config
This commit is contained in:
parent
61a1ae62ab
commit
fa9c8ef1a3
0
config/__init__.py
Normal file
0
config/__init__.py
Normal file
13
config/base.py
Normal file
13
config/base.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
APPS_SPEC = {
|
||||||
|
"gitea": {
|
||||||
|
"url": "https://git.autonomic.zone/compose-stacks/gitea",
|
||||||
|
"secrets": [
|
||||||
|
"db_passwd",
|
||||||
|
"db_root_passwd",
|
||||||
|
"internal_token",
|
||||||
|
"jwt_secret",
|
||||||
|
"secret_key",
|
||||||
|
],
|
||||||
|
"configs": ["app_ini"],
|
||||||
|
}
|
||||||
|
}
|
5
config/local.py
Normal file
5
config/local.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
SECRET_KEY = 'replace-with-truly-random-string-for-production'
|
||||||
|
|
||||||
|
SERVER_NAME = 'localhost:5001'
|
||||||
|
|
||||||
|
DEBUG = True
|
42
second.py
42
second.py
@ -15,8 +15,37 @@ from ruamel.yaml import YAML
|
|||||||
from wtforms import PasswordField, StringField
|
from wtforms import PasswordField, StringField
|
||||||
from wtforms.validators import URL, DataRequired, Length
|
from wtforms.validators import URL, DataRequired, Length
|
||||||
|
|
||||||
|
|
||||||
|
## FLASK CONFIG
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.secret_key = b'_5#y2L"F4Q8z\n\xec]/'
|
|
||||||
|
|
||||||
|
if environ.get('FLASK_CONFIG', None) is None:
|
||||||
|
environ['FLASK_CONFIG'] = 'config/local.py'
|
||||||
|
app.config.from_envvar('FLASK_CONFIG')
|
||||||
|
|
||||||
|
|
||||||
|
## AUTHENTICATION
|
||||||
|
|
||||||
|
|
||||||
|
from flask_login import LoginManager, UserMixin
|
||||||
|
login_manager = LoginManager()
|
||||||
|
login_manager.init_app(app)
|
||||||
|
|
||||||
|
|
||||||
|
class User(UserMixin, object):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@login_manager.user_loader
|
||||||
|
def load_user(user_id):
|
||||||
|
return User.get(user_id)
|
||||||
|
|
||||||
|
|
||||||
|
## CONFIG
|
||||||
|
|
||||||
|
|
||||||
yaml = YAML()
|
yaml = YAML()
|
||||||
|
|
||||||
@ -36,6 +65,9 @@ APPS_SPEC = {
|
|||||||
DATA_DIR = Path("./data")
|
DATA_DIR = Path("./data")
|
||||||
|
|
||||||
|
|
||||||
|
## HELPERS
|
||||||
|
|
||||||
|
|
||||||
def clone_app_template(app_name: str) -> None:
|
def clone_app_template(app_name: str) -> None:
|
||||||
"""Git clone an app template repository."""
|
"""Git clone an app template repository."""
|
||||||
clone_path = DATA_DIR / app_name
|
clone_path = DATA_DIR / app_name
|
||||||
@ -126,6 +158,9 @@ def get_loaded_env(app_name, request_form):
|
|||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
||||||
|
## FORMS
|
||||||
|
|
||||||
|
|
||||||
class GiteaInstallForm(FlaskForm):
|
class GiteaInstallForm(FlaskForm):
|
||||||
"""Gitea installation form."""
|
"""Gitea installation form."""
|
||||||
|
|
||||||
@ -155,6 +190,9 @@ class GiteaInstallForm(FlaskForm):
|
|||||||
ssh_host_port = StringField("SSH host port", default="2225")
|
ssh_host_port = StringField("SSH host port", default="2225")
|
||||||
|
|
||||||
|
|
||||||
|
## VIEWS
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
"""Home page for app installation possibilities."""
|
"""Home page for app installation possibilities."""
|
||||||
@ -202,4 +240,4 @@ def deploy(app_name):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(debug=True, host="0.0.0.0")
|
app.run()
|
||||||
|
1
static/picnic.min.css
vendored
Normal file
1
static/picnic.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
36
templates/base.html
Normal file
36
templates/base.html
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="robots" content="noindex, nofollow">
|
||||||
|
|
||||||
|
{% block meta %}
|
||||||
|
<meta name="copyright" content="GPLv3">
|
||||||
|
<meta name="application-name" content="Magic App">
|
||||||
|
{% endblock meta %}
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='picnic.min.css') }}">
|
||||||
|
{% if debug %}
|
||||||
|
{% else %}
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/picnic">
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<title>{% block title %}🎩{% endblock %}</title>
|
||||||
|
</head>
|
||||||
|
<body style="padding-top: 3em;">
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
<nav>
|
||||||
|
<a href="#" class="brand">
|
||||||
|
<span>Magic App</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<!-- responsive-->
|
||||||
|
<input id="bmenub" type="checkbox" class="show">
|
||||||
|
<label for="bmenub" class="burger pseudo button">menu</label>
|
||||||
|
|
||||||
|
<div class="menu">
|
||||||
|
<a href="{{ url_for('index') }}" class="button">Apps</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1,16 +1,11 @@
|
|||||||
<!DOCTYPE html>
|
{% extends "base.html" %}
|
||||||
<html lang="en">
|
|
||||||
<head>
|
{% block content %}
|
||||||
<meta charset="utf-8" />
|
<h1>Installable apps</h1>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<p>Where the magic h<em>app</em>ens.</p>
|
||||||
<title>Magic App</title>
|
<ul>
|
||||||
</head>
|
{% for app in apps %}
|
||||||
<body>
|
<li><a href="/install/{{ app }}">{{ app }}</a></li>
|
||||||
<p>List of apps that can be installed:</p>
|
</ul>
|
||||||
<ul>
|
{% endfor %}
|
||||||
{% for app in apps %}
|
{% endblock content %}
|
||||||
<li><a href="/install/{{ app }}">{{ app }}</a></li>
|
|
||||||
</ul>
|
|
||||||
{% endfor %}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
@ -1,20 +1,15 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
{% from "second/macros.html" import with_errors %}
|
{% from "second/macros.html" import with_errors %}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
{% block title %}Install {{ app_name }} {{ super() }}{% endblock %}
|
||||||
<html lang="en">
|
|
||||||
<head>
|
{% block content %}
|
||||||
<meta charset="utf-8" />
|
<p>Install {{ app_name }}</p>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<form method="POST" action="/deploy/{{ app_name }}">
|
||||||
<title>Install {{ app_name }}</title>
|
{% for field in form %}
|
||||||
</head>
|
{{ field.label() }}
|
||||||
<body>
|
{{ with_errors(field, style='font-weight: bold') }}
|
||||||
<p>Install {{ app_name }}</p>
|
{% endfor %}
|
||||||
<form method="POST" action="/deploy/{{ app_name }}">
|
<input type="submit" value="Deploy" />
|
||||||
{% for field in form %}
|
</form>
|
||||||
{{ field.label() }}
|
{% endblock content %}
|
||||||
{{ with_errors(field, style='font-weight: bold') }}
|
|
||||||
{% endfor %}
|
|
||||||
<input type="submit" value="Deploy" />
|
|
||||||
</form>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
Reference in New Issue
Block a user