diff --git a/.editorconfig b/.editorconfig index f70a443..c97c983 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,6 +6,10 @@ end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true +[*.{html,js,json}] +indent_size = 2 +indent_style = space + [*.md] trim_trailing_whitespace = false diff --git a/lnbits/__init__.py b/lnbits/__init__.py index 2bb0b57..fdac129 100644 --- a/lnbits/__init__.py +++ b/lnbits/__init__.py @@ -1,3 +1,4 @@ +import importlib import json import requests import uuid @@ -9,12 +10,17 @@ from lnurl import Lnurl, LnurlWithdrawResponse from . import bolt11 from .core import core_app from .db import init_databases, open_db -from .extensions.withdraw import withdraw_ext from .helpers import ExtensionManager, megajson from .settings import WALLET, DEFAULT_USER_WALLET_NAME, FEE_RESERVE app = Flask(__name__) +valid_extensions = [ext for ext in ExtensionManager().extensions if ext.is_valid] + + +# optimization & security +# ----------------------- + Talisman( app, content_security_policy={ @@ -32,20 +38,41 @@ Talisman( }, ) + +# blueprints / extensions +# ----------------------- + +app.register_blueprint(core_app) + +for ext in valid_extensions: + try: + ext_module = importlib.import_module(f"lnbits.extensions.{ext.code}") + app.register_blueprint(getattr(ext_module, f"{ext.code}_ext"), url_prefix=f"/{ext.code}") + except Exception: + raise ImportError(f"Please make sure that the extension `{ext.code}` follows conventions.") + + # filters -app.jinja_env.globals["EXTENSIONS"] = [ext for ext in ExtensionManager().extensions if ext.is_valid] +# ------- + +app.jinja_env.globals["EXTENSIONS"] = valid_extensions app.jinja_env.filters["megajson"] = megajson -# blueprints -app.register_blueprint(core_app) -app.register_blueprint(withdraw_ext, url_prefix="/withdraw") +# init +# ---- @app.before_first_request def init(): init_databases() +# vvvvvvvvvvvvvvvvvvvvvvvvvvv +# move the rest to `core_app` +# vvvvvvvvvvvvvvvvvvvvvvvvvvv +# vvvvvvvvvvvvvvvvvvvvvvvvvvv + + @app.route("/deletewallet") def deletewallet(): user_id = request.args.get("usr") diff --git a/lnbits/extensions/withdraw/config.json b/lnbits/extensions/withdraw/config.json index b34bb10..1303256 100644 --- a/lnbits/extensions/withdraw/config.json +++ b/lnbits/extensions/withdraw/config.json @@ -1,5 +1,5 @@ { - "name": "LNURLw", - "short_description": "Make LNURL withdraw links.", - "ion_icon": "beer" + "name": "LNURLw", + "short_description": "Make LNURL withdraw links.", + "ion_icon": "beer" } diff --git a/lnbits/templates/extensions.html b/lnbits/templates/extensions.html index 308e46e..2a74218 100644 --- a/lnbits/templates/extensions.html +++ b/lnbits/templates/extensions.html @@ -4,115 +4,111 @@ {% block messages %} - - - ! - - + + + ! + + {% endblock %} {% block menuitems %} -
  • - - Wallets - - - -
  • -
  • - - Extensions - - - -
  • +
  • + + Wallets + + + +
  • +
  • + + Extensions + + + +
  • {% endblock %} {% block body %} - -
    + +
    - -
    -
    -

    Wallet Control panel

    - + +
    +
    +

    Wallet Control panel

    + -
    -
    +
    +
    -
    -

    Bookmark to save your wallet. Wallet is in BETA, use with caution.

    -
    -
    +
    +

    Bookmark to save your wallet. Wallet is in BETA, use with caution.

    +
    +
    - -
    - -
    + +
    + +
    - {% for extension in EXTENSIONS %} -
    - -
    - -
    - -
    - {% if extension.code in user_ext %} - Disable - {% else %} - Enable - {% endif %} -
    -
    - {% endfor %} + {% for extension in EXTENSIONS %} +
    + +
    + +
    + +
    + {% if extension.code in user_ext %} + Disable + {% else %} + Enable + {% endif %} +
    +
    + {% endfor %} -
    - -
    -
    +
    + + +
    - + {% endblock %}