Skip to content

Commit

Permalink
Add v8 plugins support to the site
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jul 9, 2017
1 parent 32008cb commit 7e5caac
Show file tree
Hide file tree
Showing 33 changed files with 210 additions and 49 deletions.
12 changes: 8 additions & 4 deletions site/conf.py
Expand Up @@ -29,21 +29,25 @@

# Package index configuration
PKGINDEX_DIRS = {
'v7': ('v7', 'plugin.tmpl')
'v7': ('v7', 'plugin.tmpl'),
'v8': ('v8', 'plugin.tmpl')
}

PKGINDEX_HANDLERS = {
'v7': ['dirname_as_title', 'parse_plugin_file']
'v7': ['dirname_as_title', 'parse_plugin_file', 'add_dummy_multiver'],
'v8': ['dirname_as_title', 'parse_plugin_file', 'add_dummy_multiver']
}
PKGINDEX_CONFIG = {
'extension': '.plugin',
'versions_supported': [7],
'versions_supported': [7, 8],
'json_filename': 'plugins.json',
}

plugins_submenu = (
('/', 'Plugins Home'),
('/categories/', 'Categories'),
('/v7/', 'Version 7'),
('/v8/', 'Version 8'),
)

# Output folder -- change if using locally
Expand Down Expand Up @@ -1211,7 +1215,7 @@

# If you hate "Filenames with Capital Letters and Spaces.md", you should
# set this to true.
UNSLUGIFY_TITLES = True
FILE_METADATA_UNSLUGIFY_TITLES = True

# Additional metadata that is added to a post when creating a new_post
# ADDITIONAL_METADATA = {}
Expand Down
13 changes: 0 additions & 13 deletions site/continuous-import.plugin

This file was deleted.

2 changes: 1 addition & 1 deletion site/pages/categories/Command.rst
Expand Up @@ -4,7 +4,7 @@
.. category: category_page
.. post-list::
:sort: slug
:sort: slug_sortable
:categories: Command
:post_type: pages
:template: plugin_list.tmpl
2 changes: 1 addition & 1 deletion site/pages/categories/Compiler.rst
Expand Up @@ -4,7 +4,7 @@
.. category: category_page
.. post-list::
:sort: slug
:sort: slug_sortable
:categories: Compiler
:post_type: pages
:template: plugin_list.tmpl
2 changes: 1 addition & 1 deletion site/pages/categories/CompilerExtension.rst
Expand Up @@ -4,7 +4,7 @@
.. category: category_page
.. post-list::
:sort: slug
:sort: slug_sortable
:categories: CompilerExtension
:post_type: pages
:template: plugin_list.tmpl
2 changes: 1 addition & 1 deletion site/pages/categories/ConfigPlugin.rst
Expand Up @@ -4,7 +4,7 @@
.. category: category_page
.. post-list::
:sort: slug
:sort: slug_sortable
:categories: ConfigPlugin
:post_type: pages
:template: plugin_list.tmpl
2 changes: 1 addition & 1 deletion site/pages/categories/LateTask.rst
Expand Up @@ -4,7 +4,7 @@
.. category: category_page
.. post-list::
:sort: slug
:sort: slug_sortable
:categories: LateTask
:post_type: pages
:template: plugin_list.tmpl
2 changes: 1 addition & 1 deletion site/pages/categories/PostScanner.rst
Expand Up @@ -4,7 +4,7 @@
.. category: category_page
.. post-list::
:sort: slug
:sort: slug_sortable
:categories: PostScanner
:post_type: pages
:template: plugin_list.tmpl
2 changes: 1 addition & 1 deletion site/pages/categories/ShortcodePlugin.rst
Expand Up @@ -4,7 +4,7 @@
.. category: category_page
.. post-list::
:sort: slug
:sort: slug_sortable
:categories: ShortcodePlugin
:post_type: pages
:template: plugin_list.tmpl
2 changes: 1 addition & 1 deletion site/pages/categories/SignalHandler.rst
Expand Up @@ -4,7 +4,7 @@
.. category: category_page
.. post-list::
:sort: slug
:sort: slug_sortable
:categories: SignalHandler
:post_type: pages
:template: plugin_list.tmpl
2 changes: 1 addition & 1 deletion site/pages/categories/Task.rst
Expand Up @@ -4,7 +4,7 @@
.. category: category_page
.. post-list::
:sort: slug
:sort: slug_sortable
:categories: Task
:post_type: pages
:template: plugin_list.tmpl
2 changes: 1 addition & 1 deletion site/pages/categories/TaskMultiplier.rst
Expand Up @@ -4,7 +4,7 @@
.. category: category_page
.. post-list::
:sort: slug
:sort: slug_sortable
:categories: TaskMultiplier
:post_type: pages
:template: plugin_list.tmpl
2 changes: 1 addition & 1 deletion site/pages/categories/TemplateSystem.rst
Expand Up @@ -4,7 +4,7 @@
.. category: category_page
.. post-list::
:sort: slug
:sort: slug_sortable
:categories: TemplateSystem
:post_type: pages
:template: plugin_list.tmpl
2 changes: 1 addition & 1 deletion site/pages/categories/gen.py
Expand Up @@ -9,7 +9,7 @@
.. category: category_page
.. post-list::
:sort: slug
:sort: slug_sortable
:categories: {0}
:post_type: pages
:template: plugin_list.tmpl
Expand Down
2 changes: 1 addition & 1 deletion site/pages/index.rst
Expand Up @@ -31,7 +31,7 @@ All available plugins
=====================

.. post-list::
:sort: slug
:sort: slug_sortable
:tags: plugin
:post_type: pages
:template: plugin_list.tmpl
Expand Down
2 changes: 1 addition & 1 deletion site/pages/sidemenu.rst
Expand Up @@ -6,7 +6,7 @@
.. url_type: full_path
.. post-list::
:sort: slug
:sort: slug_sortable
:tags: plugin
:post_type: pages
:template: sidemenu_list.tmpl
4 changes: 2 additions & 2 deletions site/pages/v7.rst
Expand Up @@ -4,7 +4,7 @@
.. category: version_page
.. post-list::
:sort: slug
:tags: plugin, v7
:sort: slug_sortable
:tags: v7
:post_type: pages
:template: plugin_list.tmpl
10 changes: 10 additions & 0 deletions site/pages/v8.rst
@@ -0,0 +1,10 @@
.. title: Version 8
.. slug: v8
.. date: 1970-01-01 00:00:00 UTC
.. category: version_page
.. post-list::
:sort: slug_sortable
:tags: v8
:post_type: pages
:template: plugin_list.tmpl
6 changes: 3 additions & 3 deletions site/templates/plugin.tmpl
Expand Up @@ -20,9 +20,9 @@
${post.meta('author')}
% endif
<p class="minverline">Supports Nikola v${post.meta('minver')}
% if post.meta('maxver'):
% if post.meta('maxver') and post.meta('maxver') != post.meta('minver'):
through ${post.meta('maxver')}
% else:
% elif not post.meta('maxver'):
or newer
% endif
</p>
Expand Down Expand Up @@ -64,5 +64,5 @@
</article>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidemenu-container"></div>
<script>var pkgindex_item_name = "${post.meta('slug')}";</script>
<script>var pkgindex_item_name = "${post.meta('slug_versioned')}";</script>
</%block>
4 changes: 4 additions & 0 deletions site/templates/plugin_list.tmpl
Expand Up @@ -6,8 +6,12 @@
<ul class="post-list">
% for post in posts:
<li class="post-list-item">
% if post.meta('multiver'):
<a href="${post.permalink(lang)}"><span class="text-muted">v${post.meta('dirver')}/</span>${post.title(lang)|h}</a> — ${post.meta('description')}
% else:
<a href="${post.permalink(lang)}">${post.title(lang)|h}</a> — ${post.meta('description')}
</li>
% endif
% endfor
</ul>
%endif
Expand Down
6 changes: 5 additions & 1 deletion site/templates/sidemenu_list.tmpl
Expand Up @@ -3,7 +3,11 @@
%if posts:
<div class="list-group">
% for post in posts:
<a class="list-group-item sidemenu-item" data-name="${post.meta('slug')}" href="${post.permalink(lang)}">${post.title(lang)|h}</a>
% if post.meta('multiver'):
<a class="list-group-item sidemenu-item" data-name="${post.meta('slug_versioned')}" href="${post.permalink(lang)}"><span class="text-muted">v${post.meta('dirver')}/</span>${post.title(lang)|h}</a>
% else:
<a class="list-group-item sidemenu-item" data-name="${post.meta('slug_versioned')}" href="${post.permalink(lang)}">${post.title(lang)|h}</a>
% endif
% endfor
</div>
%endif
Expand Down
1 change: 1 addition & 0 deletions site/v8
2 changes: 0 additions & 2 deletions v7/helloworld/helloworld.plugin
Expand Up @@ -4,8 +4,6 @@ Module = helloworld
Tests = test_helloworld

[Nikola]
MinVersion = 6.0.0
MaxVersion = 7.0.0
PluginCategory = Task

[Documentation]
Expand Down
8 changes: 4 additions & 4 deletions v7/ical/README.md
Expand Up @@ -9,13 +9,13 @@ external file, or embedded in your document.
Example with external file:

```
{{% calendar file=my_event.ical %}}
{{% raw %}}{{% calendar file=my_event.ical %}}{{% /raw %}}
```

Example with embedded calendar:

```
{{% calendar %}}
{{% raw %}}{{% calendar %}}
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
Expand All @@ -28,7 +28,7 @@ DTEND:19970715T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR
{{% /calendar %}}
{{% /calendar %}}{{% /raw %}}
```

Expand All @@ -37,5 +37,5 @@ a different template, just use the ``template`` argument (it will be loaded from
or from ``templates/``:

```
{{% calendar file=my_event.ical template=my_fancy_template.tmpl %}}
{{% raw %}}{{% calendar file=my_event.ical template=my_fancy_template.tmpl %}}{{% /raw %}}
```
2 changes: 1 addition & 1 deletion v7/notebook_shortcode/README.md
Expand Up @@ -4,7 +4,7 @@ adapting an existing notebook into a post with additional markup.
Usage:

```
{{% notebook path/to/notebook.ipynb %}}
{{% raw %}}{{% notebook path/to/notebook.ipynb %}}{{% /raw %}}
```

Note: `ipynb` must be enabled and configured (COMPILERS, POSTS/PAGES) for CSS to appear properly. If you are using math
Expand Down
16 changes: 14 additions & 2 deletions v7/pkgindex_compiler/pkgindex_compiler.py
Expand Up @@ -48,6 +48,11 @@ def _version_from_path(path):
return int(path.split('/')[0].split('v')[-1])


def add_dummy_multiver(post, pkg_dir, config):
"""Add a dummy multiver=False value."""
return {'multiver': False}


def _cp_try_get(config, section, option):
try:
return config.get(section, option)
Expand Down Expand Up @@ -76,20 +81,25 @@ def parse_plugin_file(post, pkg_dir, config):
data['website'] = _cp_try_get(c, 'Documentation', 'Website')
data['minver'] = _cp_try_get(c, 'Nikola', 'MinVersion')
data['maxver'] = _cp_try_get(c, 'Nikola', 'MaxVersion')
data['dirver'] = _version_from_path(pkg_dir)
data['slug_versioned'] = 'v{0}/{1}'.format(data['dirver'], plugin)
data['slug_sortable'] = '{1} v{0}'.format(data['dirver'], plugin)

category = c.get('Nikola', 'PluginCategory')
data['category'] = category

if data['minver']:
minver = data['minver'].split('.')[0]
else:
minver = _version_from_path(pkg_dir)
minver = data['dirver']
data['minver'] = minver
if data['maxver']:
maxver = data['maxver'].split('.')[0]
else:
maxver = config['versions_supported'][-1]

# Plugins may specify older versions
minver = max(int(minver), config['versions_supported'][0])
data['allver'] = list(range(int(minver), int(maxver) + 1))

tags = ['plugin', category]
Expand Down Expand Up @@ -218,7 +228,8 @@ def add_category(post, pkg_dir, config, args):
'dirname_as_title': dirname_as_title,
'parse_plugin_file': parse_plugin_file,
'parse_theme_info': parse_theme_info,
'add_category': add_category
'add_category': add_category,
'add_dummy_multiver': add_dummy_multiver,
}


Expand All @@ -238,6 +249,7 @@ class CompilePackageIndexEntries(PageCompiler):
friendly_name = "pkgindex_compiler"
markdown_compiler = None
pi_enabled = False
supports_metadata = True

def set_site(self, site):
"""Set site for the compiler."""
Expand Down

0 comments on commit 7e5caac

Please sign in to comment.