New style display of posts

This commit is contained in:
Manuel Ebert 2012-05-30 18:12:10 +02:00
parent 11a73b4fc2
commit d5b6d559c3
2 changed files with 12 additions and 10 deletions

View file

@ -19,18 +19,20 @@ class Entry:
def __str__(self): def __str__(self):
date_str = self.date.strftime(self.journal.config['timeformat']) date_str = self.date.strftime(self.journal.config['timeformat'])
body_wrapper = "\n" if self.body else ""
if self.journal.config['linewrap']: if self.journal.config['linewrap']:
body = body_wrapper + textwrap.fill(self.body, self.journal.config['linewrap']) title = textwrap.fill(date_str + " " + self.title, self.journal.config['linewrap'])
seplen = len(title.splitlines()[-1])
body = textwrap.fill(self.body, self.journal.config['linewrap'], initial_indent="| ", subsequent_indent="| ")
else: else:
body = body_wrapper + self.body.strip() title = date_str + " " + self.title
space = "\n" seplen = len(title)
body = self.body.strip()
separator = "\n" #+ "-"*seplen + "\n"
return "{date} {title} {body} {space}".format( return "{title}{sep}{body}\n".format(
date=date_str, title=title,
title=self.title, sep=separator if self.body else "",
body=body, body=body
space=space
) )
def __repr__(self): def __repr__(self):

View file

@ -134,7 +134,7 @@ class Journal:
def __str__(self): def __str__(self):
"""Prettyprints the journal's entries""" """Prettyprints the journal's entries"""
sep = "-"*60+"\n" sep = "\n"
pp = sep.join([str(e) for e in self.entries]) pp = sep.join([str(e) for e in self.entries])
if self.config['highlight']: # highlight tags if self.config['highlight']: # highlight tags
if self.search_tags: if self.search_tags: