summaryrefslogtreecommitdiffstats
path: root/nikola/plugins/compile/rest/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'nikola/plugins/compile/rest/__init__.py')
-rw-r--r--nikola/plugins/compile/rest/__init__.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/nikola/plugins/compile/rest/__init__.py b/nikola/plugins/compile/rest/__init__.py
index 9a4e19b..a93199c 100644
--- a/nikola/plugins/compile/rest/__init__.py
+++ b/nikola/plugins/compile/rest/__init__.py
@@ -40,13 +40,8 @@ try:
except ImportError:
has_docutils = False
-try:
- from collections import OrderedDict
-except ImportError:
- OrderedDict = dict # NOQA
-
from nikola.plugin_categories import PageCompiler
-from nikola.utils import get_logger, makedirs, req_missing
+from nikola.utils import get_logger, makedirs, req_missing, write_metadata
class CompileRest(PageCompiler):
@@ -102,22 +97,25 @@ class CompileRest(PageCompiler):
else:
return False
- def create_post(self, path, onefile=False, is_page=False, **kw):
- metadata = OrderedDict()
+ def create_post(self, path, **kw):
+ content = kw.pop('content', None)
+ onefile = kw.pop('onefile', False)
+ # is_page is not used by create_post as of now.
+ kw.pop('is_page', False)
+ metadata = {}
metadata.update(self.default_metadata)
metadata.update(kw)
makedirs(os.path.dirname(path))
+ if not content.endswith('\n'):
+ content += '\n'
with codecs.open(path, "wb+", "utf8") as fd:
if onefile:
- for k, v in metadata.items():
- fd.write('.. {0}: {1}\n'.format(k, v))
- fd.write("\nWrite your {0} here.".format('page' if is_page else 'post'))
+ fd.write(write_metadata(metadata))
+ fd.write('\n' + content)
def set_site(self, site):
for plugin_info in site.plugin_manager.getPluginsOfCategory("RestExtension"):
- if (plugin_info.name in site.config['DISABLED_PLUGINS']
- or (plugin_info.name in site.EXTRA_PLUGINS and
- plugin_info.name not in site.config['ENABLED_EXTRAS'])):
+ if plugin_info.name in site.config['DISABLED_PLUGINS']:
site.plugin_manager.removePluginFromCategory(plugin_info, "RestExtension")
continue