[sync] updated: + albums, kazimir rendering, other changes
This commit is contained in:
1 parent
2ea3c1f322
commit
dc8363ee84
18 files changed
+331
-410
No files matched your search
@@ -10,13 +10,13 @@ import utils.image
|
||||
|
||||
|
||||
def thumbnail(src, dest, size, ext=None):
|
||||
# image_magick_resize(src, dest, size, quality=85)
|
||||
# return utils.image.read_image(dest)
|
||||
image_magick_resize(src, dest, size, quality=85)
|
||||
return utils.image.read_image(dest)
|
||||
|
||||
image = utils.image.read_image(src)
|
||||
image.thumbnail(size)
|
||||
image.save(override_extension(dest, ext))
|
||||
return image
|
||||
# image = utils.image.read_image(src)
|
||||
# image.thumbnail(size)
|
||||
# image.save(override_extension(dest, ext))
|
||||
# return image
|
||||
|
||||
|
||||
def optimize(src, dest, quality=85, ext=None):
|
||||
@@ -69,9 +69,9 @@ def orient(image):
|
||||
return image
|
||||
|
||||
|
||||
def image_magick_resize(input_file, output_file, size, quality=85):
|
||||
def image_magick_resize(ifile, ofile, size, quality=85):
|
||||
s = '%dx%d' % size
|
||||
call(['convert', input_file, '-strip', '-auto-orient', '-resize', s, '-quality', str(quality), output_file])
|
||||
call(['/usr/local/bin/convert', ifile, '-strip', '-auto-orient', '-resize', s, '-quality', str(quality), ofile])
|
||||
|
||||
|
||||
# def image_magick_resize(input_file, output_file, size, quality=85):
|
||||
|
||||
+3
-43
@@ -1,54 +1,14 @@
|
||||
import re
|
||||
|
||||
import frontmatter
|
||||
import yaml
|
||||
from markdown import markdown
|
||||
|
||||
from utils.text.split import split, split_with
|
||||
from kazimir import kazimir_to_html
|
||||
|
||||
# FM_BOUNDARY = re.compile(r'^-{3,}$', re.MULTILINE)
|
||||
FM_BOUNDARY = re.compile(r'^-{3,}', re.MULTILINE)
|
||||
|
||||
def read_file(file):
|
||||
with open(file, 'rb') as f:
|
||||
data = f.read().decode('utf-8')
|
||||
return data
|
||||
|
||||
|
||||
def read_yaml(file):
|
||||
with open(file, 'rb') as f:
|
||||
data = f.read().decode('utf-8')
|
||||
return yaml.load(data)
|
||||
|
||||
|
||||
def read_md(file):
|
||||
with open(file, 'rb') as f:
|
||||
data = f.read().decode('utf-8')
|
||||
return markdown(data)
|
||||
|
||||
|
||||
def read_yaml_md(data):
|
||||
yaml_front_matter, content = parse_yaml_front_matter(data)
|
||||
return yaml_front_matter, markdown(content)
|
||||
|
||||
# data = frontmatter.load(file)
|
||||
# return data.metadata, markdown(data.content)
|
||||
|
||||
|
||||
def read_md_yaml(file):
|
||||
data = read_file(file)
|
||||
yaml_data, md_data = split_with(['\n\n', '\r\n\r\n'])(data)
|
||||
|
||||
if not yaml_data and not md_data:
|
||||
return (None, read_md(file))
|
||||
|
||||
try:
|
||||
y = yaml.load(yaml_data)
|
||||
except:
|
||||
y = None
|
||||
|
||||
m = markdown(md_data) if md_data else None
|
||||
return y, m
|
||||
return yaml_front_matter, kazimir_to_html(content)
|
||||
|
||||
|
||||
def parse_yaml_front_matter(text, **defaults):
|
||||
@@ -75,4 +35,4 @@ def parse_yaml_front_matter(text, **defaults):
|
||||
if isinstance(fm, dict):
|
||||
metadata.update(fm)
|
||||
|
||||
return metadata, content.strip()
|
||||
return metadata, content.strip()
|
||||
@@ -9,10 +9,3 @@ __check_description_filename_exp = re.compile('^[%s]+(\[\d+\])\.md$' % settings.
|
||||
|
||||
def check_description_filename(filename):
|
||||
return __check_description_filename_exp.match(filename)
|
||||
|
||||
|
||||
def suggest_description_filename(filename):
|
||||
bn = os.path.basename(filename)
|
||||
bn = os.path.splitext(bn)[0]
|
||||
v = settings.default_description_version
|
||||
return '%s [%s].md' % (bn, v)
|
||||
Reference in new issue
Block a user