diaspora/app/helpers/application_helper.rb
Florian Staudacher 0bb316e893 update bookmarklet
* snippet now in a separate JS file - compiled and uglified with the other assets
* popup gets centered in opening browser window
* publisher gets pre-filled with markdown-styled content
2015-05-01 20:20:46 +02:00

66 lines
2 KiB
Ruby

# 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
url = "https://github.com/diaspora/diaspora/blob/master/Changelog.md"
url.sub!('/master/', "/#{AppConfig.git_revision}/") if AppConfig.git_revision.present?
url
end
def source_url
AppConfig.settings.source_url.presence || "#{root_path.chomp('/')}/source.tar.gz"
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 contacts_link
if current_user.contacts.size > 0
contacts_path
else
community_spotlight_path
end
end
def all_services_connected?
current_user.services.size == AppConfig.configured_services.size
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_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
end