-
-
Save wheresrhys/0f006b39124f159b069c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var StreamModel = function () {} | |
prototype { | |
initFromSAPI() // takes a search string | |
initFromIds() // takes list of ids | |
initFromModels()// takes list of article models | |
} | |
res.get(req, res, next) { | |
/** | |
* A stream object accepts an array of content id UUIDs or CAPI search strings | |
* and returns a blob of HTML representing the stream. | |
* | |
* The returned HTML is a sequence of article card components. | |
*/ | |
var content = Promise.all( | |
ft.get(['d3fe0b06-9e43-11e3-b429-00144feab7de', ...], | |
fastft.get('regions:london'), | |
market.get('lse:twt') | |
... | |
).then(function (items) { | |
new Stream({ | |
api: [..., ...], | |
fastft: [..., ...], | |
market: [..., ...], | |
userprefs: [..., ...] | |
}) | |
.sortByDate // Orders the items by date descending | |
.sortByVisualTone // Groups the items by their tone, Eg. news, analysis, comment etc. | |
.applyTextures // Annotate the items with texture, Eg. highlight some items | |
.withFastFT(true) // Interleave the fastFT data | |
.showRelatedTopics(5) // Show n related topics at the foot of the stream | |
.requestingUser({ id: req.params.uid }) // Metadata about the person who requested the stream | |
.isFollowable(true) // Can someone follow this stream? | |
.isUserStream(true) // Not sure we need this distinction? | |
.title('Save for later') // Display title | |
.id('forlaters') // DOM id (?) | |
.page(1) // Pagination, Eg. '1 of n' | |
.applyFilters() // API v1 filter configation. Eg, { regions: ['London', 'New York'] } | |
.notFound(message) // Message to display upon the stream being empty, Eg. 'Sorry. No articles found' | |
.render // Respond with a blob of HTML representing the stream. | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment