# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['pelican', 'pelican.plugins.photos']

package_data = \
{'': ['*'], 'pelican.plugins.photos': ['test_data/*', 'test_data/agallery/*']}

install_requires = \
['Pillow>=8.2.0,<9.0.0', 'pelican>=4.5']

extras_require = \
{'markdown': ['markdown>=3.2']}

setup_kwargs = {
    'name': 'pelican-photos',
    'version': '1.0.1',
    'description': 'Add a photo or a gallery of photos to an article',
    'long_description': 'Photos: A Plugin for Pelican\n============================\n\n[![Build Status](https://img.shields.io/github/workflow/status/pelican-plugins/photos/build)](https://github.com/pelican-plugins/photos/actions)\n[![PyPI Version](https://img.shields.io/pypi/v/pelican-photos)](https://pypi.org/project/pelican-photos/)\n![License](https://img.shields.io/pypi/l/pelican-photos?color=blue)\n\nUse Photos to add a photo or a gallery of photos to an article, or to include photos in the body text. Photos are kept separately, as an organized library of high resolution photos, and resized as needed.\n\nInstallation\n------------\n\nThis plugin can be installed via:\n\n    python -m pip install pelican-photos\n\nThe plug-in requires `Pillow`: the Python Imaging Library and optionally `Piexif`, whose installation are outside the scope of this document.\n\nUsage\n-----\n\nThe plug-in resizes the referred photos, and generates thumbnails for galleries and associated photos, based on the following configuration and default values:\n\n`PHOTO_LIBRARY = "~/Pictures"`\n:\tAbsolute path to the folder where the original photos are kept, organized in sub-folders.\n\n`PHOTO_GALLERY = (1024, 768, 80)`\n:\tFor photos in galleries, maximum width and height, plus JPEG quality as a percentage. This would typically be the size of the photo displayed when the reader clicks a thumbnail.\n\n`PHOTO_ARTICLE = (760, 506, 80)`\n:\tFor photos associated with articles, maximum width, height, and quality. The maximum size would typically depend on the needs of the theme. 760px is suitable for the theme `notmyidea`.\n\n`PHOTO_THUMB = (192, 144, 60)`\n:\tFor thumbnails, maximum width, height, and quality.\n\n`PHOTO_SQUARE_THUMB = False`\n:\tCrops thumbnails to make them square.\n\n`PHOTO_RESIZE_JOBS = 5`\n: Number of parallel resize jobs to be run. Defaults to 1.\n\n`PHOTO_WATERMARK = True`\n: Adds a watermark to all photos in articles and pages. Defaults to using your site name.\n\n`PHOTO_WATERMARK_TEXT\' = SITENAME`\n: Allow the user to change the watermark text or remove it completely. By default it uses [SourceCodePro-Bold](http://www.adobe.com/products/type/font-information/source-code-pro-readme.html) as the font.\n\n`PHOTO_WATERMARK_IMG = \'\'`\n: Allows the user to add an image in addition to or as the only watermark. Set the variable to the location.\n\n**The following features require the piexif library**\n`PHOTO_EXIF_KEEP = True`\n: Keeps the exif of the input photo.\n\n`PHOTO_EXIF_REMOVE_GPS = True`\n: Removes any GPS information from the files exif data.\n\n`PHOTO_EXIF_COPYRIGHT = \'COPYRIGHT\'`\n: Attaches an author and a license to the file. Choices include:\n\t- `COPYRIGHT`: Copyright\n\t- `CC0`: Public Domain\n\t- `CC-BY-NC-ND`: Creative Commons Attribution-NonCommercial-NoDerivatives\n\t- `CC-BY-NC-SA`: Creative Commons Attribution-NonCommercial-ShareAlike\n\t- `CC-BY`: Creative Commons Attribution\n\t- `CC-BY-SA`: Creative Commons Attribution-ShareAlike\n\t- `CC-BY-NC`: Creative Commons Attribution-NonCommercial\n\t- `CC-BY-ND`: Creative Commons Attribution-NoDerivatives\n\n`PHOTO_EXIF_COPYRIGHT_AUTHOR = \'Your Name Here\'`\n: Adds an author name to the photo\'s exif and copyright statement. Defaults to `AUTHOR` value from the `pelicanconf.py`\n\nThe plug-in automatically resizes the photos and publishes them to the following output folder:\n\n    ./output/photos\n\n**WARNING:** The plug-in can take hours to resize 40,000 photos, therefore, photos and thumbnails are only generated once. Clean the output folders to regenerate the resized photos again.\n\n## How to use\n\nMaintain an organized library of high resolution photos somewhere on disk, using folders to group related images. The default path `~/Pictures` is convenient for Mac OS X users.\n\n* To create a gallery of photos, add the metadata field `gallery: {photo}folder` to an article. To simplify the transition from the plug-in Gallery, the syntax `gallery: {filename}folder` is also accepted.\n* You can now have multiple galleries. The galleries need to be seperated by a comma in the metadata field. The syntax is gallery: `{photo}folder, {photo}folder2`. You can also add titles to your galleries. The syntax is: `{photo}folder, {photo}folder2{This is a title}`. Using the following example the first gallery would have the title of the folder location and the second would have the title `This is a tile.`\n* To use an image in the body of the text, just use the syntax `{photo}folder/image.jpg` instead of the usual `{filename}/images/image.jpg`.\n* To use an image in the body of the text, which can be used with [Lightbox](http://lokeshdhakar.com/projects/lightbox2/) just use the syntax `{lightbox}folder/image.jpg`. For use with other implementations, the gallery and caption attribute names can be set with `PHOTO_LIGHTBOX_GALLERY_ATTR` and `PHOTO_LIGHTBOX_CAPTION_ATTR`.\n* To associate an image with an article, add the metadata field `image: {photo}folder/image.jpg` to an article. Use associated images to improve navigation. For compatibility, the syntax `image: {filename}/images/image.jpg` is also accepted.\n\n### Exif, Captions, and Blacklists\nFolders of photos may optionally have three text files, where each line describes one photo. You can use the `#` to comment out a line. Generating these optional files is left as an exercise for the reader (but consider using Phil Harvey\'s [exiftool](http://www.sno.phy.queensu.ca/~phil/exiftool/)). See below for one method of extracting exif data.\n\n`exif.txt`\n:\tAssociates compact technical information with photos, typically the camera settings. For example:\n\n\tbest.jpg: Canon EOS 5D Mark II - 20mm f/8 1/250s ISO 100\n\tnight.jpg: Canon EOS 5D Mark II - 47mm f/8 5s ISO 100\n\t# new.jpg: Canon EOS 5D Mark II - 47mm f/8 5s ISO 100\n\n`captions.txt`\n:\tAssociates comments with photos. For example:\n\n\tbest.jpg: My best photo ever! How lucky of me!\n\tnight.jpg: Twilight over the dam.\n\t# new.jpg: My new photo blog entry is not quite ready.\n\n`blacklist.txt`\n: Skips photos the user does not want to include. For example:\n\n\tthis-file-will-be-skipped.jpg\n\tthis-one-will-be-skipped-too.jpg\n\t# but-this-file-will-NOT-be-skipped.jpg\n\tthis-one-will-be-also-skipped.jpg\n\n\nHere is an example Markdown article that shows the four use cases:\n\n\ttitle: My Article\n\tgallery: {photo}favorite\n\timage: {photo}favorite/best.jpg\n\n\tHere are my best photos, taken with my favorite camera:\n\t![]({photo}mybag/camera.jpg).\n\t![]({lightbox}mybag/flash.jpg).\n\nThe default behavior of the Photos plugin removes the exif information from the file. If you would like to keep the exif information, you can install the `piexif` library for python and add the following settings to keep some or all of the exif information. This feature is not a replacement for the `exif.txt` feature but in addition to that feature. This feature currently only works with jpeg input files.\n\n## How to change the Jinja templates\n\nThe plugin provides the following variables to your templates:\n\n`article.photo_image`\n:\tFor articles with an associated photo, a tuple with the following information:\n\n* The filename of the original photo.\n* The output path to the generated photo.\n* The output path to the generated thumbnail.\n\nFor example, modify the template `article.html` as shown below to display the associated image before the article content:\n\n```html\n<div class="entry-content">\n\t{% if article.photo_image %}<img src="{{ SITEURL }}/{{ article.photo_image[1] }}" />{% endif %}\n\t{% include \'article_infos.html\' %}\n\t{{ article.content }}\n</div><!-- /.entry-content -->\n```\n\n`article.photo_gallery`\n:\tFor articles with a gallery, a list of the photos in the gallery. Each item in the list is a tuple with five elements:\n\n* The title of the gallery\n* The filename of the original photo.\n* The output path to the generated photo.\n* The output path to the generated thumbnail.\n* The EXIF information of the photo, as read from the file `exif.txt`.\n* The caption of the photo, as read from `captions.txt`.\n\nFor example, add the following to the template `article.html` to add the gallery as the end of the article:\n\n```html\n{% if article.photo_gallery %}\n<div class="gallery">\n\t\t{% for title, gallery in article.photo_gallery %}\n\t\t\t<h1>{{ title }}</h1>\n\t\t\t\t{% for name, photo, thumb, exif, caption in gallery %}\n\t\t\t\t\t\t<a href="{{ SITEURL }}/{{ photo }}" title="{{ name }}" exif="{{ exif }}" caption="{{ caption }}"><img src="{{ SITEURL }}/{{ thumb }}"></a>\n\t\t\t\t{% endfor %}\n\t\t{% endfor %}\n</div>\n{% endif %}\n```\n\nFor example, add the following to the template `index.html`, inside the `entry-content`, to display the thumbnail with a link to the article:\n\n```html\n{% if article.photo_image %}<a href="{{ SITEURL }}/{{ article.url }}"><img src="{{ SITEURL }}/{{ article.photo_image[2] }}"\n\tstyle="display: inline; float: right; margin: 2px 0 2ex 4ex;" /></a>\n{% endif %}\n```\n\n## How to make the gallery lightbox\n\nThere are several JavaScript libraries that display a list of images as a lightbox. The example below uses [Magnific Popup](http://dimsemenov.com/plugins/magnific-popup/), which allows the more complex initialization needed to display both the filename, the compact technical information, and the caption. The solution would be simpler if photos did not show any extra information.\n\nCopy the files `magnific-popup.css` and `magnific-popup.js` to the root of your Pelican template.\n\nAdd the following to the template `base.html`, inside the HTML `head` tags:\n\n```html\n{% if (article and article.photo_gallery) or (articles_page and articles_page.object_list[0].photo_gallery) %}\n\t<link rel="stylesheet" href="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/magnific-popup.css">\n{% endif %}\n```\n\nAdd the following to the template `base.html`, before the closing HTML `</body>` tag:\n\n```JavaScript\n{% if (article and article.photo_gallery) or (articles_page and articles_page.object_list[0].photo_gallery) %}\n<!-- jQuery 1.7.2+ or Zepto.js 1.0+ -->\n<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>\n\n<!-- Magnific Popup core JS file -->\n<script src="{{ SITEURL }}/{{ THEME_STATIC_DIR }}/magnific-popup.js"></script>\n<script>\n$(\'.gallery\').magnificPopup({\n\tdelegate: \'a\',\n\ttype: \'image\',\n\tgallery: {\n\t\tenabled: true,\n\t\tnavigateByImgClick: true,\n\t\tpreload: [1,2]\n\t},\n\timage: {\n\t\ttitleSrc: function(item) {\n\t\t\tif (item.el.attr(\'caption\') && item.el.attr(\'exif\')) {\n\t\t\t\treturn (item.el.attr(\'caption\').replace(/\\\\n/g, \'<br />\') +\n\t\t\t\t\t\'<small>\' + item.el.attr(\'title\') + \' - \' + item.el.attr(\'exif\') + \'</small>\');\n\t\t\t}\n\t\treturn item.el.attr(\'title\') + \'<small>\' + item.el.attr(\'exif\') + \'</small>\';\n\t} }\n});\n</script>\n{% endif %}\n```\n\n## How to make a Bootstrap Carousel\n\nIf you are using bootstrap, the following code is an example of how one could create a carousel.\n\n```html\n{% if article.photo_gallery %}\n  {% for title, gallery in article.photo_gallery %}\n    <h1>{{ title }}</h1>\n    <div id="carousel-{{ loop.index }}" class="carousel slide">\n      <ol class="carousel-indicators">\n          {% for i in range(0, gallery|length) %}\n          <li data-target="#carousel-{{ loop.index }}" data-slide-to="{{ i }}" {% if i==0 %} class="active" {% endif %}></li>\n          {% endfor %}\n      </ol>\n      <div class="carousel-inner">\n        {% for name, photo, thumb, exif, caption in gallery %}\n          {% if loop.first %}\n            <div class="item active">\n          {% else %}\n            <div class="item">\n          {% endif %}\n          <img src="{{ SITEURL }}/{{ photo }}" exif="{{ exif }}" alt="{{ caption }}">\n          <div class="carousel-caption">\n              <h5>{{ caption }}</h5>\n          </div> <!-- carousel-caption -->\n        </div> <!-- item -->\n        {% endfor %}\n      </div> <!-- carousel-inner -->\n      <a class="left carousel-control" href="#carousel-{{ loop.index }}" data-slide="prev">\n        <span class="glyphicon glyphicon-chevron-left"></span>\n      </a>\n      <a class="right carousel-control" href="#carousel-{{ loop.index }}" data-slide="next">\n        <span class="glyphicon glyphicon-chevron-right"></span>\n      </a>\n    </div> <!-- closes carousel-{{ loop.index }} -->\n    {% endfor %}\n{% endif %}\n```\n\n## Exiftool example\n\nYou can add the following stanza to your fab file if you are using `fabric` to generate the appropriate text files for your galleries. You need to set the location of `Exiftool` control files.\n\n```Python\ndef photo_gallery_gen(location):\n    """Create gallery metadata files."""\n    local_path = os.getcwd() + \'LOCATION OF YOUR EXIF CONTROL FILES\'\n    with lcd(location):\n        local("exiftool -p {fmt_path}/exif.fmt . > exif.txt".format(\n            fmt_path=local_path))\n        local("exiftool -p {fmt_path}/captions.fmt . > captions.txt".format(\n            fmt_path=local_path))\n\n```\n\n`captions.fmt` example file\n\n```\n$FileName: $Description\n```\n\n`exif.fmt` example file\n\n```\n$FileName: $CreateDate - $Make $Model Stats:(f/$Aperture, ${ShutterSpeed}s, ISO $ISO Flash: $Flash) GPS:($GPSPosition $GPSAltitude)\n```\n\n## Known use cases\n\n[pxquim.pt](http://pxquim.pt/) uses Photos and the plug-in Sub-parts to publish 600 photo galleries with 40,000 photos. Photos keeps the high-resolution photos separate from the site articles.\n\n[pxquim.com](http://pxquim.com/) uses sub-parts to cover conferences, where it makes sense to have a sub-part for each speaker.\n\n## Alternatives\n\nGallery\n:\tGalleries are distinct entities, without the organizational capabilities of articles. Photos must be resized separately, and must be kept with the source of the blog. Gallery was the initial inspiration for Photos.\n\nImage_process\n:\tResize and process images in the article body in a more flexible way (based on the CSS class of the image), but without the ability to create galleries. The source photos must be kept with the source of the blog.\n\nContributing\n------------\n\nContributions are welcome and much appreciated. Every little bit helps. You can contribute by improving the documentation, adding missing features, and fixing bugs. You can also help out by reviewing and commenting on [existing issues][].\n\n To start contributing to this plugin, review the [Contributing to Pelican][] documentation, beginning with the **Contributing Code** section.\n\n[existing issues]: https://github.com/pelican-plugins/photos/issues\n[Contributing to Pelican]: https://docs.getpelican.com/en/latest/contribute.html\n\nLicense\n-------\n\nThis project is licensed under the AGPL-3.0 license.\n',
    'author': 'Joaquim Baptista',
    'author_email': 'pxquim@gmail.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/pelican-plugins/photos',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'extras_require': extras_require,
    'python_requires': '>=3.6.2,<4.0',
}


setup(**setup_kwargs)
