chore: brokenbits example extension
This commit is contained in:
parent
434029966f
commit
d0b44eada9
5 changed files with 82 additions and 133 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "SHORT-NAME-FOR-EXTENSIONS-PAGE",
|
"name": "Example",
|
||||||
"short_description": "BLah blah blah.",
|
"short_description": "BLah blah blah.",
|
||||||
"icon": "calendar",
|
"icon": "info",
|
||||||
"contributors": ["github_username"]
|
"contributors": ["github_username"]
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1 @@
|
||||||
/* create your extensions table and the variables needed here */
|
/* create your extensions table and the variables needed here */
|
||||||
CREATE TABLE IF NOT EXISTS example (
|
|
||||||
key INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
usr TEXT,
|
|
||||||
wal TEXT,
|
|
||||||
walnme TEXT
|
|
||||||
);
|
|
||||||
|
|
|
||||||
|
|
@ -1,103 +1,54 @@
|
||||||
<!-- @format -->
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% extends "legacy.html" %} {% block messages %}
|
{% from "macros.jinja" import window_vars with context %}
|
||||||
|
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
|
||||||
<i class="fa fa-bell-o"></i>
|
{% block page %}
|
||||||
<span class="label label-danger">!</span>
|
<q-card>
|
||||||
</a>
|
<q-card-section>
|
||||||
<ul class="dropdown-menu">
|
<h5 class="text-subtitle1 q-mt-none q-mb-md">Frameworks used by LNbits</h5>
|
||||||
<li class="header"><b>Instant wallet, bookmark to save</b></li>
|
<q-list>
|
||||||
<li></li>
|
<q-item v-for="tool in tools" :key="tool.name" tag="a" :href="tool.url" target="_blank">
|
||||||
</ul>
|
{% raw %} <!-- with raw Flask won't try to interpret the Vue moustaches -->
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label>{{ tool.name }}</q-item-label>
|
||||||
|
<q-item-label caption>{{ tool.language }}</q-item-label>
|
||||||
|
</q-item-section>
|
||||||
|
{% endraw %}
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
<q-separator class="q-my-lg"></q-separator>
|
||||||
|
<p>A magical "w" is always available, with info about the user, wallets and extensions:</p>
|
||||||
|
<code class="text-caption">{% raw %}{{ w }}{% endraw %}</code>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
{% block menuitems %}
|
{{ window_vars(user) }}
|
||||||
<li class="treeview">
|
|
||||||
<a href="#">
|
|
||||||
<i class="fa fa-bitcoin"></i> <span>Wallets</span>
|
|
||||||
<i class="fa fa-angle-left pull-right"></i>
|
|
||||||
</a>
|
|
||||||
<ul class="treeview-menu">
|
|
||||||
{% for w in user_wallets %}
|
|
||||||
<li>
|
|
||||||
<a href="{{ url_for('wallet') }}?wal={{ w.id }}&usr={{ w.user }}"><i class="fa fa-bolt"></i> {{ w.name }}</a>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
<li><a onclick="sidebarmake()">Add a wallet +</a></li>
|
|
||||||
<div id="sidebarmake"></div>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li class="active treeview">
|
|
||||||
<a href="#">
|
|
||||||
<i class="fa fa-th"></i> <span>Extensions</span>
|
|
||||||
<i class="fa fa-angle-left pull-right"></i>
|
|
||||||
</a>
|
|
||||||
<ul class="treeview-menu">
|
|
||||||
{% for extension in EXTENSIONS %}
|
|
||||||
{% if extension.code in user_ext %}
|
|
||||||
<li>
|
|
||||||
<a href="{{ url_for(extension.code + '.index') }}?usr={{ user }}"><i class="fa fa-plus"></i> {{ extension.name }}</a>
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
<li>
|
|
||||||
<a href="{{ url_for('core.extensions') }}?usr={{ user }}">Manager</a></li>
|
|
||||||
</ul>
|
|
||||||
</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">
|
|
||||||
<h1>
|
|
||||||
Withdraw link maker
|
|
||||||
<small>powered by LNURL</small>
|
|
||||||
|
|
||||||
</h1>
|
|
||||||
<ol class="breadcrumb">
|
|
||||||
<li>
|
|
||||||
<a href="{{ url_for('wallet') }}?usr={{ user }}"><i class="fa fa-dashboard"></i> Home</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="{{ url_for('core.extensions') }}?usr={{ user }}"><li class="fa fa-dashboard">Extensions</li></a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<i class="active" class="fa fa-dashboard">example</i>
|
|
||||||
</li>
|
|
||||||
</ol>
|
|
||||||
<br /><br />
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- DOWNLOAD AND SEARCH ADMINLITE2 FOR HTML-->
|
|
||||||
|
|
||||||
</section>
|
|
||||||
<!-- Main content -->
|
|
||||||
<section class="content">
|
|
||||||
<!-- Small boxes (Stat box) -->
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<!-- general form elements -->
|
|
||||||
<div class="box box-primary">
|
|
||||||
<div class="box-header">
|
|
||||||
<h3 class="box-title"> EXAMPLE BOX HEADING</h3>
|
|
||||||
</div><!-- /.box-header -->
|
|
||||||
<div class="box-body">
|
|
||||||
<p>*Some content in here</p>
|
|
||||||
</div>
|
|
||||||
</div><!-- /.box -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
new Vue({
|
||||||
|
el: '#vue',
|
||||||
|
mixins: [windowMixin],
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
tools: []
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created: function () {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
//ADD YOUR JAVASCIPT HERE//
|
// axios is available for making requests
|
||||||
|
axios({
|
||||||
|
method: 'GET',
|
||||||
|
url: '/example/api/v1/tools',
|
||||||
|
headers: {
|
||||||
|
'X-example-header': 'not-used'
|
||||||
|
}
|
||||||
|
}).then(function (response) {
|
||||||
|
self.tools = response.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,11 @@
|
||||||
#add your dependencies here
|
from flask import g, render_template
|
||||||
|
|
||||||
from flask import jsonify, render_template, request, redirect, url_for
|
from lnbits.decorators import check_user_exists, validate_uuids
|
||||||
from lnbits.db import open_db, open_ext_db
|
|
||||||
from lnbits.extensions.example import example_ext
|
from lnbits.extensions.example import example_ext
|
||||||
|
|
||||||
#add your endpoints here
|
|
||||||
|
|
||||||
@example_ext.route("/")
|
@example_ext.route("/")
|
||||||
|
@validate_uuids(["usr"], required=True)
|
||||||
|
@check_user_exists()
|
||||||
def index():
|
def index():
|
||||||
"""Try to add descriptions for others."""
|
return render_template("example/index.html", user=g.user)
|
||||||
usr = request.args.get("usr")
|
|
||||||
|
|
||||||
if usr:
|
|
||||||
if not len(usr) > 20:
|
|
||||||
return redirect(url_for("home"))
|
|
||||||
|
|
||||||
# Get all the data
|
|
||||||
with open_db() as db:
|
|
||||||
user_wallets = db.fetchall("SELECT * FROM wallets WHERE user = ?", (usr,))
|
|
||||||
user_ext = db.fetchall("SELECT extension FROM extensions WHERE user = ? AND active = 1", (usr,))
|
|
||||||
user_ext = [v[0] for v in user_ext]
|
|
||||||
|
|
||||||
return render_template(
|
|
||||||
"example/index.html"
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,36 @@
|
||||||
|
|
||||||
# add your dependencies here
|
# add your dependencies here
|
||||||
|
|
||||||
import json
|
# import json
|
||||||
import requests
|
# import requests
|
||||||
from flask import jsonify, render_template, request, redirect, url_for
|
|
||||||
from lnbits.db import open_db, open_ext_db
|
from flask import jsonify
|
||||||
|
|
||||||
|
from lnbits.helpers import Status
|
||||||
from lnbits.extensions.example import example_ext
|
from lnbits.extensions.example import example_ext
|
||||||
|
|
||||||
|
|
||||||
# add your endpoints here
|
# add your endpoints here
|
||||||
|
|
||||||
@example_ext.route("/api/v1/example", methods=["GET","POST"])
|
@example_ext.route("/api/v1/tools", methods=["GET"])
|
||||||
def api_example():
|
def api_example():
|
||||||
"""Try to add descriptions for others."""
|
"""Try to add descriptions for others."""
|
||||||
#YOUR-CODE
|
tools = [
|
||||||
|
{
|
||||||
|
"name": "Flask",
|
||||||
|
"url": "https://flask.palletsprojects.com/",
|
||||||
|
"language": "Python",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Vue.js",
|
||||||
|
"url": "https://vuejs.org/",
|
||||||
|
"language": "JavaScript",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Quasar Framework",
|
||||||
|
"url": "https://vuejs.org/",
|
||||||
|
"language": "JavaScript",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
return jsonify({"status": "TRUE"}), 200
|
return jsonify(tools), Status.OK
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue