Update global timeline example to use mastodon.ar.al

(Instead of App.net as that is now defunct.)
parent 3663cd9b
################################################################################
#
# Set App.net posts example.
# Set Mastodon posts example.
#
# Displays the global timeline from App.net.
#
......@@ -14,17 +14,10 @@ superagent = require 'superagent'
exports.route = (request, response) ->
superagent.get('https://alpha-api.app.net/stream/0/posts/stream/global')
superagent.get('https://mastodon.ar.al/api/v1/timelines/public')
.end (error, globalTimelineResponse) ->
# Attach a custom function to the data to count the number of posts
globalTimelineResponse.body.numberOfPosts = ->
if this.data
return this.data.length
else
return 0
globalTimeline = globalTimelineResponse.body
# Option to render a static template.
......@@ -36,11 +29,11 @@ exports.route = (request, response) ->
globalTimeline.errorType = 'Network'
globalTimeline.error = error
else if not globalTimeline.data
else if not globalTimeline
# There was an App.net error
globalTimeline.errorType = 'App.net'
globalTimeline.error = "(##{globalTimeline.meta.code}) #{globalTimeline.meta.error_message}"
globalTimeline.error = "Could not get the public timeline."
# Render the response
response.render 'posts', globalTimeline
response.render 'posts', { data: globalTimeline }
......@@ -49,15 +49,15 @@
<h1><a href='./'><img id='set-logo' src='images/set-logo.svg' alt='Set logo'></a></h1>
</header>
<h2>App.net Global Timeline</h2>
<p>The latest <span data-set-text='numberOfPosts'>NN</span> posts from <a href='http://join.app.net'>App.net</a>.</p>
<h2>Aral’s Mastodon – Global Timeline</h2>
<p>The latest <span data-set-text='data.length'>NN</span> posts from <a href='https://mastodon.ar.al'>mastodon.ar.al</a>.</p>
<ul>
<li data-set-if='not:error' data-set-repeat='post data'>
<img data-set-attribute='src post.user.avatar_image.url; alt post.user.name' src='http://placehold.it/100x100' alt=''>
<img data-set-attribute='src post.account.avatar_static; alt post.account.display_name' src='https://placehold.it/100x100' alt=''>
<p><a class='user' data-set-attribute='href post.user.canonical_url' data-set-text='post.user.name' href=''>Jane User</a>
<p><a class='user' data-set-attribute='href post.account.url' data-set-text='post.account.display_name' href=''>Jane User</a>
<span class='postText' data-set-text='html post.html'>This is a sample post. This list item will be the one that is used as the prototype for the final list. Working with actual content as a place‐holder means you can do things like add (and style) <a href='http://aralbalkan.com'>links</a>, like this one to <a href='https://Ind.ie'>Ind.ie</a>.</span></p>
<span class='postText' data-set-text='html post.content'>This is a sample post. This list item will be the one that is used as the prototype for the final list. Working with actual content as a place‐holder means you can do things like add (and style) <a href='http://aralbalkan.com'>links</a>, like this one to <a href='https://ind.ie'>Ind.ie</a>.</span></p>
</li>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment