From 3da148f4063f2910aedf443f06a50946903e91de Mon Sep 17 00:00:00 2001 From: ThomasV Date: Fri, 24 Jul 2015 12:36:08 +0200 Subject: [PATCH] use local copy of javascript files --- lib/wallet.py | 33 ++++++++++++++++++++++++++------- lib/www/index.html | 11 +++++------ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/lib/wallet.py b/lib/wallet.py index f20bf431..c6b64917 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -1278,8 +1278,32 @@ class Abstract_Wallet(object): self.receive_requests[key] = req self.storage.put('payment_requests', self.receive_requests) + def check_www_dir(self, config): + import urllib, urlparse, shutil, os + rdir = config.get('requests_dir') + if not os.path.exists(rdir): + os.mkdir(rdir) + index = os.path.join(rdir, 'index.html') + if not os.path.exists(index): + src = os.path.join(os.path.dirname(__file__), 'www', 'index.html') + shutil.copy(src, index) + files = [ + "https://code.jquery.com/jquery-1.9.1.min.js", + "https://raw.githubusercontent.com/davidshimjs/qrcodejs/master/qrcode.js", + "https://code.jquery.com/ui/1.10.3/jquery-ui.js", + "https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" + ] + for URL in files: + path = urlparse.urlsplit(URL).path + filename = os.path.basename(path) + path = os.path.join(rdir, filename) + if not os.path.exists(path): + print_error("downloading ", URL) + urllib.urlretrieve(URL, path) + + def add_payment_request(self, req, config): - import shutil, os + import os addr = req['address'] amount = req.get('amount') message = req.get('memo') @@ -1289,12 +1313,7 @@ class Abstract_Wallet(object): rdir = config.get('requests_dir') if rdir and amount is not None: - if not os.path.exists(rdir): - os.mkdir(rdir) - index = os.path.join(rdir, 'index.html') - if not os.path.exists(index): - src = os.path.join(os.path.dirname(__file__), 'www', 'index.html') - shutil.copy(src, index) + self.check_www_dir(config) key = req.get('id', addr) pr = paymentrequest.make_request(config, req) path = os.path.join(rdir, key) diff --git a/lib/www/index.html b/lib/www/index.html index 0bbc347e..e041c425 100644 --- a/lib/www/index.html +++ b/lib/www/index.html @@ -1,12 +1,11 @@ - Payment request - - - - - + Payment request + + + +