Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yPhil
Pétrolette
Commits
3800c2a0
Commit
3800c2a0
authored
Mar 19, 2021
by
yPhil
Browse files
MediaRSS: Video player OK, Audio tomorrow
parent
0f3304c1
Pipeline
#399277
failed with stage
in 1 minute and 34 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
petrolette.js
View file @
3800c2a0
...
...
@@ -22,6 +22,7 @@ app.disable('x-powered-by');
app
.
use
(
compression
());
app
.
use
(
helmet
.
originAgentCluster
());
app
.
use
(
helmet
.
noSniff
());
app
.
use
(
cors
());
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
...
...
public/js/PTL.feed.js
View file @
3800c2a0
...
...
@@ -316,6 +316,8 @@ PTL.feed = {
var
$description
=
$
.
parseHTML
(
item
.
description
),
summary
,
imageUrl
,
videoUrl
,
videoType
,
imageUrls
=
[],
imgTypes
=
[
'
image
'
,
'
image/jpg
'
,
...
...
@@ -396,6 +398,19 @@ PTL.feed = {
}
}
if
(
item
[
'
media:group
'
])
{
if
(
item
[
'
media:group
'
][
'
media:content
'
])
{
if
(
item
[
'
media:group
'
][
'
media:content
'
][
0
])
{
if
(
item
[
'
media:group
'
][
'
media:content
'
][
0
][
'
@
'
])
{
if
(
item
[
'
media:group
'
][
'
media:content
'
][
0
][
'
@
'
].
medium
&&
item
[
'
media:group
'
][
'
media:content
'
][
0
][
'
@
'
].
medium
===
'
video
'
)
{
videoUrl
=
item
[
'
media:group
'
][
'
media:content
'
][
0
][
'
@
'
].
url
;
videoType
=
item
[
'
media:group
'
][
'
media:content
'
][
0
][
'
@
'
].
type
;
}
}
}
}
}
if
(
item
.
enclosures
&&
typeof
item
.
enclosures
[
0
]
!==
'
undefined
'
&&
item
.
enclosures
[
0
].
url
)
{
if
(
item
.
enclosures
[
0
].
url
&&
item
.
enclosures
[
0
].
url
.
endsWith
(
"
.jpg
"
))
{
...
...
@@ -406,12 +421,17 @@ PTL.feed = {
imageUrl
=
item
.
enclosures
[
0
].
url
;
}
if
(
item
.
enclosures
[
0
].
url
&&
item
.
enclosures
[
0
].
url
.
match
(
/
\.(
mp4|webm
)
$/
))
{
if
(
!
videoUrl
&&
item
.
enclosures
[
0
].
url
&&
item
.
enclosures
[
0
].
url
.
match
(
/
\.(
mp4|webm
)
$/
))
{
videoUrl
=
item
.
enclosures
[
0
].
url
;
videoType
=
item
.
enclosures
[
0
].
type
;
}
if
(
videoUrl
&&
videoType
)
{
var
videoPlayer
=
document
.
createElement
(
'
video
'
);
videoPlayer
.
controls
=
'
controls
'
;
videoPlayer
.
src
=
item
.
enclosures
[
0
].
u
rl
;
videoPlayer
.
type
=
item
.
enclosures
[
0
].
t
ype
;
videoPlayer
.
src
=
videoU
rl
;
videoPlayer
.
type
=
videoT
ype
;
$itemDiv
.
append
(
videoPlayer
);
...
...
@@ -442,42 +462,20 @@ PTL.feed = {
}
}
if
(
item
[
'
media:group
'
])
{
var
mgmc
=
item
[
'
media:group
'
][
'
media:content
'
];
for
(
var
i
=
0
;
i
<
mgmc
.
length
;
i
++
)
{
if
(
mgmc
[
i
][
'
@
'
].
url
)
imageUrl
=
mgmc
[
i
][
'
@
'
].
url
;
}
}
//
if (item['media:group']) {
//
var mgmc = item['media:group']['media:content'];
//
for (var i = 0; i < mgmc.length; i++) {
//
if (mgmc[i]['@'].url) imageUrl = mgmc[i]['@'].url;
//
}
//
}
$itemLink
.
attr
(
'
class
'
,
'
ui-helper-clearfix feed-link
'
)
.
attr
(
'
href
'
,
item
.
link
||
item
.
enclosures
[
0
].
url
)
.
append
(
item
[
'
mastodon:scope
'
]
?
$summary
.
trim
()
:
item
.
title
);
if
(
imageUrls
&&
imageUrls
.
length
>=
1
)
{
console
.
log
(
'
imageUrls.length: %s (%s)
'
,
imageUrls
.
length
);
$image
=
$
(
'
<div>
'
)
.
attr
(
'
class
'
,
'
ptl-img
'
)
.
appendTo
(
$imageLink
);
for
(
var
i
=
0
,
len
=
imageUrls
.
length
;
i
<
len
;
i
++
)
{
$
(
'
<a>
'
)
.
attr
(
'
href
'
,
imageUrls
[
i
])
.
attr
(
'
data-fancybox
'
,
'
gallery
'
)
// .attr('data-caption', $imageLinkButton)
.
appendTo
(
$image
)
.
append
(
$
(
'
<img>
'
)
.
attr
(
'
src
'
,
imageUrls
[
i
])
.
attr
(
'
alt
'
,
item
[
'
mastodon:scope
'
]
?
$summary
.
trim
()
:
item
.
title
)
.
appendTo
(
$image
));
}
}
else
if
(
imageUrl
&&
typeof
imageUrl
!==
'
undefined
'
&&
!
imageUrl
.
includes
(
'
pixel
'
))
{
if
(
!
videoUrl
&&
imageUrl
&&
typeof
imageUrl
!==
'
undefined
'
&&
!
imageUrl
.
includes
(
'
pixel
'
))
{
// Can't pass a JQ object as the button
$imageLink
.
attr
(
'
href
'
,
imageUrl
)
.
attr
(
'
title
'
,
$summary
.
trim
())
...
...
public/js/PTL.main.js
View file @
3800c2a0
...
...
@@ -320,7 +320,7 @@ var PTL = (function() {
$
.
fancybox
.
defaults
.
buttons
=
[
'
slideShow
'
,
'
fullScreen
'
,
'
thumbs
'
,
//
'thumbs',
'
download
'
,
'
zoom
'
,
'
close
'
...
...
Write
Preview
Supports
Markdown
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