From 6363199b91bd75ccd9e647740501053d9fc9b0d5 Mon Sep 17 00:00:00 2001 From: Chris Warrick Date: Mon, 1 Aug 2016 09:29:59 +0200 Subject: [PATCH] Fix #2420 -- use new_post path for meta files, too Signed-off-by: Chris Warrick --- CHANGES.txt | 2 ++ nikola/plugins/command/new_post.py | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index a7a386c809..88e81be045 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -11,6 +11,8 @@ Features Bugfixes -------- +* Put 2-file post metadata in the same place as the text file when + specifying a path in ``new_post``, ``new_page`` (Issue #2420) * Register dependencies in post-list shortcode (Issue #2412) * Support post-list shortcode better (Issue #2408) * Fix gallery links in base theme (Issue #2416) diff --git a/nikola/plugins/command/new_post.py b/nikola/plugins/command/new_post.py index af4d44bd91..36cc04f3dd 100644 --- a/nikola/plugins/command/new_post.py +++ b/nikola/plugins/command/new_post.py @@ -325,14 +325,17 @@ def _execute(self, options, args): 'description': '', 'type': 'text', } - output_path = os.path.dirname(entry[0]) - meta_path = os.path.join(output_path, slug + ".meta") - pattern = os.path.basename(entry[0]) - suffix = pattern[1:] + if not path: + pattern = os.path.basename(entry[0]) + suffix = pattern[1:] + output_path = os.path.dirname(entry[0]) + txt_path = os.path.join(output_path, slug + suffix) + meta_path = os.path.join(output_path, slug + ".meta") else: txt_path = os.path.join(self.site.original_cwd, path) + meta_path = os.path.splitext(txt_path)[0] + ".meta" if (not onefile and os.path.isfile(meta_path)) or \ os.path.isfile(txt_path):