Module: EmailerHelper

Includes:
ApplicationHelper
Included in:
ExportEmailHelper
Defined in:
app/helpers/emailer_helper.rb

Instance Method Summary collapse

Instance Method Details

#brief_citation(request, options = {}) ⇒ Object

returns a plain text short citation



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/helpers/emailer_helper.rb', line 5

def brief_citation(request, options = {})
  
  options[:include_labels] ||= false

  rv =""
  
  
  cite = request.referent.to_citation 

  title = truncate(cite[:title].strip, :length => 70,  :seperator => '...')
  
  rv << (cite[:title_label].strip + ": ")if options[:include_labels]
  rv << title
  rv << "\n"
  
  if cite[:author]  
    rv << "Author: " if options[:include_labels]
    rv << cite[:author].strip
    rv << "\n"
  end
  if cite[:subtitle]
    rv << (cite[:subtitle_label].strip + ": ") if options[:include_labels]
    rv << cite[:subtitle].strip
    rv << "\n"
  end

  pub = []
  pub << date_format(cite[:date]) unless cite[:date].blank?	
  pub << 'Vol: '+cite[:volume].strip unless cite[:volume].blank?
  pub << 'Iss: '+cite[:issue].strip unless cite[:issue].blank?	
  pub << 'p. '+cite[:page].strip unless cite[:page].blank?
  if pub.length > 0
    rv << "Published: " if options[:include_labels]
    rv << pub.join('  ')
  end
  
  return rv  
end