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 * Compatibility python 2 and 3
* Possibility to add custom css and js http://prosopopee.readthedocs.io/en/latest/theming.html * 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) 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:: 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: menu:
- about: "About" - about: "About"
- first_gallery: "My first gallery" - 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 :: Currently a `gm` settings key allows to customize the default GraphicsMagick's behavior. It looks like ::
title: Gallery
settings: settings:
gm: gm:
quality: 75 quality: 75
@ -81,16 +83,17 @@ Video convertor
Prosopopée can use ffmpeg or libav and if you want you can customize the settings:: Prosopopée can use ffmpeg or libav and if you want you can customize the settings::
title: Gallery
settings: settings:
ffmpeg: ffmpeg:
binary: "ffmpeg", binary: "ffmpeg"
loglevel: "error", loglevel: "error"
format: "webm", format: "webm"
resolution: "1280x720", resolution: "1280x720"
vbitrate: "3900k", vbitrate: "3900k"
abitrate: "100k", abitrate: "100k"
audio: "libvorbis", audio: "libvorbis"
video: "libvpx", video: "libvpx"
other: "-qmin 10 -qmax 42 -maxrate 500k -bufsize 1500k" other: "-qmin 10 -qmax 42 -maxrate 500k -bufsize 1500k"
The meaning of the currently supported FFMEG or LIBAV's settings is as follows : 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 * `abitrate` Set audio bitrate
* `audio` Set the audio codec * `audio` Set the audio codec
* `video` Set the video codec * `video` Set the video codec
* `extension` Set the extension of output file
* `other` Set different options if you need more * `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 Light Mode
~~~~~~~~~~ ~~~~~~~~~~
For enabled the light mode:: For enabled the light mode::
title: Gallery
settings: settings:
light_mode: true 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 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:: you need add key in **root** settings.yaml. For example::
title: Gallery
licence: licence:
name: WTFPL name: WTFPL
url: "http://www.wtfpl.net/txt/copying/" 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: 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+:: By defaut you can share on facebook, twitter, pinterest, google+::
title: Gallery
share: true share: true
url: "http://prosopopee.com" url: "http://prosopopee.com"
@ -164,6 +183,7 @@ RSS
For activate the RSS you need add this key in **root** settings.yaml:: For activate the RSS you need add this key in **root** settings.yaml::
title: Gallery
rss: true rss: true
url: "http://prosopopee.com" 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:: For activate the Open Graph Meta you need add this key in **root** settings.yaml::
title: Sur les chemins
settings:
og: true og: true
Optionnal: You need use description and lang key in settings gallery. 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:: If you wanna configure the deployement of your website by rsync::
title: Gallery
settings: settings:
deploy: deploy:
ssh: true (optional need for ssh) ssh: true (optional need for ssh)
username: beudbeud (optional need for ssh) username: username (optional need for ssh)
hostname: beudibox.fr (optional need for ssh) hostname: server.com (optional need for ssh)
dest: /var/www/surleschemins/build/ dest: /var/www/website/build/
others: --delete-afte (optional) 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 Gallery settings.yaml
--------------------- ---------------------

View File

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