diff --git a/lnbits/extensions/TwitchAlerts/README.md b/lnbits/extensions/TwitchAlerts/README.md new file mode 100644 index 000000000..543fc337a --- /dev/null +++ b/lnbits/extensions/TwitchAlerts/README.md @@ -0,0 +1,11 @@ +

Example Extension

+

*tagline*

+This is an TwitchAlerts extension to help you organise and build you own. + +Try to include an image + + + +

If your extension has API endpoints, include useful ones here

+ +curl -H "Content-type: application/json" -X POST https://YOUR-LNBITS/YOUR-EXTENSION/api/v1/EXAMPLE -d '{"amount":"100","memo":"TwitchAlerts"}' -H "X-Api-Key: YOUR_WALLET-ADMIN/INVOICE-KEY" diff --git a/lnbits/extensions/TwitchAlerts/__init__.py b/lnbits/extensions/TwitchAlerts/__init__.py new file mode 100644 index 000000000..c31c56284 --- /dev/null +++ b/lnbits/extensions/TwitchAlerts/__init__.py @@ -0,0 +1,12 @@ +from quart import Blueprint +from lnbits.db import Database + +db = Database("ext_TwitchAlerts") + +TwitchAlerts_ext: Blueprint = Blueprint( + "TwitchAlerts", __name__, static_folder="static", template_folder="templates" +) + + +from .views_api import * # noqa +from .views import * # noqa diff --git a/lnbits/extensions/TwitchAlerts/config.json b/lnbits/extensions/TwitchAlerts/config.json new file mode 100644 index 000000000..55389373b --- /dev/null +++ b/lnbits/extensions/TwitchAlerts/config.json @@ -0,0 +1,6 @@ +{ + "name": "Build your own!", + "short_description": "Join us, make an extension", + "icon": "info", + "contributors": ["github_username"] +} diff --git a/lnbits/extensions/TwitchAlerts/migrations.py b/lnbits/extensions/TwitchAlerts/migrations.py new file mode 100644 index 000000000..2d107d196 --- /dev/null +++ b/lnbits/extensions/TwitchAlerts/migrations.py @@ -0,0 +1,11 @@ +# async def m001_initial(db): + +# await db.execute( +# """ +# CREATE TABLE IF NOT EXISTS TwitchAlerts ( +# id TEXT PRIMARY KEY, +# wallet TEXT NOT NULL, +# time TIMESTAMP NOT NULL DEFAULT (strftime('%s', 'now')) +# ); +# """ +# ) diff --git a/lnbits/extensions/TwitchAlerts/models.py b/lnbits/extensions/TwitchAlerts/models.py new file mode 100644 index 000000000..be5232339 --- /dev/null +++ b/lnbits/extensions/TwitchAlerts/models.py @@ -0,0 +1,11 @@ +# from sqlite3 import Row +# from typing import NamedTuple + + +# class Example(NamedTuple): +# id: str +# wallet: str +# +# @classmethod +# def from_row(cls, row: Row) -> "Example": +# return cls(**dict(row)) diff --git a/lnbits/extensions/TwitchAlerts/templates/example/index.html b/lnbits/extensions/TwitchAlerts/templates/example/index.html new file mode 100644 index 000000000..e78e07bc8 --- /dev/null +++ b/lnbits/extensions/TwitchAlerts/templates/example/index.html @@ -0,0 +1,57 @@ +{% extends "base.html" %} {% from "macros.jinja" import window_vars with context +%} {% block page %} + + +
Frameworks used by LNbits
+ + + {% raw %} + + + {{ tool.name }} + {{ tool.language }} + + {% endraw %} + + + +

+ A magical "g" is always available, with info about the user, wallets and + extensions: +

+ {% raw %}{{ g }}{% endraw %} +
+
+{% endblock %} {% block scripts %} {{ window_vars(user) }} + +{% endblock %} diff --git a/lnbits/extensions/TwitchAlerts/views.py b/lnbits/extensions/TwitchAlerts/views.py new file mode 100644 index 000000000..f080a62e6 --- /dev/null +++ b/lnbits/extensions/TwitchAlerts/views.py @@ -0,0 +1,12 @@ +from quart import g, render_template + +from lnbits.decorators import check_user_exists, validate_uuids + +from . import TwitchAlerts_ext + + +@TwitchAlerts_ext.route("/") +@validate_uuids(["usr"], required=True) +@check_user_exists() +async def index(): + return await render_template("TwitchAlerts/index.html", user=g.user) diff --git a/lnbits/extensions/TwitchAlerts/views_api.py b/lnbits/extensions/TwitchAlerts/views_api.py new file mode 100644 index 000000000..1641d5eb8 --- /dev/null +++ b/lnbits/extensions/TwitchAlerts/views_api.py @@ -0,0 +1,40 @@ +# views_api.py is for you API endpoints that could be hit by another service + +# add your dependencies here + +# import json +# import httpx +# (use httpx just like requests, except instead of response.ok there's only the +# response.is_error that is its inverse) + +from quart import jsonify +from http import HTTPStatus + +from . import TwitchAlerts_ext + + +# add your endpoints here + + +@TwitchAlerts_ext.route("/api/v1/tools", methods=["GET"]) +async def api_TwitchAlerts(): + """Try to add descriptions for others.""" + tools = [ + { + "name": "Quart", + "url": "https://pgjones.gitlab.io/quart/", + "language": "Python", + }, + { + "name": "Vue.js", + "url": "https://vuejs.org/", + "language": "JavaScript", + }, + { + "name": "Quasar Framework", + "url": "https://quasar.dev/", + "language": "JavaScript", + }, + ] + + return jsonify(tools), HTTPStatus.OK