feat: Add HIP02 addresses
This commit is contained in:
parent
43ac7cfc6d
commit
8a409334b6
11
README.md
11
README.md
@ -1,5 +1,14 @@
|
|||||||
# shakecities
|
# ShakeCities
|
||||||
|
A joint project between Nathan.Woodburn/ and crymzyn/
|
||||||
|
ShakeCities is a geocities clone with an emphasis on Handshake domains.
|
||||||
|
Create a free site on yourname.shakecities/. You control that site and can add whatever you want to it.
|
||||||
|
Every domain comes enabled with HTTPS via DANE. We have support HIP02 aliases, so you can send HNS to yourname.shakecities/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Deployment
|
||||||
```
|
```
|
||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
|
68
db.py
68
db.py
@ -129,13 +129,71 @@ def get_website_data(domain):
|
|||||||
|
|
||||||
return parsed
|
return parsed
|
||||||
|
|
||||||
def update_website_data(domain,data):
|
def get_website_data_raw(domain):
|
||||||
connection = mysql.connector.connect(**dbargs)
|
connection = mysql.connector.connect(**dbargs)
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
# Create json object
|
cursor.execute("""
|
||||||
data = {
|
SELECT * FROM site WHERE domain = %s
|
||||||
"data": data
|
""", (domain,))
|
||||||
}
|
data = cursor.fetchall()
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
|
|
||||||
|
if data == []:
|
||||||
|
# Create new entry
|
||||||
|
connection = mysql.connector.connect(**dbargs)
|
||||||
|
cursor = connection.cursor()
|
||||||
|
data = {
|
||||||
|
"data": ""
|
||||||
|
}
|
||||||
|
insert_query = "INSERT INTO site (data,domain) VALUES (%s,%s)"
|
||||||
|
cursor.execute(insert_query, (json.dumps(data), domain))
|
||||||
|
connection.commit()
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
|
return ""
|
||||||
|
|
||||||
|
parsed = data[0][2]
|
||||||
|
parsed = json.loads(parsed)
|
||||||
|
|
||||||
|
return parsed
|
||||||
|
|
||||||
|
def update_website_data(domain,data):
|
||||||
|
data = get_website_data_raw(domain)
|
||||||
|
|
||||||
|
connection = mysql.connector.connect(**dbargs)
|
||||||
|
cursor = connection.cursor()
|
||||||
|
# Update json object
|
||||||
|
data['data'] = data
|
||||||
|
|
||||||
|
update_query = "UPDATE site SET data = %s WHERE domain = %s"
|
||||||
|
cursor.execute(update_query, (json.dumps(data), domain))
|
||||||
|
|
||||||
|
connection.commit()
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
|
|
||||||
|
def update_website_data_raw(domain,data):
|
||||||
|
connection = mysql.connector.connect(**dbargs)
|
||||||
|
cursor = connection.cursor()
|
||||||
|
# Update json object
|
||||||
|
data = json.loads(data)
|
||||||
|
|
||||||
|
update_query = "UPDATE site SET data = %s WHERE domain = %s"
|
||||||
|
cursor.execute(update_query, (json.dumps(data), domain))
|
||||||
|
|
||||||
|
connection.commit()
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
|
|
||||||
|
def update_website_wallet(domain,token,address):
|
||||||
|
data = get_website_data_raw(domain)
|
||||||
|
|
||||||
|
connection = mysql.connector.connect(**dbargs)
|
||||||
|
cursor = connection.cursor()
|
||||||
|
# Update json object
|
||||||
|
data[token] = address
|
||||||
|
|
||||||
update_query = "UPDATE site SET data = %s WHERE domain = %s"
|
update_query = "UPDATE site SET data = %s WHERE domain = %s"
|
||||||
cursor.execute(update_query, (json.dumps(data), domain))
|
cursor.execute(update_query, (json.dumps(data), domain))
|
||||||
|
|
||||||
|
15
main.py
15
main.py
@ -88,8 +88,10 @@ def edit():
|
|||||||
resp.set_cookie('token', '', expires=0)
|
resp.set_cookie('token', '', expires=0)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
data = db.get_website_data(user['domain'])
|
data = db.get_website_data_raw(user['domain'])
|
||||||
return render_template('edit.html',account=user['email'],account_link="account",data=data)
|
|
||||||
|
|
||||||
|
return render_template('edit.html',account=user['email'],account_link="account",data=data['data'],hns=data['HNS'],btc=data['BTC'],eth=data['ETH'])
|
||||||
|
|
||||||
|
|
||||||
@app.route('/edit', methods=['POST'])
|
@app.route('/edit', methods=['POST'])
|
||||||
@ -105,8 +107,13 @@ def send_edit():
|
|||||||
resp.set_cookie('token', '', expires=0)
|
resp.set_cookie('token', '', expires=0)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
data = request.form['data']
|
data = {}
|
||||||
db.update_website_data(user['domain'],data)
|
data['data'] = request.form['data']
|
||||||
|
data['HNS'] = request.form['hns']
|
||||||
|
data['BTC'] = request.form['btc']
|
||||||
|
data['ETH'] = request.form['eth']
|
||||||
|
|
||||||
|
db.update_website_data_raw(user['domain'],data)
|
||||||
return redirect('/edit')
|
return redirect('/edit')
|
||||||
|
|
||||||
|
|
||||||
|
23
proposal.md
Normal file
23
proposal.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
This project is a joint collaboration with [Nathan.Woodburn/](https://github.com/nathanwoodburn/) and [crymzyn/](https://github.com/crymzyn)
|
||||||
|
|
||||||
|
|
||||||
|
What have you built previously?
|
||||||
|
- [HNSHosting WP](https://hnshosting.au)
|
||||||
|
- [Woodburn Faucet](https://faucet.woodburn.au)
|
||||||
|
|
||||||
|
|
||||||
|
What will you be building? Why is that a valuable open source contribution to Handshake?
|
||||||
|
ShakeCities is a geocities clone with an emphasis on Handshake domains.
|
||||||
|
Create a free site on yourname.shakecities/. You control that site and can add whatever you want to it.
|
||||||
|
Every domain comes enabled with HTTPS via DANE. We have support HIP02 aliases, so you can send HNS to yourname.shakecities/
|
||||||
|
|
||||||
|
This will be a valuable resource to the Handshake community as it will allow new users to deploy a website in minutes.
|
||||||
|
In addition it will include information on how to create a site to the users own domains to encourage them to move towards decentralisation.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
What are completion criteria?
|
||||||
|
Fully working project site with user pages actively served over HTTPS.
|
||||||
|
|
||||||
|
What is your contact information?
|
||||||
|
`github@nathan.woodburn.au`
|
20
sites/db.py
20
sites/db.py
@ -33,3 +33,23 @@ def get_website_data(domain):
|
|||||||
parsed = parsed.encode('utf-8').decode('unicode-escape')
|
parsed = parsed.encode('utf-8').decode('unicode-escape')
|
||||||
|
|
||||||
return parsed
|
return parsed
|
||||||
|
|
||||||
|
def get_website_wallet(domain,token):
|
||||||
|
connection = mysql.connector.connect(**dbargs)
|
||||||
|
cursor = connection.cursor()
|
||||||
|
cursor.execute("""
|
||||||
|
SELECT * FROM site WHERE domain = %s
|
||||||
|
""", (domain,))
|
||||||
|
data = cursor.fetchall()
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
||||||
|
|
||||||
|
if data == []:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
parsed = data[0][2]
|
||||||
|
parsed = json.loads(parsed)
|
||||||
|
if token in parsed:
|
||||||
|
parsed = parsed[token]
|
||||||
|
|
||||||
|
return ""
|
@ -35,6 +35,16 @@ def index():
|
|||||||
return website.render(data)
|
return website.render(data)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/.well-known/wallets/<token>')
|
||||||
|
def wallet(token):
|
||||||
|
address = db.get_website_wallet(request.host.split('.')[0],token)
|
||||||
|
if address == "":
|
||||||
|
return redirect('/')
|
||||||
|
# Plain text
|
||||||
|
response = make_response(address)
|
||||||
|
response.mimetype = "text/plain"
|
||||||
|
return response
|
||||||
|
|
||||||
@app.route('/<path:path>')
|
@app.route('/<path:path>')
|
||||||
def catch_all(path):
|
def catch_all(path):
|
||||||
return redirect('/') # 404 catch all
|
return redirect('/') # 404 catch all
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<h1 style="text-align: center;">Edit your page</h1>
|
<h1 style="text-align: center;">Edit your page</h1>
|
||||||
</section>
|
</section>
|
||||||
<section style="width: 80%;margin: auto;">
|
<section style="width: 80%;margin: auto;">
|
||||||
<form method="post"><textarea class="form-control form-control-lg" rows="25" name="data" placeholder="Website data">{{data}}</textarea><input class="btn btn-primary" type="submit" style="margin-top: 10px;"></form>
|
<form method="post"><textarea class="form-control form-control-lg" rows="25" name="data" placeholder="Website data">{{data}}</textarea><input class="form-control" type="text" style="margin-top: 10px;" placeholder="HNS Address" name="hns" value="{{hns}}"><input class="form-control" type="text" style="margin-top: 10px;" name="btc" placeholder="BTC Address" value="{{btc}}"><input class="form-control" type="text" style="margin-top: 10px;" placeholder="ETH Address" name="eth" value="{{eth}}"><input class="btn btn-primary" type="submit" style="margin-top: 10px;"></form>
|
||||||
</section>
|
</section>
|
||||||
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
|
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
Reference in New Issue
Block a user