commit b09e535999537a60df9a46b7f1b12806f87b856b
parent cbf112d815032db1b4be7eb393712ad1fc429f6e
Author: rob <rob@tarina.org>
Date: Sat, 7 Dec 2024 12:36:56 +0200
lots of fixes
Diffstat:
8 files changed, 82 insertions(+), 77 deletions(-)
diff --git a/db/cyberpunkcafe.db b/db/cyberpunkcafe.db
Binary files differ.
diff --git a/public_html/static/robstyle.css b/public_html/static/robstyle.css
@@ -42,6 +42,7 @@ body
font-weight: normal;
color: #f4f4f4;
font-size: 11pt;
+ word-wrap: break-word;
}
a
@@ -185,7 +186,7 @@ img
{
margin: 0px auto;
height: auto;
- max-width: 400px;
+ width: 450px;
text-align: center;
}
@@ -458,8 +459,9 @@ pre
.product
{
- margin: 0px auto;
+ margin: 10px auto;
scroll-margin-top: 10rem;
+ width: 80%;
padding: 10px;
border-radius:5px;
background-color:#333;
diff --git a/public_html/static/splash.css b/public_html/static/splash.css
@@ -188,7 +188,7 @@ img
{
margin: 0px auto;
height: auto;
- max-width: 500px;
+ max-width: 400px;
text-align: center;
}
@@ -215,7 +215,7 @@ img
width: 50%;
height: auto;
text-align: center;
- max-width: 300px;
+ max-width: 400px;
}
.bild
diff --git a/public_html/templates/almost.html b/public_html/templates/almost.html
@@ -1,4 +1,17 @@
$def with (products,bag,sessionkey,productname,inbag,db,getprice,getrate,category,markdown)
+
+$ siteconfig = db.select('propaganda', what='id, name, description, description2')[0]
+
+<HEAD>
+ <meta charset="utf-8">
+ <title>$siteconfig.name | $siteconfig.description</title>
+ <link rel="stylesheet" href="/static/splash.css?v=100" type="text/css" rel="stylesheet"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta http-equiv="cache-control" content="no-cache">
+</HEAD>
+
+<BODY>
+
$ totsats = 0
$ toteuro = 0
$ x = 0
@@ -27,15 +40,14 @@ $if sessionkey != 'empty':
</div>
</div>
-$ siteconfig = db.select('propaganda', what='id, name, description, description2')[0]
<div class="introtext">
<br>
<code>~*~</code>
<br>
<br>
-<h1>$siteconfig.name</h1>
-$:markdown.markdown(siteconfig.description)
+$#<h1>$siteconfig.name</h1>
+$#$:markdown.markdown(siteconfig.description)
$:markdown.markdown(siteconfig.description2)
<code>~</code>
<br>
@@ -73,3 +85,5 @@ $for g in goodies:
<br>
<br>
<br>
+
+</BODY>
diff --git a/public_html/templates/base.html b/public_html/templates/base.html
@@ -2,8 +2,8 @@ $def with (content)
<!doctype html>
<HEAD>
<meta charset="utf-8">
- <title>Gonzo Pi | a reboot of filmmaking</title>
- <link rel="stylesheet" href="/static/robstyle.css?v=139" type="text/css" rel="stylesheet"/>
+ <title>Robin Bäckman | Inventor, filmmaker, gardener</title>
+ <link rel="stylesheet" href="/static/robstyle.css?v=127" type="text/css" rel="stylesheet"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="cache-control" content="no-cache">
</HEAD>
diff --git a/public_html/templates/index.html b/public_html/templates/index.html
@@ -1,4 +1,4 @@
-$def with (products,bag,sessionkey,productname,inbag,db,getprice,getrate,category,markdown,getbtcratetime)
+$def with (products,bag,sessionkey,productname,inbag,db,getprice,getrate,category,markdown)
$ totsats = 0
$ toteuro = 0
$ x = 0
@@ -41,10 +41,12 @@ $ categories = db.select('categories', what='id, category')
$:markdown.markdown(siteconfig.description)
$:markdown.markdown(siteconfig.description2)
-<b><a href="/">All</a>
+<div id="selectproducts">
+<b><a href="/shop#selectproducts">All</a>
$for c in categories:
- | <a href="?category=$c.category">$c.category</a>
+ | <a href="?category=$c.category#selectproducts">$c.category</a>
</b>
+</div>
<br>
</div>
<div id="productlist">
@@ -86,8 +88,6 @@ $for i in products:
<img class="logo" src="/static/bitcoin.png">
<br>
<h2>$getrate()€/₿</h2>
-Bitcoin rate from
-<h6>$getbtcratetime()</h6>
<small>powered by <a href="https://github.com/ElementsProject/lightning">CLN</a>, <a href="https://dev.tarina.org/p/thiswebshoprules/">thiswebshoprules</a> and <a href="https://webpy.org">web.py </a></small>
<br>
<br>
diff --git a/public_html/templates/splash.html b/public_html/templates/splash.html
@@ -1,15 +1,5 @@
$def with (content)
-<!doctype html>
-<HEAD>
- <meta charset="utf-8">
- <title>Gonzo Pi | a reboot of filmmaking</title>
- <link rel="stylesheet" href="/static/splash.css?v=200" type="text/css" rel="stylesheet"/>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <meta http-equiv="cache-control" content="no-cache">
-</HEAD>
-
-<BODY>
+<!doctype html>
$:content
-</BODY>
diff --git a/server.py b/server.py
@@ -45,8 +45,10 @@ urls = (
'/bitcoin', 'bitcoin',
'/shipping/(.*)', 'shipping',
'/propaganda?', 'propaganda',
+ '/uploads?', 'uploads',
'/config', 'config',
- '/payments?', 'payments')
+ '/payments?', 'payments',
+ '/cv', 'cv')
bag = ''
@@ -70,7 +72,6 @@ rendersplash = web.template.render(templatedir, base="splash")
db = web.database(dbn='sqlite', db=basedir + "db/cyberpunkcafe.db")
session = web.session.Session(app,store,initializer={'login':0, 'privilege':0, 'bag':[], 'sessionkey':'empty'})
-
allowedchar = '_','-','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','1','2','3','4','5','6','7','8','9','0'
#----------- Database setup -------------
@@ -93,6 +94,24 @@ def logged():
else:
return False
+
+#-------------Get files and sort em by date modified---------------
+
+def getfiles(filmfolder):
+ #get a list of films, in order of settings.p file last modified
+ films_sorted = []
+ films = next(os.walk(filmfolder))[1]
+ for i in films:
+ uploaded = os.listdir(filmfolder + i + '/')
+ for f in uploaded:
+ if os.path.isfile(filmfolder + i + '/'+f) == True:
+ lastupdate = os.path.getmtime(filmfolder + i + '/' + f)
+ films_sorted.append((i,f,lastupdate))
+ else:
+ films_sorted.append((i,f,0))
+ films_sorted = sorted(films_sorted, key=lambda tup: tup[2], reverse=True)
+ return films_sorted
+
def sendmail(email, subject, msg):
#Send mail
echomsg = subprocess.Popen(('echo', msg), stdout=subprocess.PIPE)
@@ -196,61 +215,31 @@ def getavailable(productid):
return ''
return name.available
-def getbtcrate():
- btc_to_euro = db.select("btcrate", where="currency='EUR'")
- #shippinginfo = db.select('shipping', where="country='" + pendinginfo.country + "'", what='price, days')[0]
- try:
- if time.time() - btc_to_euro[0].timeadded > 6000:
- btcrate = 64485
- b = BtcConverter()
- btcrate = int(b.get_latest_price('EUR'))
- db.update('btcrate', where='currency="EUR"', rate=btcrate, timeadded=time.time())
- else:
- btc_to_euro = db.select("btcrate", where="currency='EUR'")
- btcrate = btc_to_euro[0].rate
- except:
- db.insert('btcrate', currency='EUR', rate=64485, timeadded=time.time())
- return btcrate
-
-def getbtcratetime():
- btc_to_euro = db.select("btcrate", where="currency='EUR'")
- btctime = btc_to_euro[0].timeadded
- return datetime.datetime.fromtimestamp(btctime).strftime('%c')
-
def getprice(productid):
p = db.query("SELECT * FROM products WHERE id='"+str(productid)+"';")[0]
- #b = BtcConverter()
- btcrate=getbtcrate()
+ b = BtcConverter()
if p.currency=='euro':
- sat = 1/btcrate*(p.price/100) * 100000000
- #sat = b.convert_to_btc(p.price/100, 'EUR') * 100000000
+ sat = b.convert_to_btc(p.price/100, 'EUR') * 100000000
euro = p.price/100
if p.currency=='bitcoin':
- euro = btcrate*p.price/100000000
- #euro = b.convert_btc_to_cur(p.price/100000000,'EUR')
+ euro = b.convert_btc_to_cur(p.price/100000000,'EUR')
sat = p.price
return int(sat), round(euro,2)
def btc_to_eur(amount):
- #b = BtcConverter()
- btcrate=getbtcrate()
- #euro = round(b.convert_btc_to_cur(amount/100000000,'EUR'),2)
- euro = round(btcrate*amount/100000000)
+ b = BtcConverter()
+ euro = round(b.convert_btc_to_cur(amount/100000000,'EUR'),2)
return euro
def eur_to_sat(amount):
- btcrate=getbtcrate()
- #b = BtcConverter()
- #btc = b.convert_to_btc(amount/100, 'EUR')
- btc = 1/btcrate*(amount/100)
+ b = BtcConverter()
+ btc = b.convert_to_btc(amount/100, 'EUR')
sat=btc*100000000
return int(sat)
def getrate():
- #b = BtcConverter()
- btcrate=getbtcrate()
- #return int(b.get_latest_price('EUR'))
- return int(btcrate)
+ b = BtcConverter()
+ return int(b.get_latest_price('EUR'))
def checkforoldbags():
print('checking for old bags')
@@ -345,7 +334,7 @@ class index():
inbag = None
if inbag < 1:
session.sessionkey = 'empty'
- return render.index(products,bag,session.sessionkey,productname,inbag,db,getprice,getrate,i.category, markdown,getbtcratetime)
+ return render.index(products,bag,session.sessionkey,productname,inbag,db,getprice,getrate,i.category, markdown)
class almost():
def GET(self):
@@ -540,13 +529,13 @@ class payln:
msg = 'You got a new order, from ' + customer.firstname + ' ' + customer.lastname + ' from ' + customer.country + ' email: ' + customer.email + ' this dude wantz ' + lninvoice['description']
else:
msg='sup?'
- sendmail(webmaster, 'Gonzo Pi Shop', msg)
+ sendmail(webmaster, 'Robs Shop', msg)
# send mail to customer
if ordertype()=='physical':
- msg = "Thank you for order " + lninvoice['description'] + " at Tarina shop, we'll be processing your order as soon as possible and send it to " + customer.firstname + ' ' + customer.lastname + ', ' + customer.address + ', ' + str(customer.postalcode) + ', ' + customer.town + ', ' + customer.country + '. To pay/view status or take a look at the digital goodies of your order please visit ' + baseurl + '/goodies/'+digitalkey
+ msg = "Thank you for order " + lninvoice['description'] + " at Robins webshop, we'll be processing your order as soon as possible and send it to " + customer.firstname + ' ' + customer.lastname + ', ' + customer.address + ', ' + str(customer.postalcode) + ', ' + customer.town + ', ' + customer.country + '. To pay/view status or take a look at the digital goodies of your order please visit ' + baseurl + '/goodies/'+digitalkey
else:
- msg='sup? thanks! here the goodies '+baseurl+'/goodies/'+digitalkey
- sendmail(customer.email, 'Gonzo Pi Shop', msg)
+ msg="sup? thanks! here's a link to the digital goodies "+baseurl+'/goodies/'+digitalkey
+ sendmail(customer.email, 'A message from Robins webshop', msg)
web.seeother('/payln/'+invoice_key)
if lninvoice['status'] == 'paid':
bag = db.query("SELECT * FROM paidbags WHERE sessionkey='"+invoice_key+"';")
@@ -578,9 +567,9 @@ class paybtc:
confirmations = int(i['confirmations'])
print(str(confirmations))
if invoice.datepaid == None and confirmations > 6:
- msg = 'Gonzo Pi shop order update! someone sent you Bitcoin! ' + baseurl + '/paybtc/' + invoice.invoice_key
+ msg = 'Robins webshop order update! someone sent you Bitcoin! ' + baseurl + '/paybtc/' + invoice.invoice_key
print(msg)
- sendmail(webmaster, 'Gonzo Pi Shop', msg)
+ sendmail(webmaster, 'Robs Shop', msg)
db.update('invoices', where="invoice_key='" + invoice.invoice_key + "'", status='paid', datepaid=time.strftime('%Y-%m-%d %H:%M:%S'))
pendinginfo = getpendinginfo()
bag = db.query("SELECT * FROM customerbag WHERE sessionkey='"+invoice_key+"';")
@@ -602,16 +591,16 @@ class orders():
paylink = 'payln/'
if i.status == 'thankyou':
msg="Hi " + customer.email + ", thank you for your order! You can track the status of your order at "+baseurl+'/'+paylink+i.key
- sendmail(customer.email, 'Gonzo Pi Shop, a thank you!', msg)
+ sendmail(customer.email, 'Robs Shop, a thank you!', msg)
elif i.status == 'shipped':
msg="Hi " + customer.email + ", your order has been shipped!. You can track the status of your order at "+baseurl+'/'+paylink+i.key
- sendmail(customer.email, 'Gonzo Pi Shop, your order has been shipped!', msg)
+ sendmail(customer.email, 'Rob Shop, your order has been shipped!', msg)
elif i.status == 'paynotice':
msg="Hi " + customer.email + ", we noticed you have an unpaid order in our shop, thank you. You can track the status of your order at " + baseurl + paylink + payment.invoice_key
- sendmail(customer.email, 'Gonzo Pi Shop, order waiting for payment!', msg)
+ sendmail(customer.email, 'Rob Shop, order waiting for payment!', msg)
elif i.status == 'paid':
msg="Hi " + customer.email + ", thank you! payment received. You can track the status of your order at " + baseurl + paylink + payment.invoice_key
- sendmail(customer.email, 'Gonzo Pi Shop, order payment received', msg)
+ sendmail(customer.email, 'Rob Shop, order payment received', msg)
raise web.seeother(referer)
payments = db.select('invoices', what='btc, ln, invoice_key, products, payment, amount, totsats, timestamp, status, datepaid, dateshipped', order='timestamp DESC')
if i.key == None and i.status != None:
@@ -817,6 +806,12 @@ class propaganda:
image.save(imgdir + '/thumb/'+soundname)
raise web.seeother('/propaganda')
+class uploads:
+ def GET(self):
+ if logged():
+ uploaded = getfiles(staticdir+'upload/')
+ return render.uploads(uploaded)
+
class config:
form = web.form.Form(
web.form.Textbox('name', web.form.notnull, description="Site name:"),
@@ -1110,6 +1105,10 @@ class shipping:
else:
raise web.seeother('/login')
+class cv:
+ def GET(self):
+ return render.cv()
+
class bitcoin:
def GET(self):
if logged():