From 94b34163004c60ef73b10c31971dbc1a70918401 Mon Sep 17 00:00:00 2001
From: Kristjan
Date: Sat, 2 Jan 2021 16:58:03 +0100
Subject: [PATCH] prettier formatting
---
lnbits/extensions/subdomains/README.md | 27 +-
lnbits/extensions/subdomains/config.json | 8 +-
.../templates/subdomains/_api_docs.html | 15 +-
.../templates/subdomains/display.html | 83 ++++--
.../templates/subdomains/index.html | 279 ++++++++++++++----
5 files changed, 311 insertions(+), 101 deletions(-)
diff --git a/lnbits/extensions/subdomains/README.md b/lnbits/extensions/subdomains/README.md
index 48c2c12ca..49dfc223d 100644
--- a/lnbits/extensions/subdomains/README.md
+++ b/lnbits/extensions/subdomains/README.md
@@ -1,26 +1,30 @@
Subdomains Extension
-So the goal of the extension is to allow the owner of a domain to sell their subdomain to the anyone who is willing to pay some money for it.
+So the goal of the extension is to allow the owner of a domain to sell their subdomain to the anyone who is willing to pay some money for it.
## Requirements
+
- Free cloudflare account
- Cloudflare as a dns server provider
- Cloudflare TOKEN and Cloudflare zone-id where the domain is parked
-
## Usage
+
1. Register at cloudflare and setup your domain with them. (Just follow instructions they provide...)
2. Change DNS server at your domain registrar to point to cloudflare's
-3. Get Cloudflare zoneID for your domain
-
+3. Get Cloudflare zoneID for your domain
+
4. get Cloudflare API TOKEN
-
-
+
+
5. Open the lnbits subdomains extension and register your domain with lnbits
6. Click on the button in the table to open the public form that was generated for your domain
- - Extension also supports webhooks so you can get notified when someone buys a new domain
+
+- Extension also supports webhooks so you can get notified when someone buys a new domain
+
## API Endpoints
+
- **Domains**
- GET /api/v1/domains
- POST /api/v1/domains
@@ -32,12 +36,13 @@ So the goal of the extension is to allow the owner of a domain to sell their sub
- GET /api/v1/subdomains/
- DELETE /api/v1/subdomains/
-## Useful
+## Useful
### Cloudflare
+
- Cloudflare offers programmatic subdomain registration... (create new A record)
- you can keep your existing domain's registrar, you just have to transfer dns records to the cloudflare (free service)
-- more information:
+- more information:
- https://api.cloudflare.com/#getting-started-requests
- API endpoints needed for our project:
- https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records
@@ -45,5 +50,5 @@ So the goal of the extension is to allow the owner of a domain to sell their sub
- https://api.cloudflare.com/#dns-records-for-a-zone-delete-dns-record
- https://api.cloudflare.com/#dns-records-for-a-zone-update-dns-record
- api can be used by providing authorization token OR authorization key
- - check API Tokens and API Keys : https://api.cloudflare.com/#getting-started-requests
-- Cloudflare API postman collection: https://support.cloudflare.com/hc/en-us/articles/115002323852-Using-Cloudflare-API-with-Postman-Collections
\ No newline at end of file
+ - check API Tokens and API Keys : https://api.cloudflare.com/#getting-started-requests
+- Cloudflare API postman collection: https://support.cloudflare.com/hc/en-us/articles/115002323852-Using-Cloudflare-API-with-Postman-Collections
diff --git a/lnbits/extensions/subdomains/config.json b/lnbits/extensions/subdomains/config.json
index 4a34be565..6bf9480cd 100644
--- a/lnbits/extensions/subdomains/config.json
+++ b/lnbits/extensions/subdomains/config.json
@@ -1,6 +1,6 @@
{
- "name": "Subdomains",
- "short_description": "Sell subdomains of your domain",
- "icon": "domain",
- "contributors": ["grmkris"]
+ "name": "Subdomains",
+ "short_description": "Sell subdomains of your domain",
+ "icon": "domain",
+ "contributors": ["grmkris"]
}
diff --git a/lnbits/extensions/subdomains/templates/subdomains/_api_docs.html b/lnbits/extensions/subdomains/templates/subdomains/_api_docs.html
index 61b79947d..cc1518e90 100644
--- a/lnbits/extensions/subdomains/templates/subdomains/_api_docs.html
+++ b/lnbits/extensions/subdomains/templates/subdomains/_api_docs.html
@@ -1,4 +1,9 @@
-
+
@@ -6,11 +11,13 @@
Charge people for using your subdomain name...
- Are you the owner of cool-domain.com and want to sell cool-subdomain.cool-domain.com
+ Are you the owner of cool-domain.com and want to sell
+ cool-subdomain.cool-domain.com
- Created by, Kris
+ Created by, Kris
-
\ No newline at end of file
+
diff --git a/lnbits/extensions/subdomains/templates/subdomains/display.html b/lnbits/extensions/subdomains/templates/subdomains/display.html
index 3e3d6f654..e46228cdc 100644
--- a/lnbits/extensions/subdomains/templates/subdomains/display.html
+++ b/lnbits/extensions/subdomains/templates/subdomains/display.html
@@ -8,26 +8,59 @@
{{ domain_desc }}
-
-
-
+
+
+
-
+
-
+
Cost per day: {{ domain_cost }} sats
- {% raw %}
- Total cost: {{amountSats}} sats
- {% endraw %}
+ {% raw %} Total cost: {{amountSats}} sats {% endraw %}
+
- Submit
- Cancel
+ type="submit"
+ >Submit
+ Cancel
@@ -35,18 +68,27 @@
-
+
- Copy invoice
+ Copy invoice
Close
@@ -105,7 +147,7 @@
dismissMsg()
clearInterval(paymentChecker)
- setTimeout(function () { }, 10000)
+ setTimeout(function () {}, 10000)
},
Invoice: function () {
var self = this
@@ -157,10 +199,9 @@
self.$q.notify({
type: 'positive',
message: 'Sent, thank you!',
- icon: 'thumb_up',
+ icon: 'thumb_up'
})
- console.log("END")
-
+ console.log('END')
}
})
.catch(function (error) {
@@ -177,4 +218,4 @@
}
})
-{% endblock %}
\ No newline at end of file
+{% endblock %}
diff --git a/lnbits/extensions/subdomains/templates/subdomains/index.html b/lnbits/extensions/subdomains/templates/subdomains/index.html
index 8294f65f8..05168a798 100644
--- a/lnbits/extensions/subdomains/templates/subdomains/index.html
+++ b/lnbits/extensions/subdomains/templates/subdomains/index.html
@@ -5,7 +5,9 @@
- New Domain
+ New Domain
@@ -16,11 +18,19 @@
Domains
- Export to CSV
+ Export to CSV
-
+
{% raw %}
@@ -34,18 +44,40 @@
-
+
{{ col.value }}
-
+
-
+
@@ -61,11 +93,19 @@
Subdomains
- Export to CSV
+ Export to CSV
-
+
{% raw %}
@@ -78,8 +118,15 @@
-
+
@@ -87,7 +134,14 @@
-
+
@@ -98,9 +152,7 @@
-
- LNbits Subdomain extension
-
+ LNbits Subdomain extension
@@ -110,36 +162,96 @@
-
-
+
-
-
-
+
+
+
-
+
-
-
+
+
-
+
- Update Form
- Update Form
+ Create Domain
- Cancel
+ type="submit"
+ >Create Domain
+ Cancel
-
{% endblock %} {% block scripts %} {{ window_vars(user) }}
@@ -161,14 +273,49 @@
return {
domains: [],
subdomains: [],
- dnsRecordTypes: ['A', 'AAAA', 'CNAME', 'HTTPS', 'TXT', 'SRV', 'LOC', 'MX', 'NS', 'SPF', 'CERT', 'DNSKEY', 'DS', 'NAPTR', 'SMIMEA', 'SSHFP', 'SVCB', 'TLSA', 'URI'],
+ dnsRecordTypes: [
+ 'A',
+ 'AAAA',
+ 'CNAME',
+ 'HTTPS',
+ 'TXT',
+ 'SRV',
+ 'LOC',
+ 'MX',
+ 'NS',
+ 'SPF',
+ 'CERT',
+ 'DNSKEY',
+ 'DS',
+ 'NAPTR',
+ 'SMIMEA',
+ 'SSHFP',
+ 'SVCB',
+ 'TLSA',
+ 'URI'
+ ],
domainsTable: {
columns: [
- { name: 'id', align: 'left', label: 'ID', field: 'id' },
- { name: 'domain', align: 'left', label: 'Domain name', field: 'domain' },
- { name: 'allowed_record_types', align: 'left', label: 'Allowed record types', field: 'allowed_record_types' },
- { name: 'wallet', align: 'left', label: 'Wallet', field: 'wallet' },
- { name: 'webhook', align: 'left', label: 'Webhook', field: 'webhook' },
+ {name: 'id', align: 'left', label: 'ID', field: 'id'},
+ {
+ name: 'domain',
+ align: 'left',
+ label: 'Domain name',
+ field: 'domain'
+ },
+ {
+ name: 'allowed_record_types',
+ align: 'left',
+ label: 'Allowed record types',
+ field: 'allowed_record_types'
+ },
+ {name: 'wallet', align: 'left', label: 'Wallet', field: 'wallet'},
+ {
+ name: 'webhook',
+ align: 'left',
+ label: 'Webhook',
+ field: 'webhook'
+ },
{
name: 'description',
align: 'left',
@@ -184,13 +331,28 @@
],
pagination: {
rowsPerPage: 10
- },
+ }
},
subdomainsTable: {
columns: [
- { name: 'subdomain', align: 'left', label: 'Subdomain name', field: 'subdomain' },
- { name: 'domain', align: 'left', label: 'Domain name', field: 'domain_name' },
- { name: 'record_type', align: 'left', label: 'Record type', field: 'record_type' },
+ {
+ name: 'subdomain',
+ align: 'left',
+ label: 'Subdomain name',
+ field: 'subdomain'
+ },
+ {
+ name: 'domain',
+ align: 'left',
+ label: 'Domain name',
+ field: 'domain_name'
+ },
+ {
+ name: 'record_type',
+ align: 'left',
+ label: 'Record type',
+ field: 'record_type'
+ },
{
name: 'email',
align: 'left',
@@ -215,11 +377,11 @@
label: 'Duration in days',
field: 'duration'
},
- { name: 'id', align: 'left', label: 'ID', field: 'id' }
+ {name: 'id', align: 'left', label: 'ID', field: 'id'}
],
pagination: {
rowsPerPage: 10
- },
+ }
},
domainDialog: {
show: false,
@@ -242,11 +404,10 @@
return mapLNDomain(obj)
})
})
-
},
deleteSubdomain: function (subdomainId) {
var self = this
- var subdomains = _.findWhere(this.subdomains, { id: subdomainId })
+ var subdomains = _.findWhere(this.subdomains, {id: subdomainId})
LNbits.utils
.confirmDialog('Are you sure you want to delete this subdomain')
@@ -255,7 +416,7 @@
.request(
'DELETE',
'/subdomain/api/v1/subdomains/' + subdomainId,
- _.findWhere(self.g.user.wallets, { id: subdomains.wallet }).inkey
+ _.findWhere(self.g.user.wallets, {id: subdomains.wallet}).inkey
)
.then(function (response) {
self.subdomains = _.reject(self.subdomains, function (obj) {
@@ -266,7 +427,6 @@
LNbits.utils.notifyApiError(error)
})
})
-
},
exportSubdomainsCSV: function () {
LNbits.utils.exportCSV(this.subdomainsTable.columns, this.subdomains)
@@ -286,14 +446,13 @@
return mapLNDomain(obj)
})
})
-
},
sendFormData: function () {
var wallet = _.findWhere(this.g.user.wallets, {
id: this.domainDialog.data.wallet
})
var data = this.domainDialog.data
- data.allowed_record_types = data.allowed_record_types.join(", ")
+ data.allowed_record_types = data.allowed_record_types.join(', ')
console.log(this.domainDialog)
if (data.id) {
this.updateDomain(wallet, data)
@@ -315,10 +474,9 @@
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
-
},
updateDomainDialog: function (formId) {
- var link = _.findWhere(this.domains, { id: formId })
+ var link = _.findWhere(this.domains, {id: formId})
console.log(link.id)
this.domainDialog.data.id = link.id
this.domainDialog.data.wallet = link.wallet
@@ -328,14 +486,15 @@
this.domainDialog.data.cf_zone_id = link.cf_zone_id
this.domainDialog.data.webhook = link.webhook
this.domainDialog.data.cost = link.cost
- this.domainDialog.data.allowed_record_types = link.allowed_record_types.split(", ")
+ this.domainDialog.data.allowed_record_types = link.allowed_record_types.split(
+ ', '
+ )
this.domainDialog.show = true
},
updateDomain: function (wallet, data) {
var self = this
console.log(data)
-
LNbits.api
.request(
'PUT',
@@ -354,11 +513,10 @@
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
-
},
deleteDomain: function (domainId) {
var self = this
- var domains = _.findWhere(this.domains, { id: domainId })
+ var domains = _.findWhere(this.domains, {id: domainId})
LNbits.utils
.confirmDialog('Are you sure you want to delete this domain link?')
@@ -367,7 +525,7 @@
.request(
'DELETE',
'/subdomains/api/v1/domains/' + domainId,
- _.findWhere(self.g.user.wallets, { id: domains.wallet }).inkey
+ _.findWhere(self.g.user.wallets, {id: domains.wallet}).inkey
)
.then(function (response) {
self.domains = _.reject(self.domains, function (obj) {
@@ -378,7 +536,6 @@
LNbits.utils.notifyApiError(error)
})
})
-
},
exportDomainsCSV: function () {
LNbits.utils.exportCSV(this.domainsTable.columns, this.domains)
@@ -392,4 +549,4 @@
}
})
-{% endblock %}
\ No newline at end of file
+{% endblock %}