Module: ApplicationHelper
- Included in:
- OpieController
- Defined in:
- app/helpers/application_helper.rb
Overview
COPYRIGHT:
Copyright (c) 2005-2009 North Carolina State University
Developed with funding for the National eXtension Initiative.
LICENSE:
BSD(-compatible)
see LICENSE file or view at http://about.extension.org/wiki/LICENSE
Instance Method Summary (collapse)
- - (Object) article_summary(content)
- - (Object) expanded_time_print(time)
- - (Object) format_text_for_display(content)
- - (Object) humane_date(time)
- - (Object) is_submitter(question_response)
-
- (Object) micro_time_print(time, class_name)
old time print.
- - (Object) selected_tab_if(tab_name)
- - (Object) wrap_text(txt, col = 120)
Instance Method Details
- (Object) article_summary(content)
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/helpers/application_helper.rb', line 71 def article_summary(content) return nil unless content = Regexp.new('<p>(.+?)<\/p>', Regexp::MULTILINE) find_sum = Regexp.new(Regexp.escape('<div id="summary" class="printme toc">') + "(.*?)" + Regexp.escape("</div>"), Regexp::MULTILINE) summary_match = find_sum.match(content) if summary_match summary = summary_match[1] else match = .match(content) clean_content = match ? (match[1]) : "" summary = word_truncate(clean_content) end return summary end |
- (Object) expanded_time_print(time)
53 54 55 |
# File 'app/helpers/application_helper.rb', line 53 def (time) time.strftime("%B %d, %Y") end |
- (Object) format_text_for_display(content)
89 90 91 |
# File 'app/helpers/application_helper.rb', line 89 def format_text_for_display(content) return word_wrap(simple_format(auto_link(content, :all, :target => "_blank"))) end |
- (Object) humane_date(time)
57 58 59 60 61 62 63 |
# File 'app/helpers/application_helper.rb', line 57 def humane_date(time) if(time.blank?) '' else time.strftime("%B %e, %Y, %l:%M %p %Z") end end |
- (Object) is_submitter(question_response)
14 15 16 17 18 19 20 |
# File 'app/helpers/application_helper.rb', line 14 def is_submitter(question_response) if question_response.submitter return true else return false end end |
- (Object) micro_time_print(time, class_name)
old time print
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/helpers/application_helper.rb', line 23 def micro_time_print(time, class_name) return "" unless time day_fmt = "%Y%m%d" day_and_time_fmt = "%Y-%m-%dT%H:%M:%S" # ISO 8601 day_display = "%B %d, %Y" day_and_time_display = "%B %d, %Y at %l:%M %p" case class_name when 'published', 'updated' mformat = day_fmt mdisplay = day_display when 'dtstart' if time.hour == 0 mformat = day_fmt mdisplay = day_display else mformat = day_and_time_fmt mdisplay = day_and_time_display end when 'dtend' if time.hour == 0 mformat = day_fmt mdisplay = day_display else mformat = day_and_time_fmt mdisplay = day_and_time_display end end '<abbr class="' + class_name + '" title="' + time.strftime(mformat) + '">' + time.strftime(mdisplay) + '</abbr>' end |
- (Object) selected_tab_if(tab_name)
10 11 12 |
# File 'app/helpers/application_helper.rb', line 10 def selected_tab_if(tab_name) 'class="selected"' if @selected_tab == tab_name end |
- (Object) wrap_text(txt, col = 120)
66 67 68 69 |
# File 'app/helpers/application_helper.rb', line 66 def wrap_text(txt, col=120) txt.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/, "\\1\\3\n") end |