-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented basic story loader + tested recursive component creation
Recursively converting the words/sentences to angular components seems like it will be very slow and so I do not plan to continue that test
- Loading branch information
1 parent
3f3cf55
commit 297a97e
Showing
19 changed files
with
850 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const DigitalReaderStory = require('../../models/drStory'); | ||
const mongoose = require('mongoose'); | ||
|
||
/** | ||
* Set feedback status of story to 'viewed' | ||
* @param {Object} req user: User information; params: story ID | ||
* @param {Object} res | ||
* @param {Object} next | ||
* @return {Promise} Story object | ||
*/ | ||
module.exports = async (req, res, next) => { | ||
|
||
function yes() { | ||
res.json(story); | ||
} | ||
function no(status=404, msg='not found') { | ||
res.status(status).json(msg); | ||
} | ||
|
||
if (!req.user) return no(400, 'need to know user'); | ||
if (!req.user._id) return no(400, 'need to know user\'s id'); | ||
|
||
const story = await DigitalReaderStory.findById(new mongoose.mongo.ObjectId(req.params.id)); | ||
if (!story) return no(); | ||
|
||
if (story.public) return yes(); | ||
|
||
// if the story is private - but the current user is its owner, return the story | ||
if (story.owner.toString() === req.user._id) return yes(); | ||
|
||
return no(401, 'not authorised'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
ngapp/src/app/dr-story-viewer/dr-story-builder/dr-story-builder.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
<!--<div class="container"> | ||
</div>--> | ||
<span> | ||
{{ content.nodeName }} | ||
<span | ||
*ngFor="let child of content.childNodes" | ||
> | ||
<app-dr-story-builder | ||
[type]="'body'" | ||
[content]="child"></app-dr-story-builder> | ||
</span> | ||
</span> |
Oops, something went wrong.