Modifying excerpts

19 views
Skip to first unread message

Joes Staal

unread,
Nov 18, 2012, 8:07:29 AM11/18/12
to blogofil...@googlegroups.com
Hi,

I've been playing around with blogofile for the last couples of days and I've got the feeling I am not understanding something correctly.
I want to modify the excerpt function by setting adding a line <!--readmore--> in my posts (all written in markdown). It wasn't difficult to get that to work, I just had to add/change the following in _config.py:

# Overrule the excerpt function from blogofile itself.
def excerpt(content, num=0):
    index = content.find('<!--readmore-->')
    if (index != -1):
        return content[:index]
    else:
        return content

blog.post_excerpts.method = excerpt
blog.post_excerpts.enabled = True

So far so good. But the next step I want to take is to have a 'Read more' link under the post that links to the full post. I can't find out how to realise that and any pointers would be much appreciated.

Cheers,

Joes

Péter Zsoldos

unread,
Nov 18, 2012, 10:32:04 AM11/18/12
to blogofil...@googlegroups.com
Hi,

On Sun, Nov 18, 2012 at 2:07 PM, Joes Staal <joes....@gmail.com> wrote:
[...]
So far so good. But the next step I want to take is to have a 'Read more' link under the post that links to the full post. I can't find out how to realise that and any pointers would be much appreciated.


I would modify the templates where the excerpts should show, e.g.: _templates/blog/archive_index.mako or _templates/blog/chronological.mako.

Inside the template I'd then have something like this:
<article>
<h2>${post.title}</h2>
<p>${post.excerpt}</p>
<p><a href="${post.permapath()}">Read more</a></p>
</article>

HTH,

Peter
--
http://www.linkedin.com/in/zsoldosp :::: http://zsoldosp.blogspot.com :::: http://twitter.com/zsepi

Doug Latornell

unread,
Nov 18, 2012, 2:02:58 PM11/18/12
to blogofil...@googlegroups.com
On Sun, Nov 18, 2012 at 7:32 AM, Péter Zsoldos <peter....@gmail.com> wrote:
Hi,

On Sun, Nov 18, 2012 at 2:07 PM, Joes Staal <joes....@gmail.com> wrote:
[...]
So far so good. But the next step I want to take is to have a 'Read more' link under the post that links to the full post. I can't find out how to realise that and any pointers would be much appreciated.


I would modify the templates where the excerpts should show, e.g.: _templates/blog/archive_index.mako or _templates/blog/chronological.mako.

Inside the template I'd then have something like this:
<article>
<h2>${post.title}</h2>
<p>${post.excerpt}</p>
<p><a href="${post.permapath()}">Read more</a></p>
</article>

Yep, that should work. FWIW post.path is a synonym for post.permapath().
 

Joes Staal

unread,
Nov 18, 2012, 4:02:32 PM11/18/12
to blogofil...@googlegroups.com, d...@douglatornell.ca
Excellent, thank you very much, that does the trick.
I have no experience with the template system, so I am learning on the job.

Thx,

Joes
Reply all
Reply to author
Forward
0 new messages