Created
October 18, 2008 06:29
-
-
Save wfarr/17619 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Merb | |
| module PostsHelper | |
| def generate_post_link(post) | |
| "posts/view/#{post.id}-#{post.slug}" | |
| end | |
| def generate_post_date(post) | |
| "Posted #{print_date(post.created_at)}" | |
| end | |
| def generate_post_small(post) | |
| para = paragraphs(post.content)[0...3] | |
| para = paragraphs(post.content)[0..4] if para.first[0] == ?$ | |
| para.slice! -1 if para[-1] && para[-1][0] == ?! | |
| return para.join("\r\n\r\n") | |
| end | |
| private | |
| def print_date(date) | |
| date.strftime('%d %b %Y') | |
| end | |
| def paragraphs(content) | |
| @paragraphs ||= content.split(/\r?\n\r?\n/) | |
| end | |
| end | |
| end # Merb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment