|
|
@ -15,7 +15,8 @@ pages_path = 'web/work'
|
|
|
|
#def generate_xml():
|
|
|
|
#def generate_xml():
|
|
|
|
gallery_exp=re.compile('<gallery>.*?</gallery>')
|
|
|
|
gallery_exp=re.compile('<gallery>.*?</gallery>')
|
|
|
|
file_exp=re.compile('File:(.*?)(?=File:|<\/gallery>)')
|
|
|
|
file_exp=re.compile('File:(.*?)(?=File:|<\/gallery>)')
|
|
|
|
img_exp=re.compile('(^.*?\.(gif|jpg|jpeg|png))', re.I)
|
|
|
|
#img_exp=re.compile('(^.*?\.(gif|jpg|jpeg|png))', re.I)
|
|
|
|
|
|
|
|
img_exp=re.compile('File:((.*?)\.(gif|jpg|jpeg|png))(?=\||File:|<\/gallery>)', re.I)
|
|
|
|
|
|
|
|
|
|
|
|
def replace_gallery(content):
|
|
|
|
def replace_gallery(content):
|
|
|
|
# from <gallery>.*</gallery> imgs, return list of img ET elements
|
|
|
|
# from <gallery>.*</gallery> imgs, return list of img ET elements
|
|
|
@ -26,17 +27,16 @@ def replace_gallery(content):
|
|
|
|
print 'gallery_found', gallery_found
|
|
|
|
print 'gallery_found', gallery_found
|
|
|
|
for gallery in gallery_found: # in case there is more than 1 <gallery>
|
|
|
|
for gallery in gallery_found: # in case there is more than 1 <gallery>
|
|
|
|
print 'GALLERY', gallery
|
|
|
|
print 'GALLERY', gallery
|
|
|
|
allfiles =re.findall(file_exp, gallery)
|
|
|
|
allfiles =re.findall(img_exp, gallery)
|
|
|
|
print 'ALLFILES', allfiles
|
|
|
|
print 'ALLFILES', allfiles
|
|
|
|
for imgfile in allfiles:
|
|
|
|
for imgfile in allfiles:
|
|
|
|
img = ((re.search(img_exp, imgfile)).group(0))#.decode('utf-8')
|
|
|
|
imgfile = imgfile[0]
|
|
|
|
imgsrc = api_thumb_url(img)
|
|
|
|
imgsrc = api_thumb_url(imgfile) # search for original image
|
|
|
|
|
|
|
|
print imgfile, imgsrc
|
|
|
|
img_el = ET.Element('img', attrib={'src': imgsrc})
|
|
|
|
img_el = ET.Element('img', attrib={'src': imgsrc})
|
|
|
|
gallery_imgs.append(img_el)
|
|
|
|
gallery_imgs.append(img_el)
|
|
|
|
print 'gallery img', img, ET.tostring(img_el)
|
|
|
|
# print 'gallery img', imgfile, ET.tostring(img_el)
|
|
|
|
return content, gallery_imgs
|
|
|
|
return content, gallery_imgs
|
|
|
|
# need to return a list of images that is the gallery
|
|
|
|
|
|
|
|
# need to replace <gallery>.*</gallery> with ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_workpage( allworks_dict, work_key): # replace text content in dict with html nodes, holding the content
|
|
|
|
def create_workpage( allworks_dict, work_key): # replace text content in dict with html nodes, holding the content
|
|
|
|
for key in allworks_dict.keys():
|
|
|
|
for key in allworks_dict.keys():
|
|
|
|