Ind.ie is now Small Technology Foundation.
Commit 6683bb8e authored by Aral Balkan's avatar Aral Balkan

Migrated profiling example from App.net to Mastodon

parent 2c1d5d01
......@@ -21,7 +21,7 @@ exports.route = (request, response) ->
globalTimeline = globalTimelineResponse.body
# Handle network and App.net errors gracefully.
# Handle network and Mastodon errors gracefully.
if error
# There was a network error
globalTimeline.errorType = 'Network'
......@@ -29,12 +29,12 @@ exports.route = (request, response) ->
else if not globalTimeline
# There was an App.net error
globalTimeline.errorType = 'App.net'
# There was an Mastodon error
globalTimeline.errorType = 'Mastodon'
globalTimeline.error = "Could not get the public timeline."
# Render the response and ask for the data to be injected into the rendered template
# (we’re going to append to it via Ajax calls on the client‐side to render an
# expanding timeline of App.net posts.)
# expanding timeline of Mastodon posts.)
response.render 'posts-client-side-updates', { data: globalTimeline, __set: { injectData: yes } }
......@@ -23,7 +23,7 @@ exports.route = (request, response) ->
# Option to render a static template.
globalTimeline.__set = { renderStatic: yes }
# Handle network and App.net errors gracefully.
# Handle network and Mastodon errors gracefully.
if error
# There was a network error
globalTimeline.errorType = 'Network'
......@@ -31,8 +31,8 @@ exports.route = (request, response) ->
else if not globalTimeline
# There was an App.net error
globalTimeline.errorType = 'App.net'
# There was an Mastodon error
globalTimeline.errorType = 'Mastodon'
globalTimeline.error = "Could not get the public timeline."
# Render the response
......
......@@ -18,22 +18,15 @@ exports.route = (request, response) ->
# Time the data call
timer.reset()
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) ->
timer.elapsedTime('Data transfer from App.net')
# 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
timer.elapsedTime('Data transfer from mastodon.ar.al')
globalTimeline = globalTimelineResponse.body
# Handle network and App.net errors gracefully.
# Handle network and Mastodon errors gracefully.
if error
# There was a network error
globalTimeline.errorType = 'Network'
......@@ -41,11 +34,11 @@ exports.route = (request, response) ->
else if not globalTimeline.data
# There was an App.net error
globalTimeline.errorType = 'App.net'
globalTimeline.error = "(##{globalTimeline.meta.code}) #{globalTimeline.meta.error_message}"
# There was an Mastodon error
globalTimeline.errorType = 'Mastodon'
globalTimeline.error = "Could not get the public timeline."
# Time the template render
timer.reset()
response.render 'posts', globalTimeline
response.render 'posts', { data: globalTimeline }
timer.elapsedTime('Template render')
......@@ -408,8 +408,8 @@
globalTimeline.error = error;
} else if (!globalTimeline) {
globalTimeline.data = [];
globalTimeline.errorType = 'App.net';
globalTimeline.error = "Could not get Mastodon data";
globalTimeline.errorType = 'Mastodon';
globalTimeline.error = 'Could not get the public timeline.';
}
set(document.body, { data: globalTimeline });
});
......@@ -477,7 +477,7 @@
<li data-set-dummy><img src='http://placehold.it/100x100' alt='User name’s avatar'><p><a class='user' href=''>Yet A. Nother-Person</a> <span class='postText'>By using a range of copy&#8202;&#8202;and actual content&#8202;&#8202; you can get a better feel for the constraints of your design e.g., what happens with really long URLs like this: http://thisisareallylongurlohmyyourerightitisaverylongurlwhatlongurlsyouhavegrandma.com</p></li>
<!-- Display an error message for network & App.net errors -->
<!-- Display an error message for network & Mastodon errors -->
<li data-set-if='error'><span data-set-text='errorType'>(Error type)</span> error: <span data-set-text='error'>the network or Mastodon error message</span>.</li>
</ul>
......
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