Setup fetching commentary intros and articles
This commit is contained in:
parent
ed264eedda
commit
49dbf4a672
|
@ -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' });
|
||||
});
|
||||
|
|
|
@ -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 };
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{{page-title "Commentary Article"}}
|
||||
|
||||
<div class="container pt-4">
|
||||
{{{@model.body}}}
|
||||
</div>
|
||||
|
||||
{{outlet}}
|
|
@ -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);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue