cleaned up formatting in application_helper, removed unnecessary return

This commit is contained in:
Arzumy MD 2011-05-06 00:18:58 +08:00
parent 2c4954bac8
commit 6ba2b00fb8

View file

@ -5,7 +5,7 @@
module ApplicationHelper module ApplicationHelper
@@youtube_title_cache = Hash.new("no-title") @@youtube_title_cache = Hash.new("no-title")
def timeago(time, options = {}) def timeago(time, options={})
options[:class] ||= "timeago" options[:class] ||= "timeago"
content_tag(:abbr, time.to_s, options.merge(:title => time.iso8601)) if time content_tag(:abbr, time.to_s, options.merge(:title => time.iso8601)) if time
end end
@ -15,19 +15,19 @@ module ApplicationHelper
current_user ? current_user.name : t("application.helper.diaspora_alpha") current_user ? current_user.name : t("application.helper.diaspora_alpha")
end end
def aspects_with_post aspects, post def aspects_with_post(aspects, post)
aspects.select do |aspect| aspects.select do |aspect|
AspectVisibility.exists?(:aspect_id => aspect.id, :post_id => post.id) AspectVisibility.exists?(:aspect_id => aspect.id, :post_id => post.id)
end end
end end
def aspects_without_post aspects, post def aspects_without_post(aspects, post)
aspects.reject do |aspect| aspects.reject do |aspect|
AspectVisibility.exists?(:aspect_id => aspect.id, :post_id => post.id) AspectVisibility.exists?(:aspect_id => aspect.id, :post_id => post.id)
end end
end end
def aspect_badges aspects, opts = {} def aspect_badges(aspects, opts={})
str = '' str = ''
aspects.each do |aspect| aspects.each do |aspect|
str << aspect_badge(aspect, opts) str << aspect_badge(aspect, opts)
@ -39,7 +39,7 @@ module ApplicationHelper
"javascript:(function(){f='#{AppConfig[:pod_url]}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=620,height=250'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()" "javascript:(function(){f='#{AppConfig[:pod_url]}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=620,height=250'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"
end end
def aspect_badge aspect, opts = {} def aspect_badge(aspect, opts={})
str = "<span class='aspect_badge single'>" str = "<span class='aspect_badge single'>"
link = opts.delete(:link) link = opts.delete(:link)
if !link if !link
@ -50,7 +50,7 @@ module ApplicationHelper
str << "</span>" str << "</span>"
end end
def aspect_links aspects, opts={} def aspect_links(aspects, opts={})
str = "" str = ""
aspects.each do |aspect| aspects.each do |aspect|
str << '<li>' str << '<li>'
@ -60,7 +60,7 @@ module ApplicationHelper
str.html_safe str.html_safe
end end
def aspect_li aspect, opts= {} def aspect_li(aspect, opts={})
param_string = "" param_string = ""
if opts.size > 0 if opts.size > 0
param_string << '?' param_string << '?'
@ -90,7 +90,7 @@ module ApplicationHelper
!@aspect.nil? && !@aspect.instance_of?(Symbol) && @aspect.id == aspect.id !@aspect.nil? && !@aspect.instance_of?(Symbol) && @aspect.id == aspect.id
end end
def aspect_or_all_path aspect def aspect_or_all_path(aspect)
if @aspect.is_a? Aspect if @aspect.is_a? Aspect
aspect_path @aspect aspect_path @aspect
else else
@ -98,7 +98,7 @@ module ApplicationHelper
end end
end end
def object_path(object, opts = {}) def object_path(object, opts={})
return "" if object.nil? return "" if object.nil?
object = object.person if object.is_a? User object = object.person if object.is_a? User
eval("#{object.class.name.underscore}_path(object, opts)") eval("#{object.class.name.underscore}_path(object, opts)")
@ -147,7 +147,7 @@ module ApplicationHelper
link_to string, path, :rel => 'external' link_to string, path, :rel => 'external'
end end
def person_image_link(person, opts = {}) def person_image_link(person, opts={})
return "" if person.nil? || person.profile.nil? return "" if person.nil? || person.profile.nil?
if opts[:to] == :photos if opts[:to] == :photos
link_to person_image_tag(person, opts[:size]), person_photos_path(person) link_to person_image_tag(person, opts[:size]), person_photos_path(person)
@ -162,7 +162,7 @@ module ApplicationHelper
(':' + post.id.to_s).to_sym (':' + post.id.to_s).to_sym
end end
def markdownify(message, options = {}) def markdownify(message, options={})
message = h(message).html_safe message = h(message).html_safe
options[:newlines] = true if !options.has_key?(:newlines) options[:newlines] = true if !options.has_key?(:newlines)
@ -177,7 +177,7 @@ module ApplicationHelper
message.gsub!(/\n+/, '<br />') if options[:newlines] message.gsub!(/\n+/, '<br />') if options[:newlines]
return message message
end end
@ -193,6 +193,7 @@ module ApplicationHelper
res = "<a target=\"#{escape}_blank\" href=\"#{protocol}#{url}\" title=\"#{title}\">#{link}</a>" res = "<a target=\"#{escape}_blank\" href=\"#{protocol}#{url}\" title=\"#{title}\">#{link}</a>"
res res
end end
message.gsub!(/\[([^\[]+)\]\(([^ ]+)\)/) do |m| message.gsub!(/\[([^\[]+)\]\(([^ ]+)\)/) do |m|
escape = "\\" escape = "\\"
link = $1 link = $1
@ -204,7 +205,7 @@ module ApplicationHelper
res res
end end
return message message
end end
def process_youtube(message, youtube_maps) def process_youtube(message, youtube_maps)
@ -220,7 +221,7 @@ module ApplicationHelper
end end
' <a class="video-link" data-host="youtube.com" data-video-id="' + video_id + '" data-anchor="' + anchor + '" href="'+ match_data[0].strip + '" target="_blank">Youtube: ' + title + '</a>' ' <a class="video-link" data-host="youtube.com" data-video-id="' + video_id + '" data-anchor="' + anchor + '" href="'+ match_data[0].strip + '" target="_blank">Youtube: ' + title + '</a>'
end end
return processed_message processed_message
end end
def process_autolinks(message) def process_autolinks(message)
@ -237,7 +238,7 @@ module ApplicationHelper
res res
end end
end end
return message message
end end
def process_emphasis(message) def process_emphasis(message)
@ -252,7 +253,7 @@ module ApplicationHelper
message.gsub!("-^doublescore^-", "__") message.gsub!("-^doublescore^-", "__")
message.gsub!("-^star^-", "*") message.gsub!("-^star^-", "*")
message.gsub!("-^score^-", "_") message.gsub!("-^score^-", "_")
return message message
end end
def process_vimeo(message, vimeo_maps) def process_vimeo(message, vimeo_maps)
@ -267,7 +268,7 @@ module ApplicationHelper
end end
' <a class="video-link" data-host="vimeo.com" data-video-id="' + video_id + '" href="' + match_data[0] + '" target="_blank">Vimeo: ' + title + '</a>' ' <a class="video-link" data-host="vimeo.com" data-video-id="' + video_id + '" href="' + match_data[0] + '" target="_blank">Vimeo: ' + title + '</a>'
end end
return processed_message processed_message
end end
def process_emoticons(message) def process_emoticons(message)
@ -307,7 +308,7 @@ module ApplicationHelper
end end
def direction_for(string) def direction_for(string)
return (string.cleaned_is_rtl?) ? 'rtl' : '' string.cleaned_is_rtl? ? 'rtl' : ''
end end
def rtl? def rtl?