diff --git a/app/router.js b/app/router.js index 19a17db..47ed1c4 100644 --- a/app/router.js +++ b/app/router.js @@ -17,4 +17,5 @@ Router.map(function() { this.route('contact-us'); this.route('morph-legend'); this.route('commentary-intro', { path: '/commentary/:book_id' }); + this.route('commentary-article', { path: '/commentary/articles/:article_id' }); }); diff --git a/app/routes/commentary-article.js b/app/routes/commentary-article.js new file mode 100644 index 0000000..7d09682 --- /dev/null +++ b/app/routes/commentary-article.js @@ -0,0 +1,13 @@ +import Route from '@ember/routing/route'; +import fetch from 'fetch'; +import { htmlSafe } from '@ember/template'; + +export default class CommentaryArticleRoute extends Route { + async model(params) { + const response = await fetch(window.GwtFrontend.hostUrl + '/api/v1/commentary/articles/' + params.article_id); + const body = await response.text().then(function(text){ + return new htmlSafe(text); + }); + return { body }; + } +} diff --git a/app/routes/commentary-intro.js b/app/routes/commentary-intro.js index 2aaa2d9..4c758f8 100644 --- a/app/routes/commentary-intro.js +++ b/app/routes/commentary-intro.js @@ -4,7 +4,7 @@ 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 response = await fetch(window.GwtFrontend.hostUrl + '/api/v1/commentary/' + params.book_id + '/chapter/intro'); const body = await response.text().then(function(text){ return new htmlSafe(text); }); diff --git a/app/templates/commentary-article.hbs b/app/templates/commentary-article.hbs new file mode 100644 index 0000000..e0b05ce --- /dev/null +++ b/app/templates/commentary-article.hbs @@ -0,0 +1,7 @@ +{{page-title "Commentary Article"}} + +
+ {{{@model.body}}} +
+ +{{outlet}} \ No newline at end of file diff --git a/tests/unit/routes/commentary-article-test.js b/tests/unit/routes/commentary-article-test.js new file mode 100644 index 0000000..50dc50b --- /dev/null +++ b/tests/unit/routes/commentary-article-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | commentary-article', function(hooks) { + setupTest(hooks); + + test('it exists', function(assert) { + let route = this.owner.lookup('route:commentary-article'); + assert.ok(route); + }); +});