|
| 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) |