Setup fetching commentary intros and articles

This commit is contained in:
Leonard Smith 2021-05-26 16:53:40 -05:00
parent ed264eedda
commit 49dbf4a672
5 changed files with 33 additions and 1 deletions

View File

@ -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' });
});

View File

@ -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 };
}
}

View File

@ -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);
});

View File

@ -0,0 +1,7 @@
{{page-title "Commentary Article"}}
<div class="container pt-4">
{{{@model.body}}}
</div>
{{outlet}}

View File

@ -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);
});
});