From d9603cba572e6b34286b802c8713f39858ac8513 Mon Sep 17 00:00:00 2001 From: Leonard Smith Date: Fri, 21 May 2021 09:37:40 -0500 Subject: [PATCH] Add Commentary Book intros to the chapter nav --- app/components/chapter-nav.hbs | 1 + app/router.js | 1 + app/routes/commentary-intro.js | 13 +++++++++++++ app/templates/commentary-intro.hbs | 7 +++++++ tests/unit/routes/commentary-intro-test.js | 11 +++++++++++ 5 files changed, 33 insertions(+) create mode 100644 app/routes/commentary-intro.js create mode 100644 app/templates/commentary-intro.hbs create mode 100644 tests/unit/routes/commentary-intro-test.js diff --git a/app/components/chapter-nav.hbs b/app/components/chapter-nav.hbs index 2a1ae58..3f3d19a 100644 --- a/app/components/chapter-nav.hbs +++ b/app/components/chapter-nav.hbs @@ -1,5 +1,6 @@ Chapters: + Intro {{#each @book.chapters as |chapter|}} {{/each}} diff --git a/app/router.js b/app/router.js index 3037f83..19a17db 100644 --- a/app/router.js +++ b/app/router.js @@ -16,4 +16,5 @@ Router.map(function() { this.route('site-purpose'); this.route('contact-us'); this.route('morph-legend'); + this.route('commentary-intro', { path: '/commentary/:book_id' }); }); diff --git a/app/routes/commentary-intro.js b/app/routes/commentary-intro.js new file mode 100644 index 0000000..2aaa2d9 --- /dev/null +++ b/app/routes/commentary-intro.js @@ -0,0 +1,13 @@ +import Route from '@ember/routing/route'; +import fetch from 'fetch'; +import { htmlSafe } from '@ember/template'; + +export default class CommentaryIntroRoute extends Route { + async model(params) { + const response = await fetch('http://gwt.api/api/v1/commentary/' + params.book_id + '/chapter/intro'); + const body = await response.text().then(function(text){ + return new htmlSafe(text); + }); + return { body }; + } +} diff --git a/app/templates/commentary-intro.hbs b/app/templates/commentary-intro.hbs new file mode 100644 index 0000000..f187273 --- /dev/null +++ b/app/templates/commentary-intro.hbs @@ -0,0 +1,7 @@ +{{page-title "Book Introduction"}} + +
+ {{{@model.body}}} +
+ +{{outlet}} \ No newline at end of file diff --git a/tests/unit/routes/commentary-intro-test.js b/tests/unit/routes/commentary-intro-test.js new file mode 100644 index 0000000..2879e6a --- /dev/null +++ b/tests/unit/routes/commentary-intro-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | commentary-intro', function(hooks) { + setupTest(hooks); + + test('it exists', function(assert) { + let route = this.owner.lookup('route:commentary-intro'); + assert.ok(route); + }); +});