Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
P
parlote-facil
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
facil
parlote-facil
Validations
74b8921c
Valider
74b8921c
rédigé
14 years ago
par
Raphael Sofaer
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
make video urls have correct href
parent
17f41f12
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
app/helpers/application_helper.rb
+16
-16
16 ajouts, 16 suppressions
app/helpers/application_helper.rb
spec/helpers/application_helper_spec.rb
+16
-0
16 ajouts, 0 suppression
spec/helpers/application_helper_spec.rb
avec
32 ajouts
et
16 suppressions
app/helpers/application_helper.rb
+
16
−
16
Voir le fichier @
74b8921c
...
...
@@ -10,10 +10,6 @@ module ApplicationHelper
content_tag
(
:abbr
,
time
.
to_s
,
options
.
merge
(
:title
=>
time
.
iso8601
))
if
time
end
def
modern_browser?
false
end
def
page_title
text
=
nil
title
=
""
if
text
.
blank?
...
...
@@ -68,7 +64,7 @@ module ApplicationHelper
param_string
<<
"
#{
k
}
=
#{
v
}
"
end
end
"<li>
"<li>
<a href='/aspects/
#{
aspect
.
id
}#{
param_string
}
'>
#{
aspect
.
name
}
</a>
...
...
@@ -210,25 +206,29 @@ module ApplicationHelper
def
process_youtube
(
message
,
youtube_maps
)
regex
=
/( |^)(http:\/\/)?www\.youtube\.com\/watch[^ ]*v=([A-Za-z0-9_\-]+)(&[^ ]*|)/
while
youtube
=
message
.
match
(
regex
)
video_id
=
youtube
[
3
]
processed_message
=
message
.
gsub
(
regex
)
do
|
matched_string
|
match_data
=
matched_string
.
match
(
regex
)
video_id
=
match_data
[
3
]
if
youtube_maps
&&
youtube_maps
[
video_id
]
title
=
h
(
CGI
::
unescape
(
youtube_maps
[
video_id
]))
else
title
=
I18n
.
t
'application.helper.video_title.unknown'
end
message
.
gsub!
(
youtube
[
0
],
'<a class="video-link" data-host="youtube.com" data-video-id="'
+
video_id
+
'" href="
#video
">Youtube: '
+
title
+
'</a>'
)
'<a class="video-link" data-host="youtube.com" data-video-id="'
+
video_id
+
'" href="
'
+
match_data
[
0
].
strip
+
'
">Youtube: '
+
title
+
'</a>'
end
return
message
return
processed_
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?
captures
=
[
$1
,
$2
,
$3
]
if
!
captures
[
0
].
nil?
m
elsif
m
.
match
(
/(youtube|vimeo)/
)
m
.
gsub
(
/(\*|_)/
)
{
|
m
|
"
\\
#{
$1
}
"
}
#remove markers on markdown chars to not markdown inside links
else
res
=
%{<a target="_blank" href="
#{
$2
}
://
#{
$3
}
">
#{
$3
}
</a>}
res
=
%{<a target="_blank" href="
#{
captures
[
1
]
}
://
#{
captures
[
2
]
}
">
#{
captures
[
2
]
}
</a>}
res
.
gsub!
(
/(\*|_)/
)
{
|
m
|
"
\\
#{
$1
}
"
}
res
end
...
...
@@ -253,23 +253,23 @@ module ApplicationHelper
def
process_vimeo
(
message
,
vimeo_maps
)
regex
=
/https?:\/\/(?:w{3}\.)?vimeo.com\/(\d{6,})/
while
vimeo
=
message
.
match
(
regex
)
video_id
=
vimeo
[
1
]
processed_message
=
message
.
gsub
(
regex
)
do
|
matched_string
|
match_data
=
message
.
match
(
regex
)
video_id
=
match_data
[
1
]
if
vimeo_maps
&&
vimeo_maps
[
video_id
]
title
=
h
(
CGI
::
unescape
(
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
">Vimeo: '
+
title
+
'</a>'
)
'<a class="video-link" data-host="vimeo.com" data-video-id="'
+
video_id
+
'" href="
'
+
match_data
[
0
]
+
'
">Vimeo: '
+
title
+
'</a>'
end
return
message
return
processed_
message
end
def
info_text
(
text
)
image_tag
'icons/monotone_question.png'
,
:class
=>
'what_is_this'
,
:
title
=>
text
end
def
get_javascript_strings_for
(
language
)
defaults
=
I18n
.
t
(
'javascripts'
,
:
locale
=>
DEFAULT_LANGUAGE
)
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
spec/helpers/application_helper_spec.rb
+
16
−
0
Voir le fichier @
74b8921c
...
...
@@ -106,6 +106,22 @@ describe ApplicationHelper do
res
.
should
=~
/data-host="youtube.com"/
res
.
should
=~
/data-video-id="
#{
video_id
}
"/
end
it
"leaves the links in the href of the #a tag"
do
video_id
=
"ABYnqp-bxvg"
start_url
=
"http://www.youtube.com/watch?v="
+
video_id
url
=
start_url
+
"&a=GxdCwVVULXdvEBKmx_f5ywvZ0zZHHHDU&list=ML&playnext=1"
res
=
markdownify
(
url
)
res
.
should
=~
/href=[\S]+v=
#{
video_id
}
/
end
it
'does not autolink inside the link'
do
video_id
=
"ABYnqp-bxvg"
start_url
=
"http://www.youtube.com/watch?v="
+
video_id
url
=
start_url
+
"&a=GxdCwVVULXdvEBKmx_f5ywvZ0zZHHHDU&list=ML&playnext=1"
res
=
markdownify
(
url
)
pp
res
res
.
match
(
/href="<a/
).
should
be_nil
end
end
it
"recognizes multiple links of different types"
do
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter