def index(): posts = db((db.post.id > 0).select(orderby=~db.post.dateline) #db.post hast a body-field
for post in posts:
if len(post.body) > 1000: # Preview should be about 1000 chars
index = post.body.find("</p>", 1000, -1) + 4 # find the index of the next </p> and add 4 chars
post.body = post.body[0:index] # replace the body of the post post with short version
return dict(posts=posts)
Comments (0)