Module: BlogHelper

Defined in:
app/helpers/blog_helper.rb

Instance Method Summary collapse

Instance Method Details



46
47
48
# File 'app/helpers/blog_helper.rb', line 46

def absolutize_links html
  html.gsub /(href|src)="\//, %(\\1="http://#{@site.host}/)
end

#archive_month(params = {}) ⇒ Object



18
19
20
# File 'app/helpers/blog_helper.rb', line 18

def archive_month(params = {})
  Time.local(params[:year], params[:month]) if params[:year]
end

#articles_title(*args) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/helpers/blog_helper.rb', line 2

def articles_title(*args)
  options = args.extract_options!
  category, tags, month = *args
  month = archive_month(month) if month && !month.is_a?(Time)

  title = []
  title << "from #{month.strftime('%B %Y')}" if month
  title << "about #{category.title}" if category
  title << "tagged #{tags.to_sentence}" if tags
  
  if title.present?
    title = "Articles #{title.join(', ')}"
    options[:format] ? raw(options[:format]) % title : title
  end
end

#blog_article_path(section, article, options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/blog_helper.rb', line 22

def blog_article_path section, article, options={}
  if article.published_at
    super :section_permalink => section.permalink,
      :year => article.published_at.year,
      :month => article.published_at.month,
      :day => article.published_at.day,
      :permalink => article.permalink
  else
    unpublished_blog_article_path section, article
  end
end

#blog_article_url(section, article, options = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'app/helpers/blog_helper.rb', line 34

def blog_article_url section, article, options={}
  if article.published_at
    super :section_permalink => section.permalink,
      :year => article.published_at.year,
      :month => article.published_at.month,
      :day => article.published_at.day,
      :permalink => article.permalink
  else
    unpublished_blog_article_url section, article
  end
end