diff --git a/src/line-by-line-printer.js b/src/line-by-line-printer.js index 6e7e4e6..042584d 100644 --- a/src/line-by-line-printer.js +++ b/src/line-by-line-printer.js @@ -33,7 +33,8 @@ fileHtmlId: printerUtils.getHtmlId(file), diffs: diffs, filePath: filePathTemplate.render({ - fileDiffName: printerUtils.getDiffName(file) + fileDiffPath: printerUtils.getDiffPath(file), + fileDiffFilename: printerUtils.getDiffFilename(file) }, { fileIcon: fileIconTemplate, fileTag: fileTagTemplate diff --git a/src/printer-utils.js b/src/printer-utils.js index 1add31c..52ddf34 100644 --- a/src/printer-utils.js +++ b/src/printer-utils.js @@ -95,6 +95,18 @@ return 'unknown/file/path'; }; + PrinterUtils.prototype.getDiffPath = function(file) { + var path = this.getDiffName(file); + var parts = path.split(separator); + var lastPart = parts[parts.length - 1]; + return path.slice(0, -lastPart.length); + }; + + PrinterUtils.prototype.getDiffFilename = function(file) { + var parts = this.getDiffName(file).split(separator); + return parts[parts.length - 1]; + }; + PrinterUtils.prototype.getFileTypeIcon = function(file) { var templateName = 'file-changed'; diff --git a/src/side-by-side-printer.js b/src/side-by-side-printer.js index c990842..dd89fad 100644 --- a/src/side-by-side-printer.js +++ b/src/side-by-side-printer.js @@ -40,7 +40,8 @@ fileHtmlId: printerUtils.getHtmlId(file), diffs: diffs, filePath: filePathTemplate.render({ - fileDiffName: printerUtils.getDiffName(file) + fileDiffPath: printerUtils.getDiffPath(file), + fileDiffFilename: printerUtils.getDiffFilename(file) }, { fileIcon: fileIconTemplate, fileTag: fileTagTemplate diff --git a/src/templates/diff2html-templates.js b/src/templates/diff2html-templates.js index 05d9ba8..2ce2b99 100644 --- a/src/templates/diff2html-templates.js +++ b/src/templates/diff2html-templates.js @@ -1,10 +1,10 @@ (function() { if (!!!global.browserTemplates) global.browserTemplates = {}; -var Hogan = require("hogan.js");global.browserTemplates["file-summary-line"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("
  • ");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b(" ");t.b(t.rp("");t.b("\n" + i);t.b(" ");t.b(t.v(t.f("fileName",c,p,0)));t.b("");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b(" ");t.b(t.v(t.f("addedLines",c,p,0)));t.b("");t.b("\n" + i);t.b(" ");t.b(t.v(t.f("deletedLines",c,p,0)));t.b("");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b("
  • ");return t.fl(); },partials: {"");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b(" ");t.b(t.rp("");t.b("\n" + i);t.b(" ");t.b(t.v(t.f("fileName",c,p,0)));t.b("");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b(" ");t.b(t.v(t.f("addedLines",c,p,0)));t.b("");t.b("\n" + i);t.b(" ");t.b(t.v(t.f("deletedLines",c,p,0)));t.b("");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b("");return t.fl(); },partials: {"");t.b("\n" + i);t.b("
    ");t.b("\n" + i);t.b(" Files changed (");t.b(t.v(t.f("filesNumber",c,p,0)));t.b(")");t.b("\n" + i);t.b(" hide");t.b("\n" + i);t.b(" show");t.b("\n" + i);t.b("
    ");t.b("\n" + i);t.b("
      ");t.b("\n" + i);t.b(" ");t.b(t.t(t.f("files",c,p,0)));t.b("\n" + i);t.b("
    ");t.b("\n" + i);t.b("");return t.fl(); },partials: {}, subs: { }}); global.browserTemplates["generic-column-line-number"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b("
    ");t.b(t.t(t.f("blockHeader",c,p,0)));t.b("
    ");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b("");return t.fl(); },partials: {}, subs: { }}); global.browserTemplates["generic-empty-diff"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b("
    ");t.b("\n" + i);t.b(" File without changes");t.b("\n" + i);t.b("
    ");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b("");return t.fl(); },partials: {}, subs: { }}); -global.browserTemplates["generic-file-path"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("");t.b("\n" + i);t.b(" ");t.b(t.rp("");t.b("\n" + i);t.b(" ");t.b(t.v(t.f("fileDiffName",c,p,0)));t.b("");t.b("\n" + i);t.b(t.rp("");return t.fl(); },partials: {"");t.b("\n" + i);t.b(" ");t.b(t.rp("");t.b("\n" + i);t.b(" ");t.b(t.v(t.f("fileDiffPath",c,p,0)));t.b("");t.b("\n" + i);t.b(" ");t.b(t.v(t.f("fileDiffFilename",c,p,0)));t.b("");t.b("\n" + i);t.b(t.rp("");return t.fl(); },partials: {"");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b(" ");t.b(t.t(t.f("lineNumber",c,p,0)));t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b("
    ");t.b("\n" + i);if(t.s(t.f("prefix",c,p,1),c,p,0,171,247,"{{ }}")){t.rs(c,p,function(c,p,t){t.b(" ");t.b(t.t(t.f("prefix",c,p,0)));t.b("");t.b("\n" + i);});c.pop();}if(t.s(t.f("content",c,p,1),c,p,0,279,353,"{{ }}")){t.rs(c,p,function(c,p,t){t.b(" ");t.b(t.t(t.f("content",c,p,0)));t.b("");t.b("\n" + i);});c.pop();}t.b("
    ");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b("");return t.fl(); },partials: {}, subs: { }}); global.browserTemplates["generic-wrapper"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("
    ");t.b("\n" + i);t.b(" ");t.b(t.t(t.f("content",c,p,0)));t.b("\n" + i);t.b("
    ");return t.fl(); },partials: {}, subs: { }}); global.browserTemplates["icon-file-added"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("");t.b("\n" + i);t.b(" ");t.b("\n" + i);t.b("");return t.fl(); },partials: {}, subs: { }}); diff --git a/src/templates/file-summary-line.mustache b/src/templates/file-summary-line.mustache index 27d373b..0060dd7 100644 --- a/src/templates/file-summary-line.mustache +++ b/src/templates/file-summary-line.mustache @@ -1,7 +1,7 @@
  • - + {{>fileIcon}} - {{fileName}} + {{fileName}} {{addedLines}} {{deletedLines}} diff --git a/src/templates/generic-file-path.mustache b/src/templates/generic-file-path.mustache index cc71b18..e0b2b1b 100644 --- a/src/templates/generic-file-path.mustache +++ b/src/templates/generic-file-path.mustache @@ -1,5 +1,6 @@ - + {{>fileIcon}} - {{fileDiffName}} + {{fileDiffPath}} + {{fileDiffFilename}} {{>fileTag}} diff --git a/src/ui/css/diff2html.css b/src/ui/css/diff2html.css index 9d4096d..559e363 100644 --- a/src/ui/css/diff2html.css +++ b/src/ui/css/diff2html.css @@ -40,7 +40,7 @@ margin-left: 1px; } -.d2h-file-name-wrapper { +.d2h-file-path-wrapper { display: flex; align-items: center; width: 100%; @@ -49,7 +49,7 @@ line-height: 15px; } -.d2h-file-name { +.d2h-file-path { line-height: 33px; white-space: nowrap; text-overflow: ellipsis; @@ -246,7 +246,7 @@ text-align: left; } -.d2h-file-list-line .d2h-file-name { +.d2h-file-list-line .d2h-file-path { line-height: 21px; } diff --git a/test/diff2html-tests.js b/test/diff2html-tests.js index 99649d0..8545d7f 100644 --- a/test/diff2html-tests.js +++ b/test/diff2html-tests.js @@ -50,12 +50,12 @@ var filesExample1 = ' \n' + '
      \n' + '
    1. \n' + - ' \n' + + ' \n' + ' \n' + - ' sample\n' + + ' sample\n' + ' \n' + ' +1\n' + ' -1\n' + @@ -70,10 +70,11 @@ var htmlLineExample1 = '
      \n' + '
      \n' + '
      \n' + - ' \n' + + ' \n' + ' \n' + + ' \n' + ' sample\n' + ' CHANGED\n' + '
      \n' + @@ -122,10 +123,11 @@ var htmlSideExample1 = '
      \n' + '
      \n' + '
      \n' + - ' \n' + + ' \n' + ' \n' + + ' \n' + ' sample\n' + ' CHANGED\n' + '
      \n' + diff --git a/test/file-list-printer-tests.js b/test/file-list-printer-tests.js index 89e9dc1..d0004ef 100644 --- a/test/file-list-printer-tests.js +++ b/test/file-list-printer-tests.js @@ -45,12 +45,12 @@ describe('FileListPrinter', function() { '
      \n' + '
        \n' + '
      1. \n' + - ' \n' + + ' \n' + ' \n' + - ' my/file/name.js\n' + + ' my/file/name.js\n' + ' \n' + ' +12\n' + ' -41\n' + @@ -58,12 +58,12 @@ describe('FileListPrinter', function() { ' \n' + '
      2. \n' + '
      3. \n' + - ' \n' + + ' \n' + ' \n' + - ' my/file/{name1.js → name2.js}\n' + + ' my/file/{name1.js → name2.js}\n' + ' \n' + ' +12\n' + ' -41\n' + @@ -71,12 +71,12 @@ describe('FileListPrinter', function() { ' \n' + '
      4. \n' + '
      5. \n' + - ' \n' + + ' \n' + ' \n' + - ' my/file/name.js\n' + + ' my/file/name.js\n' + ' \n' + ' +12\n' + ' -0\n' + @@ -84,12 +84,12 @@ describe('FileListPrinter', function() { ' \n' + '
      6. \n' + '
      7. \n' + - ' \n' + + ' \n' + ' \n' + - ' my/file/name.js\n' + + ' my/file/name.js\n' + ' \n' + ' +0\n' + ' -41\n' + diff --git a/test/line-by-line-tests.js b/test/line-by-line-tests.js index a0ba661..9767816 100644 --- a/test/line-by-line-tests.js +++ b/test/line-by-line-tests.js @@ -153,11 +153,12 @@ describe('LineByLinePrinter', function() { var expected = '
        \n' + '
        \n' + - ' \n' + + ' \n' + ' \n' + - ' my/file/name.js\n' + + ' my/file/\n' + + ' name.js\n' + ' CHANGED\n' + '
        \n' + '
        \n' + @@ -191,11 +192,12 @@ describe('LineByLinePrinter', function() { var expected = '
        \n' + '
        \n' + - ' \n' + + ' \n' + ' \n' + - ' my/file/name.js\n' + + ' my/file/\n' + + ' name.js\n' + ' ADDED\n' + '
        \n' + '
        \n' + @@ -229,11 +231,12 @@ describe('LineByLinePrinter', function() { var expected = '
        \n' + '
        \n' + - ' \n' + + ' \n' + ' \n' + - ' my/file/name.js\n' + + ' my/file/\n' + + ' name.js\n' + ' DELETED\n' + '
        \n' + '
        \n' + @@ -267,11 +270,12 @@ describe('LineByLinePrinter', function() { var expected = '
        \n' + '
        \n' + - ' \n' + + ' \n' + ' \n' + - ' my/file/{name1.js → name2.js}\n' + + ' my/file/\n' + + ' {name1.js → name2.js}\n' + ' RENAMED\n' + '
        \n' + '
        \n' + @@ -340,10 +344,11 @@ describe('LineByLinePrinter', function() { '
        \n' + '
        \n' + '
        \n' + - ' \n' + + ' \n' + ' \n' + + ' \n' + ' sample\n' + ' CHANGED\n' + '
        \n' + @@ -406,10 +411,11 @@ describe('LineByLinePrinter', function() { '
        \n' + '
        \n' + '
        \n' + - ' \n' + + ' \n' + ' \n' + + ' \n' + ' sample\n' + ' CHANGED\n' + '
        \n' + diff --git a/test/side-by-side-printer-tests.js b/test/side-by-side-printer-tests.js index b90e2c2..dcf11ba 100644 --- a/test/side-by-side-printer-tests.js +++ b/test/side-by-side-printer-tests.js @@ -231,10 +231,11 @@ describe('SideBySidePrinter', function() { '
        \n' + '
        \n' + '
        \n' + - ' \n' + + ' \n' + ' \n' + + ' \n' + ' sample\n' + ' CHANGED\n' + '
        \n' + @@ -308,10 +309,11 @@ describe('SideBySidePrinter', function() { '
        \n' + '
        \n' + '
        \n' + - ' \n' + + ' \n' + ' \n' + + ' \n' + ' sample\n' + ' CHANGED\n' + '
        \n' +