thiswebshoprules

git clone https://git.tarina.org/thiswebshoprules
Log | Files | Refs

commit bd234ed9ec22aefb2e743285f3bdc26f0700d070
parent 18bc3234ac6a2212166810a0782325899759edfc
Author: rob <rob@tarina.org>
Date:   Wed, 21 Feb 2024 13:26:17 +0200

lots of improvement

Diffstat:
Mpublic_html/static/style.css | 15++++++++++-----
Mpublic_html/templates/base.html | 4++--
Mpublic_html/templates/config.html | 2++
Mpublic_html/templates/index.html | 81++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------
Mpublic_html/templates/op.html | 2+-
Mpublic_html/templates/products.html | 5+++--
Mserver.py | 85++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
7 files changed, 147 insertions(+), 47 deletions(-)

diff --git a/public_html/static/style.css b/public_html/static/style.css @@ -121,8 +121,8 @@ table, tbody, tr, td input, select { padding: 4px; - color: #666; - background-color: #111; + color: #fff; + background-color: #555; font-size: 16px; border: 0px; } @@ -130,8 +130,8 @@ input, select textarea { padding: 4px; - color: #666; - background-color: #111; + color: #fff; + background-color: #555; font-size: 16px; border: 0px; width: 100%; @@ -242,5 +242,10 @@ button #description { - height:100px; + height:200px; +} + +#description2 +{ + height:200px; } 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>Rockman Brothers | International Heavy Voodoo Sound</title> - <link rel="stylesheet" href="/static/robstyle.css?v=12" type="text/css" rel="stylesheet"/> + <title>Gonzo Pi Shop | Buy all things Gonzo Pi</title> + <link rel="stylesheet" href="/static/robstyle.css?v=24" 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/config.html b/public_html/templates/config.html @@ -7,6 +7,8 @@ $:configform.render() </form> <br> <b>Logo</b> +<br> +<img src="/static/img/thumb/logo.png"> <form method="POST" enctype="multipart/form-data" action=""> <input type="file" name="imgfile"/> <br> <br/> diff --git a/public_html/templates/index.html b/public_html/templates/index.html @@ -1,11 +1,11 @@ -$def with (products,bag,sessionkey,productname,inbag,db,getprice,getrate) +$def with (products,bag,sessionkey,productname,inbag,db,getprice,getrate,category,markdown) $ totsats = 0 $ toteuro = 0 $ x = 0 $if sessionkey != 'empty': <div id="bag"> <div id="insidebag"> - in your order:<br> + in your cart:<br> $for i in bag: $code: price = getprice(i.product) @@ -13,48 +13,69 @@ $if sessionkey != 'empty': p_totsats=i.quantity*price[0] p_toteuro=i.quantity*price[1] $i.quantity x $productname(i.product) - <a href="/dropitem/$i.product">X</a> $p_totsats $p_toteuro&euro;<br> + $p_totsats $p_toteuro&euro; <a href="/dropitem/$i.product">remove</a><br> $code: totsats += p_totsats toteuro += p_toteuro $if totsats > 0: total: $totsats Satoshi or $toteuro &euro; - <a href="/checkout">Checkout</a> + <br> + <a href="/checkout">CHECKOUT --></a> + <br> + <code>~</code> </div> </div> + +$ siteconfig = db.select('siteconfig', what='id, name, description, description2')[0] +$ categories = db.select('categories', what='id, category') + <div id="container"> +<div class="intro"> +<img src="/static/img/thumb/logo.png"> <br> -<h1>Rockman Brothers</h1> -<h4>International Heavy Voodoo Sound</h4> -<br> -<div id="logocontainer"> +<h1>$siteconfig.name</h1> +<h6>$siteconfig.description</h6> +<pre>$siteconfig.description2</pre> -</div> +<a href="/">All</a> | +$for c in categories: + <a href="?category=$c.category">$c.category</a> | +<br> +</div> <div id="productlist"> $for i in products: - <div class="product" id="$i.id"> - $ goodies = db.query("SELECT * FROM soundlink WHERE id='" +i.id+"';") - $for g in goodies: - $if g.soundname[-5:] == '.jpeg' or g.soundname[-4:] == '.png': - <a href="/bigpic/$g.id"><img class="imgprod" src="/static/img/web/$g.soundname"></a> - $code: - sat, euro = getprice(i.id) - <h2> - $i.name - </h2> - <code>$i.category</code> - <pre>$i.description</pre> - $if i.available > 0: - Price $sat Satoshi ~ $euro &euro; <a href="?putinbag=$i.id#$i.id">add to bag</a><br> - Available $i.available pcs - $else: - SOLD OUT! check back later. - </div> - <br> - <small>~-~</small> - <br> + $if category == i.category or category == None: + <div class="product" id="$i.id"> + <code>~*~</code> + <h2> + $i.name + </h2> + <code>$i.category</code> + <br> + <br> + $ goodies = db.query("SELECT * FROM soundlink WHERE id='" +i.id+"';") + $for g in goodies: + $if g.soundname[-5:] == '.jpeg' or g.soundname[-4:] == '.png': + <a href="/bigpic/$g.id"><img class="imgprod" src="/static/img/web/$g.soundname"></a> + $code: + sat, euro = getprice(i.id) + $:markdown.markdown(i.description) + product: $i.name + <br> + category: $i.category + <br> + <br> + $if i.available > 0: + Price $sat Satoshi ~ $euro &euro; <a href="?putinbag=$i.id#$i.id">add to cart</a><br> + Available $i.available pcs + $else: + SOLD OUT! check back later. + </div> + <br> + <small>~-~</small> + <br> </div> <img class="logo" src="/static/bitcoin.png"> <br> diff --git a/public_html/templates/op.html b/public_html/templates/op.html @@ -3,7 +3,7 @@ $def with (content) <HEAD> <meta charset="utf-8"> <title>Tarina web shop Welcome!</title> - <link rel="stylesheet" href="/static/style.css?v=999.99" type="text/css" rel="stylesheet"/> + <link rel="stylesheet" href="/static/robstyle.css?v=1.15" 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/products.html b/public_html/templates/products.html @@ -2,8 +2,9 @@ $def with (addproduct, listproducts, goodies, idvalue) <div id="container"> <div id="default"> <br> -$for i in listproducts: - <a href='/products/$i.id'>$i.name $i.price</a> +$for i in listproducts: + <div class="editproduct" id="$i.id"><a href='/products/$i.id'>$i.name[:15]</a></div> +<br> $if idvalue == '': <h2>Add product</h2> $else: diff --git a/server.py b/server.py @@ -17,6 +17,7 @@ import shutil import settings import binascii import base64 +import markdown from PIL import Image from forex_python.bitcoin import BtcConverter from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException @@ -168,6 +169,13 @@ def getproduct(productid): return '' return product +def getcategories(): + try: + categories = db.query("SELECT * FROM categories;")[0] + except: + return '' + return categories + def ordertype(): physical=False bag = db.query("SELECT * FROM customerbag WHERE sessionkey='" + session.sessionkey +"';") @@ -279,7 +287,7 @@ def getpendinginfo(): class index(): def GET(self): checkforoldbags() - i = web.input(dropitem=None, putinbag=None,error=None,prod=None) + i = web.input(dropitem=None, putinbag=None,error=None,prod=None,category=None) if session.sessionkey == 'empty': session.sessionkey = hashlib.sha256(str(random.getrandbits(256)).encode('utf-8')).hexdigest()[15:35] if i.dropitem != None: @@ -302,7 +310,7 @@ class index(): inbag = None if inbag < 1: session.sessionkey = 'empty' - return render.index(products,bag,session.sessionkey,productname,inbag,db,getprice,getrate) + return render.index(products,bag,session.sessionkey,productname,inbag,db,getprice,getrate,i.category, markdown) class putinbag: def GET(self, p): @@ -626,14 +634,15 @@ class op: class config: form = web.form.Form( web.form.Textbox('name', web.form.notnull, description="Site name:"), - web.form.Textarea('description', web.form.notnull, description="Description:"), + web.form.Textarea('description', web.form.notnull, description="Slogan:"), + web.form.Textarea('description2', web.form.notnull, description="Description:"), web.form.Button('Save')) def GET(self): if logged(): configsite = self.form() try: - oldsiteconfig = db.select('siteconfig', what='id, name, description')[0] - configsite.fill(name=oldsiteconfig.name, description=oldsiteconfig.description) + oldsiteconfig = db.select('siteconfig', what='id, name, description, description2')[0] + configsite.fill(name=oldsiteconfig.name, description=oldsiteconfig.description, description2=oldsiteconfig.description2) except: print('no non no') return renderop.config(configsite) @@ -641,8 +650,70 @@ class config: raise web.seeother('/login') def POST(self): addcategory = self.form() - i = web.input() - db.update('siteconfig', where='id=1', name=i.name, description=i.description) + i = web.input(imgfile={}, name=None) + if i.name != None: + db.update('siteconfig', where='id=1', name=i.name, description=i.description, description2=i.description2 ) + if i.imgfile != {}: + if i.imgfile.filename == '': + print('hmmm... no image to upload') + raise web.seeother('/config/') + print('YEAH, Upload image!') + + ##---------- UPLOAD IMAGE ---------- + + filepath=i.imgfile.filename.replace('\\','/') # replaces the windows-style slashes with linux ones. + #split and only take the filename with extension + #soundpath=filepath.split('/')[-1] + #if soundpath == '': + # return render.nope("strange, no filename found!") + #get filetype, last three + imgname=filepath.split('/')[-1] # splits the and chooses the last part (the filename with extension) + filetype = imgname.split('.')[-1].lower() + if filetype == 'jpg': + filetype = 'jpeg' + soundname = imgname.split('.')[0] + #lets remove unwanted characters yes please! + sound = '' + for p in soundname.lower(): + if p in allowedchar: + sound = sound + p + if sound == '': + raise web.seeother('/upload?fail=wierdname') + soundname = 'logo.' + filetype + print(soundname) + print("filename is " + imgname + " filetype is " + filetype + " soundname is " + soundname + " trying to upload file from: " + filepath) + #if filetype != 'wav' or 'ogg' or 'flac' or 'jpeg' or 'jpg' or 'mp3': + # web.seeother('/upload?fail=notsupported') + #imghash = hashlib.md5(str(random.getrandbits(256)).encode('utf-8')).hexdigest() + #imgname = imghash + #imgname = str(len(os.listdir(imgdir))).zfill(3) + '.jpeg' + soundlink = hashlib.sha256(str(random.getrandbits(256)).encode('utf-8')).hexdigest()[9:36] + imgdir = staticdir+'upload/' + os.system('mkdir -p ' + imgdir) + fout = open(imgdir + soundname,'wb') # creates the file where the uploaded file should be stored + fout.write(i.imgfile.file.read()) # writes the uploaded file to the newly created file. + fout.close() # closes the file, upload complete. + + if filetype == 'jpeg' or filetype == 'png': + ##---------- OPEN FILE & CHEKC IF JPEG -------- + + image = Image.open(imgdir + soundname) + #if image.format != 'JPEG': + # os.remove(imgdir +'/'+ soundname) + # raise web.seeother('/products/' + idvalue) + + ##---------- RESIZE IMAGE SAVE TO PRODUCT----------- + + imgdir=staticdir+'img' + try: + os.makedirs(imgdir + '/web/', exist_ok=True) + os.makedirs(imgdir + '/thumb/', exist_ok=True) + except: + print('Folders is') + image.thumbnail((900,900), Image.ANTIALIAS) + image.save(imgdir + '/web/'+soundname) + image.thumbnail((300,300), Image.ANTIALIAS) + image.save(imgdir + '/thumb/'+soundname) raise web.seeother('/config') class categories: