Skip to content
Permalink
Browse files

Fix #2380 -- copy imported two-file posts

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jun 21, 2016
1 parent 06b18f6 commit 0667520926082dccea1839efd69f9c188359275e
Showing with 16 additions and 7 deletions.
  1. +3 −0 CHANGES.txt
  2. +13 −7 nikola/plugins/command/new_post.py
@@ -9,6 +9,9 @@ Features
Bugfixes
--------

* Copy files when importing two-file posts instead of reading and
writing (useful for binary formats, eg. docx) (Issue #2380)

New in v7.7.9
=============

@@ -29,10 +29,11 @@
from __future__ import unicode_literals, print_function
import io
import datetime
import operator
import os
import sys
import shutil
import subprocess
import operator
import sys

from blinker import signal
import dateutil.tz
@@ -366,17 +367,22 @@ def _execute(self, options, args):
onefile = False
LOGGER.warn('This compiler does not support one-file posts.')

if import_file:
if onefile and import_file:
with io.open(import_file, 'r', encoding='utf-8') as fh:
content = fh.read()
else:
elif not import_file:
if is_page:
content = self.site.MESSAGES[self.site.default_lang]["Write your page here."]
else:
content = self.site.MESSAGES[self.site.default_lang]["Write your post here."]
compiler_plugin.create_post(
txt_path, content=content, onefile=onefile, title=title,
slug=slug, date=date, tags=tags, is_page=is_page, **metadata)

if (not onefile) and import_file:
# Two-file posts are copied on import (Issue #2380)
shutil.copy(import_file, txt_path)
else:
compiler_plugin.create_post(
txt_path, content=content, onefile=onefile, title=title,
slug=slug, date=date, tags=tags, is_page=is_page, **metadata)

event = dict(path=txt_path)

0 comments on commit 0667520

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