PDF export
This commit is contained in:
parent
ffaf85f502
commit
cb467ed9dd
@ -1,5 +1,5 @@
|
||||
CACHE MANIFEST
|
||||
#Date Sat Sep 21 2013 16:28:43
|
||||
#Date Sun Sep 22 2013 23:14:34
|
||||
|
||||
CACHE:
|
||||
index.html
|
||||
|
610
res-min/main.js
610
res-min/main.js
File diff suppressed because one or more lines are too long
@ -1665,5 +1665,6 @@ div.jGrowl div.jGrowl-notification{min-height:80px}
|
||||
.viewer .document-panel .search-bar{padding:20px 20px 10px}
|
||||
.viewer .document-panel .search-bar .input-group-btn{display:none}
|
||||
.viewer .ui-layout-toggler{display:none !important}
|
||||
body.pdf{background-color:transparent}
|
||||
.navbar .working-indicator.show{background-image:url("../img/loader-blue-gray.gif")}
|
||||
@media only screen and (-webkit-min-device-pixel-ratio:2),only screen and (min--moz-device-pixel-ratio:2),only screen and (-o-min-device-pixel-ratio:2/1),only screen and (min-device-pixel-ratio:2),only screen and (min-resolution:192dpi),only screen and (min-resolution:2dppx){.navbar .working-indicator.show{background-image:url("../img/loader-blue-gray2x.gif");background-size:50px 17px}}@media only screen and (-webkit-min-device-pixel-ratio:2),only screen and (min--moz-device-pixel-ratio:2),only screen and (-o-min-device-pixel-ratio:2/1),only screen and (min-device-pixel-ratio:2),only screen and (min-resolution:192dpi),only screen and (min-resolution:2dppx){.navbar .working-indicator.show{background-image:url("../img/loader-blue-gray2x.gif");background-size:50px 17px}}
|
||||
|
@ -1665,3 +1665,4 @@ div.jGrowl div.jGrowl-notification{min-height:80px}
|
||||
.viewer .document-panel .search-bar{padding:20px 20px 10px}
|
||||
.viewer .document-panel .search-bar .input-group-btn{display:none}
|
||||
.viewer .ui-layout-toggler{display:none !important}
|
||||
body.pdf{background-color:transparent}
|
||||
|
@ -1665,6 +1665,7 @@ div.jGrowl div.jGrowl-notification{min-height:80px}
|
||||
.viewer .document-panel .search-bar{padding:20px 20px 10px}
|
||||
.viewer .document-panel .search-bar .input-group-btn{display:none}
|
||||
.viewer .ui-layout-toggler{display:none !important}
|
||||
body.pdf{background-color:transparent}
|
||||
.form-control:focus{-webkit-box-shadow:inset 0 1px 1px rgba(255,255,255,0),0 0 8px rgba(255,255,255,0.75);box-shadow:inset 0 1px 1px rgba(255,255,255,0),0 0 8px rgba(255,255,255,0.75)}
|
||||
.navbar .working-indicator.show{background-image:url("../img/loader-night.gif")}
|
||||
@media only screen and (-webkit-min-device-pixel-ratio:2),only screen and (min--moz-device-pixel-ratio:2),only screen and (-o-min-device-pixel-ratio:2/1),only screen and (min-device-pixel-ratio:2),only screen and (min-resolution:192dpi),only screen and (min-resolution:2dppx){.navbar .working-indicator.show{background-image:url("../img/loader-night2x.gif");background-size:50px 17px}}@media only screen and (-webkit-min-device-pixel-ratio:2),only screen and (min--moz-device-pixel-ratio:2),only screen and (-o-min-device-pixel-ratio:2/1),only screen and (min-device-pixel-ratio:2),only screen and (min-resolution:192dpi),only screen and (min-resolution:2dppx){.navbar .working-indicator.show{background-image:url("../img/loader-night2x.gif");background-size:50px 17px}}.ace-tm .ace_cursor{border-left-color:#fff}
|
||||
|
@ -1665,6 +1665,7 @@ div.jGrowl div.jGrowl-notification{min-height:80px}
|
||||
.viewer .document-panel .search-bar{padding:20px 20px 10px}
|
||||
.viewer .document-panel .search-bar .input-group-btn{display:none}
|
||||
.viewer .ui-layout-toggler{display:none !important}
|
||||
body.pdf{background-color:transparent}
|
||||
@font-face{font-family:'cursive_standardregular';src:url('../font/cursive_standard-webfont.eot');src:url('../font/cursive_standard-webfont.eot?#iefix') format('embedded-opentype'),url('../font/cursive_standard-webfont.woff') format('woff'),url('../font/cursive_standard-webfont.ttf') format('truetype'),url('../font/cursive_standard-webfont.svg#cursive_standardregular') format('svg');font-weight:normal;font-style:normal}.navbar{background-image:-webkit-gradient(linear, left 0, left 100%, from(#385e50), to(#34584b));background-image:-webkit-linear-gradient(top, #385e50, 0, #34584b, 100%);background-image:-moz-linear-gradient(top, #385e50 0, #34584b 100%);background-image:linear-gradient(to bottom, #385e50 0, #34584b 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff385e50', endColorstr='#ff34584b', GradientType=0)}
|
||||
.ui-layout-resizer-north .resizer-decorator{position:absolute;width:100%;height:7px;background-color:#b9aa9f;-webkit-box-shadow:0 -1px 15px rgba(0,0,0,0.3);box-shadow:0 -1px 15px rgba(0,0,0,0.3);z-index:10;display:block !important}
|
||||
.ui-layout-resizer-east{z-index:1 !important}
|
||||
|
@ -32,6 +32,7 @@ var PICASA_PROXY_URL = "http://stackedit-picasa-proxy.herokuapp.com/";
|
||||
var WORDPRESS_CLIENT_ID = '3185';
|
||||
var WORDPRESS_PROXY_URL = "http://stackedit-wordpress-proxy.herokuapp.com/";
|
||||
var SSH_PROXY_URL = "http://stackedit-ssh-proxy.herokuapp.com/";
|
||||
var HTMLTOPDF_URL = "http://benweet.insomnia247.nl/stackedit-htmltopdf/";
|
||||
|
||||
// Use by Google's client.js
|
||||
var delayedFunction = undefined;
|
||||
|
@ -713,6 +713,11 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
// Hide menu panel when clicking 'Save as' button
|
||||
$('.collapse-save-as a').click(function() {
|
||||
$menuPanelElt.collapse('hide');
|
||||
});
|
||||
|
||||
// Configure Mousetrap
|
||||
mousetrap.stopCallback = function(e, element, combo) {
|
||||
return isMenuPanelShown || isDocumentPanelShown || isModalShown || $(element).is("input, select, textarea:not(.ace_text-input)");
|
||||
|
@ -79,6 +79,7 @@
|
||||
<li><a class="action-download-html" href="#">Save as HTML</a></li>
|
||||
<li><a class="action-download-template" href="#">Save
|
||||
using template</a></li>
|
||||
<li><a class="action-download-pdf" href="#">Save as PDF</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -21,6 +21,7 @@
|
||||
<li><a class="action-download-html" href="#">Save as HTML</a></li>
|
||||
<li><a class="action-download-template" href="#">Save
|
||||
using template</a></li>
|
||||
<li><a class="action-download-pdf" href="#">Save as PDF</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -8,6 +8,8 @@ define([
|
||||
"fileMgr",
|
||||
"sharing",
|
||||
"classes/Provider",
|
||||
"classes/AsyncTask",
|
||||
"config",
|
||||
"providers/bloggerProvider",
|
||||
"providers/dropboxProvider",
|
||||
"providers/gistProvider",
|
||||
@ -16,7 +18,7 @@ define([
|
||||
"providers/sshProvider",
|
||||
"providers/tumblrProvider",
|
||||
"providers/wordpressProvider"
|
||||
], function($, _, utils, settings, eventMgr, fileSystem, fileMgr, sharing, Provider) {
|
||||
], function($, _, utils, settings, eventMgr, fileSystem, fileMgr, sharing, Provider, AsyncTask) {
|
||||
|
||||
var publisher = {};
|
||||
|
||||
@ -243,6 +245,12 @@ define([
|
||||
localStorage[provider.providerId + ".publishPreferences"] = JSON.stringify(publishPreferences);
|
||||
}
|
||||
|
||||
// Listen to offline status changes
|
||||
var isOffline = false;
|
||||
eventMgr.addListener("onOfflineChanged", function(isOfflineParam) {
|
||||
isOffline = isOfflineParam;
|
||||
});
|
||||
|
||||
var initPublishButtonTmpl = [
|
||||
'<li>',
|
||||
' <a href="#"',
|
||||
@ -308,6 +316,43 @@ define([
|
||||
var content = publisher.applyTemplate(fileDesc, undefined, previewHtml);
|
||||
utils.saveAs(content, fileDesc.title + (settings.template.indexOf("documentHTML") === -1 ? ".md" : ".html"));
|
||||
});
|
||||
$(".action-download-pdf").click(function() {
|
||||
var fileDesc = fileMgr.currentFile;
|
||||
var content = publisher.applyTemplate(fileDesc, {
|
||||
customTmpl: settings.pdfTemplate
|
||||
}, previewHtml);
|
||||
var task = new AsyncTask();
|
||||
var pdf = undefined;
|
||||
task.onRun(function() {
|
||||
if(isOffline === true) {
|
||||
eventMgr.onError("Operation not available in offline mode.");
|
||||
task.chain();
|
||||
return;
|
||||
}
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', HTMLTOPDF_URL, true);
|
||||
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||
xhr.responseType = 'blob';
|
||||
xhr.onreadystatechange = function() {
|
||||
if(this.readyState == 4) {
|
||||
if(this.status == 200) {
|
||||
pdf = this.response;
|
||||
}
|
||||
else {
|
||||
eventMgr.onError("Error when trying to generate PDF: " + this.status);
|
||||
}
|
||||
task.chain();
|
||||
}
|
||||
};
|
||||
xhr.send(content);
|
||||
});
|
||||
task.onSuccess(function() {
|
||||
if(pdf !== undefined) {
|
||||
utils.saveAs(pdf, fileMgr.currentFile.title + ".pdf");
|
||||
}
|
||||
});
|
||||
task.enqueue();
|
||||
});
|
||||
});
|
||||
|
||||
eventMgr.onPublisherCreated(publisher);
|
||||
|
@ -28,6 +28,30 @@ define([
|
||||
'<body><div class="container"><%= documentHTML %></div></body>\n',
|
||||
'</html>'
|
||||
].join(""),
|
||||
pdfTemplate: [
|
||||
'<!DOCTYPE html>\n',
|
||||
'<html>\n',
|
||||
'<head>\n',
|
||||
'<meta charset="utf-8">\n',
|
||||
'<title><%= documentTitle %></title>\n',
|
||||
'<link rel="stylesheet" href="',
|
||||
MAIN_URL,
|
||||
'res-min/themes/default.css" />\n',
|
||||
'<style type="text/css">\n',
|
||||
"@font-face {font-family: MathJax_Main; src: url('", MAIN_URL, "lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Main-Regular.woff') format('woff'), url('http://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Main-Regular.otf') format('opentype')}\n",
|
||||
"@font-face {font-family: MathJax_Main; src: url('", MAIN_URL, "lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Main-Bold.woff') format('woff'), url('http://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Main-Bold.otf') format('opentype'); font-weight: bold}\n",
|
||||
"@font-face {font-family: MathJax_Main; src: url('", MAIN_URL, "lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Main-Italic.woff') format('woff'), url('http://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Main-Italic.otf') format('opentype'); font-style: italic}\n",
|
||||
"@font-face {font-family: MathJax_Math; src: url('", MAIN_URL, "lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Math-Italic.woff') format('woff'), url('http://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Math-Italic.otf') format('opentype'); font-style: italic}\n",
|
||||
"@font-face {font-family: MathJax_Caligraphic; src: url('", MAIN_URL, "lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Caligraphic-Regular.woff') format('woff'), url('http://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Caligraphic-Regular.otf') format('opentype')}\n",
|
||||
"@font-face {font-family: MathJax_Size1; src: url('", MAIN_URL, "lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Size1-Regular.woff') format('woff'), url('http://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Size1-Regular.otf') format('opentype')}\n",
|
||||
"@font-face {font-family: MathJax_Size2; src: url('", MAIN_URL, "lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Size2-Regular.woff') format('woff'), url('http://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Size2-Regular.otf') format('opentype')}\n",
|
||||
"@font-face {font-family: MathJax_Size3; src: url('", MAIN_URL, "lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Size3-Regular.woff') format('woff'), url('http://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Size3-Regular.otf') format('opentype')}\n",
|
||||
"@font-face {font-family: MathJax_Size4; src: url('", MAIN_URL, "lib/MathJax/fonts/HTML-CSS/TeX/woff/MathJax_Size4-Regular.woff') format('woff'), url('http://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS/TeX/otf/MathJax_Size4-Regular.otf') format('opentype')}\n",
|
||||
'</style>\n',
|
||||
'</head>\n',
|
||||
'<body class="pdf"><%= documentHTML %></body>\n',
|
||||
'</html>'
|
||||
].join(""),
|
||||
sshProxy: SSH_PROXY_URL,
|
||||
extensionSettings: {}
|
||||
};
|
||||
|
@ -1243,3 +1243,10 @@ div.jGrowl {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************
|
||||
* PDF
|
||||
*******************/
|
||||
body.pdf {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
@ -215,12 +215,14 @@ define([
|
||||
// Export data on disk
|
||||
utils.saveAs = function(content, filename) {
|
||||
if(saveAs !== undefined) {
|
||||
var blob = new Blob([
|
||||
if(_.isString(content)) {
|
||||
content = new Blob([
|
||||
content
|
||||
], {
|
||||
type: "text/plain;charset=utf-8"
|
||||
});
|
||||
saveAs(blob, filename);
|
||||
}
|
||||
saveAs(content, filename);
|
||||
}
|
||||
else {
|
||||
var uriContent = "data:application/octet-stream;base64," + utils.encodeBase64(content);
|
||||
|
Loading…
Reference in New Issue
Block a user