Skip to content

Commit ad44a62

Browse files
committed
stub out a basic footer that requests github user information and displays it (only available on syntax-basics article for now)
1 parent f458a11 commit ad44a62

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

Rules

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
# because “*” matches zero or more characters.
1212

1313
require "cgi"
14+
require "curb"
15+
require "json"
1416

1517
class Nanoc3::Filter
1618
class CodeBlocks < Nanoc3::Filter

content/javascript-101/syntax-basics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ chapter: js101
33
section: 1
44
title: Syntax Basics
55
attribution: jQuery Fundamentals
6+
github: jquery
67
---
78
Understanding statements, variable naming, whitespace, and other basic JavaScript syntax.
89

layouts/article_footer.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<div class="clearfix">
2+
<div class="github">
3+
<%if @item[:github] %>
4+
<% github_user = @item[:github] || "jquery" %>
5+
<% user_request = Curl::Easy.http_get("https://api.github.com/users/"+github_user) %>
6+
<% user_request.perform %>
7+
<% user_obj = JSON.parse(user_request.body_str) %>
8+
<h3>By <%= user_obj["name"] %></h3>
9+
<img src="<%= user_obj["avatar_url"] %>" />
10+
<% else %>
11+
<h3>By <%= @item[:attribution] %></h3>
12+
<% end %>
13+
</div>
14+
15+
<h4>Suggestions? Problems? Feedback?</h4>
16+
You can open an issue or submit a pull request for
17+
<a target="_blank" href="https://github.com/jquery/web-learn-jquery-com/blob/master/content/<%= @item.identifier.slice(1..-2) %>.md">
18+
this article on GitHub
19+
</a>
20+
<a href="#">(Help!)</a>
21+
</div>

layouts/default.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ <h2 class="title"><%= @item[:title] %></h2>
1414
</div>
1515

1616
<%= render 'sidebar' %>
17-
17+
<%= render 'article_footer' %>
1818
</div>
1919
<!-- /body -->
2020

0 commit comments

Comments
 (0)