Skip to content

Instantly share code, notes, and snippets.

@smtalim
Created September 20, 2011 05:01
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save smtalim/1228369 to your computer and use it in GitHub Desktop.
Save smtalim/1228369 to your computer and use it in GitHub Desktop.
Sinatra app's layout.erb, style.css
<div>
<h1>A Sinatra app to access Google+</h1>
<p>I'm sorry but the "The Sinatra app to access Google+" Web Service is not accessible from the folder you typed in.</p>
<p>The correct URL is: <a href="http://sinatragplus.heroku.com/">http://sinatragplus.heroku.com/</a></p>
<p><a href="/">Back</a></p>
</div>
<div id="footer">
<p><b>A Fun Sinatra App for Google+ by RubyLearning 20 Sept. 2011</b>.</p>
</div>
<div>
<h1>A Sinatra app to access Google+</h1>
<!--
By default error will catch Sinatra::ServerError
Sinatra will pass you the error via the ‘sinatra.error’
in request.env
-->
<p>
<% e = request.env['sinatra_error'] %>
<%= p e.to_s %>
<%= p e.backtrace.join("\n") %>
Application error
</p>
</div>
<div id="footer">
<p><b>A Fun Sinatra App for Google+ by RubyLearning 20 Sept. 2011</b>.</p>
</div>
<div>
<h1>A Sinatra app to access Google+</h1>
<h3>Get Google+ Info</h3>
<p>We shall be using Google+ to pull the given ID's information.</p>
<form action="/show" method="post" accept-charset="utf-8">
Enter your Google API Key: <input type="text" name="apikey" /><br />
Enter your Google+ ID:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="gid" />
<input type="submit" value=".. fetch the G+ info!">
</form>
</div>
<div id="footer">
<p><b>A Fun Sinatra App for Google+ by RubyLearning 20 Sept. 2011</b>.</p>
</div>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>A Sinatra app to access Google+</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="RubyLearning.org" />
<meta name="keywords" content="rubylearning,ruby,ruby programming,ruby course,sinatra course" />
<link rel="stylesheet" type="text/css" href="/stylesheets/style.css" />
<link rel="icon" type="image/ico" href="/images/favicon.ico" />
</head>
<body>
<%= yield %>
</body>
</html>
<div>
<h1>A Sinatra app to access Google+</h1>
<h3>Get Google+ Info</h3>
<p>This Google+ ID belongs to <%= @gplus.row0 %></p>
<p>
<table id="hor-minimalist-a" summary="Google+ details">
<thead>
<tr>
<th scope="col">Property</th>
<th scope="col">Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tagline</td>
<td><%= @gplus.row1 %></td>
</tr>
<tr>
<td>G+ URL</td>
<td><%= @gplus.row2 %></td>
</tr>
</tbody>
</table>
</p>
<p><a href="/">Back</a></p>
</div>
<div id="footer">
<p><b>A Fun Sinatra App for Google+ by RubyLearning 20 Sept. 2011</b>.</p>
</div>
# sinatragplus.rb
require 'sinatra'
require 'google_plus'
error do
erb :'500'
end
#class
class GPlus
def initialize(apikey, gid)
@apikey = apikey
@gid = gid
get_info
end
attr_reader :row0, :row1, :row2
private
#Get info about specific G+ ID
def get_info
# GooglePlus.api_key = 'Your API Key'
begin
GooglePlus.api_key = @apikey
person = GooglePlus::Person.get(@gid.to_i)
@row0 = person.display_name
@row1 = person.tagline
@row2 = person.url
rescue Exception => msg
# display the system generated error message
puts msg
end
end
end
get '/' do
erb :index
end
# Display Google+ details
post '/show' do
@gplus = GPlus.new(params[:apikey], params[:gid])
erb :show
end
body
{
line-height: 1.6em;
}
h1 {
color: #2A1959;
border-bottom: 2px solid #2A1959;
}
h2 {
color: #474B94;
font-size: 1.2 em;
}
#footer {
clear: both;
border-top: 1px solid #2A1959;
text-align: left;
height: 50px;
font-size: 70%;
width: 100%;
}
#hor-minimalist-a
{
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 12px;
background: #fff;
margin: 45px;
width: 480px;
border-collapse: collapse;
text-align: left;
}
#hor-minimalist-a th
{
font-size: 14px;
font-weight: normal;
color: #039;
padding: 10px 8px;
border-bottom: 2px solid #6678b1;
}
#hor-minimalist-a td
{
color: #669;
padding: 9px 8px 0px 8px;
}
#hor-minimalist-a tbody tr:hover td
{
color: #009;
}
@DouglasAllen
Copy link

Could you put the footer in the layout.erb?

@Clepsyd
Copy link

Clepsyd commented Aug 27, 2019

8 years later, those few files answered in 10 seconds some questions I've been asking myself for the past 2 weeks.
Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment