diff --git a/lnbits/extensions/example/__init__.py b/lnbits/extensions/example/__init__.py index f90fa4907..8cd9211b3 100644 --- a/lnbits/extensions/example/__init__.py +++ b/lnbits/extensions/example/__init__.py @@ -1,4 +1,5 @@ import asyncio + from fastapi import APIRouter from fastapi.staticfiles import StaticFiles @@ -22,10 +23,12 @@ example_static_files = [ def example_renderer(): return template_renderer(["lnbits/extensions/example/templates"]) + from .tasks import wait_for_paid_invoices from .views import * from .views_api import * + def tpos_start(): loop = asyncio.get_event_loop() - loop.create_task(catch_everything_and_restart(wait_for_paid_invoices)) \ No newline at end of file + loop.create_task(catch_everything_and_restart(wait_for_paid_invoices)) diff --git a/lnbits/extensions/example/crud.py b/lnbits/extensions/example/crud.py index 5540c5ec1..8e5508fb5 100644 --- a/lnbits/extensions/example/crud.py +++ b/lnbits/extensions/example/crud.py @@ -2,4 +2,4 @@ # add your dependencies here -# add your fnctions here \ No newline at end of file +# add your fnctions here diff --git a/lnbits/extensions/example/static/conversion-example.png b/lnbits/extensions/example/static/conversion-example.png new file mode 100644 index 000000000..544e6335c Binary files /dev/null and b/lnbits/extensions/example/static/conversion-example.png differ diff --git a/lnbits/extensions/example/static/conversion-example2.png b/lnbits/extensions/example/static/conversion-example2.png new file mode 100644 index 000000000..7543fdc9e Binary files /dev/null and b/lnbits/extensions/example/static/conversion-example2.png differ diff --git a/lnbits/extensions/example/static/vuejslogo.png b/lnbits/extensions/example/static/vuejslogo.png index fe23ad992..065c4a897 100644 Binary files a/lnbits/extensions/example/static/vuejslogo.png and b/lnbits/extensions/example/static/vuejslogo.png differ diff --git a/lnbits/extensions/example/tasks.py b/lnbits/extensions/example/tasks.py index 677b3cff2..923194212 100644 --- a/lnbits/extensions/example/tasks.py +++ b/lnbits/extensions/example/tasks.py @@ -3,11 +3,14 @@ # add your dependencies here import asyncio + from loguru import logger + from lnbits.core.models import Payment from lnbits.helpers import get_current_extension_name from lnbits.tasks import register_invoice_listener + async def wait_for_paid_invoices(): invoice_queue = asyncio.Queue() register_invoice_listener(invoice_queue, get_current_extension_name()) @@ -16,8 +19,11 @@ async def wait_for_paid_invoices(): payment = await invoice_queue.get() await on_invoice_paid(payment) + async def on_invoice_paid(payment: Payment) -> None: - if payment.extra.get("tag") != "example": # Will grab any payment with the tag "example" + if ( + payment.extra.get("tag") != "example" + ): # Will grab any payment with the tag "example" logger.debug(payment) # Do something - return \ No newline at end of file + return diff --git a/lnbits/extensions/example/templates/example/index.html b/lnbits/extensions/example/templates/example/index.html index fd95ee31b..c2891b2fa 100644 --- a/lnbits/extensions/example/templates/example/index.html +++ b/lnbits/extensions/example/templates/example/index.html @@ -4,12 +4,44 @@ - - - + + +
- Update thing - Create thing + Update thing + Create thing Cancel
@@ -19,7 +51,8 @@
- {{SITE_TITLE}} Extension Development Guide (Collection of resources for extension developers) + {{SITE_TITLE}} Extension Development Guide + (Collection of resources for extension developers)
@@ -32,11 +65,11 @@ align="justify" narrow-indicator > - - - - - + + + + + @@ -46,58 +79,129 @@
Frameworks
- - + - + @@ -105,7 +209,56 @@
- + +
Useful Tools
+
+ + + + + +
+
File Structure
@@ -121,46 +274,6 @@
Submission
Coming soon...
- - -
Useful Tools
-
- - - - - - - -
-
@@ -168,41 +281,41 @@ {% endblock %} {% block scripts %} {{ window_vars(user) }} diff --git a/lnbits/extensions/example/views_api.py b/lnbits/extensions/example/views_api.py index 9d56a6410..556096ce2 100644 --- a/lnbits/extensions/example/views_api.py +++ b/lnbits/extensions/example/views_api.py @@ -6,6 +6,7 @@ from . import example_ext # add your endpoints here + @example_ext.get("/api/v1/test/{test_data}") async def api_example(test_data): # Do some python things and return the data