| OLD | NEW |
| 1 # Methods added to this helper will be available to all templates in the applica
tion. | 1 # Methods added to this helper will be available to all templates in the applica
tion. |
| 2 module ApplicationHelper | 2 module ApplicationHelper |
| 3 | 3 |
| 4 def render_array_of_partials(array) | 4 def render_array_of_partials(array) |
| 5 return if array.nil? | 5 return if array.nil? |
| 6 buf = "" | 6 buf = "" |
| 7 for partial in array | 7 for partial in array |
| 8 buf << render(:partial => partial) | 8 buf << render(:partial => partial) |
| 9 end | 9 end |
| 10 buf | 10 buf |
| (...skipping 24 matching lines...) Show 10 above Show 10 below |
| 35 "#{size} #{word}s" | 35 "#{size} #{word}s" |
| 36 end | 36 end |
| 37 end | 37 end |
| 38 | 38 |
| 39 def nil_if_blank(string) | 39 def nil_if_blank(string) |
| 40 return nil if string.blank? | 40 return nil if string.blank? |
| 41 string | 41 string |
| 42 end | 42 end |
| 43 | 43 |
| 44 def link_to_tag(tag) | 44 def link_to_tag(tag) |
| 45 references = tag.news_items_count | 45 references = tag.news_items.count |
| 46 styles = [] | 46 styles = [] |
| 47 styles << 'font-weight:' + ((references > 1) ? 'bold' : 'normal') | 47 styles << 'font-weight:' + ((references > 1) ? 'bold' : 'normal') |
| 48 styles << 'font-size:9pt' if references <= 2 | 48 styles << 'font-size:9pt' if references <= 2 |
| 49 styles << 'font-size:' + (9 + references).to_s + 'pt' if references > 2 | 49 styles << 'font-size:' + (9 + references).to_s + 'pt' if references > 2 |
| 50 html = link_to(tag.name, | 50 html = link_to(tag.name, |
| 51 {:controller => 'news', :action => 'search', 'search[tags]' => tag.name}, | 51 {:controller => 'news', :action => 'search', 'search[tags]' => tag.name}, |
| 52 {:style => styles.join(';')}) | 52 {:style => styles.join(';')}) |
| 53 (references > 0) ? html : '' | 53 (references > 0) ? html : '' |
| 54 end | 54 end |
| 55 | 55 |
| 56 def interpose(text) | 56 def interpose(text) |
| 57 new_text = text.dup | 57 new_text = text.dup |
| 58 new_text.gsub!("[SIGNIN]", link_to("Sign In", :controller => 'account', :act
ion => 'login')) | 58 new_text.gsub!("[SIGNIN]", link_to("Sign In", :controller => 'account', :act
ion => 'login')) |
| 59 new_text.gsub!("[REGISTER]", link_to("Register", :controller => 'account', :
action => 'signup')) | 59 new_text.gsub!("[REGISTER]", link_to("Register", :controller => 'account', :
action => 'signup')) |
| 60 new_text | 60 new_text |
| 61 end | 61 end |
| 62 end | 62 end |
| OLD | NEW |