Skip to content

Commit

Permalink
release 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
beudbeud committed May 8, 2020
1 parent 8727261 commit 819ff8d
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 45 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ sections:
## Usage
```bash
prosopopee.py
prosopopee.py test
prosopopee.py preview
prosopopee.py deploy
prosopopee.py autogen (-d <folder> | --all ) [--force]
prosopopee.py (-h | --help)
prosopopee.py --version
prosopopee
prosopopee test
prosopopee preview
prosopopee deploy
prosopopee autogen (-d <folder> | --all ) [--force]
prosopopee (-h | --help)
prosopopee --version

Options:
test Verify all your yaml data
Expand Down
7 changes: 7 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

1.0.1 (2020-05-08)

* Fix check date format
* Fix error datetime
* lazyload for video
* add controls on fullscreen video

1.0.0 the covid release (2020-04-29)

* Add automatic generation gallery
Expand Down
5 changes: 4 additions & 1 deletion prosopopee/autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def get_exif(filename):

def build_template(folder, force):
files_grabbed = []
gallery_settings = load_settings(folder)
try:
gallery_settings = load_settings(folder)
except FileNotFoundError:
error(False, "Can't open %s/settings.yaml" % folder)
if 'static' not in gallery_settings:
if 'title' and 'date' and 'cover' in gallery_settings:
if 'sections' in gallery_settings and force is not True:
Expand Down
36 changes: 13 additions & 23 deletions prosopopee/prosopopee.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"""Prosopopee. Static site generator for your story.
Usage:
prosopopee.py
prosopopee.py test
prosopopee.py preview
prosopopee.py deploy
prosopopee.py autogen (-d <folder> | --all ) [--force]
prosopopee.py (-h | --help)
prosopopee.py --version
prosopopee
prosopopee test
prosopopee preview
prosopopee deploy
prosopopee autogen (-d <folder> | --all ) [--force]
prosopopee (-h | --help)
prosopopee --version
Options:
test Verify all your yaml data
Expand All @@ -36,7 +36,6 @@
from .utils import error, warning, okgreen, encrypt, rfc822, load_settings
from .autogen import autogen

import datetime

DEFAULTS = {
"rss": True,
Expand Down Expand Up @@ -121,12 +120,10 @@ def ffmpeg(self, source, target, options):

if options.get("resize"):
command = "{binary} {loglevel} -i {source} {resize} -vframes 1 -y {target}".format(**ffmpeg_switches)
print(command)
error(os.system(command) == 0, "%s command failed" % ffmpeg_switches["binary"])
else:
command = "{binary} {loglevel} -i {source} {video} {vbitrate} {other} {audio} {abitrate} {resolution} {format} -y {target}".format(**ffmpeg_switches)
print(command)
error(os.system(command) == 0, "%s command failed" % ffmpeg_switches["binary"])
print(command)
error(os.system(command) == 0, "%s command failed" % ffmpeg_switches["binary"])

CACHE.cache_picture(source, target, options)

Expand Down Expand Up @@ -392,12 +389,6 @@ def process_directory(gallery_name, settings, parent_templates, parent_gallery_p
gallery_path = gallery_name

gallery_settings = load_settings(gallery_path)
if gallery_settings.get("date"):
try:
datetime.datetime.strptime(str(gallery_settings.get("date")), '%Y-%m-%d')
except ValueError:
error(False, "Incorrect data format, should be YYYY-MM-DD in %s/settings.yaml" % (gallery_path))

error(isinstance(gallery_settings, dict), "Your %s should be a dict" % gallery_name.joinpath("settings.yaml"))
error(gallery_settings.get("title"), "You should specify a title in %s" % gallery_name.joinpath("settings.yaml"))

Expand Down Expand Up @@ -453,7 +444,7 @@ def create_cover(gallery_name, gallery_settings, gallery_path):
cover_image_type = "image"

error(cover_image_path.exists(), "File for %s cover image doesn't exist at "
"%s" % (gallery_name, cover_image_path))
"%s" % (gallery_name, cover_image_path))

gallery_cover = {
"title": gallery_settings["title"],
Expand Down Expand Up @@ -509,8 +500,7 @@ def build_gallery(settings, gallery_settings, gallery_path, template):
# Build light mode gallery
if gallery_settings.get("light_mode", False) or (
settings["settings"].get("light_mode", False) and
gallery_settings.get("light_mode") is None
):
gallery_settings.get("light_mode") is None):

# Prepare light mode
Path("build").joinpath(gallery_path, "light").makedirs_p()
Expand Down Expand Up @@ -581,7 +571,7 @@ def build_index(settings, galleries_cover, templates, gallery_path='', sub_index


def main():
arguments = docopt(__doc__, version='1.0.0')
arguments = docopt(__doc__, version='1.0.1')
settings = get_settings()

front_page_galleries_cover = []
Expand Down Expand Up @@ -610,7 +600,7 @@ def main():

if arguments['deploy']:
error(os.system("which rsync > /dev/null") == 0, "I can't locate the rsync, "
"please install the 'rsync' package.\n")
"please install the 'rsync' package.\n")
error(Path("build").exists(), "Please build the website before launch deployment")

r_dest = settings["settings"]["deploy"]["dest"]
Expand Down
2 changes: 2 additions & 0 deletions prosopopee/themes/exposure/templates/gallery-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@

function goFullscreen(id) {
var element = document.getElementById(id);
element.setAttribute("controls", true);

if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.mozRequestFullScreen) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
{{ video.copy() }}
<section class="bordered-picture baguette" style="position: relative;">
<div class="caption">
<img class="lazy" data-src="{{ video.generate_thumbnail("2000") }}" src="./../static/img/11-14.svg" alt="">
<video class="lazy" id="{{ video }}" onclick="goFullscreen('{{ video }}');" data-poster="{{ video.generate_thumbnail("2000") }}" alt="" autoplay="autoplay" loop="loop" preload="none" muted {% if section.image.controls %}controls="true"{% endif %}>
<img class="lazy" data-src="{{ video.generate_thumbnail("2000") }}" src="./../static/img/11-14.svg" alt="">
<video class="lazy" id="{{ video }}.{{ format }}" onclick="goFullscreen('{{ video }}.{{ format }}');" data-src="{{ video }}.{{ format }}" data-poster="{{ video.generate_thumbnail("2000") }}" alt="" loop="loop" preload="none" autoplay muted {% if video.controls %}controls="true"{% endif %}>
<source src="{{ video }}.{{ format }}" type="video/{{ format }}">
</video>
{% if caption %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
{% else %}
<img class="lazy" data-src="{{ video.generate_thumbnail("600") }}" src="./../static/img/11-14.svg" alt="">
{% endif %}
<video class="lazy" id="{{ video }}" onclick="goFullscreen('{{ video }}');" data-poster="{{ video.generate_thumbnail("600") }}" alt="" loop="loop" preload="none" autoplay muted {% if image.controls %}controls="true"{% endif %}>
<source src="{{ video }}.{{ format }}" type="video/{{ format }}">
<video class="lazy" id="{{ video }}.{{ format }}" onclick="goFullscreen('{{ video }}.{{ format }}');" data-src="{{ video }}.{{ format }}" data-poster="{{ video.generate_thumbnail("600") }}" alt="" loop="loop" preload="none" autoplay muted {% if image.controls %}controls="true"{% endif %}>
<source data-src="{{ video }}.{{ format }}" type="video/{{ format }}">
</video>
{% if caption %}
<div class="caption__overlay">
Expand Down
23 changes: 14 additions & 9 deletions prosopopee/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@
import base64

from subprocess import check_output

from path import Path

from jinja2 import Environment, FileSystemLoader

from email.utils import formatdate
from datetime import datetime

from builtins import str

import ruamel.yaml as yaml
from datetime import datetime

class bcolors:
OKGREEN = '\033[92m'
Expand All @@ -39,11 +33,13 @@ def okgreen(logging, ok_message):
sys.stderr.write("%s%s: %s%s" % (bcolors.OKGREEN, logging, bcolors.ENDC, ok_message))
sys.stderr.write("\n")


def makeform(template, settings, gallery_settings):
from_template = template.get_template("form.html")
form = base64.b64encode(from_template.render(settings=settings, gallery=gallery_settings).encode("Utf-8"))
return str(form, 'utf-8')


def encrypt(password, template, gallery_path, settings, gallery_settings):
encrypted_template = template.get_template("encrypted.html")
index_plain = Path("build").joinpath(gallery_path, "index.html")
Expand All @@ -56,20 +52,29 @@ def encrypt(password, template, gallery_path, settings, gallery_settings):
).encode("Utf-8")
return html


def rfc822(dt):
epoch = datetime.utcfromtimestamp(0).date()
return formatdate((dt - epoch).total_seconds())


def load_settings(folder):
try:
gallery_settings = yaml.safe_load(open(Path(".").joinpath(folder, "settings.yaml").abspath(), "r"))
except yaml.YAMLError as exc:
if hasattr(exc, 'problem_mark'):
mark = exc.problem_mark
error(False, "There are something wrong in %s/settings.yaml line %s" % (folder ,mark.line))
error(False, "There are something wrong in %s/settings.yaml line %s" % (folder, mark.line))
else:
error(False, "There are something wrong in %s/settings.yaml" % folder)
error(False, "There are something wrong in %s/settings.yaml" % folder)
except ValueError:
error(False, "Incorrect data format, should be YYYY-MM-DD in %s/settings.yaml" % folder)
if gallery_settings is None:
error(False, "The %s/settings.yaml file is empty" % folder)
else:
if gallery_settings.get("date"):
try:
datetime.strptime(str(gallery_settings.get("date")), '%Y-%m-%d')
except ValueError:
error(False, "Incorrect data format, should be YYYY-MM-DD in %s/settings.yaml" % folder)
return gallery_settings
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
long_description = fh.read()

setup(name='prosopopee',
version='1.0.0',
version='1.0.1',
description='A static website generator that allows you to tell a story with your pictures',
author='Laurent Peuch',
long_description=long_description,
Expand Down

0 comments on commit 819ff8d

Please sign in to comment.