summaryrefslogtreecommitdiffstats
path: root/nikola/plugins/compile/ipynb/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'nikola/plugins/compile/ipynb/__init__.py')
-rw-r--r--nikola/plugins/compile/ipynb/__init__.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/nikola/plugins/compile/ipynb/__init__.py b/nikola/plugins/compile/ipynb/__init__.py
index 7c318ca..5f2f0b3 100644
--- a/nikola/plugins/compile/ipynb/__init__.py
+++ b/nikola/plugins/compile/ipynb/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2013 Damian Avila.
+# Copyright © 2013-2014 Damián Avila and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
@@ -41,6 +41,11 @@ except ImportError:
from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, req_missing
+try:
+ from collections import OrderedDict
+except ImportError:
+ OrderedDict = None # NOQA
+
class CompileIPynb(PageCompiler):
"""Compile IPynb into HTML."""
@@ -49,7 +54,7 @@ class CompileIPynb(PageCompiler):
def compile_html(self, source, dest, is_two_file=True):
if flag is None:
- req_missing(['ipython>=1.0.0'], 'build this site (compile ipynb)')
+ req_missing(['ipython>=1.1.0'], 'build this site (compile ipynb)')
makedirs(os.path.dirname(dest))
HTMLExporter.default_template = 'basic'
c = Config(self.site.config['IPYNB_CONFIG'])
@@ -62,18 +67,20 @@ class CompileIPynb(PageCompiler):
out_file.write(body)
def create_post(self, path, onefile=False, **kw):
- metadata = {}
+ if OrderedDict is not None:
+ metadata = OrderedDict()
+ else:
+ metadata = {}
metadata.update(self.default_metadata)
metadata.update(kw)
d_name = os.path.dirname(path)
makedirs(os.path.dirname(path))
meta_path = os.path.join(d_name, kw['slug'] + ".meta")
with codecs.open(meta_path, "wb+", "utf8") as fd:
- if onefile:
- fd.write('%s\n' % kw['title'])
- fd.write('%s\n' % kw['slug'])
- fd.write('%s\n' % kw['date'])
- fd.write('%s\n' % kw['tags'])
+ fd.write('\n'.join((metadata['title'], metadata['slug'],
+ metadata['date'], metadata['tags'],
+ metadata['link'],
+ metadata['description'], metadata['type'])))
print("Your post's metadata is at: ", meta_path)
with codecs.open(path, "wb+", "utf8") as fd:
fd.write("""{