Skip to content
Permalink
Browse files

Fixes #1089: remove document title from ToC.

  • Loading branch information...
mortengf committed Oct 5, 2015
1 parent c057202 commit da23ce7e531c383fceb2f0e0b44c0a121b48caf2
Showing with 29 additions and 45 deletions.
  1. +1 −1 lib/project-utils.js
  2. +2 −13 routes/project.js
  3. +10 −15 test/it.js
  4. +16 −16 test/unit-test.js
@@ -73,7 +73,7 @@ function getHeadingNumberMap(headingNumbersEncountered) {
var headingNumberMap = [];
for (var i=0; i<headingNumbersEncountered.length; i++) {
var headingNumberOriginal = headingNumbersEncountered[i];
headingNumberMap[headingNumberOriginal] = i + 1;
headingNumberMap[headingNumberOriginal] = i;
}

return headingNumberMap;
@@ -517,19 +517,8 @@ exports.get_toc = function (req, res, next) {
}

var target = documentFilename;

var tocEntry = new TOCEntry({
id: documentId,
type: 'document',
level: 0,
target: target,
text: document.name
});

var documentToCEntries = [tocEntry];
var documentChildToCEntries = project_utils.generateToCJSON(target, document.text);
Array.prototype.push.apply(documentToCEntries, documentChildToCEntries);
documentToCs[documentId] = documentToCEntries;
var tocEntries = project_utils.generateToCJSON(target, document.text);
documentToCs[documentId] = tocEntries;
}

callback();
@@ -1791,22 +1791,17 @@ describe('Scripler RESTful API', function () {
.expect(200)
.end(function (err, res) {
if (err) throw new Error(err + " (" + res.body.errorMessage + ")");
assert.equal(res.body.toc.length, 10);
assert.equal(res.body.toc[0].id, coverDocumentId);
assert.equal(res.body.toc[0].type, 'document');
assert.equal(res.body.toc.length, 4);
assert.equal(res.body.toc[0].id, "id_1");
assert.equal(res.body.toc[0].type, 'h1');
assert.equal(res.body.toc[0].level, 0);
assert.equal(res.body.toc[0].target, 'Cover.html');
assert.equal(res.body.toc[0].text, 'Cover');
assert.equal(res.body.toc[4].id, childDocumentId);
assert.equal(res.body.toc[4].type, 'document');
assert.equal(res.body.toc[4].level, 0);
assert.equal(res.body.toc[4].target, conf.epub.documentPrefix + childDocumentId + ".html");
assert.equal(res.body.toc[4].text, 'Sikke et dokument');
assert.equal(res.body.toc[9].id, "id_25");
assert.equal(res.body.toc[9].type, 'a');
assert.equal(res.body.toc[9].level, 3);
assert.equal(res.body.toc[9].target, conf.epub.documentPrefix + jimboDocumentId + ".html#id_25");
assert.equal(res.body.toc[9].text, 'LinkyDinky');
assert.equal(res.body.toc[0].target, conf.epub.documentPrefix + childDocumentId + ".html#id_1");
assert.equal(res.body.toc[0].text, 'Introduction');
assert.equal(res.body.toc[3].id, "id_25");
assert.equal(res.body.toc[3].type, 'a');
assert.equal(res.body.toc[3].level, 2);
assert.equal(res.body.toc[3].target, conf.epub.documentPrefix + jimboDocumentId + ".html#id_25");
assert.equal(res.body.toc[3].text, 'LinkyDinky');
done();
});
})
@@ -176,55 +176,55 @@ describe('project-utils', function () {
var document1ToCEntriesJSONExpected = [new TOCEntry({
id: "id_1",
type: "h1",
level: 1,
level: 0,
target: "Document1.html#" + conf.epub.anchorIdPrefix + "1",
text: "Introduction"
}), new TOCEntry({
"id": "id_2",
"type": "h2",
"level": 2,
"level": 1,
"target": "Document1.html#" + conf.epub.anchorIdPrefix + "2",
"text": "Hi"
}), new TOCEntry({
"id": "id_62",
"type": "h3",
"level": 3,
"level": 2,
"target": "Document1.html#" + conf.epub.anchorIdPrefix + "62",
"text": "A new start"
}), new TOCEntry({
"id": "id_8",
"type": "h2",
"level": 2,
"level": 1,
"target": "Document1.html#" + conf.epub.anchorIdPrefix + "8",
"text": "Something else"
}), new TOCEntry({
"id": "id_15",
"type": "a",
"level": 3,
"level": 2,
"target": "Document1.html#" + conf.epub.anchorIdPrefix + "15",
"text": "My Anc"
}), new TOCEntry({
"id": "id_991",
"type": "h1",
"level": 1,
"level": 0,
"target": "Document1.html#" + conf.epub.anchorIdPrefix + "991",
"text": "Moving on"
}), new TOCEntry({
"id": "id_3",
"type": "h6",
"level": 4,
"level": 3,
"target": "Document1.html#" + conf.epub.anchorIdPrefix + "3",
"text": "Cool story, bro"
}), new TOCEntry({
"id": "id_27",
"type": "h6",
"level": 4,
"level": 3,
"target": "Document1.html#" + conf.epub.anchorIdPrefix + "27",
"text": "Not too shabby"
}), new TOCEntry({
"id": "id_88",
"type": "a",
"level": 5,
"level": 4,
"target": "Document1.html#" + conf.epub.anchorIdPrefix + "88",
"text": "y0"
})];
@@ -262,43 +262,43 @@ describe('project-utils', function () {
var document2ToCEntriesJSONExpected = [new TOCEntry({
id: "id_741",
type: "h2",
level: 1,
level: 0,
target: "Document2.html#" + conf.epub.anchorIdPrefix + "741",
text: "Introduction"
}), new TOCEntry({
"id": "id_90",
"type": "h4",
"level": 3,
"level": 2,
"target": "Document2.html#" + conf.epub.anchorIdPrefix + "90",
"text": "Popeye's Left Eye"
}), new TOCEntry({
"id": "id_10",
"type": "h4",
"level": 3,
"level": 2,
"target": "Document2.html#" + conf.epub.anchorIdPrefix + "10",
"text": "Mein Gott!"
}), new TOCEntry({
"id": "id_666",
"type": "h6",
"level": 4,
"level": 3,
"target": "Document2.html#" + conf.epub.anchorIdPrefix + "666",
"text": "Hola, Señor Coconut"
}), new TOCEntry({
"id": "id_32",
"type": "h3",
"level": 2,
"level": 1,
"target": "Document2.html#" + conf.epub.anchorIdPrefix + "32",
"text": "Gutenberg's Drawer"
}), new TOCEntry({
"id": "id_101",
"type": "a",
"level": 3,
"level": 2,
"target": "Document2.html#" + conf.epub.anchorIdPrefix + "101",
"text": "Anchor1"
}), new TOCEntry({
"id": "id_109",
"type": "a",
"level": 3,
"level": 2,
"target": "Document2.html#" + conf.epub.anchorIdPrefix + "109",
"text": "Anchor2"
})];

0 comments on commit da23ce7

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.