Automatic commit from deploy
BIN
galleries/demo/20150115194213.jpg
Normal file
|
After Width: | Height: | Size: 614 KiB |
BIN
galleries/demo/20150116081700.jpg
Normal file
|
After Width: | Height: | Size: 451 KiB |
BIN
galleries/demo/20150116083823.jpg
Normal file
|
After Width: | Height: | Size: 611 KiB |
BIN
galleries/demo/20150117162912.jpg
Normal file
|
After Width: | Height: | Size: 773 KiB |
BIN
galleries/demo/20150118173759.jpg
Normal file
|
After Width: | Height: | Size: 598 KiB |
BIN
galleries/demo/20150120182641.jpg
Normal file
|
After Width: | Height: | Size: 596 KiB |
BIN
galleries/demo/20150120182721.jpg
Normal file
|
After Width: | Height: | Size: 557 KiB |
BIN
galleries/demo/20150120182749.jpg
Normal file
|
After Width: | Height: | Size: 827 KiB |
BIN
galleries/demo/20150127075737.jpg
Normal file
|
After Width: | Height: | Size: 480 KiB |
BIN
galleries/demo/20150127112648.jpg
Normal file
|
After Width: | Height: | Size: 789 KiB |
BIN
galleries/demo/20150205190502.jpg
Normal file
|
After Width: | Height: | Size: 510 KiB |
BIN
galleries/demo/IMG_1717.jpg
Normal file
|
After Width: | Height: | Size: 3.3 MiB |
BIN
galleries/demo/IMG_1726.jpg
Normal file
|
After Width: | Height: | Size: 3.7 MiB |
8
plugins/gallery_directive/README.md
Normal file
|
|
@ -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.
|
||||
14
plugins/gallery_directive/gallery_directive.plugin
Normal file
|
|
@ -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
|
||||
|
||||
100
plugins/gallery_directive/gallery_directive.py
Normal file
|
|
@ -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<!-- foo -->\n%s\n\n\n' % output
|
||||
return [nodes.raw('', output, format='html')]
|
||||
1
plugins/import_feed/requirements.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
feedparser
|
||||
20
posts/2015/07/gallery-test.rst
Normal file
|
|
@ -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!
|
||||
|
||||