Skip to content

Commit

Permalink
pushing up catching more surf reports as well as only displaying capi…
Browse files Browse the repository at this point in the history
…tola for now
  • Loading branch information
ephekt committed Feb 25, 2012
1 parent 41182eb commit 145765f
Show file tree
Hide file tree
Showing 7 changed files with 394 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
log/*
8 changes: 7 additions & 1 deletion lib/grab_reports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ def grab_page url

# santa cruz: http://www.surfline.com/surf-forecasts/central-california/santa-cruz_2958
surf_spots = {
"Capitola" => "http://www.surfline.com/surf-report/capitola-central-california_10763"
"Capitola" => "http://www.surfline.com/surf-report/capitola-central-california_10763",
"Pleasure Point" => "http://www.surfline.com/surf-report/pleasure-point-central-california_4190",
"38th Ave" => "http://www.surfline.com/surf-report/38th-ave-central-california_4191",
"Steamer Lane" => "http://www.surfline.com/surf-report/steamer-lane-central-california_4188" ,
"Cowells" => "http://www.surfline.com/surf-report/cowells-central-california_4189",
"Ocean Beach (SF)" => "http://www.surfline.com/surf-report/ocean-beach-central-california_4127",
"S. Ocean Beach (SF)" => "http://www.surfline.com/surf-report/south-ocean-beach-central-california_4128"
}

surf_spots.each do |spot,url|
Expand Down
372 changes: 372 additions & 0 deletions log/sinatra.log

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions surf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ class Surf < Sinatra::Base
set :erb, :format => :html5

get "/" do
last_report = DB.execute("SELECT * FROM surf_reports ORDER BY created_at DESC LIMIT 1").first
@spot = last_report[0]
@height = last_report[1]
q = "
SELECT * FROM surf_reports
WHERE location IN ('Capitola','Pleasure Point', '38th Ave')
GROUP BY location
ORDER BY created_at DESC
"
@latest_reports = DB.execute q
erb :index
end
end
Binary file modified surf_reports.db
Binary file not shown.
9 changes: 5 additions & 4 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<div id="container" style="margin:auto; text-align: center;">
<span style="font-size:35px;color:green;font-weight:bold">YES!</span>
<div id="last_report">
<h1><%= @spot %> @ <%= @height %></h1>
<p style="font-size:12px">updated within the last hour</p>
</div>
<% @latest_reports.each do |report| %>
<div class="last_report">
<h1><%= report[0] %> @ <%= report[1] %></h1>
</div>
<% end %>
</div>
4 changes: 2 additions & 2 deletions views/layout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
<div role="main">
<%= yield %>
</div>
<footer>
<!-- Nothing -->
<footer style="text-align:center;">
<span style="font-style:italic; font-size:12px">updated within the last hour</p>
</footer>


Expand Down

0 comments on commit 145765f

Please sign in to comment.