Merge pull request 'Setup fetching commentary intros and articles' (#17) from feature/handle-fetching-commentary-articles into master
Reviewed-on: #17
This commit is contained in:
commit
c1288004d4
|
@ -17,4 +17,5 @@ Router.map(function() {
|
||||||
this.route('contact-us');
|
this.route('contact-us');
|
||||||
this.route('morph-legend');
|
this.route('morph-legend');
|
||||||
this.route('commentary-intro', { path: '/commentary/:book_id' });
|
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 {
|
export default class CommentaryIntroRoute extends Route {
|
||||||
async model(params) {
|
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){
|
const body = await response.text().then(function(text){
|
||||||
return new htmlSafe(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