mirror of
https://github.com/fergalmoran/qrmaker.git
synced 2025-12-22 10:00:50 +00:00
Fixed permalink URL generation
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
from pygooglechart import QRChart
|
from pygooglechart import QRChart
|
||||||
import logging
|
|
||||||
import re
|
import re
|
||||||
import uuid
|
import uuid
|
||||||
import shutil
|
import shutil
|
||||||
@@ -22,25 +21,18 @@ class QRMaker:
|
|||||||
|
|
||||||
def createVCard(self, data):
|
def createVCard(self, data):
|
||||||
try:
|
try:
|
||||||
logging.debug('In createVCard')
|
|
||||||
chart = QRChart(HEIGHT, WIDTH)
|
chart = QRChart(HEIGHT, WIDTH)
|
||||||
templateData = ''
|
templateData = ''
|
||||||
logging.debug('Parsing form')
|
|
||||||
for k, v in data.items():
|
for k, v in data.items():
|
||||||
templateData = self._templateData.replace('{%s}' % k, v)
|
templateData = self._templateData.replace('{%s}' % k, v)
|
||||||
self._templateData = templateData
|
self._templateData = templateData
|
||||||
|
|
||||||
logging.debug('Parsed form..')
|
|
||||||
|
|
||||||
match = re.sub(r'{\w*\w}', '', templateData)
|
match = re.sub(r'{\w*\w}', '', templateData)
|
||||||
|
|
||||||
chart.add_data(match)
|
chart.add_data(match)
|
||||||
|
|
||||||
chart.set_ec('H', 0)
|
chart.set_ec('H', 0)
|
||||||
uid = uuid.uuid1()
|
uid = uuid.uuid1()
|
||||||
logging.debug('Downloading image')
|
|
||||||
filePath = '%s/../static/cache/%s.png' % (os.path.dirname(__file__), uid)
|
filePath = '%s/../static/cache/%s.png' % (os.path.dirname(__file__), uid)
|
||||||
logging.debug('Downloading ' + filePath)
|
|
||||||
chart.download(filePath)
|
chart.download(filePath)
|
||||||
return uid
|
return uid
|
||||||
except ex:
|
except ex:
|
||||||
@@ -49,8 +41,8 @@ class QRMaker:
|
|||||||
|
|
||||||
def generatePermalink(self, id):
|
def generatePermalink(self, id):
|
||||||
shutil.copyfile(
|
shutil.copyfile(
|
||||||
'static/cache/%s.png' % id,
|
'%s/../static/cache/%s.png' % (os.path.dirname(__file__), id),
|
||||||
'static/images/permalinked/%s.png' % id
|
'%s/../static/images/permalinked/%s.png' % (os.path.dirname(__file__), id)
|
||||||
)
|
)
|
||||||
return 'static/images/permalinked/%s.png' % id
|
return '%s/../static/images/permalinked/%s.png' % (os.path.dirname(__file__), id)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user