[sync] updated; page images

This commit is contained in:
tmshv committed 2016-11-23 02:10:26 +03:00
1 parent 9f58ffca09
commit a4b4e07687
6 files changed
+104 -28

No files matched your search

+16
View File
@@ -2,10 +2,12 @@ import os
import re
from datetime import datetime
from glob import glob
from lxml import etree
import lxml.html
from markdown import markdown
import settings
from sync.image import sync_image
from utils.fn import lmap, combine
@@ -80,6 +82,20 @@ def create_date_and_title_from_folder_name(folder_name, date_formats=None):
return date, title
def create_post(md, image_path_fn):
html = lxml.html.fromstring(md)
for img in html.cssselect('img'):
src = img.get('src')
path = image_path_fn(src)
if path:
img.set('src', path)
img.set('class', settings.album_html_img_class)
img.set('data-file', src)
return etree.tounicode(html)
def images_from_html(md):
if not md:
return []