|
|
@ -19,8 +19,6 @@ img_exp=re.compile('(File:|Image:)((.*?)\.(gif|jpg|jpeg|png))(?=\||File:|Image:|
|
|
|
|
video_exp=re.compile('\{\{(.*?)\|(.*?)\}\}')
|
|
|
|
video_exp=re.compile('\{\{(.*?)\|(.*?)\}\}')
|
|
|
|
|
|
|
|
|
|
|
|
def replace_gallery(content):
|
|
|
|
def replace_gallery(content):
|
|
|
|
# from <gallery>.*</gallery> imgs, return list of img ET elements
|
|
|
|
|
|
|
|
# replace <gallery>.*</gallery> with ''
|
|
|
|
|
|
|
|
gallery_imgs = []
|
|
|
|
gallery_imgs = []
|
|
|
|
gallery_found = re.findall(gallery_exp, content)
|
|
|
|
gallery_found = re.findall(gallery_exp, content)
|
|
|
|
content = re.sub(gallery_exp, '', content)
|
|
|
|
content = re.sub(gallery_exp, '', content)
|
|
|
@ -30,6 +28,9 @@ def replace_gallery(content):
|
|
|
|
imgfile = imgfile[1]
|
|
|
|
imgfile = imgfile[1]
|
|
|
|
imgsrc = api_file_url(imgfile) # search for original image
|
|
|
|
imgsrc = api_file_url(imgfile) # search for original image
|
|
|
|
gallery_imgs.append(imgsrc)
|
|
|
|
gallery_imgs.append(imgsrc)
|
|
|
|
|
|
|
|
print 'gallery_imgs', gallery_imgs
|
|
|
|
|
|
|
|
# from <gallery>.*</gallery> imgs, return list of img ET elements
|
|
|
|
|
|
|
|
# replace <gallery>.*</gallery> with ''
|
|
|
|
return content, gallery_imgs
|
|
|
|
return content, gallery_imgs
|
|
|
|
|
|
|
|
|
|
|
|
def replace_video(content):
|
|
|
|
def replace_video(content):
|
|
|
@ -45,7 +46,10 @@ def replace_video(content):
|
|
|
|
video_src="https://player.vimeo.com/video/" + video_hash
|
|
|
|
video_src="https://player.vimeo.com/video/" + video_hash
|
|
|
|
if video_src:
|
|
|
|
if video_src:
|
|
|
|
videos.append(video_src)
|
|
|
|
videos.append(video_src)
|
|
|
|
content = re.sub(video_exp, '', content)
|
|
|
|
iframe = "<iframe src='{}' width='600px' height='450px'></iframe>".format(video_src)
|
|
|
|
|
|
|
|
# content = re.sub(video_exp, ' iframe ', content)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
content = re.sub(video_exp, '', content)
|
|
|
|
return content, videos
|
|
|
|
return content, videos
|
|
|
|
|
|
|
|
|
|
|
|
def create_workpage( work, work_key, tree): # replace text content in dict with html nodes, holding the content
|
|
|
|
def create_workpage( work, work_key, tree): # replace text content in dict with html nodes, holding the content
|
|
|
@ -59,23 +63,23 @@ def create_workpage( work, work_key, tree): # replace text content in dict with
|
|
|
|
|
|
|
|
|
|
|
|
if key in ['Description', 'Extra']:
|
|
|
|
if key in ['Description', 'Extra']:
|
|
|
|
mw_content = work[key]
|
|
|
|
mw_content = work[key]
|
|
|
|
if re.search(gallery_exp, mw_content):
|
|
|
|
# if re.search(gallery_exp, mw_content):
|
|
|
|
mw_content, gallery_imgs = replace_gallery(mw_content)
|
|
|
|
# # replace_gallery must replace the gallery inline
|
|
|
|
work['Images'] = gallery_imgs
|
|
|
|
# mw_content, gallery_imgs = replace_gallery(mw_content)
|
|
|
|
for imgsrc in gallery_imgs:
|
|
|
|
# work['Images'] = gallery_imgs
|
|
|
|
img_el = ET.SubElement(div_av, 'img', attrib={'src': imgsrc})
|
|
|
|
# for imgsrc in gallery_imgs:
|
|
|
|
elif re.search(video_exp, mw_content):
|
|
|
|
# img_el = ET.SubElement(div_av, 'img', attrib={'src': imgsrc})
|
|
|
|
mw_content, videos = replace_video(mw_content)
|
|
|
|
# elif re.search(video_exp, mw_content):
|
|
|
|
work['Video'] = videos
|
|
|
|
# mw_content, videos = replace_video(mw_content)
|
|
|
|
for video in videos:
|
|
|
|
# work['Video'] = videos
|
|
|
|
iframe_el = ET.SubElement(div_av, 'iframe', attrib={'src': video, 'width':'600px', 'height':'450px'})
|
|
|
|
# # for video in videos:
|
|
|
|
print 'VIDEO', ET.tostring(iframe_el)
|
|
|
|
# # iframe_el = ET.SubElement(div_av, 'iframe', attrib={'src': video, 'width':'600px', 'height':'450px'})
|
|
|
|
|
|
|
|
# # print 'VIDEO', ET.tostring(iframe_el)
|
|
|
|
|
|
|
|
|
|
|
|
print '--------------'
|
|
|
|
print '--------------'
|
|
|
|
print 'mw_content', mw_content
|
|
|
|
print 'mw_content', mw_content
|
|
|
|
print '--------------'
|
|
|
|
print '--------------'
|
|
|
|
x=mw_content
|
|
|
|
html_content = pandoc2html( mw_content if key in work.keys() else '') # convert to HTML
|
|
|
|
html_content = pandoc2html( x if key in work.keys() else '') # convert to HTML
|
|
|
|
|
|
|
|
print 'html_content', html_content
|
|
|
|
print 'html_content', html_content
|
|
|
|
document_el = html5lib.parse(html_content, namespaceHTMLElements=False)#ET.fromstring(html_content)
|
|
|
|
document_el = html5lib.parse(html_content, namespaceHTMLElements=False)#ET.fromstring(html_content)
|
|
|
|
print ET.tostring(document_el)
|
|
|
|
print ET.tostring(document_el)
|
|
|
@ -89,14 +93,11 @@ def create_workpage( work, work_key, tree): # replace text content in dict with
|
|
|
|
div_body.append(el)
|
|
|
|
div_body.append(el)
|
|
|
|
|
|
|
|
|
|
|
|
imgs = document_el.findall('.//img')
|
|
|
|
imgs = document_el.findall('.//img')
|
|
|
|
if imgs:
|
|
|
|
# if imgs:
|
|
|
|
for img in imgs:
|
|
|
|
# for img in imgs:
|
|
|
|
src = api_file_url(img.get('src'))
|
|
|
|
# src = api_file_url(img.get('src'))
|
|
|
|
img.set('src', src)
|
|
|
|
# img.set('src', src)
|
|
|
|
print 'IMG', img, src
|
|
|
|
# print 'IMG', img, src
|
|
|
|
|
|
|
|
|
|
|
|
# div_body.append( document_el )
|
|
|
|
|
|
|
|
# print 'div_body', ET.tostring(div_body)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif key in ['Thumbnail']:
|
|
|
|
elif key in ['Thumbnail']:
|
|
|
@ -116,18 +117,6 @@ def create_workpage( work, work_key, tree): # replace text content in dict with
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# for key in work.keys():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# # p = ET.Element('p')
|
|
|
|
|
|
|
|
# # p.text = " oooo oooo oo"
|
|
|
|
|
|
|
|
# # print 'ELEMENTS', ET.tostring(div_header)
|
|
|
|
|
|
|
|
# # print 'ELEMENTS', ET.tostring(div_body)
|
|
|
|
|
|
|
|
# # print 'ELEMENTS', ET.tostring(div_av)
|
|
|
|
|
|
|
|
# # ET.SubElement(div_header, 'p' )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# print "****************************"
|
|
|
|
# print "****************************"
|
|
|
|
# print ET.tostring(div_body)
|
|
|
|
# print ET.tostring(div_body)
|
|
|
|
# print "****************************"
|
|
|
|
# print "****************************"
|
|
|
@ -171,6 +160,11 @@ for key in json_allworks.keys():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### ISSSUES
|
|
|
|
### ISSSUES
|
|
|
|
|
|
|
|
# pandoc mw->HTML NOT WORKING
|
|
|
|
|
|
|
|
# sub gallery/videos with corresponding elements
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Gallaries, Files, videos, in orginal places correct place
|
|
|
|
# Gallaries, Files, videos, in orginal places correct place
|
|
|
|
# Specificy positions in template
|
|
|
|
# Specificy positions in template
|
|
|
|
# insert <p> into <div class="body">
|
|
|
|
# insert <p> into <div class="body">
|
|
|
|