Module: CartoonistHelper

Defined in:
app/helpers/cartoonist_helper.rb

Instance Method Summary collapse

Instance Method Details

#checked(a, b = true) ⇒ Object



17
18
19
20
21
# File 'app/helpers/cartoonist_helper.rb', line 17

def checked(a, b = true)
  if a == b
    'checked="checked"'.html_safe
  end
end

#content_license_urlObject



67
68
69
# File 'app/helpers/cartoonist_helper.rb', line 67

def content_license_url
  "http://creativecommons.org/licenses/by-nc/3.0/"
end


71
72
73
74
75
76
# File 'app/helpers/cartoonist_helper.rb', line 71

def copyright_message
  year = Date.today.strftime "%Y"
  copyright_years = Setting[:copyright_starting_year].to_s
  copyright_years = "#{copyright_years}-#{year}" if year != copyright_years
  "© #{h copyright_years} #{h Setting[:copyright_owners]}".html_safe
end

#enable_disqus!(options) ⇒ Object



58
59
60
61
# File 'app/helpers/cartoonist_helper.rb', line 58

def enable_disqus!(options)
  @disqus_enabled = true
  @disqus_options = options
end

#format_time(time, fmt) ⇒ Object



23
24
25
26
27
# File 'app/helpers/cartoonist_helper.rb', line 23

def format_time(time, fmt)
  if time
    time.localtime.strftime fmt
  end
end

#licensed!Object



33
34
35
# File 'app/helpers/cartoonist_helper.rb', line 33

def licensed!
  @licensed = true
end

#licensed?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/helpers/cartoonist_helper.rb', line 37

def licensed?
  @licensed
end

#markdown(text) ⇒ Object



29
30
31
# File 'app/helpers/cartoonist_helper.rb', line 29

def markdown(text)
  Markdown.render text
end

#partial(name, locals = {}, &block) ⇒ Object



2
3
4
5
6
7
8
9
# File 'app/helpers/cartoonist_helper.rb', line 2

def partial(name, locals = {}, &block)
  if block
    raise "Cannot have a 'body' local when a block is given!" if locals.include?(:body)
    locals[:body] = capture &block
  end

  render :partial => name, :locals => locals
end

#preview?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'app/helpers/cartoonist_helper.rb', line 63

def preview?
  @for_preview
end

#rss!(path, title) ⇒ Object



41
42
43
44
# File 'app/helpers/cartoonist_helper.rb', line 41

def rss!(path, title)
  @rss_path = path
  @rss_title = title
end

#rss?Boolean

Returns:

  • (Boolean)


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

def rss?
  @rss_path
end

#rss_pathObject



50
51
52
# File 'app/helpers/cartoonist_helper.rb', line 50

def rss_path
  @rss_path
end

#rss_titleObject



54
55
56
# File 'app/helpers/cartoonist_helper.rb', line 54

def rss_title
  @rss_title
end

#selected(a, b = true) ⇒ Object



11
12
13
14
15
# File 'app/helpers/cartoonist_helper.rb', line 11

def selected(a, b = true)
  if a == b
    'selected="selected"'.html_safe
  end
end