Skip to content

Instantly share code, notes, and snippets.

@smtalim
Created September 20, 2011 05:01
Show Gist options
  • 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
<!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>
# sinatragplus.rb
require 'sinatra'
require 'google_plus'
error do
erb :'500'
end
#class
class GPlus
def initialize(apikey, gid)
@apikey = apikey
@gid = gid
puts "Calling get_info"
get_info
puts "Called get_info"
end
attr_reader :row0, :row1, :row2, :row3, :row4, :row5, :row6, :row7
private
#Get info about specific G+ ID
def get_info
# Get your Google API key from https://code.google.com/apis/console#access
# 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 stock 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