diff --git a/docs/changelog.rst b/docs/changelog.rst index 9c0f1ae..ebf7b3d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -10,6 +10,8 @@ Changelog * code cleaning by Bram * make code a bit more robust by Bram * basic CI on travis by Bram + * Light mode by beudbeud + * progressive JPEG/GIF/PNG by default for a better loading experience by 0x010C following sebian's blogpost 0.3.1 (2016-04-13) diff --git a/docs/configuration.rst b/docs/configuration.rst index bfb516d..5347482 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -13,7 +13,7 @@ The files organisation is quite simple: Root settings.yaml ------------------ -The root settings.yaml should contains 2 keys : one for the title of your website and one for the subtitle. It should looks like that:: +The root settings.yaml should contains 2 keys: one for the title of your website and one for the subtitle. It should looks like that:: title: My exploration of the outside world sub_title: it's a scary place, don't go there @@ -41,11 +41,11 @@ For example, this could be the content of `settings.yaml` in `about` folder:: You can use the `static` option to get a template closer to the one of the homepage that is better suited for a static page. You'll need to specify -"public: false" if you don't want to list this page on the homepage. On you +"public: false" if you don't want to list this page on the homepage. On case you didn't specified "public: false" you'll **need** to specify a "cover:" entry like any other gallery. -**NOTE**: except the "static: " option to disepear quite soon for a more +**NOTE**: expect the "static: " option to disappear quite soon for a more generic approach to "choose your page style". Global settings @@ -64,13 +64,15 @@ Currently a `gm` settings key allows to customize the default GraphicsMagick's b auto-orient: True strip: True resize: 50% + progressive: True -The meaning of the currently supported GraphicsMagick's settings is as follows : +The meaning of the currently supported GraphicsMagick's settings is as follows: * `quality` allows to customize the compression level of thumbnails (between 0 and 100) * `auto-orient` change the orientation of pictures so they are upright (based on corresponding EXIF tags if present) * `strip` removes all profiles and text attributes from the image (good for privacy, slightly reduce file size) * `resize` can be used to resize the fullsize version of pictures. by default, input image size is preserved + * `progressive` converts classic baseline JPEG files to progressive JPEG, and interlace PNG/GIF files (improve the page loading impression, slightly reduce file size) Any GraphicsMagick setting can be customized on a per-image basis (either `cover` or `image`, see below). @@ -121,6 +123,16 @@ To specify the theme, add the "theme" key in your "settings" key or your settings: theme: material +Light mode +~~~~~~~~~~ + +Prosopopée has a support light mode, for all gallery you need add /light on the url. +When this mode is enable Prosopopée build the gallery with light theme (no Js and pics size is 800px):: + + settings: + light_mode: true + + Licence ~~~~~~~ @@ -193,7 +205,7 @@ _______ - type: bordered-picture image: another_picture.jpg -And here is an example or a **private** gallery (notice the ``public`` keyword):: +And here is an example of a **private** gallery (notice the ``public`` keyword):: title: Gallery title sub_title: Gallery sub-title diff --git a/example/first_gallery/settings.yaml b/example/first_gallery/settings.yaml index a551c80..8f8839a 100644 --- a/example/first_gallery/settings.yaml +++ b/example/first_gallery/settings.yaml @@ -2,6 +2,7 @@ title: my first gallery sub_title: some subtitle date: 2015-12-08 cover: stuff.png +light_mode: true sections: - type: full-picture image: stuff.png diff --git a/example/first_gallery/video.mp4 b/example/first_gallery/video.mp4 old mode 100644 new mode 100755 index 95b7652..1821efb Binary files a/example/first_gallery/video.mp4 and b/example/first_gallery/video.mp4 differ diff --git a/example/second_gallery/second_level_gallery/third_level_gallery/settings.yaml b/example/second_gallery/second_level_gallery/third_level_gallery/settings.yaml index 07c801c..23849b5 100644 --- a/example/second_gallery/second_level_gallery/third_level_gallery/settings.yaml +++ b/example/second_gallery/second_level_gallery/third_level_gallery/settings.yaml @@ -2,6 +2,7 @@ title: my third level gallery sub_title: some subtitle date: 2015-12-08 cover: stuff.png +light_mode: true sections: - type: full-picture image: stuff.png diff --git a/example/settings.yaml b/example/settings.yaml index d16e29d..a891b1f 100644 --- a/example/settings.yaml +++ b/example/settings.yaml @@ -3,3 +3,4 @@ sub_title: "The subtitle" settings: gm: quality: 80 + light_mode: true diff --git a/prosopopee/prosopopee.py b/prosopopee/prosopopee.py index 5b99300..da8cee8 100644 --- a/prosopopee/prosopopee.py +++ b/prosopopee/prosopopee.py @@ -22,7 +22,8 @@ SETTINGS = { "quality": 75, "auto-orient": True, "strip": True, - "resize": None + "resize": None, + "progressive": True }, "ffmpeg": { "binary": "ffmpeg", @@ -138,10 +139,11 @@ class Image(object): "auto-orient": "-auto-orient" if options["auto-orient"] else "", "strip": "-strip" if options["strip"] else "", "quality": "-quality %s" % options["quality"] if "quality" in options else "-define jpeg:preserve-settings", - "resize": "-resize %s" % options["resize"] if options.get("resize", None) is not None else "" + "resize": "-resize %s" % options["resize"] if options.get("resize", None) is not None else "", + "progressive": "-interlace Line" if options.get("progressive", None) is True else "" } - command = "gm convert {source} {auto-orient} {strip} {quality} {resize} {target}".format(**gm_switches) + command = "gm convert '{source}' {auto-orient} {strip} {progressive} {quality} {resize} '{target}'".format(**gm_switches) warning("Generation", source) print(command) @@ -297,6 +299,10 @@ def process_directory(gallery_name, settings, parent_templates, parent_gallery_p if not os.path.exists(os.path.join("build", gallery_path)): os.makedirs(os.path.join("build", gallery_path)) + # Prepare light mode + if gallery_settings.get("light_mode",False) and not os.path.exists(os.path.join("build", gallery_path, "light")): + os.makedirs(os.path.join("build", gallery_path, "light")) + if not gallery_settings.get("public", True): build_gallery(settings, gallery_settings, gallery_path, parent_templates) else: @@ -381,6 +387,30 @@ def build_gallery(settings, gallery_settings, gallery_path, template): link=gallery_path ).encode("Utf-8")) + #Build light mode gallery + if gallery_settings.get("light_mode",False): + gallery_light_path = os.path.join(gallery_path, "light") + light_templates = get_gallery_templates("light", gallery_light_path) + + Image.base_dir = os.path.join(os.getcwd(), gallery_path) + Image.target_dir = os.path.join(os.getcwd(), "build", gallery_path) + + Video.base_dir = os.path.join(os.getcwd(), gallery_path) + Video.target_dir = os.path.join(os.getcwd(), "build", gallery_path) + + light_template_to_render = light_templates.get_template("gallery-index.html") + + index_html = open(os.path.join("build", gallery_light_path, "index.html"), "w") + + index_html.write(light_template_to_render.render( + settings=settings, + gallery=gallery_settings, + Image=Image, + Video=Video, + link=gallery_light_path + ).encode("Utf-8")) + + def build_index(settings, galleries_cover, templates, gallery_path=''): index_template = templates.get_template("index.html") diff --git a/prosopopee/themes/exposure/static/css/style-page.css b/prosopopee/themes/exposure/static/css/style-page.css index 1ef75c8..0b4d886 100644 --- a/prosopopee/themes/exposure/static/css/style-page.css +++ b/prosopopee/themes/exposure/static/css/style-page.css @@ -256,7 +256,7 @@ footer a { } -.share, .author { +.share, .author-meta { text-align: center; height: auto; position: relative; @@ -310,25 +310,30 @@ a.google { background-position: -172px 0 !important; } -.author img.circle { +.author-meta img.circle { border-radius: 50%; width: 80px; } -.author { +.author-meta { padding-bottom: 7em; } -.author-meta { +.author-info { color: #ccc; font-style: italic; font-size: 19px; } -.author h4 { +.author-info h4 { text-transform: uppercase; + text-align: center; + font-family: 'crimson', serif; + color: black; + font-style: normal; + font-weight: bold; } -.author .desc { +.author-info .desc { width: 350px; margin: auto; padding-bottom: 10px; @@ -343,9 +348,9 @@ a.google { position: absolute; top: 0; left: 0; - z-index: 2; + z-index: 0; width: 100%; - height: auto; + height: 100%; } .full-picture video { @@ -359,6 +364,7 @@ a.google { width: 77%; margin-left: 11.5%; margin-right: 11.5%; + object-fit: fill; } .bg-section { @@ -410,3 +416,30 @@ a.google { } +#slow-notice { + width:300px; + position: absolute; + top:0; + left:50%; + margin-left: -160px; + background-color: #F0DE7D; + text-align: center; + z-index: 999; + padding: 10px; + font-family: sans-serif; + font-size: 12px; +} + +#slow-notice a, +#slow-notice .dismiss { + color: #000; + text-decoration: underline; + cursor:pointer; +} + +#slow-notice .dismiss-container { + text-align:right; + padding-top:10px; + font-size: 10px; +} + diff --git a/prosopopee/themes/exposure/static/css/style.css b/prosopopee/themes/exposure/static/css/style.css index 3cd4eda..d3594fe 100644 --- a/prosopopee/themes/exposure/static/css/style.css +++ b/prosopopee/themes/exposure/static/css/style.css @@ -79,6 +79,7 @@ a { height: 100%; background-position: center center; background-size: cover; + overflow: hidden; } .gallery-title { @@ -262,4 +263,5 @@ nav ul li > a.item-menu::before { .gallery-cover img.fillWidth { height: 100%; + width: 100%; } diff --git a/prosopopee/themes/exposure/templates/gallery-index.html b/prosopopee/themes/exposure/templates/gallery-index.html index 25a614c..da5e858 100644 --- a/prosopopee/themes/exposure/templates/gallery-index.html +++ b/prosopopee/themes/exposure/templates/gallery-index.html @@ -71,6 +71,50 @@ $(function() { effect : "fadeIn" }); }); + +{% if settings.settings.light_mode %} +var slowLoad = window.setTimeout( function() { + var html_node = document.getElementsByTagName('html')[0]; + var div = document.createElement('div'); + div.setAttribute('id', 'slow-notice'); + var t1 = document.createTextNode("The website is taking a long time to load."); + var br = document.createElement('br'); + var t2 = document.createTextNode("You can switch to the "); + var a = document.createElement('a'); + a.setAttribute('href', './light'); + a.innerHTML = 'Light Weight Site'; + + var dismiss = document.createElement('span'); + dismiss.innerHTML = '[x] dismiss'; + dismiss.setAttribute('class', 'dismiss'); + dismiss.onclick = function() { + html_node.removeChild(div); + } + + var dismiss_container = document.createElement('div'); + dismiss_container.appendChild(dismiss); + dismiss_container.setAttribute('class', 'dismiss-container'); + + div.appendChild(t1); + div.appendChild(br); + div.appendChild(t2); + div.appendChild(a); + div.appendChild(dismiss_container); + + html_node.appendChild(div); +}, 1000 ); + +window.addEventListener( 'load', function() { + try { + window.clearTimeout( slowLoad ); + html_node.removeChild(div); + } catch (e){ + // that's okay. + } + +}); +{% endif %} + {% include "footer.html" %} diff --git a/prosopopee/themes/exposure/templates/sections/author.html b/prosopopee/themes/exposure/templates/sections/author.html index b321bf6..3676d4c 100644 --- a/prosopopee/themes/exposure/templates/sections/author.html +++ b/prosopopee/themes/exposure/templates/sections/author.html @@ -1,13 +1,14 @@ {% set image = Image(section.image) %} {{ image.copy() }} -