From 3fb5ec341a2b8bd61a87fbf45768220cd16092f3 Mon Sep 17 00:00:00 2001 From: Don Harper Date: Mon, 20 May 2019 21:02:38 -0500 Subject: [PATCH] new pluging, updated some imported files --- plugins/slides/README.md | 17 +++++ plugins/slides/slides.plugin | 14 ++++ plugins/slides/slides.py | 77 +++++++++++++++++++++ plugins/slides/templates/jinja2/slides.tmpl | 30 ++++++++ plugins/slides/templates/mako/slides.tmpl | 30 ++++++++ 5 files changed, 168 insertions(+) create mode 100644 plugins/slides/README.md create mode 100644 plugins/slides/slides.plugin create mode 100644 plugins/slides/slides.py create mode 100644 plugins/slides/templates/jinja2/slides.tmpl create mode 100644 plugins/slides/templates/mako/slides.tmpl diff --git a/plugins/slides/README.md b/plugins/slides/README.md new file mode 100644 index 00000000..9daa1c9f --- /dev/null +++ b/plugins/slides/README.md @@ -0,0 +1,17 @@ +Slides for reStructuredText. + +This was previously part of Nikola core, but has been downgraded to optional plugin. + +Compatible with Nikola v7 and v8, Bootstrap 4. (The v7 version is Bootstrap 3.) + +Example: + +``` + .. slides:: + + /galleries/demo/tesla_conducts_lg.jpg + /galleries/demo/tesla_lightning2_lg.jpg + /galleries/demo/tesla4_lg.jpg + /galleries/demo/tesla_lightning1_lg.jpg + /galleries/demo/tesla_tower1_lg.jpg +``` diff --git a/plugins/slides/slides.plugin b/plugins/slides/slides.plugin new file mode 100644 index 00000000..43c2ed08 --- /dev/null +++ b/plugins/slides/slides.plugin @@ -0,0 +1,14 @@ +[Core] +name = rest_slides +module = slides + +[Nikola] +compiler = rest +PluginCategory = CompilerExtension + +[Documentation] +author = Roberto Alsina +version = 0.1 +website = https://plugins.getnikola.com/slides +description = Slides directive + diff --git a/plugins/slides/slides.py b/plugins/slides/slides.py new file mode 100644 index 00000000..fb2d5c69 --- /dev/null +++ b/plugins/slides/slides.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- + +# Copyright © 2012-2018 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. + +"""Slides directive for reStructuredText.""" + + +import uuid + +from docutils import nodes +from docutils.parsers.rst import Directive, directives + +from nikola.plugin_categories import RestExtension + + +class Plugin(RestExtension): + """Plugin for reST slides directive.""" + + name = "rest_slides" + + def set_site(self, site): + """Set Nikola site.""" + self.site = site + directives.register_directive('slides', Slides) + Slides.site = site + return super(Plugin, self).set_site(site) + + +class Slides(Directive): + """reST extension for inserting slideshows.""" + + has_content = True + + def run(self): + """Run the slides directive.""" + if len(self.content) == 0: # pragma: no cover + return + + if self.site.invariant: # for testing purposes + carousel_id = 'slides_' + 'fixedvaluethatisnotauuid' + else: + carousel_id = 'slides_' + uuid.uuid4().hex + + output = self.site.template_system.render_template( + 'slides.tmpl', + None, + { + 'slides_content': self.content, + 'carousel_id': carousel_id, + } + ) + return [nodes.raw('', output, format='html')] + + +directives.register_directive('slides', Slides) diff --git a/plugins/slides/templates/jinja2/slides.tmpl b/plugins/slides/templates/jinja2/slides.tmpl new file mode 100644 index 00000000..7e1a0d4f --- /dev/null +++ b/plugins/slides/templates/jinja2/slides.tmpl @@ -0,0 +1,30 @@ +{% block content %} + +{% endblock %} diff --git a/plugins/slides/templates/mako/slides.tmpl b/plugins/slides/templates/mako/slides.tmpl new file mode 100644 index 00000000..8fd34973 --- /dev/null +++ b/plugins/slides/templates/mako/slides.tmpl @@ -0,0 +1,30 @@ +<%block name="content"> + +