Skip to content

Commit

Permalink
Merge pull request #737 from tiangolo/fix-img-urls
Browse files Browse the repository at this point in the history
Fix baseRasterizedExporter.js to write correct image URLs

Fixes #225 #222 #642 #512
  • Loading branch information
prikhi committed Sep 21, 2015
2 parents b1021aa + b075854 commit 3691974
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions app/content/pencil/exporter/baseRasterizedExporter.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
function BaseRasterizedExporter() {
this.name = Util.getMessage("rasterized.graphics.png.files");
this.id = "BaseRasterizedExporter";
this.name = Util.getMessage("rasterized.graphics.png.files");
this.id = "BaseRasterizedExporter";
}
BaseRasterizedExporter.prototype = new BaseExporter();

BaseRasterizedExporter.prototype.requireRasterizedData = function () {
return true;
BaseRasterizedExporter.prototype.requireRasterizedData = function() {
return true;
};
BaseRasterizedExporter.prototype.getRasterizedPageDestination = function (baseDir) {
return baseDir.clone();
BaseRasterizedExporter.prototype.getRasterizedPageDestination = function(
baseDir) {
return baseDir.clone();
};

BaseRasterizedExporter.prototype.export = function (doc, options, destFile, xmlFile, callback) {
callback();
BaseRasterizedExporter.prototype.export = function(doc, options, destFile,
xmlFile, callback) {
callback();
};
BaseRasterizedExporter.prototype.getWarnings = function () {
return Util.getMessage("no.linkings.are.preserved");
BaseRasterizedExporter.prototype.getWarnings = function() {
return Util.getMessage("no.linkings.are.preserved");
};
BaseRasterizedExporter.prototype.fixAbsoluteRasterizedPaths = function (sourceDOM, destDir) {
//changing rasterized path to relative
var pathPrefix = destDir.path + DirIO.sep;
Dom.workOn("//p:Page/@rasterized", sourceDOM, function (attr) {
var path = attr.nodeValue;
if (path.indexOf(pathPrefix) == 0) {
path = path.substring(pathPrefix.length);
attr.nodeValue = path;
}
});
BaseRasterizedExporter.prototype.fixAbsoluteRasterizedPaths = function(
sourceDOM, destDir) {
//changing rasterized path to relative
var pathPrefix = destDir.path + DirIO.sep;
Dom.workOn("//p:Page/@rasterized", sourceDOM, function(attr) {
var path = attr.nodeValue;
if (path.indexOf(pathPrefix) == 0) {
path = path.substring(pathPrefix.length);
attr.nodeValue = path.replace(DirIO.sep, "/");
}
});
};

Pencil.registerDocumentExporter(new BaseRasterizedExporter());

0 comments on commit 3691974

Please sign in to comment.