summaryrefslogtreecommitdiffstats
path: root/nikola/plugins/compile_html.py
diff options
context:
space:
mode:
Diffstat (limited to 'nikola/plugins/compile_html.py')
-rw-r--r--nikola/plugins/compile_html.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/nikola/plugins/compile_html.py b/nikola/plugins/compile_html.py
index 24e01fb..850a3e5 100644
--- a/nikola/plugins/compile_html.py
+++ b/nikola/plugins/compile_html.py
@@ -8,11 +8,11 @@
# distribute, sublicense, and/or sell copies of the
# Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice
# shall be included in all copies or substantial portions of
# the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
@@ -26,7 +26,7 @@
import os
import shutil
-
+import codecs
from nikola.plugin_categories import PageCompiler
@@ -39,6 +39,23 @@ class CompileHtml(PageCompiler):
def compile_html(self, source, dest):
try:
os.makedirs(os.path.dirname(dest))
- except:
+ except Exception:
pass
shutil.copyfile(source, dest)
+
+ def create_post(self, path, onefile=False, title="", slug="",
+ date="", tags=""):
+ d_name = os.path.dirname(path)
+ if not os.path.isdir(d_name):
+ os.makedirs(os.path.dirname(path))
+ with codecs.open(path, "wb+", "utf8") as fd:
+ if onefile:
+ fd.write('<!-- \n')
+ fd.write('.. title: %s\n' % title)
+ fd.write('.. slug: %s\n' % slug)
+ fd.write('.. date: %s\n' % date)
+ fd.write('.. tags: %s\n' % tags)
+ fd.write('.. link: \n')
+ fd.write('.. description: \n')
+ fd.write('-->\n\n')
+ fd.write("\n<p>Write your post here.</p>")