def cb_prepare( app ) if app.isHomePage?( app['PATH_INFO'] ) app['entries'].each { |entry| content = entry['body'] entry['fullbody'] = content entry['body'] = generateSummary( content ) } end end def generateSummary( body ) body = body.gsub( /<[^>]+>/, '' ) words = body.scan( /[^\s]+/ ) words = words.slice( 0, [20, words.length].min ) return "

%s...

" % words.join( " " ) end