Skip to content

Commit

Permalink
fix issue with slide calc under https
Browse files Browse the repository at this point in the history
  • Loading branch information
antobinary committed Jul 26, 2016
1 parent a47f159 commit 3e07087
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 39 deletions.
Expand Up @@ -3,49 +3,93 @@ import Slides from '/imports/api/slides';

export function addSlideToCollection(meetingId, presentationId, slideObject) {
const url = Npm.require('url');
const http = Npm.require('http');

const imageUri = slideObject.svg_uri != null ? slideObject.svg_uri : slideObject.png_uri;
if (Slides.findOne({
meetingId: meetingId,
'slide.id': slideObject.id,
}) == null) {
const options = url.parse(imageUri);
http.get(options, Meteor.bindEnvironment(function (response) {
let contentType = response.headers['content-type'];

if (contentType.match(/svg/gi) || contentType.match(/png/gi)) {
let chunks = [];
response.on('data', Meteor.bindEnvironment(function (chunk) {
chunks.push(chunk);
})).on('end', Meteor.bindEnvironment(function () {
let buffer = Buffer.concat(chunks);
const dimensions = sizeOf(buffer);
const entry = {
meetingId: meetingId,
presentationId: presentationId,
slide: {
height_ratio: slideObject.height_ratio,
y_offset: slideObject.y_offset,
num: slideObject.num,
x_offset: slideObject.x_offset,
current: slideObject.current,
img_uri: slideObject.svg_uri != null ? slideObject.svg_uri : slideObject.png_uri,
txt_uri: slideObject.txt_uri,
id: slideObject.id,
width_ratio: slideObject.width_ratio,
swf_uri: slideObject.swf_uri,
thumb_uri: slideObject.thumb_uri,
width: dimensions.width,
height: dimensions.height,
},
};
Slides.insert(entry);
}));
} else {
console.log(`Slide file is not accessible or not ready yet`);
console.log(`response content-type`, response.headers['content-type']);
}
}));

if (process.env.NODE_ENV === 'development') {
const http = Npm.require('http');

http.get(options, Meteor.bindEnvironment(function (response) {
let contentType = response.headers['content-type'];

if (contentType.match(/svg/gi) || contentType.match(/png/gi)) {
let chunks = [];
response.on('data', Meteor.bindEnvironment(function (chunk) {
chunks.push(chunk);
})).on('end', Meteor.bindEnvironment(function () {
let buffer = Buffer.concat(chunks);
const dimensions = sizeOf(buffer);
const entry = {
meetingId: meetingId,
presentationId: presentationId,
slide: {
height_ratio: slideObject.height_ratio,
y_offset: slideObject.y_offset,
num: slideObject.num,
x_offset: slideObject.x_offset,
current: slideObject.current,
img_uri: slideObject.svg_uri != null ? slideObject.svg_uri : slideObject.png_uri,
txt_uri: slideObject.txt_uri,
id: slideObject.id,
width_ratio: slideObject.width_ratio,
swf_uri: slideObject.swf_uri,
thumb_uri: slideObject.thumb_uri,
width: dimensions.width,
height: dimensions.height,
},
};
Slides.insert(entry);
}));
} else {
console.log(`Slide file is not accessible or not ready yet`);
console.log(`response content-type`, response.headers['content-type']);
}
}));
} else {
const https = Npm.require('https');

https.get(options, Meteor.bindEnvironment(function (response) {
let contentType = response.headers['content-type'];

if (contentType.match(/svg/gi) || contentType.match(/png/gi)) {
let chunks = [];
response.on('data', Meteor.bindEnvironment(function (chunk) {
chunks.push(chunk);
})).on('end', Meteor.bindEnvironment(function () {
let buffer = Buffer.concat(chunks);
const dimensions = sizeOf(buffer);
const entry = {
meetingId: meetingId,
presentationId: presentationId,
slide: {
height_ratio: slideObject.height_ratio,
y_offset: slideObject.y_offset,
num: slideObject.num,
x_offset: slideObject.x_offset,
current: slideObject.current,
img_uri: slideObject.svg_uri != null ? slideObject.svg_uri : slideObject.png_uri,
txt_uri: slideObject.txt_uri,
id: slideObject.id,
width_ratio: slideObject.width_ratio,
swf_uri: slideObject.swf_uri,
thumb_uri: slideObject.thumb_uri,
width: dimensions.width,
height: dimensions.height,
},
};
Slides.insert(entry);
}));
} else {
console.log(`Slide file is not accessible or not ready yet`);
console.log(`response content-type`, response.headers['content-type']);
}
}));
}

//logger.info "added slide id =[#{id}]:#{slideObject.id} in #{meetingId}. Now there
// are #{Slides.find({meetingId: meetingId}).count()} slides in the meeting"
Expand Down
Expand Up @@ -44,7 +44,7 @@ Meteor.publish('users', function (credentials) {
}
} else { //subscribing before the user was added to the collection
Meteor.call('validateAuthToken', credentials);
logger.error(`there was no user ${userid} in ${meetingId}. Sending validateAuthToken`);
logger.info(`Sending validateAuthTokenthere for user ${userid} in ${meetingId}.`);
return getUsers(meetingId);
}
});
Expand Down
2 changes: 1 addition & 1 deletion bigbluebutton-html5/start.sh
@@ -1,4 +1,4 @@
#
# the idea is that this way we prevent test runs (for whenever needed)
HOME=/usr/share/meteor JASMINE_SERVER_UNIT=0 JASMINE_SERVER_INTEGRATION=0 JASMINE_CLIENT_INTEGRATION=0 JASMINE_BROWSER=PhantomJS JASMINE_MIRROR_PORT=3000 ROOT_URL=http://127.0.0.1/html5client meteor
JASMINE_SERVER_UNIT=0 JASMINE_SERVER_INTEGRATION=0 JASMINE_CLIENT_INTEGRATION=0 JASMINE_BROWSER=PhantomJS JASMINE_MIRROR_PORT=3000 ROOT_URL=http://127.0.0.1/html5client meteor
# ROOT_URL_PATH_PREFIX=html5client meteor

0 comments on commit 3e07087

Please sign in to comment.