Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Livestream tab #9255

Merged
merged 35 commits into from
Jan 31, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
94d41bf
Add tab to embed livestreaming videos on channel
gdelavald Dec 27, 2017
b3c4af0
Add option to enable livestream tab
gdelavald Dec 27, 2017
166c2fd
Adds support for youtube, vimeo and twitch-channel urls
gdelavald Dec 27, 2017
a40fd3b
Enable twitch channel embeds
gdelavald Dec 27, 2017
6422e50
Remove unused else
gdelavald Dec 27, 2017
6b56020
Fixes twitch parsing on channels
gdelavald Dec 27, 2017
5214b8d
Fix error when url not parseable, add podcast icon
gdelavald Dec 27, 2017
9861349
Allow editing when url is empty
gdelavald Dec 27, 2017
fef945e
Adds popout component & basic popout functionality
gdelavald Dec 28, 2017
b45235b
Styling on popout component and livestream tab
gdelavald Dec 29, 2017
bdd83a7
Add popout remove callback on logout
gdelavald Dec 29, 2017
adc37a5
Add english strings, enable cancel button
gdelavald Dec 29, 2017
c5a5955
Styling changes and small fixes
gdelavald Dec 29, 2017
a078f7e
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
gdelavald Dec 29, 2017
7bc50ee
Missing string translation
gdelavald Dec 29, 2017
b01bf45
Fix for empty url on livestream source
gdelavald Dec 29, 2017
d7a8328
Replace iframe with html object, improve popout features
gdelavald Jan 2, 2018
66be235
Improvements to switching rooms with livestreams and styling
gdelavald Jan 3, 2018
f08dc01
Resolve exception when closing popout from different channel
gdelavald Jan 3, 2018
bfb924a
Added popout drag-n-drop
gdelavald Jan 12, 2018
567d18f
Prevent file drag n drop from interfering with popout component
gdelavald Jan 12, 2018
2a4e51f
Adds new styling and improvements for popout behavior
gdelavald Jan 15, 2018
4f85652
Add new styling for livestreamtab
gdelavald Jan 15, 2018
419ae83
Hide player on toggled version, improvements to style
gdelavald Jan 15, 2018
8c68e4d
Layout changes to popout component
gdelavald Jan 17, 2018
f4f191e
Changes icons, add audio only mode
gdelavald Jan 18, 2018
1cc9e2c
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
gdelavald Jan 30, 2018
e8f1641
Fix conflicts and update style to match new contextual bar
gdelavald Jan 30, 2018
bcb02fa
Small style enhancement
gdelavald Jan 30, 2018
4ca0056
Small style enhancement 2
gdelavald Jan 30, 2018
38346c2
Removing package-lock for some reason
gdelavald Jan 30, 2018
bac24ba
Small refactor on method name
gdelavald Jan 30, 2018
51eaedb
fix linter
ggazzo Jan 30, 2018
3ce7070
Merge branch 'livestream-tab' of https://github.com/RocketChat/Rocket…
gdelavald Jan 30, 2018
14a7c43
Improves drag-n-drop ux
gdelavald Jan 31, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ rocketchat:katex
rocketchat:ldap
rocketchat:lib
rocketchat:livechat
rocketchat:livestream
rocketchat:logger
rocketchat:login-token
rocketchat:mailer
Expand Down
1 change: 1 addition & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ rocketchat:katex@0.0.1
rocketchat:ldap@0.0.1
rocketchat:lib@0.0.1
rocketchat:livechat@0.0.1
rocketchat:livestream@0.0.1
rocketchat:logger@0.0.1
rocketchat:login-token@1.0.0
rocketchat:mailer@0.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Meteor.methods({
method: 'saveRoomSettings'
});
}
if (!['roomName', 'roomTopic', 'roomAnnouncement', 'roomDescription', 'roomType', 'readOnly', 'reactWhenReadOnly', 'systemMessages', 'default', 'joinCode', 'tokenpass'].some((s) => s === setting)) {
if (!['roomName', 'roomTopic', 'roomAnnouncement', 'roomDescription', 'roomType', 'readOnly', 'reactWhenReadOnly', 'systemMessages', 'default', 'joinCode', 'tokenpass', 'streamingOptions'].some((s) => s === setting)) {
throw new Meteor.Error('error-invalid-settings', 'Invalid settings provided', {
method: 'saveRoomSettings'
});
Expand Down Expand Up @@ -75,6 +75,9 @@ Meteor.methods({
});
RocketChat.saveRoomTokenpass(rid, value);
break;
case 'streamingOptions':
RocketChat.saveStreamingOptions(rid, value);
break;
case 'readOnly':
if (value !== room.ro) {
RocketChat.saveRoomReadOnly(rid, value, Meteor.user());
Expand Down
16 changes: 16 additions & 0 deletions packages/rocketchat-livestream/client/tabBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Meteor.startup(function() {
Tracker.autorun(function() {
if (RocketChat.settings.get('Livestream_enabled')) {
return RocketChat.TabBar.addButton({
groups: ['channel', 'group'],
id: 'livestream',
i18nTitle: 'Livestream',
icon: 'play',
template: 'liveStreamTab',
order: 3
});
} else {
RocketChat.TabBar.removeButton('livestream');
}
});
});
29 changes: 29 additions & 0 deletions packages/rocketchat-livestream/client/views/liveStreamTab.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template name="liveStreamTab">
<div class="contextual-bar__header flex-tab__header">
<div class="title">
<h2>{{_ "Livestream_title" }}</h2>
</div>
</div>
<div class="contextual-bar__content flex-tab">
{{#if canEdit}}
{{#if editing}}
<form class="liveStreamTab_form">
gdelavald marked this conversation as resolved.
Show resolved Hide resolved
<input type="text" name="streamingOptions" class="content-background-color editing" placeholder="{{_ "Livestream_url"}}" value="{{ streamingSource }}"/>
<button type="button" class="button js-cancel" title="{{_ 'Cancel'}}" >{{_ "Cancel"}}</button>
<button type="button" class="button primary js-save">{{_ "Save"}}</button>
</form>
{{else}}
<div class="setting-block">
gdelavald marked this conversation as resolved.
Show resolved Hide resolved
<span class="current-setting streamingSourceSetting"> {{ streamingSource }} </span>
</div>
{{/if}}
{{/if}}
{{#if hasSource}}
<iframe width="356" height="350" src="{{ streamingSource }}"
frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen>
</iframe>
{{else}}
<div> {{_ "Livestream_not_found" }}</div>
{{/if}}
</div>
</template>
65 changes: 65 additions & 0 deletions packages/rocketchat-livestream/client/views/liveStreamTab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import toastr from 'toastr';

Template.liveStreamTab.helpers({
streamingSource() {
const streamingOptions = Template.instance().streamingOptions.get();
if (streamingOptions == null) {
return '';
} else {
const parsedUrl = streamingOptions.url.match(/(http:|https:|)\/\/(clips.|player.|www.)?(twitch\.tv|vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com))\/(video\/|embed\/|watch\?v=|v\/|embed\?clip=)?([A-Za-z0-9._%-]*)(\&\S+)?/);
gdelavald marked this conversation as resolved.
Show resolved Hide resolved
let source = streamingOptions.url;
if (parsedUrl[3].includes('youtu')) {
source = `https://www.youtube.com/embed/${ parsedUrl[6] }`;
} else if (parsedUrl[3].includes('vimeo')) {
source = `https://player.vimeo.com/video/${ parsedUrl[6] }`;
} else if (parsedUrl[3].includes('twitch')) {
source = `http://player.twitch.tv/?channel=${ parsedUrl[6] }`;
}
// @TODO add support for other urls

return source;
}

},
hasSource() {
return !!Template.instance().streamingOptions.get() && Template.instance().streamingOptions.get().url !== '';
},
canEdit() {
return RocketChat.authz.hasAllPermission('edit-room', this.rid);
},
editing() {
return Template.instance().editing.get() || !Template.instance().streamingOptions.get();
}
});

Template.liveStreamTab.onCreated(function() {
this.editing = new ReactiveVar(false);
this.streamingOptions = new ReactiveVar();

this.autorun(() => {
const room = RocketChat.models.Rooms.findOne(this.data.rid, { fields: { streamingOptions : 1 } });
this.streamingOptions.set(room.streamingOptions);
});
});

Template.liveStreamTab.events({
'click .js-save'(e, i) {
e.preventDefault();

const streamingOptions = {
url: i.find('[name=streamingOptions]').value
};
Meteor.call('saveRoomSettings', this.rid, 'streamingOptions', streamingOptions, function(err) {
if (err) {
return handleError(err);
}
i.editing.set(false);
i.streamingOptions.set(streamingOptions);
return toastr.success(TAPi18n.__('Streaming_source_changed_succesfully'));
});
},
'click .streamingSourceSetting'(e, i) {
e.preventDefault();
i.editing.set(true);
}
});
25 changes: 25 additions & 0 deletions packages/rocketchat-livestream/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Package.describe({
name: 'rocketchat:livestream',
version: '0.0.1',
summary: 'Embed livestream to Rocket.Chat channels',
git: ''
});

Package.onUse(function(api) {
api.use('templating', 'client');
api.use([
'ecmascript',
'rocketchat:lib'
]);
api.addFiles([
'client/views/liveStreamTab.html',
'client/views/liveStreamTab.js',
'client/tabBar.js'
], 'client');

api.addFiles([
'server/models/Rooms.js',
'server/functions/saveStreamingOptions.js',
'server/settings.js'
], 'server');
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
RocketChat.saveStreamingOptions = function(rid, streamingOptions) {
if (!Match.test(rid, String)) {
throw new Meteor.Error('invalid-room', 'Invalid room', {
'function': 'RocketChat.saveStreamingOptions'
});
}

return RocketChat.models.Rooms.setStreamingOptionsById(rid, streamingOptions);
};
8 changes: 8 additions & 0 deletions packages/rocketchat-livestream/server/models/Rooms.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
RocketChat.models.Rooms.setStreamingOptionsById = function(_id, streamingOptions) {
const update = {
$set: {
streamingOptions
}
};
return this.update({ _id }, update);
};
9 changes: 9 additions & 0 deletions packages/rocketchat-livestream/server/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Meteor.startup(function() {
RocketChat.settings.addGroup('LiveStream', function() {
this.add('Livestream_enabled', false, {
type: 'boolean',
i18nLabel: 'Enabled',
public: true
});
});
});
3 changes: 2 additions & 1 deletion server/publications/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const fields = {
ro: 1,
reactWhenReadOnly: 1,
sentiment: 1,
tokenpass: 1
tokenpass: 1,
streamingOptions: 1
};

const roomMap = (record) => {
Expand Down
6 changes: 4 additions & 2 deletions server/startup/roomPublishes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Meteor.startup(function() {
jitsiTimeout: 1,
description: 1,
sysMes: 1,
joinCodeRequired: 1
joinCodeRequired: 1,
streamingOptions: 1
}
};

Expand Down Expand Up @@ -49,7 +50,8 @@ Meteor.startup(function() {
jitsiTimeout: 1,
description: 1,
sysMes: 1,
tokenpass: 1
tokenpass: 1,
streamingOptions: 1
}
};

Expand Down