refactor: use Flask Blueprints to organize extensions

- extensions are now blueprints: keep views, templastes and statics in the same folder
- increase app security using `flask-talisman`
- whenever possible use {{ url_for }} for links between pages
- remove references to non-existing JavaScript code
- add missing favicon.ico
This commit is contained in:
Eneko Illarramendi
2020-01-31 21:07:05 +01:00
parent 4beb7be852
commit 9e90aabead
29 changed files with 541 additions and 1115 deletions
+8
View File
@@ -0,0 +1,8 @@
from flask import Blueprint
core_app = Blueprint("core", __name__, template_folder="templates")
from .views_api import * # noqa
from .views import * # noqa
Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

+98
View File
@@ -0,0 +1,98 @@
<!-- @format -->
{% extends "base.html" %} {% block menuitems %}
<li><a href="https://where39.com/"><p>Where39 anon locations</p><img src="static/where39.png" style="width:170px"></a></li>
<li><a href="https://github.com/arcbtc/Quickening"><p>The Quickening <$8 PoS</p><img src="static/quick.gif" style="width:170px"></a></li>
<li><a href="http://jigawatt.co/"><p>Buy BTC stamps + electronics</p><img src="static/stamps.jpg" style="width:170px"></a></li>
<li><a href="mailto:ben@arc.wales"><h3>Advertise here!</h3></a></li>
{% endblock %} {% block body %}
<!-- Right side column. Contains the navbar and content of the page -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<ol class="breadcrumb">
<li>
<a href="{{ url_for('core.home') }}"><i class="fa fa-dashboard"></i> Home</a>
</li>
</ol>
<br /><br />
<div class="row">
<div class="col-md-6">
<div class="alert alert-danger alert-dismissable">
<h4>
TESTING ONLY - wallet is still in BETA and very unstable
</h4>
</div></div></div>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-md-3">
<!-- Default box -->
<div class="box">
<div class="box-header">
{% block call_to_action %}
<h1>
<small>Make a wallet</small>
</h1>
<div class="form-group">
<input
type="text"
class="form-control"
id="walname"
placeholder="Name your LNBits wallet"
required
/>
</div>
<button type="button" class="btn btn-primary" onclick="newwallet()">
Submit
</button>
{% endblock %}
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
</div>
<div class="row">
<div class="col-md-6">
<!-- Default box -->
<div class="box">
<div class="box-header">
<h1>
<a href="index.html" class="logo"><b>LN</b>bits</a>
<small>free and open-source lightning wallet</small>
</h1>
<p>
LNbits is a simple, free and open-source lightning-network wallet
for bits and bobs. You can run it on your own server, or use this
one.
<br /><br />
The wallet can be used in a variety of ways, an instant wallet for
LN demonstrations, a fallback wallet for the LNURL scheme, an
accounts system to mitigate the risk of exposing applications to
your full balance.
<br /><br />
The wallet can run on top of LND, lntxbot, paywall, opennode
<br /><br />
Please note that although one of the aims of this wallet is to
mitigate exposure of all your funds, its still very BETA and may
in fact do the opposite!
<br />
<a href="https://github.com/arcbtc/lnbits"
>https://github.com/arcbtc/lnbits</a
>
</p>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
</div>
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
{% endblock %}
+14
View File
@@ -0,0 +1,14 @@
from flask import render_template, send_from_directory
from os import path
from lnbits.core import core_app
@core_app.route("/favicon.ico")
def favicon():
return send_from_directory(path.join(core_app.root_path, "static"), "favicon.ico")
@core_app.route("/")
def home():
return render_template("index.html")
View File