Created
September 20, 2011 05:01
-
-
Save smtalim/1228369 to your computer and use it in GitHub Desktop.
Sinatra app's layout.erb, style.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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: <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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } |
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
Could you put the footer in the layout.erb?