Skip to content
Permalink
Browse files

Compatibility with new-style metadata in Nikola v7

Signed-off-by: Chris “Kwpolska” Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Mar 29, 2014
1 parent eacc93e commit 6c52b93e570377455cac137478c7d5c7b230b95a
@@ -35,7 +35,7 @@
import subprocess

from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, req_missing
from nikola.utils import makedirs, req_missing, write_metadata

try:
from collections import OrderedDict
@@ -70,7 +70,6 @@ def create_post(self, path, **kw):
with codecs.open(path, "wb+", "utf8") as fd:
if one_file:
fd.write("/////////////////////////////////////////////\n")
for k, v in metadata.items():
fd.write('.. {0}: {1}\n'.format(k, v))
fd.write(write_metadata(metadata))
fd.write("/////////////////////////////////////////////\n")
fd.write(content)
@@ -36,7 +36,7 @@
bbcode = None # NOQA

from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, req_missing
from nikola.utils import makedirs, req_missing, write_metadata
try:
from collections import OrderedDict
except ImportError:
@@ -68,8 +68,8 @@ def compile_html(self, source, dest, is_two_file=True):

def create_post(self, path, content, onefile=False, is_page=False, **kw):
content = kw.pop('content', None)
one_file = kw.pop('one_file', False) # NOQA
is_page = kw.pop('is_page', False) # NOQA
onefile = kw.pop('onefile', False)
kw.pop('is_page', False)
metadata = OrderedDict()
metadata.update(self.default_metadata)
metadata.update(kw)
@@ -79,7 +79,6 @@ def create_post(self, path, content, onefile=False, is_page=False, **kw):
with codecs.open(path, "wb+", "utf8") as fd:
if onefile:
fd.write('[note]<!--\n')
for k, v in metadata.items():
fd.write('.. {0}: {1}\n'.format(k, v))
fd.write(write_metadata(metadata))
fd.write('-->[/note]\n\n')
fd.write(content)
@@ -46,7 +46,7 @@
podcast_extension = None

from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, req_missing
from nikola.utils import makedirs, req_missing, write_metadata


class CompileMisaka(PageCompiler):
@@ -75,8 +75,8 @@ def compile_html(self, source, dest, is_two_file=True):

def create_post(self, path, content, onefile=False, is_page=False, **kw):
content = kw.pop('content', None)
one_file = kw.pop('one_file', False) # NOQA
is_page = kw.pop('is_page', False) # NOQA
onefile = kw.pop('onefile', False)
kw.pop('is_page', False)
metadata = OrderedDict()
metadata.update(self.default_metadata)
metadata.update(kw)
@@ -86,7 +86,6 @@ def create_post(self, path, content, onefile=False, is_page=False, **kw):
with codecs.open(path, "wb+", "utf8") as fd:
if onefile:
fd.write('<!-- \n')
for k, v in metadata.items():
fd.write('.. {0}: {1}\n'.format(k, v))
fd.write(write_metadata(metadata))
fd.write('-->\n\n')
fd.write(content)
@@ -2,6 +2,10 @@
Name = orgmode
Module = orgmode


[Nikola]
MinVersion = 6.0.0

[Documentation]
Author = Puneeth Chaganti
Version = 0.1
@@ -44,6 +44,12 @@
from nikola.plugin_categories import PageCompiler
from nikola.utils import req_missing, makedirs

# v6 compat
try:
from nikola.utils import write_metadata
except ImportError:
write_metadata = None # NOQA


class CompileOrgmode(PageCompiler):
""" Compile org-mode markup into HTML using emacs. """
@@ -71,9 +77,9 @@ def compile_html(self, source, dest, is_two_file=True):
source, e.returncode))

def create_post(self, path, onefile=False, **kw):
content = kw.pop('content', None) # NOQA
one_file = kw.pop('one_file', False) # NOQA
is_page = kw.pop('is_page', False) # NOQA
content = kw.pop('content', None)
onefile = kw.pop('onefile', False)
kw.pop('is_page', False)
metadata = OrderedDict()
metadata.update(self.default_metadata)
metadata.update(kw)
@@ -82,8 +88,14 @@ def create_post(self, path, onefile=False, **kw):
with codecs.open(path, "wb+", "utf8") as fd:
if onefile:
fd.write("#+BEGIN_COMMENT\n")
for k, v in metadata.items():
fd.write('.. {0}: {1}\n'.format(k, v))
if write_metadata:
fd.write(write_metadata(metadata))
else:
for k, v in metadata.items():
fd.write('.. {0}: {1}\n'.format(k, v))
fd.write("#+END_COMMENT\n")
fd.write("\n\n")
fd.write('Write your post here.')
if content:
fd.write(content)
else:
fd.write('Write your post here.')
@@ -2,9 +2,11 @@
Name = textile
Module = textile

[Nikola]
MinVersion = 7.0.0

[Documentation]
Author = Roberto Alsina
Version = 0.1
Website = http://getnikola.com
Description = Compile Textile into HTML

@@ -36,7 +36,7 @@
textile = None # NOQA

from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, req_missing
from nikola.utils import makedirs, req_missing, write_metadata

try:
from collections import OrderedDict
@@ -62,7 +62,10 @@ def compile_html(self, source, dest, is_two_file=True):
output = textile(data, head_offset=1)
out_file.write(output)

def create_post(self, path, content, onefile=False, is_page=False, **kw):
def create_post(self, path, **kw):
content = kw.pop('content', None)
onefile = kw.pop('onefile', False)
kw.pop('is_page', False)
metadata = OrderedDict()
metadata.update(self.default_metadata)
metadata.update(kw)
@@ -72,7 +75,6 @@ def create_post(self, path, content, onefile=False, is_page=False, **kw):
with codecs.open(path, "wb+", "utf8") as fd:
if onefile:
fd.write('<notextile> <!--\n')
for k, v in metadata.items():
fd.write('.. {0}: {1}\n'.format(k, v))
fd.write(write_metadata(metadata))
fd.write('--></notextile>\n\n')
fd.write(content)

0 comments on commit 6c52b93

Please sign in to comment.
You can’t perform that action at this time.