Module: ApplicationHelper

Included in:
AdminsController, LanguageHelper, LayoutHelper, LikesController, 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

Returns:

  • (Boolean)

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

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

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


39
40
41
42
43
# File 'app/helpers/application_helper.rb', line 39

def bookmarklet_code(height=400, width=620)
  "javascript:" +
    BookmarkletRenderer.body +
    "bookmarklet('#{bookmarklet_url}', #{width}, #{height});"
end

#changelog_urlObject


16
17
18
19
20
21
22
23
# File 'app/helpers/application_helper.rb', line 16

def changelog_url
  return AppConfig.settings.changelog_url.get if AppConfig.settings.changelog_url.present?

  url = "https://github.com/diaspora/diaspora/blob/master/Changelog.md"
  return url if AppConfig.git_revision.blank?

  url.sub("/master/", "/#{AppConfig.git_revision}/")
end

#donations_enabled?Boolean

Returns:

  • (Boolean)

29
30
31
32
33
# File 'app/helpers/application_helper.rb', line 29

def donations_enabled?
  AppConfig.settings.paypal_donations.enable? ||
  AppConfig.settings.liberapay_username.present? ||
  AppConfig.bitcoin_donation_address.present?
end

#jquery_include_tagObject

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


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'app/helpers/application_helper.rb', line 59

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

#pod_nameObject


8
9
10
# File 'app/helpers/application_helper.rb', line 8

def pod_name
  AppConfig.settings.pod_name
end

#pod_versionObject


12
13
14
# File 'app/helpers/application_helper.rb', line 12

def pod_version
  AppConfig.version.number
end

#popover_with_close_html(without_close_html) ⇒ Object


53
54
55
# File 'app/helpers/application_helper.rb', line 53

def popover_with_close_html(without_close_html)
  without_close_html + link_to('&times;'.html_safe, "#", :class => 'close')
end

#qrcode_uriObject


76
77
78
79
# File 'app/helpers/application_helper.rb', line 76

def qrcode_uri
  label = current_user.username
  current_user.otp_provisioning_uri(label, issuer: AppConfig.environment.url)
end

#service_unconnected?(service) ⇒ Boolean

Returns:

  • (Boolean)

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

def service_unconnected?(service)
  AppConfig.show_service?(service, current_user) && current_user.services.none? {|x| x.provider == service }
end

#source_urlObject


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

def source_url
  AppConfig.settings.source_url.presence || "#{root_path.chomp('/')}/source.tar.gz"
end

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


35
36
37
# File 'app/helpers/application_helper.rb', line 35

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