Skip to content

Instantly share code, notes, and snippets.

@faymek
Last active December 21, 2017 13:50
Show Gist options
  • Save faymek/6b1812d551f394b6b58e30b076bb4e08 to your computer and use it in GitHub Desktop.
Save faymek/6b1812d551f394b6b58e30b076bb4e08 to your computer and use it in GitHub Desktop.
source 'https://rubygems.org'
gem 'sinatra'
gem "octokit"
GEM
remote: https://rubygems.org/
specs:
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
faraday (0.13.1)
multipart-post (>= 1.2, < 3)
multipart-post (2.0.0)
mustermann (1.0.1)
octokit (4.8.0)
sawyer (~> 0.8.0, >= 0.5.3)
public_suffix (3.0.1)
rack (2.0.3)
rack-protection (2.0.0)
rack
sawyer (0.8.1)
addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 1.0)
sinatra (2.0.0)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.0)
tilt (~> 2.0)
tilt (2.0.8)
PLATFORMS
ruby
DEPENDENCIES
octokit
sinatra
BUNDLED WITH
1.16.0
require "sinatra"
require "octokit"
set :views, "."
helpers do
def h(text)
Rack::Utils.escape_html(text)
end
end
get '/:username' do |username|
#user = Octokit.user username
gists = Octokit.gists username, :per_page => 5
erb :index, locals:{ :gists => gists, username: username}
#count = user.public_gists
#erb :index, locals: { :count => count }
end
<html>
<body>
<h2>User <%= username %>'s last five gists</h2>
<% gists.each do |g| %>
<% g[:files].fields.each do |f| %>
<b><%= f %></b>:
<%= 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