Giter Site home page Giter Site logo

pelican-gallery's Introduction

#Pelican-Gallery: A Gallery plugin for the Pelican static site generator

This plugin creates a gallery attribute on content (article.gallery) you want to create. You will define named presets which can be referenced in your templates. It will attempt to be smart about regenerating photos once they exist.

  • Resizes images respective of aspect ratio
  • Allows for multiple presets e.g. -> article.gallery.photos[0]['thumb']

Installation

Add gallery.py to your plugins folder. You may need to set this up if you haven't already:

#Pelican Conf
PLUGIN_PATH = "my_plugins"
PLUGINS = [my_plugins.gallery"]

see: http://docs.getpelican.com/en/latest/plugins.html for more details on plugins in Pelican

This plugin requires the PIL library to function. Install Python PIL library in your virtual environment. On Mac OSX I found that this works best if you use brew package manager as many of the underlying C libraries are easier to install using this method. There are ways to do it without brew but you'll need to read up on what is best for your environment

brew install pil

Feel free to write more transforms, see the PIL docs for what it can do:

##Settings: You will need to add some variables to your pelicanconf.py and publishconf.py respectively. The settings should be added towards the bottom as there are some dependencies on other variables that come with a basic pelican setup.

###Example configuration values from peliconconf.py:

GALLERY_FOLDER = "galleries"
GALLERY_SRC_PATH = "%s%s" % (BASE_PATH, "gallery_src")
GALLERY_OUTPUT_PATH = "%s%s%s" % (BASE_PATH, OUTPUT_PATH, GALLERY_FOLDER)
GALLERY_REGENERATE_EXISTING = False
GALLERY_PRESETS = [
                    {"name": "thumb", "actions": [{"type": "fit", "height": 100, "width": 100, "from": (0.5, 0.5) }]},
                    {"name": "slider", "actions": [{"type": "fit", "height": 300, "width": 900, "from": (0.5, 0.5) }]},
                    {"name": "large", "actions": [{"type": "resize", "height": 640, "width": 850, "from": (0.5, 0.5) }]},
                    {"name": "thumb_greyscale", 
                        "actions": [
                            {"type": "fit", "height": 100, "width": 100, "from": (0.5, 0.5) },
                            {"type": "greyscale"}
                        ]},
                  ]

# This setting is optional, used for thumbnails in bootstrap
THUMBNAIL_GALLERY_CLASS = "span2"

Add to markdown header

Gallery: my/gallery/path

##Template implementation This is just a sample of how you might iterate over a gallery in a template or template partial.

{% if article.gallery %}
    <h3>Gallery</h3>
    <ul class="thumbnails">
    {% for photo_set in article.gallery.photos %}
      <li class="{{THUMBNAIL_GALLERY_CLASS}}">
        <a href="{{ SITEURL }}/{{ photo_set['large'].src }}" class="thumbnail fancybox-thumbs" rel="article.gallery.galleryName">
          <img src="{{ SITEURL }}/{{ photo_set['thumb'].src }}" alt="{{ photo_set['thumb'].src }}" width="{{ photo_set['thumb'].width }}" height="{{ photo_set['thumb'].height }}" />
        </a>
      </li>
      {% endfor %}
    </ul>
{% endif %}

The MIT License (MIT)

Copyright (c) 2013 Christopher D. Hunter - chrishunters.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

pelican-gallery's People

Contributors

hunt3r avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.