From 9f51abaeaf466bde7f7035e593193937f4408626 Mon Sep 17 00:00:00 2001 From: Adrien Beudin Date: Thu, 11 Feb 2016 22:54:27 +0100 Subject: [PATCH 1/6] Add tags and new features for menu --- prosopopee/prosopopee.py | 12 ++++++++---- prosopopee/static/css/style.css | 23 +++++++++++++++++++++-- prosopopee/templates/index.html | 2 +- prosopopee/templates/menu.html | 20 +++++++++++++------- 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/prosopopee/prosopopee.py b/prosopopee/prosopopee.py index 0c0f0e8..6b3c223 100644 --- a/prosopopee/prosopopee.py +++ b/prosopopee/prosopopee.py @@ -158,6 +158,7 @@ def main(): gallery_title = gallery_settings["title"] gallery_sub_title = gallery_settings.get("sub_title", "") gallery_date = gallery_settings["date"] if "date" in gallery_settings else "" + gallery_tags = gallery_settings["tags"] if "date" in gallery_settings else "" if gallery_settings.get("public", True): front_page_galleries_cover.append({ @@ -165,6 +166,7 @@ def main(): "link": gallery, "sub_title": gallery_sub_title, "date": gallery_date, + "tags": gallery_tags, "cover": cover_image_path, }) @@ -179,10 +181,11 @@ def main(): 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")) + for item in settings.get("menu"): + if item.get("type") == "page": + file_name = item.get("url") + 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.target_dir = os.path.join(os.getcwd(), "build") @@ -192,3 +195,4 @@ def main(): if __name__ == '__main__': main() + diff --git a/prosopopee/static/css/style.css b/prosopopee/static/css/style.css index fc5ca08..d3e2a59 100644 --- a/prosopopee/static/css/style.css +++ b/prosopopee/static/css/style.css @@ -90,7 +90,7 @@ a { text-align: center; 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%; - padding: 20% 0 0; + padding: 20% 0 10px 0; } .gallery-header { @@ -145,7 +145,6 @@ a { } .gallery-datetime { - margin-bottom: 1em; font-family: 'crimson', serif; text-transform: uppercase; letter-spacing: 2px; @@ -233,3 +232,23 @@ nav ul li > a.item-menu::before { line-height: 1; 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; +} diff --git a/prosopopee/templates/index.html b/prosopopee/templates/index.html index a94247e..03b880f 100644 --- a/prosopopee/templates/index.html +++ b/prosopopee/templates/index.html @@ -11,6 +11,7 @@

{{ gallery.title }}

{% if gallery.sub_title %}

{{ gallery.sub_title }}

{% endif %} {% if gallery.date %}{% endif %} + {% if gallery.tags %}{% endif %} {% set cover = Image(gallery.cover) %} @@ -21,6 +22,5 @@ {% endfor %} -

.

{% endblock %} diff --git a/prosopopee/templates/menu.html b/prosopopee/templates/menu.html index 90f2fb6..16b8ef4 100644 --- a/prosopopee/templates/menu.html +++ b/prosopopee/templates/menu.html @@ -1,14 +1,20 @@ From 5aa2f4f96b1bc31a71731353c387c2754fd547fb Mon Sep 17 00:00:00 2001 From: Adrien Beudin Date: Thu, 11 Feb 2016 23:14:22 +0100 Subject: [PATCH 2/6] update doc and exemple --- README.md | 34 ++++++++++++++++++++++++---------- example/contact.yaml | 5 ----- example/settings-menu.yaml | 13 ++++++++++--- 3 files changed, 34 insertions(+), 18 deletions(-) delete mode 100644 example/contact.yaml diff --git a/README.md b/README.md index 7ceafdf..6f92d50 100644 --- a/README.md +++ b/README.md @@ -62,21 +62,35 @@ sub_title: it's a scary place, don't go there It is possible to add a menu to your homepage that links to static pages. To do so, add a `menu` key to your `settings.yaml`, for example: ```yaml -menu: - - about: "About Me" - - contact: "Contact" +menu: + name: "About" + type: "page" + url: "about" + - name: "My first gallery" + type: "folder" + url: "first_gallery" + - name: "Twitter" + type: "external" + url: "http://twitter.com" ``` -The first part (`about` and `contact`) here are the name of the files (without -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)). +You can use 3 type of item in the menu: -For example, this could be the content of `contact.yaml`: +* page +* folder +* external + +For page, the url is the files (without the `.yaml`) +For folder, the url is the name of the folder (like first_gallery in exemple) +And for the external, the url is the full url of the website. You can +use it too for make home in the menu. +So, here, you'll need to create a ``about.yaml`` files in the root directory. +Their content are similar to galleries (see [bellow](#gallery-settingsyaml)). + +For example, this could be the content of `about.yaml`: ```yaml -title: "Contact" +title: "About" sections: - type: text text: Some text, HTML is allowed. diff --git a/example/contact.yaml b/example/contact.yaml deleted file mode 100644 index edcea46..0000000 --- a/example/contact.yaml +++ /dev/null @@ -1,5 +0,0 @@ -title: "Menu 2" -sections: - - type: text - text: « voici plein de blabla à rajouter et ceci est du gras 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 » - diff --git a/example/settings-menu.yaml b/example/settings-menu.yaml index 745ebf0..6bb823c 100644 --- a/example/settings-menu.yaml +++ b/example/settings-menu.yaml @@ -1,4 +1,11 @@ title: "Example gallery" -menu: - - about: "Menu 1" - - contact: "Menu 2" +menu: + - name: "About" + type: "page" + url: "about" + - name: "My first gallery" + type: "folder" + url: "first_gallery" + - name: "Twitter" + type: "external" + url: "http://twitter.com" From 419ce00c0e4d92f8e332f03b65b65dacbd0d8000 Mon Sep 17 00:00:00 2001 From: Adrien Beudin Date: Thu, 11 Feb 2016 23:19:24 +0100 Subject: [PATCH 3/6] fix tags --- prosopopee/prosopopee.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prosopopee/prosopopee.py b/prosopopee/prosopopee.py index 6b3c223..84dd0ba 100644 --- a/prosopopee/prosopopee.py +++ b/prosopopee/prosopopee.py @@ -158,7 +158,7 @@ def main(): gallery_title = gallery_settings["title"] gallery_sub_title = gallery_settings.get("sub_title", "") gallery_date = gallery_settings["date"] if "date" in gallery_settings else "" - gallery_tags = gallery_settings["tags"] if "date" in gallery_settings else "" + gallery_tags = gallery_settings["tags"] if "tags" in gallery_settings else "" if gallery_settings.get("public", True): front_page_galleries_cover.append({ From 4bb171b91a16f2ca9a40af326bb531619fdc34dc Mon Sep 17 00:00:00 2001 From: Adrien Beudin Date: Thu, 11 Feb 2016 23:26:34 +0100 Subject: [PATCH 4/6] add tags in README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 6f92d50..e675733 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ sections: This settings.yaml will describe: * 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) * 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. @@ -112,6 +113,9 @@ title: Gallery title sub_title: Gallery sub-title date: 2016-01-15 cover: my_cover_picture.jpg +tags: + - #yolo + - #travel sections: - type: full-picture image: big_picture.jpg From 55def9c4a86382c7fe49e54f9bdd7e0fa455a728 Mon Sep 17 00:00:00 2001 From: Adrien Beudin Date: Sat, 13 Feb 2016 11:21:51 +0100 Subject: [PATCH 5/6] add external link in menu and more easier config --- README.md | 34 ++++++++++----------------------- example/about.yaml | 5 ----- example/about/settings.yaml | 6 ++++++ prosopopee/prosopopee.py | 23 ++++++++++------------ prosopopee/templates/base.html | 5 ++--- prosopopee/templates/index.html | 9 +++++++++ prosopopee/templates/menu.html | 17 ++++++++--------- prosopopee/templates/page.html | 18 +++++++++++------ 8 files changed, 57 insertions(+), 60 deletions(-) delete mode 100644 example/about.yaml create mode 100644 example/about/settings.yaml diff --git a/README.md b/README.md index e675733..b2f6fb9 100644 --- a/README.md +++ b/README.md @@ -58,44 +58,30 @@ sub_title: it's a scary place, don't go there ``` #### Menu - + It is possible to add a menu to your homepage that links to static pages. To do so, add a `menu` key to your `settings.yaml`, for example: ```yaml menu: - name: "About" - type: "page" - url: "about" - - name: "My first gallery" - type: "folder" - url: "first_gallery" - - name: "Twitter" - type: "external" - url: "http://twitter.com" + - about: "About" + - first_gallery: "My first gallery" + - http://twitter.com: "Twitter" ``` -You can use 3 type of item in the menu: - -* page -* folder -* external - -For page, the url is the files (without the `.yaml`) -For folder, the url is the name of the folder (like first_gallery in exemple) -And for the external, the url is the full url of the website. You can -use it too for make home in the menu. -So, here, you'll need to create a ``about.yaml`` files in the root directory. -Their content are similar to galleries (see [bellow](#gallery-settingsyaml)). - -For example, this could be the content of `about.yaml`: +For example, this could be the content of `settings.yaml` in `about` folder: ```yaml title: "About" +static: true +public: false sections: - type: text text: Some text, HTML is allowed. ``` +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 This settings.yaml will describe: diff --git a/example/about.yaml b/example/about.yaml deleted file mode 100644 index e3d98fe..0000000 --- a/example/about.yaml +++ /dev/null @@ -1,5 +0,0 @@ -title: "Menu 1" -sections: - - type: text - text: « voici plein de blabla à rajouter et ceci est du gras 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 » - diff --git a/example/about/settings.yaml b/example/about/settings.yaml new file mode 100644 index 0000000..e32ce5c --- /dev/null +++ b/example/about/settings.yaml @@ -0,0 +1,6 @@ +title: "About" +static: true +public: false +sections: + - type: text + text: Some text, HTML is allowed. diff --git a/prosopopee/prosopopee.py b/prosopopee/prosopopee.py index 84dd0ba..3d9b8c2 100644 --- a/prosopopee/prosopopee.py +++ b/prosopopee/prosopopee.py @@ -149,11 +149,11 @@ def main(): 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("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"]) - - error(os.path.exists(cover_image_path), "File for %s cover image doesn't exists at %s" % (gallery, cover_image_path)) + + 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"))) + 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_sub_title = gallery_settings.get("sub_title", "") @@ -176,17 +176,14 @@ def main(): # this should probably be a factory Image.base_dir = os.path.join(os.getcwd(), 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"])) - for item in settings.get("menu"): - if item.get("type") == "page": - file_name = item.get("url") - 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.target_dir = os.path.join(os.getcwd(), "build") diff --git a/prosopopee/templates/base.html b/prosopopee/templates/base.html index 06cef16..a62bd68 100644 --- a/prosopopee/templates/base.html +++ b/prosopopee/templates/base.html @@ -2,8 +2,6 @@ - - {% block css %} {% endblock %} @@ -15,7 +13,8 @@