Skip to content

Instantly share code, notes, and snippets.

@ishotjr
Last active August 29, 2015 14:27
Show Gist options
  • Save ishotjr/bd19bc24a7d0f317643a to your computer and use it in GitHub Desktop.
Save ishotjr/bd19bc24a7d0f317643a to your computer and use it in GitHub Desktop.
source 'https://rubygems.org'
gem 'sinatra'
gem 'octokit'
require 'sinatra'
require 'octokit'
set :views, "."
helpers do
def h(text)
Rack::Utils.escape_html(text)
end
end
get '/:username' do |username|
gists = Octokit.gists username, :per_page => 5
erb :index, locals: { :gists => gists, username: username }
end
<!DOCTYPE html>
<html lang="en">
<body>
<h2>User <%= username %>'s last five gists</h2>
<% gists.each do |g| %>
<% g[:files].fields.each do |f| %>
<strong><%= f %></strong>:
<%= h g[:files][f.to_sym].rels[:raw].get.data %>
<br>
<br>
<% end %>
<% end %>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment