From 3f3bade58e3b258aadab8ecf084004d06e62cede Mon Sep 17 00:00:00 2001 From: Aaron O'Mullan Date: Mon, 31 Mar 2014 16:21:04 -0700 Subject: [PATCH] Change summary data format Simplify chapter objects, by making them identical to article objects besides the .articles attribute --- lib/parse/summary.js | 5 ++--- templates/includes/book/summary.html | 2 +- test/summary.js | 24 ++++++++++++------------ 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/lib/parse/summary.js b/lib/parse/summary.js index f0214016a..1237b37d8 100644 --- a/lib/parse/summary.js +++ b/lib/parse/summary.js @@ -90,10 +90,9 @@ function parseArticle(nodes) { } function parseChapter(nodes) { - return { - chapter: parseTitle(_.first(nodes).text), + return _.extend(parseTitle(_.first(nodes).text), { articles: _.map(listSplit(filterList(nodes), 'list_item_start', 'list_item_end'), parseArticle) - }; + }); } function parseSummary(src) { diff --git a/templates/includes/book/summary.html b/templates/includes/book/summary.html index 52eeb2f70..161ba7983 100644 --- a/templates/includes/book/summary.html +++ b/templates/includes/book/summary.html @@ -9,7 +9,7 @@
  • {% for item in summary.chapters %}
  • - {{ item.chapter.title }} + {{ item.title }} {% if item.articles.length > 0 %}