diff --git a/prosopopee/prosopopee.py b/prosopopee/prosopopee.py index 08f3fdb..8db6842 100644 --- a/prosopopee/prosopopee.py +++ b/prosopopee/prosopopee.py @@ -15,6 +15,7 @@ DEFAULTS = { "share": False, "settings": {}, "show_date": True, + "light_mode": False, } SETTINGS = { @@ -256,6 +257,7 @@ def main(): if theme != "exposure": templates_dir.append(os.path.join(os.path.split(os.path.realpath(__file__))[0], "themes", "exposure", "templates")) + templates = Environment(loader=FileSystemLoader(templates_dir)) index_template = templates.get_template("index.html") @@ -326,6 +328,35 @@ def main(): link=gallery ).encode("Utf-8")) + if settings["settings"].get("light_mode", True): + print "light mode enable" + if not os.path.exists(os.path.join("build", gallery, "light")): + os.makedirs(os.path.join("build", gallery, "light")) + + if os.path.exists(os.path.join(os.getcwd(), "build", gallery, "light", "static")): + shutil.rmtree(os.path.join(os.getcwd(), "build", gallery, "light", "static")) + + shutil.copytree(os.path.join(os.path.split(os.path.realpath(__file__))[0], "themes", "light", "static"), + os.path.join(os.getcwd(), "build", gallery, "light","static")) + + light_templates_dir = os.path.join(os.path.split(os.path.realpath(__file__))[0], "themes", "light", "templates") + light_templates = Environment(loader=FileSystemLoader(light_templates_dir)) + light_gallery_index_template = light_templates.get_template("gallery-index.html") + + light_template_to_render = light_gallery_index_template + + index_html = open(os.path.join("build", gallery, "light", "index.html"), "w") + + index_html.write(light_template_to_render.render( + settings=settings, + gallery=gallery_settings, + Image=Image, + Video=Video, + link=gallery + ).encode("Utf-8")) + + + if settings["rss"]: feed_xml = open(os.path.join("build", "feed.xml"), "w") diff --git a/prosopopee/themes/exposure/static/css/style-page.css b/prosopopee/themes/exposure/static/css/style-page.css index 0c2888a..1eeb26b 100644 --- a/prosopopee/themes/exposure/static/css/style-page.css +++ b/prosopopee/themes/exposure/static/css/style-page.css @@ -415,3 +415,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/templates/gallery-index.html b/prosopopee/themes/exposure/templates/gallery-index.html index 25a614c..36f502e 100644 --- a/prosopopee/themes/exposure/templates/gallery-index.html +++ b/prosopopee/themes/exposure/templates/gallery-index.html @@ -71,6 +71,48 @@ $(function() { effect : "fadeIn" }); }); + +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); +}, 10 ); + +window.addEventListener( 'load', function() { + try { + window.clearTimeout( slowLoad ); + html_node.removeChild(div); + } catch (e){ + // that's okay. + } + +}); + {% include "footer.html" %} diff --git a/prosopopee/themes/light/templates/gallery-index.html b/prosopopee/themes/light/templates/gallery-index.html index 1c72316..582cb79 100644 --- a/prosopopee/themes/light/templates/gallery-index.html +++ b/prosopopee/themes/light/templates/gallery-index.html @@ -3,8 +3,8 @@
- - + + @@ -23,8 +23,8 @@