diff --git a/distribusi/cli.py b/distribusi/cli.py
index 632ba25..8447da4 100644
--- a/distribusi/cli.py
+++ b/distribusi/cli.py
@@ -2,7 +2,6 @@ import argparse
from distribusi.distribusi import distribusify
-
def build_argparser():
parser = argparse.ArgumentParser("""
distbusi is a content management system for the web that produces static
@@ -19,6 +18,12 @@ def build_argparser():
help="Select which directory to distribute"
)
+ parser.add_argument(
+ '-s',
+ '--style',
+ help="Select a CSS style to include"
+ )
+
parser.add_argument(
'-v',
'--verbose',
@@ -40,12 +45,27 @@ def build_argparser():
action="store_true"
)
+ parser.add_argument(
+ '-nf',
+ '--no-filenames',
+ help="Don't use the template to ouput html",
+ action="store_true"
+ )
+
+ parser.add_argument(
+ '-c',
+ '--captions',
+ help="Print captions stored in exif metadata",
+ action="store_true"
+ )
+
return parser
def cli_entrypoint():
parser = build_argparser()
args = parser.parse_args()
+ directory = '.'
if args.directory:
if args.verbose:
diff --git a/distribusi/distribusi.py b/distribusi/distribusi.py
index 4e2a2de..36b57a0 100644
--- a/distribusi/distribusi.py
+++ b/distribusi/distribusi.py
@@ -5,7 +5,7 @@ from io import BytesIO
import magic
from distribusi.page_template import html_footer, html_head
from PIL import Image
-
+import subprocess
CODE_TYPES = [
'x-c',
@@ -13,7 +13,7 @@ CODE_TYPES = [
]
FILE_TYPES = {
- 'image': '',
+ 'image': '',
'pdf': (
''
@@ -32,8 +32,16 @@ FILE_TYPES = {
MIME_TYPE = magic.Magic(mime=True)
+def caption(image):
+ process = subprocess.Popen(['exiftool', '-Comment', image], stdout=subprocess.PIPE)
+ out, err = process.communicate()
+ try:
+ caption = out.decode("utf-8").split(": ", 1)[1]
+ except:
+ caption = ''
+ return caption
-def thumbnail(image, name):
+def thumbnail(image, name, args):
size = (450, 450)
im = Image.open(image)
im.thumbnail(size)
@@ -41,19 +49,25 @@ def thumbnail(image, name):
im.save(output, format='JPEG')
im_data = output.getvalue()
data_url = base64.b64encode(im_data).decode()
+ cap = caption(image)
+ if cap and args.captions:
+ cap = "
{}'
+ else:
+ filename = ''
if 'image' in mime:
- html = '