Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
2abcd8d147
34 changed files with 183 additions and 164 deletions
|
|
@ -24,21 +24,24 @@ module ApplicationHelper
|
|||
post.aspect_ids.include?(a.id)
|
||||
end
|
||||
end
|
||||
|
||||
def aspects_without_post aspects, post
|
||||
aspects.reject do |a|
|
||||
post.aspect_ids.include?(a.id)
|
||||
end
|
||||
end
|
||||
|
||||
def aspect_badge aspects
|
||||
str = ''
|
||||
if aspects.count > 1
|
||||
str = "<span class='aspect_badge all'>#{I18n.t('application.helper.aspect_badge.all_aspects')}</span>"
|
||||
elsif aspects.count == 1
|
||||
aspect = aspects.first
|
||||
str = "<span class='aspect_badge single'><a href=#{aspect_path(aspect)}>#{aspect.name}</a></span>"
|
||||
str = "<span class='aspect_badge single'><a href=#{aspect_path(aspect)}>#{aspect.name}</a></span>"
|
||||
end
|
||||
str.html_safe
|
||||
end
|
||||
|
||||
def aspect_links aspects, opts={}
|
||||
str = ""
|
||||
aspects.each do |a|
|
||||
|
|
@ -46,15 +49,16 @@ module ApplicationHelper
|
|||
end
|
||||
str.html_safe
|
||||
end
|
||||
|
||||
def aspect_li aspect, opts= {}
|
||||
param_string = ""
|
||||
if opts.size > 0
|
||||
param_string << '?'
|
||||
opts.each_pair do |k,v|
|
||||
opts.each_pair do |k, v|
|
||||
param_string << "#{k}=#{v}"
|
||||
end
|
||||
end
|
||||
"<li>
|
||||
"<li>
|
||||
<a href='/aspects/#{aspect.id}#{param_string}'>
|
||||
#{aspect.name}
|
||||
</a>
|
||||
|
|
@ -98,12 +102,12 @@ module ApplicationHelper
|
|||
|
||||
def person_url(person)
|
||||
case person.class.to_s
|
||||
when "User"
|
||||
user_path(person)
|
||||
when "Person"
|
||||
person_path(person)
|
||||
else
|
||||
I18n.t('application.helper.unknown_person')
|
||||
when "User"
|
||||
user_path(person)
|
||||
when "Person"
|
||||
person_path(person)
|
||||
else
|
||||
I18n.t('application.helper.unknown_person')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -124,28 +128,28 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def person_link(person)
|
||||
"<a href='/people/#{person.id}'>
|
||||
"<a href='/people/#{person.id}'>
|
||||
#{person.name}
|
||||
</a>".html_safe
|
||||
end
|
||||
|
||||
def image_or_default(person, size=:thumb_large)
|
||||
image_location = person.profile.image_url(size) if person.profile
|
||||
image_location ||= person.profile.image_url(:thumb_large) if person.profile #backwards compatability for old profile pictures
|
||||
image_location ||= person.profile.image_url(:thumb_large) if person.profile #backwards compatability for old profile pictures
|
||||
image_location ||= "/images/user/default.png"
|
||||
image_location
|
||||
end
|
||||
|
||||
|
||||
def hard_link(string, path)
|
||||
link_to string, path, :rel => 'external'
|
||||
link_to string, path, :rel => 'external'
|
||||
end
|
||||
|
||||
def person_image_link(person, opts = {})
|
||||
return "" if person.nil?
|
||||
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)
|
||||
else
|
||||
"<a href='/people/#{person.id}'>
|
||||
"<a href='/people/#{person.id}'>
|
||||
#{person_image_tag(person)}
|
||||
</a>".html_safe
|
||||
end
|
||||
|
|
@ -158,78 +162,23 @@ module ApplicationHelper
|
|||
def person_photos_path person
|
||||
person_id = person.id if person.respond_to?(:id)
|
||||
person_id ||= person
|
||||
|
||||
|
||||
"#{photos_path}?person_id=#{person_id}"
|
||||
end
|
||||
|
||||
def markdownify(message, options = {})
|
||||
message = h(message).html_safe
|
||||
|
||||
[:autolinks, :youtube, :emphasis, :links, :newlines].each do |k|
|
||||
if !options.has_key?(k)
|
||||
options[k] = true
|
||||
end
|
||||
if !options.has_key?(:newlines)
|
||||
options[:newlines] = true
|
||||
end
|
||||
|
||||
if options[:links]
|
||||
message.gsub!(/\[([^\[]+)\]\(([^ ]+) \"(([^&]|(&[^q])|(&q[^u])|(&qu[^o])|(&quo[^t])|("[^;]))+)\"\)/) do |m|
|
||||
escape = (options[:emphasis]) ? "\\" : ""
|
||||
res = "<a target=\"#{escape}_blank\" href=\"#{$2}\" title=\"#{$3}\">#{$1}</a>"
|
||||
res
|
||||
end
|
||||
message.gsub!(/\[([^\[]+)\]\(([^ ]+)\)/) do |m|
|
||||
escape = (options[:emphasis]) ? "\\" : ""
|
||||
res = "<a target=\"#{escape}_blank\" href=\"#{$2}\">#{$1}</a>"
|
||||
res
|
||||
end
|
||||
end
|
||||
|
||||
if options[:youtube]
|
||||
message.gsub!(/( |^)(http:\/\/)?www\.youtube\.com\/watch[^ ]*v=([A-Za-z0-9_]+)(&[^ ]*|)/) do |m|
|
||||
res = "#{$1}youtube.com::#{$3}"
|
||||
res.gsub!(/(\*|_)/) { |m| "\\#{$1}" } if options[:emphasis]
|
||||
res
|
||||
end
|
||||
end
|
||||
|
||||
if options[:autolinks]
|
||||
message.gsub!(/( |^)(www\.[^\s]+\.[^\s])/, '\1http://\2')
|
||||
message.gsub!(/(<a target="\\?_blank" href=")?(https|http|ftp):\/\/([^\s]+)/) do |m|
|
||||
if !$1.nil?
|
||||
m
|
||||
else
|
||||
res = %{<a target="_blank" href="#{$2}://#{$3}">#{$3}</a>}
|
||||
res.gsub!(/(\*|_)/) { |m| "\\#{$1}" } if options[:emphasis]
|
||||
res
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if options[:emphasis]
|
||||
message.gsub!("\\**", "-^doublestar^-")
|
||||
message.gsub!("\\__", "-^doublescore^-")
|
||||
message.gsub!("\\*", "-^star^-")
|
||||
message.gsub!("\\_", "-^score^-")
|
||||
message.gsub!(/(\*\*\*|___)(.+?)\1/m, '<em><strong>\2</strong></em>')
|
||||
message.gsub!(/(\*\*|__)(.+?)\1/m, '<strong>\2</strong>')
|
||||
message.gsub!(/(\*|_)(.+?)\1/m, '<em>\2</em>')
|
||||
message.gsub!("-^doublestar^-", "**")
|
||||
message.gsub!("-^doublescore^-", "__")
|
||||
message.gsub!("-^star^-", "*")
|
||||
message.gsub!("-^score^-", "_")
|
||||
end
|
||||
|
||||
if options[:youtube]
|
||||
while youtube = message.match(/youtube\.com::([A-Za-z0-9_\\\-]+)/)
|
||||
video_id = youtube[1]
|
||||
if options[:youtube_maps] && options[:youtube_maps][video_id]
|
||||
title = options[:youtube_maps][video_id]
|
||||
else
|
||||
title = I18n.t 'application.helper.youtube_title.unknown'
|
||||
end
|
||||
message.gsub!('youtube.com::'+video_id, '<a class="video-link" data-host="youtube.com" data-video-id="' + video_id + '" href="#video">Youtube: ' + title + '</a>')
|
||||
end
|
||||
end
|
||||
message = process_links(message)
|
||||
message = process_youtube(message)
|
||||
message = process_autolinks(message)
|
||||
message = process_emphasis(message)
|
||||
message = process_youtube_again(message, options[:youtube_maps])
|
||||
message = process_vimeo(message, options[:vimeo_maps])
|
||||
|
||||
if options[:newlines]
|
||||
message.gsub!(/\n+/, '<br />')
|
||||
|
|
@ -238,6 +187,87 @@ module ApplicationHelper
|
|||
return message
|
||||
end
|
||||
|
||||
def process_links(message)
|
||||
message.gsub!(/\[([^\[]+)\]\(([^ ]+) \"(([^&]|(&[^q])|(&q[^u])|(&qu[^o])|(&quo[^t])|("[^;]))+)\"\)/) do |m|
|
||||
escape = "\\"
|
||||
res = "<a target=\"#{escape}_blank\" href=\"#{$2}\" title=\"#{$3}\">#{$1}</a>"
|
||||
res
|
||||
end
|
||||
message.gsub!(/\[([^\[]+)\]\(([^ ]+)\)/) do |m|
|
||||
escape = "\\"
|
||||
res = "<a target=\"#{escape}_blank\" href=\"#{$2}\">#{$1}</a>"
|
||||
res
|
||||
end
|
||||
|
||||
return message
|
||||
end
|
||||
|
||||
def process_youtube(message)
|
||||
message.gsub!(/( |^)(http:\/\/)?www\.youtube\.com\/watch[^ ]*v=([A-Za-z0-9_]+)(&[^ ]*|)/) do |m|
|
||||
res = "#{$1}youtube.com::#{$3}"
|
||||
res.gsub!(/(\*|_)/) { |m| "\\#{$1}" }
|
||||
res
|
||||
end
|
||||
return message
|
||||
end
|
||||
|
||||
def process_autolinks(message)
|
||||
message.gsub!(/( |^)(www\.[^\s]+\.[^\s])/, '\1http://\2')
|
||||
message.gsub!(/(<a target="\\?_blank" href=")?(https|http|ftp):\/\/([^\s]+)/) do |m|
|
||||
if !$1.nil?
|
||||
m
|
||||
else
|
||||
res = %{<a target="_blank" href="#{$2}://#{$3}">#{$3}</a>}
|
||||
res.gsub!(/(\*|_)/) { |m| "\\#{$1}" }
|
||||
res
|
||||
end
|
||||
end
|
||||
return message
|
||||
end
|
||||
|
||||
def process_emphasis(message)
|
||||
message.gsub!("\\**", "-^doublestar^-")
|
||||
message.gsub!("\\__", "-^doublescore^-")
|
||||
message.gsub!("\\*", "-^star^-")
|
||||
message.gsub!("\\_", "-^score^-")
|
||||
message.gsub!(/(\*\*\*|___)(.+?)\1/m, '<em><strong>\2</strong></em>')
|
||||
message.gsub!(/(\*\*|__)(.+?)\1/m, '<strong>\2</strong>')
|
||||
message.gsub!(/(\*|_)(.+?)\1/m, '<em>\2</em>')
|
||||
message.gsub!("-^doublestar^-", "**")
|
||||
message.gsub!("-^doublescore^-", "__")
|
||||
message.gsub!("-^star^-", "*")
|
||||
message.gsub!("-^score^-", "_")
|
||||
return message
|
||||
end
|
||||
|
||||
def process_youtube_again(message, youtube_maps)
|
||||
while youtube = message.match(/youtube\.com::([A-Za-z0-9_\\\-]+)/)
|
||||
video_id = youtube[1]
|
||||
if youtube_maps && youtube_maps[video_id]
|
||||
title = youtube_maps[video_id]
|
||||
else
|
||||
title = I18n.t 'application.helper.video_title.unknown'
|
||||
end
|
||||
message.gsub!('youtube.com::'+video_id, '<a class="video-link" data-host="youtube.com" data-video-id="' + video_id + '" href="#video">Youtube: ' + title + '</a>')
|
||||
end
|
||||
return message
|
||||
end
|
||||
|
||||
|
||||
def process_vimeo(message, vimeo_maps)
|
||||
regex = /https?:\/\/(?:w{3}\.)?vimeo.com\/(\d{6,})/
|
||||
while vimeo = message.match(regex)
|
||||
video_id = vimeo[1]
|
||||
if vimeo_maps && vimeo_maps[video_id]
|
||||
title = vimeo_maps[video_id]
|
||||
else
|
||||
title = I18n.t 'application.helper.video_title.unknown'
|
||||
end
|
||||
message.gsub!(vimeo[0], '<a class="video-link" data-host="vimeo.com" data-video-id="' + video_id + '" href="#video">Youtube: ' + title + '</a>')
|
||||
end
|
||||
return message
|
||||
end
|
||||
|
||||
def info_text(text)
|
||||
image_tag 'icons/monotone_question.png', :class => 'what_is_this', :title => text
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:hm='http://host-meta.net/xrd/1.0'>
|
||||
<hm:Host><%= APP_CONFIG[:pod_uri].host %></hm:Host>
|
||||
<Link rel='lrdd'
|
||||
template='<%= APP_CONFIG[:pod_uri].host %>/webfinger?q={uri}'>
|
||||
template='<%= APP_CONFIG[:pod_url] %>webfinger?q={uri}'>
|
||||
<Title>Resource Descriptor</Title>
|
||||
</Link>
|
||||
</XRD>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ ar:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "شخص غير معروف"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Unknown Video Title"
|
||||
are_you_sure: "Are you sure?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ ca:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "persona desconeguda"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Títol desconegut de vídeo"
|
||||
are_you_sure: "Are you sure?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ cs:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "neznámá osoba"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Unknown Video Title"
|
||||
are_you_sure: "Are you sure?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ cy:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "unknown person"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Unknown Video Title"
|
||||
are_you_sure: "Are you sure?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ da:
|
|||
aspect_badge:
|
||||
all_aspects: "Alle aspekter"
|
||||
unknown_person: "ukendt person"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Ukendt videotitel"
|
||||
are_you_sure: "Er du sikker?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ de:
|
|||
aspect_badge:
|
||||
all_aspects: "Alle Aspekte"
|
||||
unknown_person: "unbekannte Person"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Unbekannter Video-Titel"
|
||||
are_you_sure: "Bist du sicher?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ el:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "άγνωστο άτομο"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "αγνώστος τίτλος αρχείου πολυμέσων"
|
||||
are_you_sure: "Are you sure?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ en:
|
|||
application:
|
||||
helper:
|
||||
unknown_person: "unknown person"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Unknown Video Title"
|
||||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ eo:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "unknown person"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Unknown Video Title"
|
||||
are_you_sure: "Are you sure?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ es-CL:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "persona desconocida"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Titulo del video desconocido"
|
||||
are_you_sure: "¿Estás seguro?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ es:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "persona desconocida"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Título Desconocido de Vídeo"
|
||||
are_you_sure: "¿Estás seguro?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ fi:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "tuntematon persoona"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Videon otsikko tuntematon"
|
||||
are_you_sure: "Oletko varma?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ fr:
|
|||
aspect_badge:
|
||||
all_aspects: "Tous les aspects"
|
||||
unknown_person: "personne inconnue"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Titre de vidéo inconnu"
|
||||
are_you_sure: "Vous confirmez ?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ he:
|
|||
aspect_badge:
|
||||
all_aspects: "כל ההיבטים"
|
||||
unknown_person: "אדם לא ידוע"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "כותרת הווידאו אינה ידועה"
|
||||
are_you_sure: "בבטחה?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ hu:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "ismeretlen személy"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Ismeretlen videó cím"
|
||||
are_you_sure: "Biztos vagy benne?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ id:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "orang tak dikenal"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Unknown Video Title"
|
||||
are_you_sure: "Are you sure?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ it:
|
|||
aspect_badge:
|
||||
all_aspects: "Tutti gli aspetti"
|
||||
unknown_person: "persona sconosciuta"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Titolo Video Sconosciuto"
|
||||
are_you_sure: "Sei sicuro?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ lt:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "nežinomas asmuo"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Nežinomas video pavadinimas"
|
||||
are_you_sure: "Are you sure?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ mk:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "непозната личност"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Непознато име на видео"
|
||||
are_you_sure: "Are you sure?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ nb:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "ukjent person"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Unknown Video Title"
|
||||
are_you_sure: "Are you sure?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ nl:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "onbekend persoon"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Onbekende video titel"
|
||||
are_you_sure: "Weet je het zeker?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ pl:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "nieznana osoba"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Nieznany tytuł wideo"
|
||||
are_you_sure: "Na pewno?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ pt-BR:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "pessoa desconhecida"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Título de vídeo desconhecido"
|
||||
are_you_sure: "Are you sure?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ pt-PT:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "utilizador(a) desconhecido(a)"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Título do Vídeo Desconhecido"
|
||||
are_you_sure: "Are you sure?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ ro:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "persoană necunoscută"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Unknown Video Title"
|
||||
are_you_sure: "Are you sure?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ ru:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "неизвестная персона"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Неизвестный видео заголовок"
|
||||
are_you_sure: "Вы уверены?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ sk:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "neznáma osoba"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Názov videa neznámy"
|
||||
are_you_sure: "Are you sure?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ sv:
|
|||
aspect_badge:
|
||||
all_aspects: "Alla sidor"
|
||||
unknown_person: "okänd person"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Okänd videotitel"
|
||||
are_you_sure: "Är du säker?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ tr:
|
|||
aspect_badge:
|
||||
all_aspects: "All aspects"
|
||||
unknown_person: "bilinmiyen kişiler"
|
||||
youtube_title:
|
||||
video_title:
|
||||
unknown: "Bilinmeyen Video Başlığı"
|
||||
are_you_sure: "Are you sure?"
|
||||
aspects:
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@
|
|||
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
|
||||
# Mayor.create(:name => 'Daley', :city => citie
|
||||
|
||||
require File.join(File.dirname(__FILE__), "..", "..", "config", "environment")
|
||||
require File.join(File.dirname(__FILE__), "..", "config", "environment")
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
require File.join(File.dirname(__FILE__), "..", "..", "config", "environment")
|
||||
require File.join(File.dirname(__FILE__), "..", "..", "spec", "helper_methods")
|
||||
|
||||
|
||||
def set_app_config username
|
||||
current_config = YAML.load(File.read(Rails.root.join('config', 'app_config.yml.example')))
|
||||
current_config[Rails.env.to_s] ||= {}
|
||||
|
|
@ -21,6 +20,15 @@ set_app_config username unless File.exists?(Rails.root.join('config', 'app_confi
|
|||
|
||||
require Rails.root.join('config', "initializers", "_load_app_config.rb")
|
||||
include HelperMethods
|
||||
module Resque
|
||||
def enqueue(klass, *args)
|
||||
if $process_queue
|
||||
klass.send(:perform, *args)
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
# Create seed user
|
||||
user = User.build( :email => "tom@tom.joindiaspora.com",
|
||||
:username => "tom",
|
||||
|
|
@ -29,8 +37,8 @@ user = User.build( :email => "tom@tom.joindiaspora.com",
|
|||
:person => {
|
||||
:profile => { :first_name => "Alexander", :last_name => "Hamiltom",
|
||||
:image_url => "/images/user/tom.jpg"}})
|
||||
|
||||
user.save
|
||||
|
||||
user.save!
|
||||
user.person.save!
|
||||
user.seed_aspects
|
||||
|
||||
|
|
@ -42,12 +50,9 @@ user2 = User.build( :email => "korth@tom.joindiaspora.com",
|
|||
:image_url => "/images/user/korth.jpg"}})
|
||||
|
||||
|
||||
user2.save
|
||||
user2.save!
|
||||
user2.person.save!
|
||||
user2.seed_aspects
|
||||
# connecting users
|
||||
aspect = user.aspects.create(:name => "other dudes")
|
||||
aspect2 = user2.aspects.create(:name => "presidents")
|
||||
|
||||
connect_users(user, aspect, user2, aspect2)
|
||||
user.aspects.create(:name => "Presidents")
|
||||
connect_users(user, user.aspects.first, user2, user2.aspects.first)
|
||||
|
|
|
|||
|
|
@ -72,24 +72,30 @@ describe ApplicationHelper do
|
|||
markdownify(proto+"://"+url).should == "<a target=\"_blank\" href=\""+proto+"://"+url+"\">"+url+"</a>"
|
||||
end
|
||||
|
||||
it "recognizes youtube links" do
|
||||
proto="http"
|
||||
videoid = "0x__dDWdf23"
|
||||
url="www.youtube.com/watch?v="+videoid+"&a=GxdCwVVULXdvEBKmx_f5ywvZ0zZHHHDU&list=ML&playnext=1"
|
||||
title = "UP & down & UP & down &"
|
||||
res = markdownify(proto+'://'+url)
|
||||
res.should =~ /data-host="youtube.com"/
|
||||
res.should =~ /data-video-id="#{videoid}"/
|
||||
end
|
||||
|
||||
it "recognizes youtube links with hyphens" do
|
||||
proto="http"
|
||||
videoid = "ABYnqp-bxvg"
|
||||
url="www.youtube.com/watch?v="+videoid+"&a=GxdCwVVULXdvEBKmx_f5ywvZ0zZHHHDU&list=ML&playnext=1"
|
||||
title = "UP & down & UP & down &"
|
||||
res = markdownify(proto+'://'+url)
|
||||
res.should =~ /data-host="youtube.com"/
|
||||
res.should =~ /data-video-id="#{videoid}"/
|
||||
describe "video links" do
|
||||
it "recognizes vimeo links" do
|
||||
video_id = "17449557"
|
||||
url = "http://www.vimeo.com/#{video_id}"
|
||||
res = markdownify(url)
|
||||
res.should =~ /data-host="vimeo.com"/
|
||||
res.should =~ /data-video-id="#{video_id}"/
|
||||
end
|
||||
|
||||
it "recognizes youtube links" do
|
||||
video_id = "0x__dDWdf23"
|
||||
url = "http://www.youtube.com/watch?v=" + video_id + "&a=GxdCwVVULXdvEBKmx_f5ywvZ0zZHHHDU&list=ML&playnext=1"
|
||||
res = markdownify(url)
|
||||
res.should =~ /data-host="youtube.com"/
|
||||
res.should =~ /data-video-id="#{video_id}"/
|
||||
end
|
||||
|
||||
it "recognizes youtube links with hyphens" do
|
||||
video_id = "ABYnqp-bxvg"
|
||||
url = "http://www.youtube.com/watch?v=" + video_id + "&a=GxdCwVVULXdvEBKmx_f5ywvZ0zZHHHDU&list=ML&playnext=1"
|
||||
res = markdownify(url)
|
||||
res.should =~ /data-host="youtube.com"/
|
||||
res.should =~ /data-video-id="#{video_id}"/
|
||||
end
|
||||
end
|
||||
|
||||
it "recognizes multiple links of different types" do
|
||||
|
|
@ -174,35 +180,13 @@ describe ApplicationHelper do
|
|||
markdownify(message).should == "<em>some text</em> *some text<em> **some text</em> <em>some text</em> _some text<em> __some text</em>"
|
||||
end
|
||||
|
||||
describe "options" do
|
||||
before do
|
||||
@message = "http://url.com www.url.com www.youtube.com/watch?foo=bar&v=BARFOO&whatever=related *emphasis* __emphasis__ [link](www.url.com) [link](url.com \"title\")"
|
||||
end
|
||||
|
||||
it "can render only autolinks" do
|
||||
res = markdownify(@message, :youtube => false, :emphasis => false, :links => false)
|
||||
res.should == "<a target=\"_blank\" href=\"http://url.com\">url.com</a> <a target=\"_blank\" href=\"http://www.url.com\">www.url.com</a> <a target=\"_blank\" href=\"http://www.youtube.com/watch?foo=bar&v=BARFOO&whatever=related\">www.youtube.com/watch?foo=bar&v=BARFOO&whatever=related</a> *emphasis* __emphasis__ [link](www.url.com) [link](url.com "title")"
|
||||
end
|
||||
|
||||
it "can render only youtube" do
|
||||
res = markdownify(@message, :autolinks => false, :emphasis => false, :links => false)
|
||||
res.should_not =~ /a href="http:\/\/url.com"/
|
||||
res.should_not =~ /a href="http:\/\/www.url.com"/
|
||||
res.should_not =~ /<strong>emphasis<\/strong>/
|
||||
end
|
||||
|
||||
it "can render only emphasis tags" do
|
||||
res = markdownify(@message, :autolinks => false, :youtube => false, :links => false)
|
||||
res.should == "http://url.com www.url.com www.youtube.com/watch?foo=bar&v=BARFOO&whatever=related <em>emphasis</em> <strong>emphasis</strong> [link](www.url.com) [link](url.com "title")"
|
||||
end
|
||||
|
||||
it "can render only links tags" do
|
||||
res = markdownify(@message, :autolinks => false, :youtube => false, :emphasis => false)
|
||||
res.should == "http://url.com www.url.com www.youtube.com/watch?foo=bar&v=BARFOO&whatever=related *emphasis* __emphasis__ <a target=\"_blank\" href=\"www.url.com\">link</a> <a target=\"_blank\" href=\"url.com\" title=\"title\">link</a>"
|
||||
end
|
||||
end
|
||||
|
||||
describe "newlines" do
|
||||
it 'skips inserting newlines if you pass the newlines option' do
|
||||
message = "These\nare\n\some\nnew\lines"
|
||||
res = markdownify(message, :newlines => false)
|
||||
res.should == message
|
||||
end
|
||||
|
||||
it 'generates breaklines' do
|
||||
message = "These\nare\nsome\nnew\nlines"
|
||||
res = markdownify(message)
|
||||
|
|
|
|||
Loading…
Reference in a new issue