Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
300d2885
Commit
300d2885
authored
Oct 01, 2019
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch '29284-video-preview-not-working' into 'master'"
This reverts merge request !17581
parent
c7121f96
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
30 deletions
+32
-30
changelogs/unreleased/29284-video-preview-not-working.yml
changelogs/unreleased/29284-video-preview-not-working.yml
+0
-5
lib/banzai/filter/video_link_filter.rb
lib/banzai/filter/video_link_filter.rb
+17
-5
spec/lib/banzai/filter/video_link_filter_spec.rb
spec/lib/banzai/filter/video_link_filter_spec.rb
+15
-20
No files found.
changelogs/unreleased/29284-video-preview-not-working.yml
deleted
100644 → 0
View file @
c7121f96
---
title
:
Fix inline rendering of videos for uploads with uppercase file extensions
merge_request
:
17581
author
:
type
:
fixed
lib/banzai/filter/video_link_filter.rb
View file @
300d2885
...
...
@@ -8,8 +8,8 @@ module Banzai
# a "Download" link in the case the video cannot be played.
class
VideoLinkFilter
<
HTML
::
Pipeline
::
Filter
def
call
doc
.
xpath
(
'descendant-or-self::img[not(ancestor::a)]'
).
each
do
|
el
|
el
.
replace
(
video_node
(
doc
,
el
))
if
has_video_extension?
(
el
)
doc
.
xpath
(
query
).
each
do
|
el
|
el
.
replace
(
video_node
(
doc
,
el
))
end
doc
...
...
@@ -17,10 +17,22 @@ module Banzai
private
def
has_video_extension?
(
element
)
src_attr
=
context
[
:asset_proxy_enabled
]
?
'data-canonical-src'
:
'src'
def
query
@query
||=
begin
src_query
=
UploaderHelper
::
SAFE_VIDEO_EXT
.
map
do
|
ext
|
"'.
#{
ext
}
' = substring(@src, string-length(@src) -
#{
ext
.
size
}
)"
end
element
.
attr
(
src_attr
).
downcase
.
end_with?
(
*
UploaderHelper
::
SAFE_VIDEO_EXT
)
if
context
[
:asset_proxy_enabled
].
present?
src_query
.
concat
(
UploaderHelper
::
SAFE_VIDEO_EXT
.
map
do
|
ext
|
"'.
#{
ext
}
' = substring(@data-canonical-src, string-length(@data-canonical-src) -
#{
ext
.
size
}
)"
end
)
end
"descendant-or-self::img[not(ancestor::a) and (
#{
src_query
.
join
(
' or '
)
}
)]"
end
end
def
video_node
(
doc
,
element
)
...
...
spec/lib/banzai/filter/video_link_filter_spec.rb
View file @
300d2885
...
...
@@ -17,32 +17,27 @@ describe Banzai::Filter::VideoLinkFilter do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
shared_examples
'replaces the image tag with a video tag'
do
|
ext
|
it
"replaces the image tag 'path/video.
#{
ext
}
' with a video tag"
do
container
=
filter
(
link_to_image
(
"/path/video.
#{
ext
}
"
)).
children
.
first
expect
(
container
.
name
).
to
eq
'div'
expect
(
container
[
'class'
]).
to
eq
'video-container'
context
'when the element src has a video extension'
do
UploaderHelper
::
SAFE_VIDEO_EXT
.
each
do
|
ext
|
it
"replaces the image tag 'path/video.
#{
ext
}
' with a video tag"
do
container
=
filter
(
link_to_image
(
"/path/video.
#{
ext
}
"
)).
children
.
first
video
,
paragraph
=
container
.
children
expect
(
container
.
name
).
to
eq
'div'
expect
(
container
[
'class'
]).
to
eq
'video-container'
expect
(
video
.
name
).
to
eq
'video'
expect
(
video
[
'src'
]).
to
eq
"/path/video.
#{
ext
}
"
video
,
paragraph
=
container
.
children
expect
(
paragraph
.
name
).
to
eq
'p'
expect
(
video
.
name
).
to
eq
'video'
expect
(
video
[
'src'
]).
to
eq
"/path/video.
#{
ext
}
"
link
=
paragraph
.
children
.
first
expect
(
paragraph
.
name
).
to
eq
'p'
expect
(
link
.
name
).
to
eq
'a'
expect
(
link
[
'href'
]).
to
eq
"/path/video.
#{
ext
}
"
expect
(
link
[
'target'
]).
to
eq
'_blank'
end
end
link
=
paragraph
.
children
.
first
context
'when the element src has a video extension'
do
UploaderHelper
::
SAFE_VIDEO_EXT
.
each
do
|
ext
|
it_behaves_like
'replaces the image tag with a video tag'
,
ext
it_behaves_like
'replaces the image tag with a video tag'
,
ext
.
upcase
expect
(
link
.
name
).
to
eq
'a'
expect
(
link
[
'href'
]).
to
eq
"/path/video.
#{
ext
}
"
expect
(
link
[
'target'
]).
to
eq
'_blank'
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment