diff --git a/galleries/demo/20150115194213.jpg b/galleries/demo/20150115194213.jpg new file mode 100644 index 00000000..24cf5c26 Binary files /dev/null and b/galleries/demo/20150115194213.jpg differ diff --git a/galleries/demo/20150116081700.jpg b/galleries/demo/20150116081700.jpg new file mode 100644 index 00000000..9a8eb45d Binary files /dev/null and b/galleries/demo/20150116081700.jpg differ diff --git a/galleries/demo/20150116083823.jpg b/galleries/demo/20150116083823.jpg new file mode 100644 index 00000000..3d3183e5 Binary files /dev/null and b/galleries/demo/20150116083823.jpg differ diff --git a/galleries/demo/20150117162912.jpg b/galleries/demo/20150117162912.jpg new file mode 100644 index 00000000..15aad3ae Binary files /dev/null and b/galleries/demo/20150117162912.jpg differ diff --git a/galleries/demo/20150118173759.jpg b/galleries/demo/20150118173759.jpg new file mode 100644 index 00000000..8262e66c Binary files /dev/null and b/galleries/demo/20150118173759.jpg differ diff --git a/galleries/demo/20150120182641.jpg b/galleries/demo/20150120182641.jpg new file mode 100644 index 00000000..1b623713 Binary files /dev/null and b/galleries/demo/20150120182641.jpg differ diff --git a/galleries/demo/20150120182721.jpg b/galleries/demo/20150120182721.jpg new file mode 100644 index 00000000..4caa8ca5 Binary files /dev/null and b/galleries/demo/20150120182721.jpg differ diff --git a/galleries/demo/20150120182749.jpg b/galleries/demo/20150120182749.jpg new file mode 100644 index 00000000..5f05f62f Binary files /dev/null and b/galleries/demo/20150120182749.jpg differ diff --git a/galleries/demo/20150127075737.jpg b/galleries/demo/20150127075737.jpg new file mode 100644 index 00000000..fd41ecd7 Binary files /dev/null and b/galleries/demo/20150127075737.jpg differ diff --git a/galleries/demo/20150127112648.jpg b/galleries/demo/20150127112648.jpg new file mode 100644 index 00000000..82880436 Binary files /dev/null and b/galleries/demo/20150127112648.jpg differ diff --git a/galleries/demo/20150205190502.jpg b/galleries/demo/20150205190502.jpg new file mode 100644 index 00000000..6079700a Binary files /dev/null and b/galleries/demo/20150205190502.jpg differ diff --git a/galleries/demo/IMG_1717.jpg b/galleries/demo/IMG_1717.jpg new file mode 100644 index 00000000..e4af9229 Binary files /dev/null and b/galleries/demo/IMG_1717.jpg differ diff --git a/galleries/demo/IMG_1726.jpg b/galleries/demo/IMG_1726.jpg new file mode 100644 index 00000000..ae4465f6 Binary files /dev/null and b/galleries/demo/IMG_1726.jpg differ diff --git a/plugins/gallery_directive/README.md b/plugins/gallery_directive/README.md new file mode 100644 index 00000000..8d6ec3ef --- /dev/null +++ b/plugins/gallery_directive/README.md @@ -0,0 +1,8 @@ +Experimental plugin to embed Nikola galleries in reStructuredText. + +Usage:: + + .. gallery:: demo + +This should embed the gallery found in galleries/demo in your post. +Keep in mind that this is a horrible, horrible hack. diff --git a/plugins/gallery_directive/gallery_directive.plugin b/plugins/gallery_directive/gallery_directive.plugin new file mode 100644 index 00000000..a3397d9d --- /dev/null +++ b/plugins/gallery_directive/gallery_directive.plugin @@ -0,0 +1,14 @@ +[Core] +Name = gallery_directive +Module = gallery_directive + +[Nikola] +Compiler = rest +MinVersion = 7.4.1 + +[Documentation] +Author = Roberto Alsina +Version = 0.3 +Website = http://plugins.getnikola.com/#gallery_plugin +Description = A directive to embed an image gallery in a reSt document + diff --git a/plugins/gallery_directive/gallery_directive.py b/plugins/gallery_directive/gallery_directive.py new file mode 100644 index 00000000..0091923a --- /dev/null +++ b/plugins/gallery_directive/gallery_directive.py @@ -0,0 +1,100 @@ +# -*- coding: utf-8 -*- + +# Copyright © 2012-2013 Roberto Alsina and others. + +# 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. + +import json +import os + +from docutils import nodes +from docutils.parsers.rst import Directive, directives +import lxml + +from nikola.plugin_categories import RestExtension +from nikola.utils import LocaleBorg + + +class Plugin(RestExtension): + + name = "gallery_directive" + + def set_site(self, site): + self.site = site + self.inject_dependency('render_posts', 'render_galleries') + Gallery.site = site + directives.register_directive('gallery', Gallery) + return super(Plugin, self).set_site(site) + + +class Gallery(Directive): + """ Restructured text extension for inserting an image gallery + + Usage: + + .. gallery:: foo + + """ + + has_content = False + required_arguments = 1 + optional_arguments = 0 + + def run(self): + gallery_name = self.arguments[0] + kw = { + 'output_folder': self.site.config['OUTPUT_FOLDER'], + 'thumbnail_size': self.site.config['THUMBNAIL_SIZE'], + } + gallery_index_file = os.path.join(kw['output_folder'], self.site.path('gallery', gallery_name)) + gallery_index_path = self.site.path('gallery', gallery_name) + gallery_folder = os.path.dirname(gallery_index_path) + self.state.document.settings.record_dependencies.add(gallery_index_file) + with open(gallery_index_file, 'r') as inf: + data = inf.read() + dom = lxml.html.fromstring(data) + text = [e.text for e in dom.xpath('//script') if e.text and 'jsonContent = ' in e.text][0] + photo_array = json.loads(text.split(' = ', 1)[1].split(';', 1)[0]) + for img in photo_array: + img['url'] = '/' + '/'.join([gallery_folder, img['url']]) + img['url_thumb'] = '/' + '/'.join([gallery_folder, img['url_thumb']]) + photo_array_json = json.dumps(photo_array) + context = {} + context['description'] = '' + context['title'] = '' + context['lang'] = LocaleBorg().current_lang + context['crumbs'] = [] + context['folders'] = [] + context['photo_array'] = photo_array + context['photo_array_json'] = photo_array_json + context['permalink'] = '#' + context.update(self.site.GLOBAL_CONTEXT) + context.update(kw) + output = self.site.template_system.render_template( + 'gallery.tmpl', + None, + context + ) + # This magical comment makes everything work. Try removing it! + output = '\n\n%s\n\n\n' % output + return [nodes.raw('', output, format='html')] diff --git a/plugins/import_feed/requirements.txt b/plugins/import_feed/requirements.txt new file mode 100644 index 00000000..1b25361f --- /dev/null +++ b/plugins/import_feed/requirements.txt @@ -0,0 +1 @@ +feedparser diff --git a/posts/2015/07/gallery-test.rst b/posts/2015/07/gallery-test.rst new file mode 100644 index 00000000..6a66ba60 --- /dev/null +++ b/posts/2015/07/gallery-test.rst @@ -0,0 +1,20 @@ +.. title: Gallery Test +.. slug: gallery-test +.. date: 2015-07-14 21:02:09 UTC-05:00 +.. tags: photos +.. category: +.. link: +.. description: +.. type: text + + +This is a test of the gallery plugin. + +.. gallery:: demo + +and we should have a nice gallery. Cool, eh? + +Click on a photo to see it bigger, then click on the right side to move forward in the list. + +Neat! +