Skip to content

Commit ff854c8

Browse files
committedApr 24, 2015
Monkeypatched Image directive that supports class option
1 parent ab5ff35 commit ff854c8

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
 

‎v7/classy-images/classy-images.plugin

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Core]
2+
Name = classy_images
3+
Module = classy_images
4+
5+
[Documentation]
6+
Author = Roberto Alsina
7+
Version = 0.1
8+
Website = http://getnikola.com
9+
Description = Image directive replacement supporting a class option
10+

‎v7/classy-images/classy_images.py

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Copyright © 2012-2015 Roberto Alsina and others.
4+
5+
# Permission is hereby granted, free of charge, to any
6+
# person obtaining a copy of this software and associated
7+
# documentation files (the "Software"), to deal in the
8+
# Software without restriction, including without limitation
9+
# the rights to use, copy, modify, merge, publish,
10+
# distribute, sublicense, and/or sell copies of the
11+
# Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice
15+
# shall be included in all copies or substantial portions of
16+
# the Software.
17+
#
18+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19+
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20+
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21+
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
22+
# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23+
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24+
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26+
27+
from __future__ import unicode_literals
28+
29+
import uuid
Has conversations. Original line has conversations.
30+
31+
from docutils import nodes
32+
from docutils.parsers.rst import Directive, directives
33+
34+
from nikola.plugin_categories import RestExtension
35+
36+
37+
class Plugin(RestExtension):
38+
39+
name = "classy_images"
40+
41+
def set_site(self, site):
42+
self.site = site
43+
directives.register_directive('image', ClassyImages)
44+
ClassyImages.site = site
45+
return super(Plugin, self).set_site(site)
46+
47+
classy_spec = directives.images.Image.option_spec
48+
classy_spec['class'] = directives.unchanged
49+
50+
class ClassyImages(directives.images.Image):
51+
""" Restructured text extension for inserting slideshows."""
52+
53+
option_spec = classy_spec
54+
55+
def run(self):
56+
r = super(ClassyImages, self).run()
57+
r[0]['classes'] = [r[0]['classes']]
58+
return r
59+
60+
61+
directives.register_directive('image', ClassyImages)

0 commit comments

Comments
 (0)
Please sign in to comment.