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 @@