add external link in menu and more easier config
This commit is contained in:
parent
4bb171b91a
commit
55def9c4a8
32
README.md
32
README.md
@ -63,39 +63,25 @@ It is possible to add a menu to your homepage that links to static pages. To do
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
menu:
|
menu:
|
||||||
name: "About"
|
- about: "About"
|
||||||
type: "page"
|
- first_gallery: "My first gallery"
|
||||||
url: "about"
|
- http://twitter.com: "Twitter"
|
||||||
- name: "My first gallery"
|
|
||||||
type: "folder"
|
|
||||||
url: "first_gallery"
|
|
||||||
- name: "Twitter"
|
|
||||||
type: "external"
|
|
||||||
url: "http://twitter.com"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You can use 3 type of item in the menu:
|
For example, this could be the content of `settings.yaml` in `about` folder:
|
||||||
|
|
||||||
* 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
|
```yaml
|
||||||
title: "About"
|
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:
|
||||||
|
@ -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 »
|
|
||||||
|
|
6
example/about/settings.yaml
Normal file
6
example/about/settings.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
title: "About"
|
||||||
|
static: true
|
||||||
|
public: false
|
||||||
|
sections:
|
||||||
|
- type: text
|
||||||
|
text: Some text, HTML <b>is allowed</b>.
|
@ -149,10 +149,10 @@ 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")))
|
||||||
|
|
||||||
|
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(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"])
|
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))
|
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"]
|
||||||
@ -177,16 +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)
|
||||||
|
|
||||||
|
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"))
|
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"):
|
|
||||||
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.base_dir = os.getcwd()
|
||||||
Image.target_dir = os.path.join(os.getcwd(), "build")
|
Image.target_dir = os.path.join(os.getcwd(), "build")
|
||||||
|
|
||||||
|
@ -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>
|
||||||
|
@ -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 %}
|
||||||
|
@ -2,17 +2,16 @@
|
|||||||
<div class="nav-wrapper">
|
<div class="nav-wrapper">
|
||||||
<ul>
|
<ul>
|
||||||
{%- for line in settings.menu -%}
|
{%- for line in settings.menu -%}
|
||||||
{%- if line.type == "folder" -%}
|
{% set file_name, menu_name = line.items()[0] %}
|
||||||
{%- set file_name = line.url+"/" -%}
|
{% if file_name.startswith('http') %}
|
||||||
{%- elif line.type == "external" -%}
|
{% set file_name = file_name %}
|
||||||
{%- set file_name = line.url -%}
|
{% elif gallery %}
|
||||||
{%- else -%}
|
{% set file_name = "../"+file_name %}
|
||||||
{%- set file_name = line.url+".html" -%}
|
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- if loop.first -%}
|
{%- if loop.first -%}
|
||||||
<li><a href={{ file_name }} class=first-item-menu>{{ line.name }}</a></li>
|
<li><a href={{ file_name }} class=first-item-menu>{{ menu_name }}</a></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li><a href={{ file_name }} class=item-menu>{{ line.name }}</a></li>
|
<li><a href={{ file_name }} class=item-menu>{{ menu_name }}</a></li>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -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 %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user