diff --git a/web/plugins/__init__.py b/web/plugins/__init__.py new file mode 100644 index 00000000..fd7e25d7 --- /dev/null +++ b/web/plugins/__init__.py @@ -0,0 +1 @@ +# Plugin modules go here. \ No newline at end of file diff --git a/web/plugins/accordion_directive/README.md b/web/plugins/accordion_directive/README.md new file mode 100644 index 00000000..9c12469e --- /dev/null +++ b/web/plugins/accordion_directive/README.md @@ -0,0 +1,19 @@ +http://www.tutorialspoint.com/bootstrap/bootstrap_collapse_plugin.htm + +# Usage + +``` +.. accordion:: + :id: acordeon + + .. collapse:: IDE (Entorno Integrado de Desarrollo) + + Un IDE es un programa que te permite gestionar los archivos Python + de tus proyectos y también *te ayuda* coloreando la sintaxis, + dándote sugerencias de autocompletado con las funciones disponibles + y un sin fin de herramientas más. + + * `Spyder `_ + * `Ninja-IDE `_ + +``` diff --git a/web/plugins/collapse_directive/collapse_directive.plugin b/web/plugins/accordion_directive/accordion.plugin similarity index 68% rename from web/plugins/collapse_directive/collapse_directive.plugin rename to web/plugins/accordion_directive/accordion.plugin index 2f6e4a18..fa64150f 100644 --- a/web/plugins/collapse_directive/collapse_directive.plugin +++ b/web/plugins/accordion_directive/accordion.plugin @@ -1,12 +1,12 @@ [Core] -Name = collapse_directive -Module = collapse_directive +Name = accordion +Module = accordion [Nikola] MinVersion = 7.4.0 [Documentation] -Author = Manuel Kaufmann +Author = Manuel Kaufmann & Leandro E. Colombo Viña Version = 0.1 Website = http://plugins.getnikola.com/#collapse_directive Description = Useful to create collapsible groups or accordion diff --git a/web/plugins/accordion_directive/accordion.py b/web/plugins/accordion_directive/accordion.py new file mode 100644 index 00000000..99f62a13 --- /dev/null +++ b/web/plugins/accordion_directive/accordion.py @@ -0,0 +1,80 @@ +# -*- coding: utf-8 -*- + +# Copyright © 2015 Manuel Kaufmann & Leandro E. Colombo Viña + +# 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 uuid + +from docutils import nodes +from docutils.parsers.rst import Directive, directives + +from nikola.plugin_categories import RestExtension + +"""Accordion and Collapse group directive for reStructuredText""" + + +class Plugin(RestExtension): + """Plugin for accordion and collapse reST directive""" + + name = "accordion" + + def set_site(self, site): + """Set Nikola site.""" + self.site = site + directives.register_directive('accordion', Accordion) + return super(Plugin, self).set_site(site) + + +class Accordion(Directive): + """ reStructuredText extension for inserting collapsible groups or accordion.""" + + required_arguments = 0 + optional_arguments = 9999 + final_argument_whitespace = False + option_spec = { + 'class': directives.class_option, + 'id': directives.unchanged, + 'role': directives.unchanged, + 'aria-multiselectable': directives.unchanged, + } + + has_content = True + + def run(self): + self.assert_has_content() + text = '\n'.join(self.content) + options = { + 'class': self.arguments[0] if self.arguments else 'panel-group', + 'id': 'accordion', + 'role': 'tablist', + 'aria-multiselectable': 'true' + } + options.update(self.options) + + node = nodes.container(text) + node['classes'] = directives.class_option(options['class']) + self.add_name(node) + self.state.nested_parse(self.content, self.content_offset, node) + + return [node] diff --git a/web/plugins/collapse_directive/README.md b/web/plugins/collapse_directive/README.md index cff7c977..9c12469e 100644 --- a/web/plugins/collapse_directive/README.md +++ b/web/plugins/collapse_directive/README.md @@ -3,22 +3,17 @@ http://www.tutorialspoint.com/bootstrap/bootstrap_collapse_plugin.htm # Usage ``` -.. raw:: html +.. accordion:: + :id: acordeon -
+ .. collapse:: IDE (Entorno Integrado de Desarrollo) -.. collapse:: IDE (Entorno Integrado de Desarrollo) + Un IDE es un programa que te permite gestionar los archivos Python + de tus proyectos y también *te ayuda* coloreando la sintaxis, + dándote sugerencias de autocompletado con las funciones disponibles + y un sin fin de herramientas más. - Un IDE es un programa que te permite gestionar los archivos Python - de tus proyectos y también *te ayuda* coloreando la sintaxis, - dándote sugerencias de autocompletado con las funciones disponibles - y un sin fin de herramientas más. - - * `Spyder `_ - * `Ninja-IDE `_ - -.. raw:: html - -
+ * `Spyder `_ + * `Ninja-IDE `_ ``` diff --git a/web/plugins/collapse_directive/collapse.plugin b/web/plugins/collapse_directive/collapse.plugin new file mode 100644 index 00000000..c02460ae --- /dev/null +++ b/web/plugins/collapse_directive/collapse.plugin @@ -0,0 +1,12 @@ +[Core] +Name = collapse +Module = collapse + +[Nikola] +MinVersion = 7.4.0 + +[Documentation] +Author = Manuel Kaufmann & Leandro E. Colombo Viña +Version = 0.2 +Website = http://plugins.getnikola.com/#collapse_directive +Description = Useful to create collapsible groups or accordion diff --git a/web/plugins/collapse_directive/collapse_directive.py b/web/plugins/collapse_directive/collapse.py similarity index 81% rename from web/plugins/collapse_directive/collapse_directive.py rename to web/plugins/collapse_directive/collapse.py index cc8f9b03..33638e02 100644 --- a/web/plugins/collapse_directive/collapse_directive.py +++ b/web/plugins/collapse_directive/collapse.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright © 2015 Manuel Kaufmann +# Copyright © 2015 Manuel Kaufmann & Leandro E. Colombo Viña # Permission is hereby granted, free of charge, to any # person obtaining a copy of this software and associated @@ -24,26 +24,29 @@ # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import unicode_literals - from docutils import nodes from docutils.parsers.rst import Directive, directives from nikola.plugin_categories import RestExtension +"""Accordion and Collapse group directive for reStructuredText""" + class Plugin(RestExtension): + """Plugin for accordion and collapse reST directive""" - name = "collapse_directive" + name = "collapse" def set_site(self, site): + """Set Nikola site.""" self.site = site Collapse.site = site + directives.register_directive('collapse', Collapse) return super(Plugin, self).set_site(site) class Collapse(Directive): - """ Restructured text extension for inserting collapsible groups or accordion.""" + """ reStructuredText extension for inserting collapsible groups or accordion.""" # TODO: http://www.tutorialspoint.com/bootstrap/bootstrap_collapse_plugin.htm option_spec = { @@ -62,7 +65,8 @@ def _sanitize_options(self): def run(self): if len(self.content) == 0: - return + msg = 'collapse directive with no content' + return [nodes.raw('', '
{0}
'.format(msg), format='html')] # from nikola.plugins.compile.rest import rst2html # content = rst2html('\n'.join(self.content)) @@ -84,4 +88,4 @@ def run(self): return [nodes.raw('', output, format='html')] -directives.register_directive('collapse', Collapse) +#directives.register_directive('collapse', Collapse)