1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# frozen_string_literal: true
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module ApplicationHelper
def pod_name
AppConfig.settings.pod_name
end
def pod_version
AppConfig.version.number
end
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
def source_url
AppConfig.settings.source_url.presence || "#{root_path.chomp('/')}/source.tar.gz"
end
def donations_enabled?
AppConfig.settings.paypal_donations.enable? ||
AppConfig.settings.liberapay_username.present? ||
AppConfig.bitcoin_donation_address.present?
end
def timeago(time, options={})
timeago_tag(time, options.merge(:class => 'timeago', :title => time.iso8601, :force => true)) if time
end
def bookmarklet_code(height=400, width=620)
"javascript:" +
BookmarkletRenderer.body +
"bookmarklet('#{bookmarklet_url}', #{width}, #{height});"
end
def all_services_connected?
current_user.services.size == AppConfig.configured_services.size
end
def service_unconnected?(service)
AppConfig.show_service?(service, current_user) && current_user.services.none? {|x| x.provider == service }
end
def popover_with_close_html(without_close_html)
without_close_html + link_to('×'.html_safe, "#", :class => 'close')
end
# Require jQuery from CDN if possible, falling back to vendored copy, and require
# vendored jquery_ujs
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
end
|