diff options
| author | 2014-06-13 21:51:04 -0300 | |
|---|---|---|
| committer | 2014-06-13 21:51:04 -0300 | |
| commit | 3dddbd8cc879402c2047919bccd20e6697082657 (patch) | |
| tree | 38d6290f37be1d67d91c46027974e6ee3372e232 /nikola/plugins/compile/php.py | |
| parent | 7ac2cf148f7a8ea0de126fed3360b49964ce9b45 (diff) | |
| parent | 58c4878526dec5510f23c812274686787d8724ba (diff) | |
Merge tag 'upstream/7.0.1'
Upstream version 7.0.1
Diffstat (limited to 'nikola/plugins/compile/php.py')
| -rw-r--r-- | nikola/plugins/compile/php.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/nikola/plugins/compile/php.py b/nikola/plugins/compile/php.py index 0a652a6..601f098 100644 --- a/nikola/plugins/compile/php.py +++ b/nikola/plugins/compile/php.py @@ -33,12 +33,7 @@ import shutil import codecs from nikola.plugin_categories import PageCompiler -from nikola.utils import makedirs - -try: - from collections import OrderedDict -except ImportError: - OrderedDict = dict # NOQA +from nikola.utils import makedirs, write_metadata class CompilePhp(PageCompiler): @@ -50,18 +45,23 @@ class CompilePhp(PageCompiler): makedirs(os.path.dirname(dest)) shutil.copyfile(source, dest) - 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) os.makedirs(os.path.dirname(path)) + if not content.endswith('\n'): + content += '\n' 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('<!--\n') + fd.write(write_metadata(metadata)) fd.write('-->\n\n') - fd.write("\n<p>Write your {0} here.</p>".format('page' if is_page else 'post')) + fd.write(content) def extension(self): return ".php" |
