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 14 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.2
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
4 changes: 4 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,10 @@
"Livechat_title": "Livechat Title",
"Livechat_title_color": "Livechat Title Background Color",
"Livechat_Users": "Livechat Users",
"Livestream_title": "LiveStream",
"Livestream_not_found": "Livestream not found",
"Livestream_popout": "Open Livestream in Popout",
"Livestream_url": "Livestream url",
"Load_more": "Load more",
"Loading...": "Loading...",
"Loading_more_from_history": "Loading more from history",
Expand Down
34 changes: 17 additions & 17 deletions packages/rocketchat-livechat/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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: 'podcast',
template: 'liveStreamTab',
order: 3
});
} else {
RocketChat.TabBar.removeButton('livestream');
}
});
});
28 changes: 28 additions & 0 deletions packages/rocketchat-livestream/client/views/liveStreamTab.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<template name="liveStreamTab">
<div class="contextual-bar__header flex-tab__header">
<div class="title">
<h2>{{_ "Livestream_title" }}</h2>
</div>
</div>
<section class="contextual-bar__content flex-tab-bar">
{{#if canEdit}}
{{#if editing}}
<form class="liveStreamTab__form">
<input type="text" name="streamingOptions" class="rc-input__element content-background-color editing" placeholder="{{_ "Livestream_url"}}" value="{{ streamingSource }}"/>
<button type="button" class="rc-button rc-button--nude js-cancel button-block" title="{{_ 'Cancel'}}" >{{_ "Cancel"}}</button>
<button type="button" class="rc-button rc-button--primary js-save button-block">{{_ "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}}
{{> liveStreamView streamingSource=streamingSource }}
<button type="button" name="livestream-popout" class="rc-button rc-button--primary livestreamPopout"> {{_ "Livestream_popout" }} </button>
{{else}}
{{_ "Livestream_not_found" }}
{{/if}}
</section>
</template>
79 changes: 79 additions & 0 deletions packages/rocketchat-livestream/client/views/liveStreamTab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* globals popout */
import toastr from 'toastr';

function parseUrl(url) {
gdelavald marked this conversation as resolved.
Show resolved Hide resolved
const parsedUrl = 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+)?/);
let source = url;
if (parsedUrl != null) {
if (parsedUrl[3].includes('youtu')) {
source = `https://www.youtube.com/embed/${ parsedUrl[6] }?showinfo=0`;
} 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;
}
}

Template.liveStreamTab.helpers({
streamingSource() {
return Template.instance().streamingOptions.get() ? Template.instance().streamingOptions.get().url : '';
},
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() == null || (Template.instance().streamingOptions.get() != null && Template.instance().streamingOptions.get().url === '');
}
});

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-cancel'(e, i) {
e.preventDefault();
i.editing.set(false);
},
'click .js-save'(e, i) {
e.preventDefault();

const streamingOptions = {
url: parseUrl(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);
},
'click .livestreamPopout'(e, i) {
e.preventDefault();
popout.open({
content: 'liveStreamView',
data: {
'streamingSource': i.streamingOptions.get().url
}
});
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template name="liveStreamView">
<div class="streaming-popup">
<iframe width="356" height="350" src="{{ streamingSource }}"
frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen>
</iframe>
</div>
</template>
Empty file.
27 changes: 27 additions & 0 deletions packages/rocketchat-livestream/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Package.describe({
name: 'rocketchat:livestream',
version: '0.0.2',
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/views/liveStreamView.html',
'client/views/liveStreamView.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);
};
10 changes: 10 additions & 0 deletions packages/rocketchat-livestream/server/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Meteor.startup(function() {
RocketChat.settings.addGroup('LiveStream', function() {
this.add('Livestream_enabled', false, {
type: 'boolean',
i18nLabel: 'Enabled',
public: true,
alert: 'This feature is currently in beta! Please report bugs to github.com/RocketChat/Rocket.Chat/issues'
});
});
});
Loading