Fixed PDF service

This commit is contained in:
benweet 2014-08-20 00:20:51 +01:00
parent 7726b46be2
commit a037fb31a8
5 changed files with 13 additions and 9 deletions

View File

@ -39,7 +39,7 @@ var authorizedPageSizes = [
'Letter' 'Letter'
]; ];
module.exports = function(req, res, next) { exports.export = function(req, res, next) {
function onError(err) { function onError(err) {
next(err); next(err);
} }

View File

@ -6,7 +6,7 @@ define([
'fileMgr', 'fileMgr',
'editor', 'editor',
'diff_match_patch_uncompressed', 'diff_match_patch_uncompressed',
'jsondiffpatch', 'jsondiffpatch'
], function(_, utils, settings, eventMgr, fileMgr, editor, diff_match_patch, jsondiffpatch) { ], function(_, utils, settings, eventMgr, fileMgr, editor, diff_match_patch, jsondiffpatch) {
function Provider(providerId, providerName) { function Provider(providerId, providerName) {

View File

@ -23,10 +23,10 @@ define([], function() {
constants.IMPORT_IMG_MAX_CONTENT_SIZE = 10000000; constants.IMPORT_IMG_MAX_CONTENT_SIZE = 10000000;
constants.TEMPORARY_FILE_INDEX = "file.tempIndex"; constants.TEMPORARY_FILE_INDEX = "file.tempIndex";
constants.WELCOME_DOCUMENT_TITLE = "Welcome document"; constants.WELCOME_DOCUMENT_TITLE = "Welcome document";
constants.DOWNLOAD_PROXY_URL = "https://stackedit-download-proxy.herokuapp.com/"; constants.DOWNLOAD_IMPORT_URL = "/downloadImport";
constants.PICASA_PROXY_URL = "https://stackedit-picasa-proxy.herokuapp.com/"; constants.PICASA_IMPORT_IMG_URL = "/picasaImportImg";
constants.SSH_PROXY_URL = "https://stackedit-ssh-proxy.herokuapp.com/"; constants.SSH_PUBLISH_URL = '/sshPublish';
constants.HTMLTOPDF_URL = "/pdf"; constants.PDF_EXPORT_URL = "/pdfExport";
// Site dependent // Site dependent
constants.BASE_URL = "http://localhost/"; constants.BASE_URL = "http://localhost/";

View File

@ -364,7 +364,10 @@ define([
return task.chain(); return task.chain();
} }
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('POST', constants.HTMLTOPDF_URL + '?token=' + encodeURIComponent(token) + '&options=' + encodeURIComponent(settings.pdfOptions), true); xhr.open('POST', constants.PDF_EXPORT_URL + '?' + $.param({
token: token,
options: settings.pdfOptions
}), true);
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr.responseType = 'blob'; xhr.responseType = 'blob';
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
@ -373,7 +376,7 @@ define([
pdf = this.response; pdf = this.response;
} }
else { else {
eventMgr.onError("Error when trying to generate PDF: " + this.status); eventMgr.onError("Error when trying to generate PDF: " + this.statusText);
} }
task.chain(); task.chain();
} }

View File

@ -246,9 +246,10 @@ define([
localStorage.removeItem("welcomeTour"); localStorage.removeItem("welcomeTour");
if(_.has(localStorage, 'settings')) { if(_.has(localStorage, 'settings')) {
settings = JSON.parse(localStorage.settings); settings = JSON.parse(localStorage.settings);
// Remove PDF settings as it's a new web service // New web services
delete settings.pdfTemplate; delete settings.pdfTemplate;
delete settings.pdfPageSize; delete settings.pdfPageSize;
delete settings.sshProxy;
localStorage.settings = JSON.stringify(settings); localStorage.settings = JSON.stringify(settings);
} }
version = "v20"; version = "v20";