git ssb

0+

Grey the earthling / scuttleblog



Commit 0cc15bcd9a37b318d9087f8f0a7e09fee879a308

Simplify titles again

If the first line is short enough,
use it as the title and strip it from the body.

If the first list is too long,
use a truncated version as the title,
and leave the full version in the body.
Greg K Nicholson committed on 10/15/2017, 11:52:10 PM
Parent: 36dcea55c65ac21eda7d833b2616ab35da5cc6ad

Files changed

scuttleblog.pychanged
scuttleblog.pyView
@@ -63,23 +63,18 @@
6363
6464 def define_post_text(text):
6565 text = text.strip()
6666 title = text.splitlines()[0]
67- if re.match('#', text):
68- # The first line is a heading.
69- # Use it as the title and strip it from the body.
67 + maxlength = 140
68 + ellipsis = '...'
69 + if len(title) > maxlength:
70 + title = title[:maxlength].rsplit(' ', 1)[0] + ellipsis
71 + body = text
72 + else:
7073 if len(text.splitlines()) > 1:
7174 body = ''.join(text.splitlines(keepends=True)[1:]).strip()
7275 else:
7376 body = ''
74- else:
75- # Truncate the first line and use it as the title.
76- # Keep everything in the body.
77- maxlength = 100
78- ellipsis = '...'
79- if len(title) > maxlength:
80- title = title[:maxlength].rsplit(' ', 1)[0] + ellipsis
81- body = text
8277 title = re.sub('^#+\s+', '', title)
8378 return {'title': title, 'body': body}
8479
8580 def build_post_structure(p):

Built with git-ssb-web