Skip to content

Commit 1295ab8

Browse files
committed
issue #24 1/2 — support 2-file posts
Signed-off-by: Chris Warrick <[email protected]>
1 parent 9341eee commit 1295ab8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Diff for: comet/web.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ def index():
482482
wants = wants_now
483483

484484
if current_user.can_edit_all_posts and wants:
485-
posts = site.posts
485+
posts = site.all_posts
486486
pages = site.pages
487487
else:
488488
wants = False
@@ -492,7 +492,7 @@ def index():
492492
if (p.meta('author.uid')
493493
and p.meta('author.uid') != str(current_user.uid)):
494494
continue
495-
if p.use_in_feeds:
495+
if p.is_post:
496496
posts.append(p)
497497
else:
498498
pages.append(p)
@@ -543,16 +543,25 @@ def edit(path):
543543
or not author_change_success):
544544
meta['author'] = post.meta('author') or current_user.realname
545545
meta['author.uid'] = post.meta('author.uid') or current_user.uid
546-
post.compiler.create_post(post.source_path, onefile=True,
546+
547+
twofile = post.is_two_file
548+
onefile = not twofile
549+
post.compiler.create_post(post.source_path, onefile=onefile,
547550
is_page=False, **meta)
551+
if twofile:
552+
meta_path = os.path.splitext(path)[0] + '.meta'
553+
with io.open(meta_path, 'w+', encoding='utf-8') as fh:
554+
fh.write(nikola.utils.write_metadata(meta))
548555
scan_site()
549556
post = find_post(path)
550557
context['action'] = 'save'
551558
context['post_content'] = meta['content']
552559
else:
553560
context['action'] = 'edit'
554561
with io.open(path, 'r', encoding='utf-8') as fh:
555-
context['post_content'] = fh.read().split('\n\n', 1)[1]
562+
context['post_content'] = fh.read()
563+
if not post.is_two_file:
564+
context['post_content'] = context['post_content'].split('\n\n', 1)[1]
556565

557566
context['post'] = post
558567
users = []

0 commit comments

Comments
 (0)