update docs and fix reverse

This commit is contained in:
Adrien Beudin 2017-07-18 13:43:27 +02:00
parent 06e9216972
commit 92b31cda86
3 changed files with 87 additions and 50 deletions

View File

@ -5,6 +5,7 @@ Changelog
* Compatibility python 2 and 3
* Possibility to add custom css and js http://prosopopee.readthedocs.io/en/latest/theming.html
* Add reverse opion by titoko https://prosopopee.readthedocs.io/en/latest/configuration.html#reverse
0.5 (2017-06-04)

View File

@ -25,6 +25,7 @@ ____
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::
title: "About"
menu:
- about: "About"
- first_gallery: "My first gallery"
@ -58,6 +59,7 @@ GM
Currently a `gm` settings key allows to customize the default GraphicsMagick's behavior. It looks like ::
title: Gallery
settings:
gm:
quality: 75
@ -81,16 +83,17 @@ Video convertor
Prosopopée can use ffmpeg or libav and if you want you can customize the settings::
title: Gallery
settings:
ffmpeg:
binary: "ffmpeg",
loglevel: "error",
format: "webm",
resolution: "1280x720",
vbitrate: "3900k",
abitrate: "100k",
audio: "libvorbis",
video: "libvpx",
binary: "ffmpeg"
loglevel: "error"
format: "webm"
resolution: "1280x720"
vbitrate: "3900k"
abitrate: "100k"
audio: "libvorbis"
video: "libvpx"
other: "-qmin 10 -qmax 42 -maxrate 500k -bufsize 1500k"
The meaning of the currently supported FFMEG or LIBAV's settings is as follows :
@ -103,14 +106,28 @@ The meaning of the currently supported FFMEG or LIBAV's settings is as follows :
* `abitrate` Set audio bitrate
* `audio` Set the audio codec
* `video` Set the video codec
* `extension` Set the extension of output file
* `other` Set different options if you need more
example for MP4::
title: Gallery
settings:
ffmpeg:
binary: "ffmpeg"
format: "mp4"
audio: "acc"
video: "libx264"
extension: mp4
Light Mode
~~~~~~~~~~
For enabled the light mode::
title: Gallery
settings:
light_mode: true
@ -146,6 +163,7 @@ Licence
By default Prosopopée use CC-BY-SA for all the content, if you want use a another licence
you need add key in **root** settings.yaml. For example::
title: Gallery
licence:
name: WTFPL
url: "http://www.wtfpl.net/txt/copying/"
@ -156,6 +174,7 @@ Share
If you want enable the share content on social network, add key in **root** settings.yaml. For example:
By defaut you can share on facebook, twitter, pinterest, google+::
title: Gallery
share: true
url: "http://prosopopee.com"
@ -164,6 +183,7 @@ RSS
For activate the RSS you need add this key in **root** settings.yaml::
title: Gallery
rss: true
url: "http://prosopopee.com"
@ -173,6 +193,8 @@ Open Graph Meta
For activate the Open Graph Meta you need add this key in **root** settings.yaml::
title: Sur les chemins
settings:
og: true
Optionnal: You need use description and lang key in settings gallery.
@ -184,14 +206,28 @@ Deployment
If you wanna configure the deployement of your website by rsync::
title: Gallery
settings:
deploy:
ssh: true (optional need for ssh)
username: beudbeud (optional need for ssh)
hostname: beudibox.fr (optional need for ssh)
dest: /var/www/surleschemins/build/
username: username (optional need for ssh)
hostname: server.com (optional need for ssh)
dest: /var/www/website/build/
others: --delete-afte (optional)
Reverse
~~~~~~~
Normally Prosopopee build the gallery index in Anti-chronological, if you wanna reverse it::
settings:
reverse: true
Is option can be use too in gallery settings if you use multi level gallery::
title: Multi level gallery
reverse: true
Gallery settings.yaml
---------------------

View File

@ -267,6 +267,8 @@ class Image(object):
def __repr__(self):
return self.name
class TCPServerV4(socketserver.TCPServer):
allow_reuse_address = True
def get_settings():
error(Path("settings.yaml").exists(), "I can't find a "
@ -512,11 +514,11 @@ def build_gallery(settings, gallery_settings, gallery_path, template):
def build_index(settings, galleries_cover, templates, gallery_path='', sub_index=False, gallery_settings={}):
index_template = templates.get_template("index.html")
reverse = gallery_settings.get('reverse', settings.get('reverse', True))
reverse = gallery_settings.get('reverse', settings["settings"].get('reverse', False))
if reverse:
galleries_cover = reversed(sorted([x for x in galleries_cover if x != {}], key=lambda x: x["date"]))
else:
galleries_cover = sorted([x for x in galleries_cover if x != {}], key=lambda x: x["date"])
else:
galleries_cover = reversed(sorted([x for x in galleries_cover if x != {}], key=lambda x: x["date"]))
# this should probably be a factory
Image.base_dir = Path(".").joinpath(gallery_path)
@ -537,7 +539,7 @@ def build_index(settings, galleries_cover, templates, gallery_path='', sub_index
def main():
arguments = docopt(__doc__, version='0.5')
arguments = docopt(__doc__, version='0.6')
settings = get_settings()
front_page_galleries_cover = []
@ -553,15 +555,13 @@ def main():
os.chdir('build')
handler = http.server.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(("", 9000), handler)
httpd = TCPServerV4(("", 9000), handler)
print('Start server on http://localhost:9000')
# gracefully handle interrupt here
try:
httpd.serve_forever()
except (KeyboardInterrupt, SystemExit):
print('shutdown')
httpd.socket.close()
print('\nShutdown server')
httpd.shutdown()
raise
if arguments['deploy']: