Module: ApplicationHelper

Included in:
CommentsController, LayoutHelper, LikesController, PollParticipationsController, Post
Defined in:
app/helpers/application_helper.rb

Overview

Copyright © 2010-2011, Diaspora Inc. This file is

licensed under the Affero General Public License version 3 or later.  See
the COPYRIGHT file.

Instance Method Summary collapse

Instance Method Details

#all_services_connected?Boolean


44
45
46
# File 'app/helpers/application_helper.rb', line 44

def all_services_connected?
  current_user.services.size == AppConfig.configured_services.size
end

#bookmarkletObject


24
25
26
# File 'app/helpers/application_helper.rb', line 24

def bookmarklet
  raw_bookmarklet
end

#changelog_urlObject


14
15
16
17
18
# File 'app/helpers/application_helper.rb', line 14

def changelog_url
  url = "https://github.com/diaspora/diaspora/blob/master/Changelog.md"
  url.sub!('/master/', "/#{AppConfig.git_revision}/") if AppConfig.git_revision.present?
  url
end

36
37
38
39
40
41
42
# File 'app/helpers/application_helper.rb', line 36

def contacts_link
  if current_user.contacts.size > 0
    contacts_path
  else
    community_spotlight_path
  end
end

#jquery_include_tagObject

Require jQuery from CDN if possible, falling back to vendored copy, and require vendored jquery_ujs


54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/helpers/application_helper.rb', line 54

def jquery_include_tag
  buf = []
  if AppConfig.privacy.jquery_cdn?
    version = Jquery::Rails::JQUERY_VERSION
    buf << [ javascript_include_tag("//code.jquery.com/jquery-#{version}.min.js") ]
    buf << [ javascript_tag("!window.jQuery && document.write(unescape('#{j javascript_include_tag("jquery")}'));") ]
  else
    buf << [ javascript_include_tag('jquery') ]
  end
  buf << [ javascript_include_tag('jquery_ujs') ]
  buf << [ javascript_tag("jQuery.ajaxSetup({'cache': false});") ]
  buf << [ javascript_tag("$.fx.off = true;") ] if Rails.env.test?
  buf.join("\n").html_safe
end

32
33
34
# File 'app/helpers/application_helper.rb', line 32

def magic_bookmarklet_link
  bookmarklet
end

#pod_nameObject


6
7
8
# File 'app/helpers/application_helper.rb', line 6

def pod_name
  AppConfig.settings.pod_name.present? ? AppConfig.settings.pod_name : "diaspora*"
end

#pod_versionObject


10
11
12
# File 'app/helpers/application_helper.rb', line 10

def pod_version
  AppConfig.version.number.present? ? AppConfig.version.number : ""
end

#popover_with_close_html(without_close_html) ⇒ Object


48
49
50
# File 'app/helpers/application_helper.rb', line 48

def popover_with_close_html(without_close_html)
  without_close_html + link_to((:div, nil, :class => 'icons-deletelabel'), "#", :class => 'close')
end

#raw_bookmarklet(height = 400, width = 620) ⇒ Object


28
29
30
# File 'app/helpers/application_helper.rb', line 28

def raw_bookmarklet( height = 400, width = 620)
  "javascript:(function(){f='#{AppConfig.pod_uri.to_s}bookmarklet?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'&notes='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+'&v=1&';a=function(){if(!window.open(f+'noui=1&jump=doclose','diasporav1','location=yes,links=no,scrollbars=no,toolbar=no,width=#{width},height=#{height}'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"
end

#timeago(time, options = {}) ⇒ Object


20
21
22
# File 'app/helpers/application_helper.rb', line 20

def timeago(time, options={})
  timeago_tag(time, options.merge(:class => 'timeago', :title => time.iso8601, :force => true)) if time
end