sports_db 0.0.13 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
- body {
1
+ html,body {
2
+ height: 100%;
2
3
  background-color: $page_bg;
3
4
  }
4
5
  * {
@@ -22,3 +23,49 @@ body.ios {
22
23
  body.android {
23
24
  font-family: sans-serif;
24
25
  }
26
+
27
+
28
+
29
+ // Default
30
+ html { font-size: 10px; }
31
+ // 480 wide
32
+ @media (min-width: 460px) and (-webkit-min-device-pixel-ratio: 1.5) {
33
+ html { font-size: 15px; }
34
+ }
35
+ // 540 wide
36
+ @media (min-width: 520px) and (-webkit-min-device-pixel-ratio: 1.5) {
37
+ html { font-size: 16.875px; }
38
+ }
39
+ // 600 wide
40
+ @media (min-width: 580px) and (-webkit-min-device-pixel-ratio: 1.5) {
41
+ html { font-size: 18.75px; }
42
+ }
43
+ // 720 wide
44
+ @media (min-width: 700px) and (-webkit-min-device-pixel-ratio: 1.5) {
45
+ html { font-size: 22.5px; }
46
+ }
47
+ // Nexus 4, 768 wide
48
+ @media (min-width: 748px) and (-webkit-min-device-pixel-ratio: 1.5) {
49
+ html { font-size: 24px; }
50
+ }
51
+ // 800 wide
52
+ @media (min-width: 780px) and (-webkit-min-device-pixel-ratio: 1.5) {
53
+ html { font-size: 25px; }
54
+ }
55
+ // Nexus 7 (has a device pixel ratio of ~1.32)
56
+ @media (min-width: 780px) and (-webkit-min-device-pixel-ratio: 1.32) {
57
+ html { font-size: 25px; }
58
+ }
59
+ // iPads
60
+ // The device-height is reqd in order to differenciate from 768px wide devices (Nexus 4, etc.)
61
+ @media
62
+ (device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 1),
63
+ (device-width: 1024px) and (device-height: 768px) and (-webkit-device-pixel-ratio: 1),
64
+ (device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2),
65
+ (device-width: 1024px) and (device-height: 768px) and (-webkit-device-pixel-ratio: 2) {
66
+ html { font-size: 10px; }
67
+ }
68
+ // for bug 21664 (see base.js)
69
+ html.kindle {
70
+ font-size: 18.75px;
71
+ }
@@ -3,53 +3,31 @@
3
3
  <head>
4
4
  <title><%= CONFIG.app_path.downcase %></title>
5
5
  <meta id="meta_viewport" name="viewport" content="user-scalable=no, initial-scale=1, target-densityDpi=device-dpi">
6
+ <%= stylesheet_link_tag "/#{CONFIG.app_path.downcase}/cache/#{CONFIG.app_path.downcase}/assets/application" %>
6
7
  <script>
7
- // Set the base font size for the rem-based layout and type sizing.
8
- (function() {
9
- var isAndroid = navigator.userAgent.match(/android/i);
10
- var fontSize = 10; // iOS uses 10 as the base font size.
11
-
12
- // Get the base font size for Android
13
- if (isAndroid) {
14
- var obj = {};
15
- document.location.search.substring(1).split('&').forEach(function(keyValue) {
16
- var pair = keyValue.split('=');
17
- var key = decodeURIComponent(pair[0]).replace(/\+/g, ' ');
18
- var value = decodeURIComponent(pair[1]).replace(/\+/g, ' ');
19
- obj[key] = value;
20
- });
21
-
22
- obj.deviceWidth = obj.dw || screen.width;
23
-
24
- if (navigator.userAgent.match(/android/i)) {
25
- fontSize = (obj.deviceWidth / 320) * 10;
26
- }
8
+ // FIXED FB#21664.
9
+ if (navigator.userAgent.match(/Kindle/i)) {
10
+ document.documentElement.className += ' ' + 'kindle';
27
11
  }
28
-
29
- // Set the base font size
30
- document.documentElement.style.fontSize = fontSize + 'px';
31
- })()
32
12
  </script>
33
- <%= stylesheet_link_tag "application" %>
34
13
  </head>
35
14
  <body>
36
15
  <%= yield %>
37
- <loading id="loading" style="display:none"><loading_text id="loading_text">Loading&hellip;</loading_text></loading>
38
- <div id="flash" style="display:none"></div>
39
- <div id="buffer" style="display:none"></div>
40
- <div id="tmp" style="display:none"></div>
41
- <%= javascript_include_tag "application" %>
16
+ <loading id="loading" style="display: none;"><loading_text id="loading_text">Loading&hellip;</loading_text></loading>
17
+ <div id="flash" style="display: none;"></div>
18
+ <div id="buffer" style="display: none;"></div>
19
+ <div id="tmp" style="display: none;"></div>
20
+ <%= javascript_include_tag "/#{CONFIG.app_path.downcase}/cache/#{CONFIG.app_path.downcase}/assets/application" %>
42
21
  <%# Allows us to use mock on test or production without screwing up caching of page. %>
43
22
  <script>
44
23
  if (Application.params.mock) {
45
- document.write("<link rel='stylesheet' href='/<%= CONFIG.app_path %>/cache/<%= CONFIG.app_path %>/assets/mock.css'>");
46
- document.write("<script src='/<%= CONFIG.app_path %>/cache/<%= CONFIG.app_path %>/assets/core/Mock.js'><\/script>");
24
+ document.write("<link rel='stylesheet' href='/<%= CONFIG.app_path %>/assets/mock.css'>");
25
+ document.write("<script src='/<%= CONFIG.app_path %>/assets/core/Mock.js'><\/script>");
47
26
  }
48
27
  </script>
49
- <%# turn on mock automatically if using localhost or pow %>
50
- <% if request.host == 'localhost' || request.host.include?(".dev") %>
51
- <link rel='stylesheet' href='/<%= CONFIG.app_path %>/cache/<%= CONFIG.app_path %>/assets/mock.css'>
52
- <script src='/<%= CONFIG.app_path %>/cache/<%= CONFIG.app_path %>/assets/core/Mock.js'></script>
28
+ <% if request.host == 'localhost' %>
29
+ <link rel='stylesheet' href='/<%= CONFIG.app_path %>/assets/mock.css'>
30
+ <script src='/<%= CONFIG.app_path %>/assets/core/Mock.js'></script>
53
31
  <% end %>
54
32
  </body>
55
33
  </html>
@@ -1,67 +1,61 @@
1
1
  module SportsDb
2
- class TwitterBuilder
3
-
2
+ class TwitterBuilder
3
+
4
4
  def self.update_twitter
5
- new_tweets = []
6
-
7
- config = SimpleConfig.for(:feeds)
8
- config.twitter_feeds.each do |feed_title, url|
9
- parse_feed(new_tweets, url, feed_title)
10
- end
11
-
12
- Twitter.transaction do
5
+ new_tweets = []
6
+
7
+ config = SimpleConfig.for(:feeds)
8
+ config.twitter_feeds.each do |feed_title, url|
9
+ parse_feed(new_tweets, url, feed_title)
10
+ end
11
+
12
+ Twitter.transaction do
13
13
  Twitter.delete_all()
14
- new_tweets.each {|t| t.save}
15
- p "Tweets saved: #{new_tweets.length}"
16
- end
17
- end
18
-
19
- def self.update_ncaa_twitter
14
+ new_tweets.each {|t| t.save}
15
+ p "Tweets saved: #{new_tweets.length}"
16
+ end
17
+ end
18
+
19
+ def self.update_ncaa_twitter
20
20
  new_tweets = []
21
-
21
+
22
22
  config = SimpleConfig.for(:feeds)
23
- config.twitter_feeds.each do |feed_title, url|
23
+ config.twitter_feeds.each do |feed_title, url|
24
24
  parse_feed(new_tweets, url, feed_title)
25
25
  end
26
-
27
- ExternalFeed.find(:all, :conditions => ["content_type = ? and provider = ?", "twitter", "Sporting News"]).each do |feed_obj|
28
- feed_url = feed_obj.woven_feed_url
29
- if SimpleConfig.for(:application).woven_feed_server != "woven.zumobi.net"
30
- feed_url = feed_url.gsub("woven.zumobi.net", SimpleConfig.for(:application).woven_feed_server)
31
- end
32
-
33
- begin
34
- team_obj = Team.find_by_id!(feed_obj.team_id)
35
- feed_name = (team_obj.nil? ? "Unknown" : team_obj.city_name)
36
- parse_feed(new_tweets, feed_url, feed_name, feed_obj.team_id)
37
-
38
- rescue ActiveRecord::RecordNotFound
39
- p "--- Couldn't update feed, no matching team: #{feed_url}"
40
- end
26
+
27
+ ExternalFeed.find(:all, :conditions => ["content_type = ? and provider = ?", "twitter", "Sporting News"]).each do |feed_obj|
28
+ feed_url = feed_obj.woven_feed_url
29
+ if SimpleConfig.for(:application).woven_feed_server != "woven.zumobi.net"
30
+ feed_url = feed_url.gsub("woven.zumobi.net", SimpleConfig.for(:application).woven_feed_server)
31
+ end
32
+
33
+ team_obj = Team.find(feed_obj.team_id)
34
+ feed_name = (team_obj.nil? ? "Unknown" : team_obj.city_name)
35
+ parse_feed(new_tweets, feed_url, feed_name, feed_obj.team_id)
41
36
  end
42
-
37
+
43
38
  Twitter.transaction do
44
39
  Twitter.delete_all()
45
- new_tweets.each {|t| t.save}
46
- p "Tweets saved: #{new_tweets.length}"
47
- end
48
-
40
+ new_tweets.each {|t| t.save}
41
+ p "Tweets saved: #{new_tweets.length}"
42
+ end
43
+
49
44
  rescue Exception => e
50
45
  Zumobi::ExceptionHandler.error e
51
46
  end
52
47
 
53
48
 
54
- def self.parse_feed(new_tweets, url, feed_title, team_id=nil)
55
- require 'open-uri'
56
- p "Twitter - #{feed_title} - #{url}"
57
-
49
+ def self.parse_feed(new_tweets, url, feed_title, team_id=nil)
50
+ require 'open-uri'
51
+ p "Twitter - #{feed_title} - #{url}"
52
+
58
53
  begin
59
54
  open(url) do |file|
60
55
  doc = Nokogiri::XML(file.read)
61
56
  source = doc.xpath('/rss/channel/title').text
62
- source = adjust_titles(source)
63
- # this has to come after adjust_titles or it gomers it all up
64
57
  source = source.gsub('Twitter', '').strip
58
+ source = title_changes(source)
65
59
 
66
60
  if !doc.nil? && !source.nil?
67
61
  doc.xpath('//item').each do |node|
@@ -77,15 +71,15 @@ class TwitterBuilder
77
71
  t.contents = t.title
78
72
 
79
73
  team_key = team_mapping(t.source)
80
-
81
- if !team_key.blank?
82
- if Team.column_names.include?("tsn_key") && !Team.find_by_tsn_key(team_key).blank?
83
- t.team_id = Team.find_by_tsn_key(team_key).id
84
- elsif !Team.find_by_key(team_key).blank?
85
- t.team_id = Team.find_by_key(team_key).id
86
- end
74
+
75
+ if !team_key.blank?
76
+ if Team.column_names.include?("tsn_key") && !Team.find_by_tsn_key(team_key).blank?
77
+ t.team_id = Team.find_by_tsn_key(team_key).id
78
+ elsif !Team.find_by_key(team_key).blank?
79
+ t.team_id = Team.find_by_key(team_key).id
80
+ end
87
81
  end
88
-
82
+
89
83
  new_tweets << t
90
84
  end
91
85
  end
@@ -93,40 +87,34 @@ class TwitterBuilder
93
87
  rescue OpenURI::HTTPError => http_e
94
88
  p 'unable to retrieve feed'
95
89
  rescue EOFError
96
- p 'connection error'
90
+ p 'connection error'
97
91
  rescue Errno::ECONNRESET
98
- p 'connection error'
92
+ p 'connection error'
99
93
  rescue Errno::ECONNREFUSED
100
- p 'connection error'
101
- end
94
+ p 'connection error'
95
+ end
102
96
  rescue Exception => e
103
97
  Zumobi::ExceptionHandler.error e
104
98
  end
105
99
 
106
- # Adjust the title for a couple of feeds.
107
- # Return the original title if it doesn't
108
- # need to be adjusted.
109
- def self.adjust_titles(title)
110
- if title == 'Official NFL Twitter Feed'
111
- return 'NFL'
112
- elsif title == 'The Trenches Twitter'
113
- return 'The Trenches'
114
- else
115
- return title
116
- end
117
- end
100
+ def self.title_changes(source)
101
+ titles = {'Official NFL Twitter Feed' => 'NFL',
102
+ 'The Trenches Twitter' => 'The Trenches'}
118
103
 
104
+ return (titles[source].nil?) ? source : titles[source]
105
+ end
106
+
119
107
  def self.add_hash_highlight(str)
120
108
  formatted_text = []
121
109
  each_word = str.split(' ')
122
- each_word.each do |word|
110
+ each_word.each do |word|
123
111
  if word[0,7] == "http://"
124
112
  new_word = "<a href='#{word}'>#{word}</a>"
125
113
  formatted_text << new_word
126
114
  elsif word.include? "http://"
127
115
  phrase = word
128
116
  pieces = word.split("http://")
129
-
117
+
130
118
  phrase = "#{pieces[0]} <a href='http://#{pieces[1]}'>http://#{pieces[1]}</a>"
131
119
  formatted_text << phrase
132
120
  else
@@ -168,7 +156,7 @@ class TwitterBuilder
168
156
  'Carolina Panthers' => 'l.nfl.com-t.29',
169
157
  'New Orleans Saints' => 'l.nfl.com-t.30',
170
158
  'Tampa Bay Bucs' => 'l.nfl.com-t.26',
171
- 'Arizona Diamondbacks' => 'l.mlb.com-t.26',
159
+ 'Arizona Diamondbacks' => 'l.mlb.com-t.26',
172
160
  'Atlanta Braves' => 'l.mlb.com-t.15',
173
161
  'Baltimore Orioles' => 'l.mlb.com-t.1',
174
162
  'Boston Red Sox' => 'l.mlb.com-t.2',
@@ -180,7 +168,7 @@ class TwitterBuilder
180
168
  'Detroit Tigers' => 'l.mlb.com-t.8',
181
169
  'Miami Marlins' => 'l.mlb.com-t.16',
182
170
  'Houston Astros' => 'l.mlb.com-t.22',
183
- 'Kansas City Royals' => 'l.mlb.com-t.9',
171
+ 'Kansas City Royals' => 'l.mlb.com-t.9',
184
172
  'Los Angeles Angels' => 'l.mlb.com-t.11',
185
173
  'Los Angeles Dodgers' => 'l.mlb.com-t.28',
186
174
  'Milwaukee Brewers' => 'l.mlb.com-t.23',
@@ -189,7 +177,7 @@ class TwitterBuilder
189
177
  'New York Yankees' => 'l.mlb.com-t.3',
190
178
  'Oakland Athletics' => 'l.mlb.com-t.12',
191
179
  'Philadelphia Phillies' => 'l.mlb.com-t.19',
192
- 'Pittsburgh Pirates' => 'l.mlb.com-t.24',
180
+ 'Pittsburgh Pirates' => 'l.mlb.com-t.24',
193
181
  'San Diego Padres' => 'l.mlb.com-t.29',
194
182
  'San Francisco Giants' => 'l.mlb.com-t.30',
195
183
  'Seattle Mariners' => 'l.mlb.com-t.13',
@@ -198,7 +186,7 @@ class TwitterBuilder
198
186
  'Texas Rangers' => 'l.mlb.com-t.14',
199
187
  'Toronto Blue Jays' => 'l.mlb.com-t.5',
200
188
  'Washington Nationals' => 'l.mlb.com-t.17',
201
- 'Boston Celtics' => 'l.nba.com-t.1',
189
+ 'Boston Celtics' => 'l.nba.com-t.1',
202
190
  'Brooklyn Nets' => 'l.nba.com-t.3',
203
191
  'New York Knicks' => 'l.nba.com-t.4',
204
192
  'Philadelphia 76ers' => 'l.nba.com-t.6',
@@ -211,7 +199,7 @@ class TwitterBuilder
211
199
  'Atlanta Hawks' => 'l.nba.com-t.8',
212
200
  'Charlotte Bobcats' => 'l.nba.com-t.32',
213
201
  'Miami Heat' => 'l.nba.com-t.2',
214
- 'Orlando Magic' => 'l.nba.com-t.5',
202
+ 'Orlando Magic' => 'l.nba.com-t.5',
215
203
  'Washington Wizards' => 'l.nba.com-t.7',
216
204
  'Denver Nuggets' => 'l.nba.com-t.17',
217
205
  'Minnesota Timberwolves' => 'l.nba.com-t.20',
@@ -220,7 +208,7 @@ class TwitterBuilder
220
208
  'Utah Jazz' => 'l.nba.com-t.22',
221
209
  'Golden State Warriors' => 'l.nba.com-t.23',
222
210
  'Los Angeles Clippers' => 'l.nba.com-t.24',
223
- 'Los Angeles Lakers' => 'l.nba.com-t.25',
211
+ 'Los Angeles Lakers' => 'l.nba.com-t.25',
224
212
  'Phoenix Suns' => 'l.nba.com-t.26',
225
213
  'Sacramento Kings' => 'l.nba.com-t.28',
226
214
  'Dallas Mavericks' => 'l.nba.com-t.16',
@@ -233,4 +221,4 @@ class TwitterBuilder
233
221
  end
234
222
 
235
223
  end
236
- end
224
+ end
@@ -1,3 +1,3 @@
1
1
  module SportsDb
2
- VERSION = "0.0.13"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,55 +1,63 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sports_db
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.13
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Alx Dark
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2013-05-31 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-05-16 00:00:00 -06:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
15
22
  name: rails
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 3.2.13
22
- type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
- requirements:
26
+ requirements:
27
27
  - - ~>
28
- - !ruby/object:Gem::Version
28
+ - !ruby/object:Gem::Version
29
+ hash: 21
30
+ segments:
31
+ - 3
32
+ - 2
33
+ - 13
29
34
  version: 3.2.13
30
- - !ruby/object:Gem::Dependency
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
31
38
  name: sqlite3
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :development
39
39
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id002
46
51
  description: Shared code for the Zumobi sports applications
47
- email:
48
- - ! "alx.dark@zumobi.com\t"
52
+ email:
53
+ - "alx.dark@zumobi.com\t"
49
54
  executables: []
55
+
50
56
  extensions: []
57
+
51
58
  extra_rdoc_files: []
52
- files:
59
+
60
+ files:
53
61
  - app/assets/javascripts/clients/android/client.js
54
62
  - app/assets/javascripts/clients/ios/client.js
55
63
  - app/assets/javascripts/core/Application.js
@@ -162,31 +170,41 @@ files:
162
170
  - test/dummy/script/rails
163
171
  - test/sports_db_test.rb
164
172
  - test/test_helper.rb
173
+ has_rdoc: true
165
174
  homepage: http://www.zumobi.com/
166
175
  licenses: []
176
+
167
177
  post_install_message:
168
178
  rdoc_options: []
169
- require_paths:
179
+
180
+ require_paths:
170
181
  - lib
171
- required_ruby_version: !ruby/object:Gem::Requirement
182
+ required_ruby_version: !ruby/object:Gem::Requirement
172
183
  none: false
173
- requirements:
174
- - - ! '>='
175
- - !ruby/object:Gem::Version
176
- version: '0'
177
- required_rubygems_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ hash: 3
188
+ segments:
189
+ - 0
190
+ version: "0"
191
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
192
  none: false
179
- requirements:
180
- - - ! '>='
181
- - !ruby/object:Gem::Version
182
- version: '0'
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ hash: 3
197
+ segments:
198
+ - 0
199
+ version: "0"
183
200
  requirements: []
201
+
184
202
  rubyforge_project:
185
- rubygems_version: 1.8.23
203
+ rubygems_version: 1.6.2
186
204
  signing_key:
187
205
  specification_version: 3
188
206
  summary: Shared code for the Zumobi sports applications
189
- test_files:
207
+ test_files:
190
208
  - test/dummy/app/assets/javascripts/application.js
191
209
  - test/dummy/app/assets/stylesheets/application.css
192
210
  - test/dummy/app/controllers/application_controller.rb