Module ApplicationHelper
In: app/helpers/application_helper.rb

Methods added to this helper will be available to all templates in the application.

Methods

Public Class methods

[Source]

     # File app/helpers/application_helper.rb, line 736
736:   def self.add_url_method(method_id)
737:     eval "      def \#{method_id}(*arguments)\n        @controller.\#{method_id}(*arguments)\n      end\n"
738:   end

Public Instance methods

Hands over the links of the logi-version to the weaver.

[Source]

     # File app/helpers/application_helper.rb, line 256
256:   def add_popover_listings_to_weaver(weaver, logi_version, options)
257:     logi = logi_version.logi
258:     p_r_list = logi.from_links.position_range_list_translated(logi_version)
259:     p_r_list.concat(logi.external_links.position_range_list_translated(logi_version))
260:     p_r_list.concat(logi.annotations.position_range_list_translated(logi_version))
261:     p_r_clusters = p_r_list.cluster_overlaps
262: 
263:     p_r_clusters.each do |p_r_cluster|
264:       first_p_r = p_r_cluster.first
265:       links = []
266:       external_links = []
267:       annotations = []
268:       p_r_cluster.each {|p_r|
269:         if p_r.link
270:           links << p_r.link
271:         end
272:         if p_r.external_link
273:           external_links << p_r.external_link
274:         end
275:         if p_r.annotation
276:           annotations << p_r.annotation
277:         end
278:       }
279:       opening, closing = popovers_listing_opening_closing(
280:           :links => links, :external_links => external_links,
281:           :annotations => annotations)
282:       weaver.next_set
283:       weaver.add_opening(first_p_r.first, opening)
284:       weaver.add_closing(first_p_r.last, closing)
285:     end
286:   end

[Source]

     # File app/helpers/application_helper.rb, line 139
139:   def add_simple_history(tag_list_name, url_name, tags_string)
140:     page << add_simple_history_string(tag_list_name, url_name, tags_string)
141:   end

[Source]

     # File app/helpers/application_helper.rb, line 143
143:   def add_simple_history_string(tag_list_name, url_name, tags_string)
144:     return %[dhtmlHistory.add("#{url_name}", "#{tag_list_name}.replace_tags_string('#{tags_string}'); #{tag_list_name}.submit();")]
145:   end

[Source]

     # File app/helpers/application_helper.rb, line 690
690:   def back_button(text = nil)
691:     text ||= t('defaults.back')
692:     button_to text, self.return_url_or_default, :class => 'back_button'
693:   end

Contending logis

[Source]

     # File app/helpers/application_helper.rb, line 220
220:   def band_of_contender_logis(logi, contender_logis)
221:     i = contender_logis.index(logi)
222:     if i and i > 1 and contender_logis.size > 3
223:       endi = [(contender_logis.size - 1), i + 1].min
224:       begi = endi - 2
225:       return contender_logis[begi..endi]
226:     else
227:       return contender_logis
228:     end
229:   end

[Source]

     # File app/helpers/application_helper.rb, line 765
765:   def browse_ll_link(link, link_options = {}, options = {}, html_options = {})
766:     options[:length] ||= 50
767:     if options[:text]
768:       text = options[:text]
769:       options.delete(:text)
770:     else
771:       text = link.to_s(link_options.merge(:for => :show, :step => -1))
772:     end
773:     text = self.pre_truncate_options(text, options)
774:     link_to text, @controller.browse_ll_url(link, link_options, options), 
775:         html_options.merge(:class => link_class(link,
776:                 link_options[:direction]) +
777:             ' logilogi_link')
778:   end

[Source]

     # File app/helpers/application_helper.rb, line 628
628:   def by_author(author, options = {})
629:     options[:length] ||= 30
630:     return '<span class="author"><em>' + t('h.application.by_label') + 
631:         '</em> ' + user_link(author, options) +
632:         '</span>'
633:   end

[Source]

     # File app/helpers/application_helper.rb, line 684
684:   def cancel_button(options = {})
685:     options[:text] ||= t('defaults.cancel')
686:     options[:url] ||= self.return_url_or_default
687:     button_to options[:text], options[:url], :class => 'cancel_button'
688:   end

Javascript compression

[Source]

    # File app/helpers/application_helper.rb, line 25
25:   def compressed_javascript_include_tag(*sources)
26:     tag_string = javascript_include_tag(*sources)
27: 
28:     options = sources.extract_options!.stringify_keys
29:     cache   = options.delete("cache")
30: 
31:     js_path = File.join(
32:         ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')
33:     if ActionController::Base.perform_caching && cache && 
34:         !File.exists?(js_path + '.js')
35:       raise "error compressing javascripts: '" + js_path +
36:           "' doesn't exist!" unless (File.exists?(js_path))
37:       %x[ruby lib/jsmin.rb < #{js_path} > #{js_path + '.tmp'}]
38:       raise "error compressing javascripts: '" + js_path +
39:           ".tmp' doesn't exist or is empty!" unless (
40:               File.size?(js_path + '.tmp'))
41:       Zlib::GzipWriter.open(js_path + '.gz') do |gz|
42:         gz.write File.read(js_path + '.tmp').to_s
43:         gz.close
44:       end
45:       raise "error compressing javascripts: '" + js_path + 
46:           ".gz' doesn't exist!" unless (File.exists?(js_path + '.gz'))
47:       File.delete(js_path)
48:       File.delete(js_path + '.tmp')
49:     end
50: 
51:     return tag_string
52:   end

Assumed width 63.

Very simple / basic at the moment.

[Source]

     # File app/helpers/application_helper.rb, line 658
658:   def count_rows(text)
659:     return text.size / 31 + 6
660:   end

[Source]

     # File app/helpers/application_helper.rb, line 383
383:   def crosses_or_stars_title(score)
384:     if score > -1 and score < 1
385:       score = score.round
386:     end
387:     if score > 0
388:       score = score.floor
389:       return self.stars_title(score)
390:     elsif score < 0
391:       score = score.ceil
392:       return self.crosses_title(score)
393:     else
394:       t('h.application.no_stars_nor_crosses_label') + ' ' + 
395:           t(Const::Rating::SCORES[score])
396:     end
397:   end

[Source]

     # File app/helpers/application_helper.rb, line 373
373:   def crosses_title(score)
374:     return t('h.application.crosses_label', :count => (-1 * score)) + ' ' + 
375:         t(Const::Rating::SCORES[score])
376:   end

[Source]

     # File app/helpers/application_helper.rb, line 347
347:   def current_user
348:     return @controller.current_user
349:   end

[Source]

     # File app/helpers/application_helper.rb, line 558
558:   def display_standard_flashes
559:     flashes = []
560:     if flash[:error]
561:       flashes << [t('h.application.error_label') + ' ' + flash[:error], 'error']
562:     end
563:     if flash[:warning]
564:       flashes << [flash[:warning], 'warning']
565:     end
566:     if flash[:notice]
567:       flashes << [flash[:notice], 'notice']
568:     end
569:     if flashes.empty?
570:       return
571:     end
572:     content = flashes.collect { |flash_arr|
573:       content_tag('h2', t('v.application.' + flash_arr[1])) +
574:       content_tag('p', flash_arr[0], :class => "#{flash_arr[1]}")
575:     }
576:     content.join('')
577:   end

[Source]

     # File app/helpers/application_helper.rb, line 147
147:   def edit_tabs
148:     logi = current_context.link.volatile_to_logi
149:     tabs = [{:text => t('h.application.edit_text'), :name => "edit_text",
150:                 :description => t('h.application.editing_text')},
151:             {:text => t('h.application.edit_settings'), :name => "edit_settings",
152:                 :description => t('h.application.editing_settings')}]
153: 
154:     if logi.edit_rights?(current_user)
155:       tabs[0][:url] = edit_logi_url(logi)
156:     end
157:     if logi.admin_rights?(current_user)
158:       tabs[1][:url] = edit_logi_logi_settings_url(logi)
159:     end
160:     return tabs
161:   end

[Source]

     # File app/helpers/application_helper.rb, line 830
830:   def edit_user_url(user, options = {})
831:     @controller.edit_user_url(user, options)
832:   end

[Source]

     # File app/helpers/application_helper.rb, line 601
601:   def error_messages_for(object_name, options = {})
602:     options = options.symbolize_keys
603:     name = t('activerecord.models.' + (options[:object_name] || object_name.dup).downcase)
604:     name.gsub!("_"," ")
605:     object = instance_variable_get("@#{object_name}")
606:     unless object.errors.empty?
607:       content_tag("div",
608:         content_tag('h2', t('v.application.error')) +
609:         content_tag(
610:           "p",
611:           t('activerecord.errors.template.header', :count => object.errors.size,
612:               :model => name)
613:         ) +
614:         content_tag("p", t('h.application.following_fields')) +
615:         content_tag("ul", object.errors.full_messages.collect { |msg| 
616:             content_tag("li", msg) }.join),
617:         "id" => options[:id] || "error_explanation",
618:             "class" => options[:class] || "error_explanation"
619:       )
620:     end
621:   end

[Source]

    # File app/helpers/application_helper.rb, line 18
18:     def gravatar_for(bogus, options = {})
19:       "<img class=\"#{options[:class]}\" alt=\"#{options[:alt]}\" width=\"#{options[:size]}\" height=\"#{options[:size]}\" src=\"/images/user_default_avatar.png\" />"
20:     end

Time ago

[Source]

     # File app/helpers/application_helper.rb, line 507
507:   def hours_or_minutes_ago(days_ago, minutes)
508:     if days_ago == 0
509:       return case minutes
510:              when 0
511:                t('h.application.less_than_minute')
512:              when 1..60
513:                t('h.application.minutes_ago', :count => (minutes % 60))
514:              else
515:                t('h.application.hours_ago', :count => (minutes / 60).floor)
516:              end
517:     else
518:       return t('h.application.and_hours_ago', :count => (minutes / 60).floor)
519:     end
520:   end

[Source]

     # File app/helpers/application_helper.rb, line 163
163:   def insert_tabs
164:     logi = current_context.link.volatile_to_logi
165:     tabs = [{:text => t('h.application.insert_insert'), :name => "insert_insert",
166:                 :url => new_logi_logi_inserts_url(logi),
167:                 :description => t('h.application.insert_inserting')},
168:             {:text => t('h.application.remove'), :name => "insert_remove",
169:                 :url => edit_logi_annotations_url(logi),
170:                 :description => t('h.application.removing')}]
171:     return tabs
172:   end

Returns the resolv-status-class for the link in the given direction.

Used for coloring links depending on whether a Logi was found for them.

[Source]

     # File app/helpers/application_helper.rb, line 667
667:   def link_class(link, direction = nil)
668:     direction ||= :requested
669:     if link.resolved?
670:       case direction
671:       when :requested
672:         return (link.found_logi? ? "found-" : "notfound-") +
673:             (link.exact_match? ? "reqisrec" : "reqisnotrec")
674:       when :received
675:         return (link.found_logi? ? "found-" : "notfound-") + "reqisrec"
676:       else
677:         raise StandardError.new, t('h.application.error_direction')
678:       end
679:     else
680:       return "unresolved"
681:     end
682:   end

[Source]

     # File app/helpers/application_helper.rb, line 453
453:   def link_to_cloud_tag(tag, css_class)
454:     return link_to_cloud_tag_element(tag.to_s(:for => :show),
455:         @controller.tag_ll_url(tag), css_class)
456:   end

[Source]

     # File app/helpers/application_helper.rb, line 458
458:   def link_to_cloud_tag_element(text, link, css_class, *args)
459:     return '<div class="floated_rounded_wrapper">' + link_to_rounded(text, 
460:         link, 'tag cloud_tag link_tag ' + css_class, 25, *args) + '</div>'
461:   end

[Source]

     # File app/helpers/application_helper.rb, line 479
479:   def link_to_js_rounded(text, javascript, css_class, options = {})
480:     return '<div class="' + css_class + 
481:         '" onclick="' + javascript + '; return false">' +
482:         '<div class="content_padding">' + text + '</div></div>'
483:   end

[Source]

     # File app/helpers/application_helper.rb, line 467
467:   def link_to_navigation_author(text, link, *args)
468:     return link_to_rounded(text, link, 'author', 35, *args)
469:   end

[Source]

     # File app/helpers/application_helper.rb, line 463
463:   def link_to_navigation_tag(text, link, *args)
464:     return link_to_rounded(text, link, 'tag link_tag', 25, *args)
465:   end

if changed also change in lib/application_view

[Source]

     # File app/helpers/application_helper.rb, line 472
472:   def link_to_rounded(text, link, css_class, length, options = {})
473:     return '<div class="' + css_class + 
474:         '" onclick="location.href = \'' + link + '\'; return false">' +
475:         '<div class="content_padding"><a href="' + link + '">' +
476:         truncate(text, :length => length) + '</a></div></div>'
477:   end

[Source]

     # File app/helpers/application_helper.rb, line 443
443:   def link_to_suggested_cloud_tag(tag, css_class, tag_list_js_name)
444:     js = tag_list_js_name + '.add_tag_string(\'' + 
445:         tag.to_s(:for => :show) + '\'); ' + 
446:         tag_list_js_name + '.submit()'
447:     return '<div class="floated_rounded_wrapper">' + link_to_js_rounded(
448:         tag.to_s(:for => :show), js, 'tag cloud_tag ' + 
449:             (current_context.tags? ? 'add_tag icon_tag' : 'link_tag') + ' ' +
450:             css_class) + '</div>'
451:   end

Returns a html link.

Used for easily linking via logi-links.

[Source]

     # File app/helpers/application_helper.rb, line 749
749:   def ll_link(link, link_options = {}, options = {}, html_options = {})
750:     options[:length] ||= 50
751:     if options[:show] == :title
752:       text = self.truncate_options(link.volatile_to_logi.current_title, options)
753:     else
754:       options[:show] ||= :show
755:       text = self.pre_truncate_options(
756:           link.to_s(link_options.merge(:for => options[:show])), options)
757:     end
758:     options.delete(:show)
759:     link_to text, @controller.ll_url(link, link_options, options),
760:         html_options.merge(:class => link_class(link, 
761:                 link_options[:direction]) +
762:             ' logilogi_link')
763:   end

[Source]

     # File app/helpers/application_helper.rb, line 366
366:   def log_log_feed_link(options = {})
367:     if GlobalConfig.use_log_log?
368:       url = log_log_link(options.merge(:controller => 'feed'))
369:       '<div class="rss_link">' + link_to(image_tag('rss.png'), url) + '</div>'
370:     end
371:   end

[Source]

     # File app/helpers/application_helper.rb, line 355
355:   def log_log_link(options = {})
356:     if GlobalConfig.use_log_log?
357:       if options[:controller] == 'feed' and options[:channel]
358:         GlobalConfig.log_log_site + "/channels/" + options[:channel] + 
359:             "/feed.atom"
360:       else
361:         raise 'Missing attr'
362:       end
363:     end
364:   end

[Source]

     # File app/helpers/application_helper.rb, line 795
795:   def logi_extended_link(logi, options = {}, html_options = {})
796:     options[:length] ||= 60
797:     return gravatar_for(logi.creator, :class => 'extended', :size => 18) + 
798:         '<div class="extended">' +
799:         logi_ll_link(logi, :length => (options[:length] / 3.0)) +
800:         ' - ' + logi_ll_link(logi, :show => :title,
801:             :length => (options[:length] * 2 / 3.0)) + 
802:             '</div><div class="spacer"></div>'
803:   end

[Source]

     # File app/helpers/application_helper.rb, line 780
780:   def logi_ll_link(logi, options = {}, html_options = {})
781:     options[:length] ||= 40
782:     if options[:show] == :title
783:       text = self.truncate_options(logi.current_title, options)
784:     elsif options[:show] == :link
785:       text = self.pre_truncate_options(
786:           logi.link.to_s(:for => :use, :direction => :received, 
787:               :step => -1), options)
788:     else
789:       text = self.pre_truncate_options(logi.to_s(:for => :show), options)
790:     end
791:     link_to text, @controller.logi_ll_url(logi,
792:         :anchor => options[:anchor]), html_options
793:   end

[Source]

     # File app/helpers/application_helper.rb, line 805
805:   def logi_version_ll_link(logi_version, options = {}, html_options = {})
806:     text = 'version ' + logi_version.nr.to_s
807:     link_to text, @controller.logi_version_ll_url(logi_version), html_options
808:   end

Score images

[Source]

     # File app/helpers/application_helper.rb, line 498
498:   def medal(percentile)
499:     return '<div class="score_image score_image_laurel1">' +
500:         image_tag(medal_url(:percentile => percentile.to_i,
501:             :format => 'png'), :size => '90x90') +
502:         '</div>'
503:   end

Urls & Sub-urls of logi

Automatically hands to the controller stuff like ll_url browse_logis_url logi_ratings_url

Happily keeping DRY :)

[Source]

     # File app/helpers/application_helper.rb, line 727
727:   def method_missing(method_id, *arguments)
728:     if method_id.to_s =~ /_(url|path)$/
729:       ApplicationHelper.add_url_method(method_id)
730:       self.send(method_id, *arguments)
731:     else
732:       super(method_id, *arguments)
733:     end
734:   end

[Source]

     # File app/helpers/application_helper.rb, line 695
695:   def new_logi_button(text = nil)
696:     text ||= t('h.application.create_new_logi')
697:     button_to text, new_logi_url(), :class => 'go_button'
698:   end

[Source]

     # File app/helpers/application_helper.rb, line 125
125:   def new_side_menu_tabs
126:     logi = current_context.link.volatile_to_logi
127:     tabs = []
128: 
129:     tabs.push(
130:         {:text => t('h.application.contenders'), :name => "contending_logis",
131:             :description => t('h.application.competing_for')})
132:     tabs.push(
133:         {:text => t('h.application.incoming'), :name => "incoming_links",
134:             :description => t('h.application.links_to'),
135:             :disabled => current_context.incoming_links_to_logi.empty?})
136:     return tabs
137:   end

[Source]

     # File app/helpers/application_helper.rb, line 201
201:   def panel_tab_ajax_links(tabs, update)
202:     tabs.each_with_index do |tab, i|
203:       if !tab[:disabled] 
204:         if current_context.link?
205:           url = {:ll_link_string => current_context.link.to_s}
206:         else
207:           url = {}
208:         end
209:         tabs[i][:link] = link_to_remote(tab[:text], :update => update,
210:             :url => url.update(:selected => tab[:name]), :method => :get)
211:       else
212:         tabs[i][:link] = '<span>' + tab[:text] + '</span>'
213:       end
214:     end
215:     return tabs
216:   end

[Source]

     # File app/helpers/application_helper.rb, line 189
189:   def panel_tab_links(tabs)
190:     tabs.each_with_index do |tab, i|
191:       if tab[:url] 
192:         tabs[i][:link] = link_to(tab[:text], tab[:url])
193:       else
194:         tabs[i][:link] = '<span>' + tab[:text] + '</span>'
195:         tabs[i][:disabled] = true
196:       end
197:     end
198:     return tabs
199:   end

Boxes

[Source]

    # File app/helpers/application_helper.rb, line 56
56:   def panel_type_class(type_sym)
57:     if !type_sym.nil?
58:       return " panel_type_" + type_sym.to_s
59:     else
60:       return ""
61:     end
62:   end

[Source]

     # File app/helpers/application_helper.rb, line 850
850:   def peer_group_ll_link(peer_group, options = {}, html_options = {})
851:     link_to truncate_options(peer_group.name, options), @controller.peer_group_ll_url(peer_group),
852:         html_options.merge(:class => ' peer_group_ll_link')
853:   end

[Source]

     # File app/helpers/application_helper.rb, line 409
409:   def percentile_category(percentile)
410:     if percentile < 50
411:       return 1
412:     elsif percentile < 95
413:       return ((percentile - 20) / 15.0).floor
414:     else
415:       return 5
416:     end
417:   end

[Source]

     # File app/helpers/application_helper.rb, line 399
399:   def percentile_in_words(percentile)
400:     category = percentile_category(percentile)
401:     if category < 2
402:       # I18n because called from lib
403:       return I18n.t('m.const.just_began')
404:     else
405:       return I18n.t(Const::Rating::SCORES[category])
406:     end
407:   end

Perma-links

[Source]

    # File app/helpers/application_helper.rb, line 74
74:   def perma_links(logi, logi_version)
75:     return '<div class="perma_link">' +
76:         link_to(image_tag('perma.png') + ' ' + 
77:             t('h.application.copy_perma_link'),
78:             perma_logi_ll_url(logi),
79:             :onclick => "copyPerma('" + perma_logi_ll_url(logi) + "'," +
80:                 "'" + t('h.application.perma_link_label') + 
81:                 "'); return false;") + ' ' +
82:         link_to(t('h.application.to_version'),
83:             perma_logi_version_ll_url(logi_version),
84:             :onclick => "copyPerma('" + 
85:                 perma_logi_version_ll_url(logi_version) + "'," +
86:                 "'" + t('h.application.versioned_perma_link_label') +
87:                 "'); return false;") +
88:         '</div>'
89:   end

[Source]

     # File app/helpers/application_helper.rb, line 288
288:   def popover_listing(text, options)
289:     if options[:link]
290:       new_options = {:links => [options[:link]]}
291:     elsif options[:external_link]
292:       new_options = {:external_links => [options[:external_link]]}
293:     else
294:       new_options = {:annotations => [options[:annotation]]}
295:     end
296:     opening, closing = popovers_listing_opening_closing(new_options)
297:     return opening + text + closing
298:   end

[Source]

     # File app/helpers/application_helper.rb, line 300
300:   def popovers_listing_opening_closing(options)
301:     # Selects the best link
302:     if options[:links] and !options[:links].empty?
303:       best_link = options[:links].select_by_volatile_to_logi.
304:       order_by_volatile_to_logi_dot_rating_for(options[:peer_group]).first
305:       best_link ||= options[:links].first
306:       # none is found for the peergroup, take the first
307:       href = ll_url(best_link, options)
308:       title = best_link.to_s(options.merge(:for => :show))
309:       css_class = ' logilogi_link ' + link_class(best_link)
310:     elsif options[:external_links] and !options[:external_links].empty?
311:       href = options[:external_links].first.url
312:       title = options[:external_links].first.text
313:       css_class = ' logilogi_link'
314:     else
315:       href = '#'
316:       title = ''
317:       css_class = ''
318:     end
319:     url = '/do/popovers/listing?'
320:     if options[:links] and !options[:links].empty?
321:       url += '&link_ids=' + options[:links].collect {|link| 
322:           link.id.to_s}.join(',')
323:     end
324:     if options[:external_links] and !options[:external_links].empty?
325:       url += '&external_link_ids=' + options[:external_links].
326:           collect {|external_link| external_link.id.to_s}.join(',')
327:     end
328:     if options[:annotations] and !options[:annotations].empty?
329:       css_class += ' logilogi_annotation'
330:       url += '&annotation_ids=' + options[:annotations].collect {|annotation|
331:           annotation.id.to_s}.join(',')
332:     end
333:     return ['<a class="' + css_class[1..-1] + '" href="' + href + '" title="' + title +
334:         '" onmouseover="logiPopoverShow(this,\'' +
335:         url + '\')">', '</a>']
336:   end

[Source]

     # File app/helpers/application_helper.rb, line 623
623:   def power(rating)
624:     return '<span class="power">' +
625:         number_with_precision(rating.weight, :precision => 1) + '</span>'
626:   end

Messages and helpers

[Source]

     # File app/helpers/application_helper.rb, line 524
524:   def pre_truncate(text, options = {})
525:     options[:length] ||= 30
526:     if text.size > options[:length]
527:       return '..' + text[(text.size - options[:length] + 2)..-1]
528:     else
529:       return text
530:     end
531:   end

[Source]

     # File app/helpers/application_helper.rb, line 539
539:   def pre_truncate_options(text, options)
540:     return self.pre_truncate(text, :length => options.delete(:length))
541:   end

[Source]

     # File app/helpers/application_helper.rb, line 175
175:   def remove_tabs
176:     logi = current_context.link.volatile_to_logi
177:     tabs = [{:text => t('h.application.remove_links'), :name => "remove_links",
178:                 :url => edit_logi_links_url(logi),
179:                 :description => t('h.application.removing_links')},
180:             {:text => t('h.application.remove_external_links'), :name => "remove_external_links",
181:                 :url => edit_logi_external_links_url(logi),
182:                 :description => t('h.application.removing_external_links')},
183:             {:text => t('h.application.remove_annotations'), :name => "remove_annotations",
184:                 :url => edit_logi_annotations_url(logi),
185:                 :description => t('h.application.removing_annotations')}]
186:     return tabs
187:   end

[Source]

     # File app/helpers/application_helper.rb, line 543
543:   def restriction_text(restriction)
544:     t(Logi::RESTRICTIONS[restriction])
545:   end

[Source]

     # File app/helpers/application_helper.rb, line 351
351:   def return_url_or_default(default_url = nil)
352:     return @controller.return_url_or_default(default_url)
353:   end

[Source]

    # File app/helpers/application_helper.rb, line 64
64:   def selected_index(tabs, selected)
65:     tab_indices = {}
66:     tabs.each_with_index do |t, i|
67:       tab_indices[t[:name]] = i
68:     end
69:     return tab_indices[selected]
70:   end

[Source]

     # File app/helpers/application_helper.rb, line 579
579:   def show_errors(*args)
580:     if args[-1].is_a?(Hash)
581:       options = args.pop
582:     else
583:       options = {}
584:     end
585:     error_object_name = nil
586:     args.each do |object_name|
587:       object = instance_variable_get("@#{object_name}")
588:       if !object.errors.empty?
589:         error_object_name = object_name
590:         break
591:       end
592:     end
593:     if error_object_name
594:       render :partial => 'application/errors',
595:          :locals => {
596:             :object_name => error_object_name, 
597:             :with_column_of_class => options[:with_column_of_class]}
598:     end
599:   end

[Source]

     # File app/helpers/application_helper.rb, line 547
547:   def show_flash(options = {})
548:     if flash[:warning] or flash[:notice] or flash[:error] or
549:         (options[:type] and flash[options[:type]])
550:       render :partial => 'application/flash',
551:           :locals => {
552:               :flash => flash,
553:               :type => options[:type],
554:               :with_column_of_class => options[:with_column_of_class]}
555:     end
556:   end

Tabs

[Source]

     # File app/helpers/application_helper.rb, line 93
 93:   def side_menu_tabs
 94:     logi = current_context.link.volatile_to_logi
 95:     tabs = []
 96: 
 97:     if logi.home_page?
 98:       tabs.push(
 99:           {:text => t('h.application.home_logi'), :name => "home_page",
100:               :description => t('h.application.logi_is_home')})
101:     else
102:       tabs.push(
103:           {:text => t('h.application.contenders'), :name => "contending_logis",
104:               :description => t('h.application.competing_for')})
105:     end
106:     tabs.push(
107:         {:text => t('h.application.incoming'), :name => "incoming_links",
108:             :description => t('h.application.links_to'),
109:             :disabled => current_context.incoming_links_to_logi.empty?})
110:     if !logi.home_page?
111:       if !logi.comments_on_logis.empty?
112:         tabs.push(
113:             {:text => t('h.application.is_comment'), :name => "comments_on",
114:                 :description => t('h.application.comments_on')})
115:       end
116:       if !logi.steps.empty?
117:         tabs.push(
118:             {:text => t('h.application.path'), :name => "paths",
119:                 :description => t('h.application.part_of_path')})
120:       end
121:     end
122:     return tabs
123:   end

[Source]

     # File app/helpers/application_helper.rb, line 642
642:   def site_link(options = {})
643:     if options[:text]
644:       text = options[:text]
645:     else
646:       text = GlobalConfig.site_host(options)
647:     end
648:     if options[:length]
649:       text = self.pre_truncate(text, :length => options[:length])
650:     end
651:     return link_to(text, GlobalConfig.site_url(options), :class => 'sitename')
652:   end

[Source]

     # File app/helpers/application_helper.rb, line 378
378:   def stars_title(score)
379:     return t('h.application.stars_label', :count => score) + ' ' + 
380:         t(Const::Rating::SCORES[score])
381:   end

cloud

[Source]

     # File app/helpers/application_helper.rb, line 421
421:   def tag_cloud(objects, classes, &proc)
422:     max, min = objects.first.use_count, objects.first.use_count
423:     objects.each { |object|
424:       count = object.use_count.to_i
425:       max = count if count > max
426:       min = count if count < min
427:     }
428: 
429:     divisor = Math.log(max + 1 - min) / ((classes.size - 1) * 1.0)
430:     if divisor == 0 # in case max == min
431:       divisor = 1
432:     end
433: 
434:     concat('<div class="tag_cloud tags_container">')
435: 
436:     objects.each { |object|
437:       yield object, classes[(Math.log(object.use_count.to_i + 1 - min) / divisor).to_i]
438:     }
439: 
440:     concat('</div>')
441:   end

[Source]

     # File app/helpers/application_helper.rb, line 810
810:   def tag_ll_link(tag, options = {}, html_options = {})
811:     options[:length] ||= 20
812:     link_to truncate_options(tag.to_s(:for => :show), options),
813:         @controller.tag_ll_url(tag), html_options.merge(
814:             :class => ' logilogi_link tag_ll_link')
815:   end

Tags

[Source]

     # File app/helpers/application_helper.rb, line 487
487:   def tags_format_link_tag_strings(link)
488:     tag_strings = link.requested_tags
489:     str = tag_strings.last
490:     if tag_strings.size > 1
491:       str += ', ' + tag_strings[0...-1].reverse.join(', ')
492:     end
493:     return str
494:   end

[Source]

     # File app/helpers/application_helper.rb, line 700
700:   def toggle_button_to(name, *args, &block)
701:     if args.last[:disabled]
702:       disabled_button(name, *args, &block)
703:     else
704:       button_to(name, *args, &block)
705:     end
706:   end

[Source]

     # File app/helpers/application_helper.rb, line 708
708:   def toggle_button_to_remote(name, *args, &block)
709:     if args.last[:disabled]
710:       disabled_button(name, *args, &block)
711:     else
712:       button_to_remote(name, *args, &block)
713:     end
714:   end

[Source]

     # File app/helpers/application_helper.rb, line 533
533:   def truncate_options(text, options)
534:     text = truncate(text, options)
535:     options.delete(:length)
536:     return text
537:   end

[Source]

     # File app/helpers/application_helper.rb, line 635
635:   def user(user, options = {})
636:     options[:length] ||= 30
637:     return '<span class="author"> ' +
638:         user_link(user, options) +
639:         '</span>'
640:   end

[Source]

     # File app/helpers/application_helper.rb, line 838
838:   def user_group_ll_link(user_group, options = {}, html_options = {})
839:     options[:length] ||= 40
840:     if user_group.personal?
841:       self.user_link(user_group.personal_user, 
842:           options.merge(:no_you => true), html_options)
843:     else
844:       link_to truncate_options(user_group.name, options), 
845:           @controller.user_group_ll_url(user_group),
846:           html_options.merge(:class => ' user_group_ll_link')
847:     end
848:   end

[Source]

     # File app/helpers/application_helper.rb, line 817
817:   def user_link(user, options = {}, html_options = {})
818:     options[:length] ||= 20
819:     if options.kind_of?(String)
820:       name = options
821:     elsif user == self.current_user and !user.anonymous? and !options[:no_you]
822:       name = t('h.application.you')
823:     else
824:       name = user.name
825:     end
826:     link_to truncate_options(name, options), @controller.user_url(user), 
827:         html_options.merge(:class => ' user_link')
828:   end

[Source]

     # File app/helpers/application_helper.rb, line 834
834:   def user_url(user, options = {})
835:     @controller.user_url(user, options)
836:   end

Parses in the links, returns the logi_version.text with links included…

[Source]

     # File app/helpers/application_helper.rb, line 236
236:   def weave(logi_version, options = {})
237:     # see the TextWeaver class in lib/weaver/lib
238:     weaver = TextWeaver.new(logi_version.text)
239:     self.add_popover_listings_to_weaver(weaver, logi_version, options)
240:     # weaver.next_set if more tag-types are added
241:     text = weaver.weave
242:     if !options[:title]
243:       text = text.gsub(/^<h1>.+?<\/h1>\ /,"")
244:       if options[:nolink]
245:         text = text.gsub(/<a.+?>/, "")
246:         text = text.gsub(/<\/a>/, "")
247:       end
248:       return text
249:     else
250:       return text
251:     end
252:   end

[Validate]