Skip to content

Commit

Permalink
stub out a basic footer that requests github user information and dis…
Browse files Browse the repository at this point in the history
…plays it (only available on syntax-basics article for now)
  • Loading branch information
ajpiano committed Nov 8, 2011
1 parent f458a11 commit ad44a62
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Rules
Expand Up @@ -11,6 +11,8 @@
# because “*” matches zero or more characters.

require "cgi"
require "curb"
require "json"

class Nanoc3::Filter
class CodeBlocks < Nanoc3::Filter
Expand Down
1 change: 1 addition & 0 deletions content/javascript-101/syntax-basics.md
Expand Up @@ -3,6 +3,7 @@ chapter: js101
section: 1
title: Syntax Basics
attribution: jQuery Fundamentals
github: jquery
---
Understanding statements, variable naming, whitespace, and other basic JavaScript syntax.

Expand Down
21 changes: 21 additions & 0 deletions layouts/article_footer.html
@@ -0,0 +1,21 @@
<div class="clearfix">
<div class="github">
<%if @item[:github] %>
<% github_user = @item[:github] || "jquery" %>
<% user_request = Curl::Easy.http_get("https://api.github.com/users/"+github_user) %>
<% user_request.perform %>
<% user_obj = JSON.parse(user_request.body_str) %>
<h3>By <%= user_obj["name"] %></h3>
<img src="<%= user_obj["avatar_url"] %>" />
<% else %>
<h3>By <%= @item[:attribution] %></h3>
<% end %>
</div>

<h4>Suggestions? Problems? Feedback?</h4>
You can open an issue or submit a pull request for
<a target="_blank" href="https://github.com/jquery/web-learn-jquery-com/blob/master/content/<%= @item.identifier.slice(1..-2) %>.md">
this article on GitHub
</a>
<a href="#">(Help!)</a>
</div>
2 changes: 1 addition & 1 deletion layouts/default.html
Expand Up @@ -14,7 +14,7 @@ <h2 class="title"><%= @item[:title] %></h2>
</div>

<%= render 'sidebar' %>
<%= render 'article_footer' %>
</div>
<!-- /body -->

Expand Down

0 comments on commit ad44a62

Please sign in to comment.