Merge remote-tracking branch 'abeudin/master'

This commit is contained in:
Laurent Peuch 2016-02-16 08:38:00 +01:00
commit c7606f5eed
11 changed files with 96 additions and 56 deletions

View File

@ -63,30 +63,31 @@ It is possible to add a menu to your homepage that links to static pages. To do
```yaml ```yaml
menu: menu:
- about: "About Me" - about: "About"
- contact: "Contact" - first_gallery: "My first gallery"
- http://twitter.com: "Twitter"
``` ```
The first part (`about` and `contact`) here are the name of the files (without For example, this could be the content of `settings.yaml` in `about` folder:
the `.yaml`) and the second part are the menu title that will be displayed in
the templates. So, here, you'll need to create a ``about.yaml`` and a
``contact.yaml`` files in the root directory. Their content are similar to
galleries (see [bellow](#gallery-settingsyaml)).
For example, this could be the content of `contact.yaml`:
```yaml ```yaml
title: "Contact" title: "About"
static: true
public: false
sections: sections:
- type: text - type: text
text: Some text, HTML <b>is allowed</b>. text: Some text, HTML <b>is allowed</b>.
``` ```
The `static` option is use it for don't need to give date and cover at the static page.
If you don't want see the page in front page you can use the `public` option.
### Gallery settings.yaml ### Gallery settings.yaml
This settings.yaml will describe: This settings.yaml will describe:
* the title, subtitle and cover picture of your gallery that will be used on the homepage * the title, subtitle and cover picture of your gallery that will be used on the homepage
* the tags is optional
* if your gallery is public (if not, it will still be built but won't appear on the homepage) * if your gallery is public (if not, it will still be built but won't appear on the homepage)
* the date of your gallery: this will be used on the homepage since **galleries are sorted anti chronologically** on it * the date of your gallery: this will be used on the homepage since **galleries are sorted anti chronologically** on it
* the list of sections that will contains your gallery. A section will represent either one picture, a group of pictures or text. The different kind of sections will be explained in the next README section. * the list of sections that will contains your gallery. A section will represent either one picture, a group of pictures or text. The different kind of sections will be explained in the next README section.
@ -98,6 +99,9 @@ title: Gallery title
sub_title: Gallery sub-title sub_title: Gallery sub-title
date: 2016-01-15 date: 2016-01-15
cover: my_cover_picture.jpg cover: my_cover_picture.jpg
tags:
- #yolo
- #travel
sections: sections:
- type: full-picture - type: full-picture
image: big_picture.jpg image: big_picture.jpg

View File

@ -1,5 +0,0 @@
title: "Menu 1"
sections:
- type: text
text: « voici plein de blabla à rajouter et <b>ceci est du gras</b> et encore plein plein plein plein de text car je veux voir comment ça va wrapper car c'est important et il faut pas que j'oublie de mettre des margins en % sinon ça va pas le faire alala là ça devrait aller »

View File

@ -0,0 +1,6 @@
title: "About"
static: true
public: false
sections:
- type: text
text: Some text, HTML <b>is allowed</b>.

View File

@ -1,5 +0,0 @@
title: "Menu 2"
sections:
- type: text
text: « voici plein de blabla à rajouter et <b>ceci est du gras</b> et encore plein plein plein plein de text car je veux voir comment ça va wrapper car c'est important et il faut pas que j'oublie de mettre des margins en % sinon ça va pas le faire alala là ça devrait aller »

View File

@ -1,4 +1,5 @@
title: "Example gallery" title: "Example gallery"
menu: menu:
- about: "Menu 1" - about: "About"
- contact: "Menu 2" - first_gallery: "My first gallery"
- http://twitter.com: "Twitter"

View File

@ -149,15 +149,16 @@ def main():
error(isinstance(gallery_settings, dict), "Your %s should be a dict" % (os.path.join(gallery, "settings.yaml"))) error(isinstance(gallery_settings, dict), "Your %s should be a dict" % (os.path.join(gallery, "settings.yaml")))
error(gallery_settings.get("title"), "You should specify a title in %s" % (os.path.join(gallery, "settings.yaml"))) error(gallery_settings.get("title"), "You should specify a title in %s" % (os.path.join(gallery, "settings.yaml")))
error(gallery_settings.get("cover"), "You should specify a path to a cover picture in %s" % (os.path.join(gallery, "settings.yaml")))
cover_image_path = os.path.join(gallery, gallery_settings["cover"]) if gallery_settings.get("public", True):
error(gallery_settings.get("cover"), "You should specify a path to a cover picture in %s" % (os.path.join(gallery, "settings.yaml")))
error(os.path.exists(cover_image_path), "File for %s cover image doesn't exists at %s" % (gallery, cover_image_path)) cover_image_path = os.path.join(gallery, gallery_settings["cover"])
error(os.path.exists(cover_image_path), "File for %s cover image doesn't exists at %s" % (gallery, cover_image_path))
gallery_title = gallery_settings["title"] gallery_title = gallery_settings["title"]
gallery_sub_title = gallery_settings.get("sub_title", "") gallery_sub_title = gallery_settings.get("sub_title", "")
gallery_date = gallery_settings["date"] if "date" in gallery_settings else "" gallery_date = gallery_settings["date"] if "date" in gallery_settings else ""
gallery_tags = gallery_settings["tags"] if "tags" in gallery_settings else ""
if gallery_settings.get("public", True): if gallery_settings.get("public", True):
front_page_galleries_cover.append({ front_page_galleries_cover.append({
@ -165,6 +166,7 @@ def main():
"link": gallery, "link": gallery,
"sub_title": gallery_sub_title, "sub_title": gallery_sub_title,
"date": gallery_date, "date": gallery_date,
"tags": gallery_tags,
"cover": cover_image_path, "cover": cover_image_path,
}) })
@ -175,15 +177,13 @@ def main():
Image.base_dir = os.path.join(os.getcwd(), gallery) Image.base_dir = os.path.join(os.getcwd(), gallery)
Image.target_dir = os.path.join(os.getcwd(), "build", gallery) Image.target_dir = os.path.join(os.getcwd(), "build", gallery)
open(os.path.join("build", gallery, "index.html"), "w").write(gallery_index_template.render(settings=settings, gallery=gallery_settings, Image=Image).encode("Utf-8")) if gallery_settings.get("static") == True:
open(os.path.join("build", gallery, "index.html"), "w").write(page_template.render(settings=settings, gallery=gallery_settings, Image=Image).encode("Utf-8"))
else:
open(os.path.join("build", gallery, "index.html"), "w").write(gallery_index_template.render(settings=settings, gallery=gallery_settings, Image=Image).encode("Utf-8"))
front_page_galleries_cover = reversed(sorted(front_page_galleries_cover, key=lambda x: x["date"])) front_page_galleries_cover = reversed(sorted(front_page_galleries_cover, key=lambda x: x["date"]))
for item in settings.get("menu", []):
file_name, menu_name = item.items()[0]
error(os.path.exists(os.path.join(os.getcwd(), file_name + ".yaml")), "I can't find a " + file_name + ".yaml in the current working directory as specified by your menu description in your root settings.yaml")
open(os.path.join("build", file_name + ".html"), "w").write(page_template.render(settings=settings, pages=yaml.safe_load(open(file_name + ".yaml", "r")), galleries=front_page_galleries_cover).encode("Utf-8"))
Image.base_dir = os.getcwd() Image.base_dir = os.getcwd()
Image.target_dir = os.path.join(os.getcwd(), "build") Image.target_dir = os.path.join(os.getcwd(), "build")
@ -192,3 +192,4 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -90,7 +90,7 @@ a {
text-align: center; text-align: center;
z-index: 3; z-index: 3;
background: transparent linear-gradient(rgba(255, 255, 255, 0) 0%, transparent 1%, rgba(0, 0, 0, 0.07) 26%, rgba(0, 0, 0, 0.5) 71%, rgba(0, 0, 0, 0.7) 100%) repeat scroll 0% 0%; background: transparent linear-gradient(rgba(255, 255, 255, 0) 0%, transparent 1%, rgba(0, 0, 0, 0.07) 26%, rgba(0, 0, 0, 0.5) 71%, rgba(0, 0, 0, 0.7) 100%) repeat scroll 0% 0%;
padding: 20% 0 0; padding: 20% 0 10px 0;
} }
.gallery-header { .gallery-header {
@ -145,7 +145,6 @@ a {
} }
.gallery-datetime { .gallery-datetime {
margin-bottom: 1em;
font-family: 'crimson', serif; font-family: 'crimson', serif;
text-transform: uppercase; text-transform: uppercase;
letter-spacing: 2px; letter-spacing: 2px;
@ -233,3 +232,23 @@ nav ul li > a.item-menu::before {
line-height: 1; line-height: 1;
color: #ebebeb; color: #ebebeb;
} }
.gallery-tag {
font-size: 13px;
text-transform: uppercase;
font-style: normal;
display: inline;
font-family: "adobe-garamond-pro", serif;
}
.gallery-tag span {
font-size: 12px;
border-bottom: solid 1px rgba(255,255,255,0.2);
display: inline-block;
margin: 0 0 0 3px;
font-weight: bold;
font-family: "europa", sans-serif;
text-transform: uppercase;
letter-spacing: 3px;
font-style: normal;
}

View File

@ -2,8 +2,6 @@
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="static/css/fonts.css" media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="static/css/style.css" media="screen,projection"/>
{% block css %} {% block css %}
{% endblock %} {% endblock %}
@ -15,7 +13,8 @@
<body> <body>
<div class="gallery-header"> <div class="gallery-header">
<img id="logo" src="static/img/logo.svg" /> {% block logo %}
{% endblock %}
<h1>{{ settings.title }}</h1> <h1>{{ settings.title }}</h1>
{% if settings.sub_title -%}<h4>{{ settings.sub_title }}</h4>{% endif -%} {% if settings.sub_title -%}<h4>{{ settings.sub_title }}</h4>{% endif -%}
<hr> <hr>

View File

@ -1,5 +1,14 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block css %}
<link type="text/css" rel="stylesheet" href="static/css/fonts.css" media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="static/css/style.css" media="screen,projection"/>
{% endblock %}
{% block logo %}
<img id="logo" src="static/img/logo.svg" />
{% endblock %}
{% block content %} {% block content %}
<div class="galleries-grid"> <div class="galleries-grid">
{% for galleries_line in galleries|reverse|batch(3)|reverse %} {% for galleries_line in galleries|reverse|batch(3)|reverse %}
@ -11,6 +20,7 @@
<h2>{{ gallery.title }}</h2> <h2>{{ gallery.title }}</h2>
{% if gallery.sub_title %}<h3>{{ gallery.sub_title }}</h3>{% endif %} {% if gallery.sub_title %}<h3>{{ gallery.sub_title }}</h3>{% endif %}
{% if gallery.date %}<div class="gallery-datetime">{{ gallery.date.strftime("%d %B %Y") }}</div>{% endif %} {% if gallery.date %}<div class="gallery-datetime">{{ gallery.date.strftime("%d %B %Y") }}</div>{% endif %}
{% if gallery.tags %}<div class="gallery-tag">IN {% for tag in gallery.tags -%} <span>{{ tag }}</span> {% endfor -%}</div>{% endif %}
</div> </div>
</a> </a>
{% set cover = Image(gallery.cover) %} {% set cover = Image(gallery.cover) %}
@ -21,6 +31,5 @@
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
<p style="visibility: hidden">.</p> <p style="visibility: hidden">.</p>
{% endblock %} {% endblock %}

View File

@ -1,14 +1,19 @@
<nav> <nav>
<div class="nav-wrapper"> <div class="nav-wrapper">
<ul> <ul>
{% for line in settings.menu -%} {%- for line in settings.menu -%}
{% set file_name, menu_name = line.items()[0] %} {% set file_name, menu_name = line.items()[0] %}
{% if loop.first %} {% if file_name.startswith('http') %}
<li><a href={{ file_name }}.html class=first-item-menu>{{ menu_name }}</a></li> {% set file_name = file_name %}
{% elif gallery %}
{% set file_name = "../"+file_name %}
{%- endif -%}
{%- if loop.first -%}
<li><a href={{ file_name }} class=first-item-menu>{{ menu_name }}</a></li>
{% else %} {% else %}
<li><a href={{ file_name }}.html class=item-menu>{{ menu_name }}</a></li> <li><a href={{ file_name }} class=item-menu>{{ menu_name }}</a></li>
{% endif %} {%- endif -%}
{% endfor -%} {%- endfor -%}
</ul> </ul>
</div> </div>
</nav> </nav>

View File

@ -1,26 +1,32 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block css %} {% block css %}
<link type="text/css" rel="stylesheet" href="static/css/style-page.css" media="screen,projection"/> <link type="text/css" rel="stylesheet" href="../static/css/fonts.css" media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="../static/css/style.css" media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="../static/css/style-page.css" media="screen,projection"/>
{% endblock %}
{% block logo %}
<img id="logo" src="../static/img/logo.svg" />
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<section class="text"> <section class="text">
<h2>{{ pages.title }}</h2> <h2>{{ gallery.title }}</h2>
</section> </section>
{% for section in pages.sections %} {% for section in gallery.sections %}
{% include "sections/" + section.type + ".html" %} {% include "sections/" + section.type + ".html" %}
{% endfor %} {% endfor %}
<div class="back-to-home"> <div class="back-to-home">
<hr> <hr>
<a href="./index.html"> <a href="../index.html">
<div id="logo" src="static/img/logo.svg"/> <div id="logo" src="../static/img/logo.svg"/>
HOME HOME
</div> </div>
</a> </a>
</div> </div>
<script type="text/javascript" src="static/js/jquery-2.1.4.min.js" charset="utf-8"></script> <script type="text/javascript" src="../static/js/jquery-2.1.4.min.js" charset="utf-8"></script>
{% endblock %} {% endblock %}