|
@@ -98,7 +98,9 @@ def detect_content(content):
|
|
if what == 'photo':
|
|
if what == 'photo':
|
|
if value.startswith('/'):
|
|
if value.startswith('/'):
|
|
value = value[1:]
|
|
value = value[1:]
|
|
- path = os.path.join(settings['PHOTO_LIBRARY'], value)
|
|
|
|
|
|
+ path = os.path.join(
|
|
|
|
+ os.path.expanduser(settings['PHOTO_LIBRARY']),
|
|
|
|
+ value)
|
|
if not os.path.isfile(path):
|
|
if not os.path.isfile(path):
|
|
logger.error('photos: No photo %s', path)
|
|
logger.error('photos: No photo %s', path)
|
|
else:
|
|
else:
|
|
@@ -130,7 +132,9 @@ def detect_content(content):
|
|
def process_gallery_photo(generator, article, gallery):
|
|
def process_gallery_photo(generator, article, gallery):
|
|
if gallery.startswith('/'):
|
|
if gallery.startswith('/'):
|
|
gallery = gallery[1:]
|
|
gallery = gallery[1:]
|
|
- dir_gallery = os.path.join(generator.settings['PHOTO_LIBRARY'], gallery)
|
|
|
|
|
|
+ dir_gallery = os.path.join(
|
|
|
|
+ os.path.expanduser(generator.settings['PHOTO_LIBRARY']),
|
|
|
|
+ gallery)
|
|
if os.path.isdir(dir_gallery):
|
|
if os.path.isdir(dir_gallery):
|
|
logger.info('photos: Gallery detected: %s', gallery)
|
|
logger.info('photos: Gallery detected: %s', gallery)
|
|
dir_photo = os.path.join('photos', gallery.lower())
|
|
dir_photo = os.path.join('photos', gallery.lower())
|
|
@@ -139,7 +143,7 @@ def process_gallery_photo(generator, article, gallery):
|
|
msg='photos: No EXIF for gallery %s')
|
|
msg='photos: No EXIF for gallery %s')
|
|
captions = read_notes(os.path.join(dir_gallery, 'captions.txt'))
|
|
captions = read_notes(os.path.join(dir_gallery, 'captions.txt'))
|
|
article.photo_gallery = []
|
|
article.photo_gallery = []
|
|
- for pic in os.listdir(dir_gallery):
|
|
|
|
|
|
+ for pic in sorted(os.listdir(dir_gallery)):
|
|
if pic.startswith('.'): continue
|
|
if pic.startswith('.'): continue
|
|
if pic.endswith('.txt'): continue
|
|
if pic.endswith('.txt'): continue
|
|
photo = os.path.splitext(pic)[0].lower() + '.jpg'
|
|
photo = os.path.splitext(pic)[0].lower() + '.jpg'
|
|
@@ -158,6 +162,8 @@ def process_gallery_photo(generator, article, gallery):
|
|
os.path.join(dir_gallery, pic),
|
|
os.path.join(dir_gallery, pic),
|
|
os.path.join(dir_thumb, thumb),
|
|
os.path.join(dir_thumb, thumb),
|
|
generator.settings['PHOTO_THUMB'])
|
|
generator.settings['PHOTO_THUMB'])
|
|
|
|
+ else:
|
|
|
|
+ logger.error('photos: Gallery does not exist: %s at %s', gallery, dir_gallery)
|
|
|
|
|
|
|
|
|
|
def process_gallery_filename(generator, article, gallery):
|
|
def process_gallery_filename(generator, article, gallery):
|
|
@@ -165,7 +171,9 @@ def process_gallery_filename(generator, article, gallery):
|
|
gallery = gallery[1:]
|
|
gallery = gallery[1:]
|
|
else:
|
|
else:
|
|
gallery = os.path.join(article.relative_dir, gallery)
|
|
gallery = os.path.join(article.relative_dir, gallery)
|
|
- dir_gallery = os.path.join(generator.settings['PHOTO_LIBRARY'], gallery)
|
|
|
|
|
|
+ dir_gallery = os.path.join(
|
|
|
|
+ os.path.expanduser(generator.settings['PHOTO_LIBRARY']),
|
|
|
|
+ gallery)
|
|
if os.path.isdir(dir_gallery):
|
|
if os.path.isdir(dir_gallery):
|
|
logger.info('photos: Gallery detected: %s', gallery)
|
|
logger.info('photos: Gallery detected: %s', gallery)
|
|
dir_photo = gallery.lower()
|
|
dir_photo = gallery.lower()
|
|
@@ -174,7 +182,7 @@ def process_gallery_filename(generator, article, gallery):
|
|
msg='photos: No EXIF for gallery %s')
|
|
msg='photos: No EXIF for gallery %s')
|
|
captions = read_notes(os.path.join(dir_gallery, 'captions.txt'))
|
|
captions = read_notes(os.path.join(dir_gallery, 'captions.txt'))
|
|
article.photo_gallery = []
|
|
article.photo_gallery = []
|
|
- for pic in os.listdir(dir_gallery):
|
|
|
|
|
|
+ for pic in sorted(os.listdir(dir_gallery)):
|
|
if pic.startswith('.'): continue
|
|
if pic.startswith('.'): continue
|
|
if pic.endswith('.txt'): continue
|
|
if pic.endswith('.txt'): continue
|
|
photo = pic.lower()
|
|
photo = pic.lower()
|
|
@@ -189,6 +197,8 @@ def process_gallery_filename(generator, article, gallery):
|
|
os.path.join(dir_gallery, pic),
|
|
os.path.join(dir_gallery, pic),
|
|
os.path.join(dir_thumb, thumb),
|
|
os.path.join(dir_thumb, thumb),
|
|
generator.settings['PHOTO_THUMB'])
|
|
generator.settings['PHOTO_THUMB'])
|
|
|
|
+ else:
|
|
|
|
+ logger.error('photos: Gallery does not exist: %s at %s', gallery, dir_gallery)
|
|
|
|
|
|
|
|
|
|
def detect_gallery(generator):
|
|
def detect_gallery(generator):
|
|
@@ -206,7 +216,9 @@ def detect_gallery(generator):
|
|
def process_image_photo(generator, article, image):
|
|
def process_image_photo(generator, article, image):
|
|
if image.startswith('/'):
|
|
if image.startswith('/'):
|
|
image = image[1:]
|
|
image = image[1:]
|
|
- path = os.path.join(generator.settings['PHOTO_LIBRARY'], image)
|
|
|
|
|
|
+ path = os.path.join(
|
|
|
|
+ os.path.expanduser(generator.settings['PHOTO_LIBRARY']),
|
|
|
|
+ image)
|
|
if os.path.isfile(path):
|
|
if os.path.isfile(path):
|
|
photo = os.path.splitext(image)[0].lower() + 'a.jpg'
|
|
photo = os.path.splitext(image)[0].lower() + 'a.jpg'
|
|
thumb = os.path.splitext(image)[0].lower() + 't.jpg'
|
|
thumb = os.path.splitext(image)[0].lower() + 't.jpg'
|