sportdb-admin 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/Manifest.txt +37 -0
  3. data/README.md +1 -1
  4. data/app/assets/javascripts/sport_db_admin/application.js +15 -0
  5. data/app/assets/stylesheets/sport_db_admin/application.css.scss +141 -0
  6. data/app/controllers/sport_db_admin/application_controller.rb +6 -0
  7. data/app/controllers/sport_db_admin/countries_controller.rb +25 -0
  8. data/app/controllers/sport_db_admin/events_controller.rb +25 -0
  9. data/app/controllers/sport_db_admin/games_controller.rb +36 -0
  10. data/app/controllers/sport_db_admin/pages_controller.rb +13 -0
  11. data/app/controllers/sport_db_admin/regions_controller.rb +16 -0
  12. data/app/controllers/sport_db_admin/rounds_controller.rb +15 -0
  13. data/app/controllers/sport_db_admin/teams_controller.rb +49 -0
  14. data/app/helpers/sport_db_admin/application_helper.rb +50 -0
  15. data/app/helpers/sport_db_admin/part_helper.rb +47 -0
  16. data/app/helpers/sport_db_admin/routes_helper.rb +23 -0
  17. data/app/views/layouts/sport_db_admin/application.html.erb +36 -0
  18. data/app/views/sport_db_admin/countries/index.html.erb +49 -0
  19. data/app/views/sport_db_admin/countries/show.html.erb +107 -0
  20. data/app/views/sport_db_admin/events/index.html.erb +32 -0
  21. data/app/views/sport_db_admin/events/show.html.erb +116 -0
  22. data/app/views/sport_db_admin/games/_games.html.erb +47 -0
  23. data/app/views/sport_db_admin/games/index.html.erb +22 -0
  24. data/app/views/sport_db_admin/pages/about.html.erb +51 -0
  25. data/app/views/sport_db_admin/pages/index.html.erb +2 -0
  26. data/app/views/sport_db_admin/regions/index.html.erb +54 -0
  27. data/app/views/sport_db_admin/rounds/index.html.erb +50 -0
  28. data/app/views/sport_db_admin/shared/_td_game_date.html.erb +4 -0
  29. data/app/views/sport_db_admin/shared/_td_game_debug.html.erb +7 -0
  30. data/app/views/sport_db_admin/shared/_td_game_flags.html.erb +13 -0
  31. data/app/views/sport_db_admin/shared/_td_game_round.html.erb +9 -0
  32. data/app/views/sport_db_admin/shared/_td_game_score.html.erb +3 -0
  33. data/app/views/sport_db_admin/shared/_td_game_team1.html.erb +21 -0
  34. data/app/views/sport_db_admin/shared/_td_game_team2.html.erb +19 -0
  35. data/app/views/sport_db_admin/shared/_team_world_tree.html.erb +16 -0
  36. data/app/views/sport_db_admin/teams/index.html.erb +7 -0
  37. data/app/views/sport_db_admin/teams/index_clubs.html.erb +49 -0
  38. data/app/views/sport_db_admin/teams/index_national_teams.html.erb +45 -0
  39. data/app/views/sport_db_admin/teams/show.html.erb +50 -0
  40. data/config/routes.rb +68 -0
  41. data/lib/sportdb/admin.rb +12 -1
  42. data/lib/sportdb/admin/version.rb +1 -1
  43. metadata +58 -15
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 15ff1f77d4daac78d66473e66955d868c0422c96
4
+ data.tar.gz: 3575dd98cd4f48709d3c2dc253d028e1f0043681
5
+ SHA512:
6
+ metadata.gz: a4425d5081d2e8fc46b872dc235ef5cd63fdd856b73daf891adfcc3f8dff406e9fa2e00726dea126d241bf6e8983b9021343a71cc92894ee09929b3757fab088
7
+ data.tar.gz: 0b27e7517d40d8ef316648b772385a28026022d5f224630ad05229e67bc33661e34264636af8323a483752c069d41fe58c28bb98fca6b90a30a60cf74c220ba9
@@ -2,6 +2,43 @@ History.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
+ app/assets/javascripts/sport_db_admin/application.js
6
+ app/assets/stylesheets/sport_db_admin/application.css.scss
7
+ app/controllers/sport_db_admin/application_controller.rb
8
+ app/controllers/sport_db_admin/countries_controller.rb
9
+ app/controllers/sport_db_admin/events_controller.rb
10
+ app/controllers/sport_db_admin/games_controller.rb
11
+ app/controllers/sport_db_admin/pages_controller.rb
12
+ app/controllers/sport_db_admin/regions_controller.rb
13
+ app/controllers/sport_db_admin/rounds_controller.rb
14
+ app/controllers/sport_db_admin/teams_controller.rb
15
+ app/helpers/sport_db_admin/application_helper.rb
16
+ app/helpers/sport_db_admin/part_helper.rb
17
+ app/helpers/sport_db_admin/routes_helper.rb
18
+ app/views/layouts/sport_db_admin/application.html.erb
19
+ app/views/sport_db_admin/countries/index.html.erb
20
+ app/views/sport_db_admin/countries/show.html.erb
21
+ app/views/sport_db_admin/events/index.html.erb
22
+ app/views/sport_db_admin/events/show.html.erb
23
+ app/views/sport_db_admin/games/_games.html.erb
24
+ app/views/sport_db_admin/games/index.html.erb
25
+ app/views/sport_db_admin/pages/about.html.erb
26
+ app/views/sport_db_admin/pages/index.html.erb
27
+ app/views/sport_db_admin/regions/index.html.erb
28
+ app/views/sport_db_admin/rounds/index.html.erb
29
+ app/views/sport_db_admin/shared/_td_game_date.html.erb
30
+ app/views/sport_db_admin/shared/_td_game_debug.html.erb
31
+ app/views/sport_db_admin/shared/_td_game_flags.html.erb
32
+ app/views/sport_db_admin/shared/_td_game_round.html.erb
33
+ app/views/sport_db_admin/shared/_td_game_score.html.erb
34
+ app/views/sport_db_admin/shared/_td_game_team1.html.erb
35
+ app/views/sport_db_admin/shared/_td_game_team2.html.erb
36
+ app/views/sport_db_admin/shared/_team_world_tree.html.erb
37
+ app/views/sport_db_admin/teams/index.html.erb
38
+ app/views/sport_db_admin/teams/index_clubs.html.erb
39
+ app/views/sport_db_admin/teams/index_national_teams.html.erb
40
+ app/views/sport_db_admin/teams/show.html.erb
41
+ config/routes.rb
5
42
  lib/sportdb/admin.rb
6
43
  lib/sportdb/admin/engine.rb
7
44
  lib/sportdb/admin/version.rb
data/README.md CHANGED
@@ -11,7 +11,7 @@ Open sports web admin addon / rails engine
11
11
  ## Demo
12
12
 
13
13
  Try the `sport.db` web admin demo running
14
- on Heroku [`football.herokuapp.com`](http://football.herokuapp.com).
14
+ on Heroku [`footballdb.herokuapp.com`](http://footballdb.herokuapp.com).
15
15
 
16
16
  ## Usage
17
17
 
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,141 @@
1
+
2
+
3
+ // $base-font-size: 18px; // was 20px
4
+ $base-font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
5
+
6
+
7
+ $dark-gray: #333333;
8
+ $azure: #F0FFFF; // azure (see wikipedia web colors)
9
+
10
+
11
+ body
12
+ {
13
+ font-family: $base-font-family;
14
+ }
15
+
16
+
17
+ a {
18
+ color: black;
19
+ text-decoration: none;
20
+
21
+ &:hover {
22
+ color: black;
23
+ background-color: aqua;
24
+ text-decoration: underline;
25
+ }
26
+
27
+ &:visited { color: black; }
28
+ }
29
+
30
+
31
+ .team-count,
32
+ .city-count,
33
+ .event-count,
34
+ .country-count {
35
+ color: $dark-gray;
36
+ font-size: 12px; // ~80%
37
+ }
38
+
39
+ table {
40
+ td.event-key,
41
+ td.team-key,
42
+ td.round-key,
43
+ td.city-key,
44
+ td.country-key,
45
+ td.region-key,
46
+ td.league-key {
47
+ color: $dark-gray;
48
+ font-size: 12px; // ~80%
49
+ * {
50
+ color: $dark-gray;
51
+ font-size: 12px; // ~80%
52
+ }
53
+ }
54
+ }
55
+
56
+
57
+ table.play {
58
+ tr.game-round,
59
+ tr.round-week {
60
+ background-color: $azure;
61
+
62
+ td {
63
+ border-top: 1px solid black;
64
+ border-bottom: 1px solid black;
65
+ }
66
+ }
67
+
68
+ tr.game-day {
69
+ td {
70
+ border-top: 1px solid black;
71
+ border-bottom: 1px solid black;
72
+ }
73
+ }
74
+
75
+ tr.game-year,
76
+ tr.game-week,
77
+ tr.round-year {
78
+ background-color: $azure; // todo: make it darker 20%?
79
+ font-size: 22px; // ~10%
80
+
81
+ td {
82
+ border-top: 1px solid black;
83
+ border-bottom: 1px solid black;
84
+ }
85
+ }
86
+
87
+ td.game-score {
88
+ text-align: center;
89
+ }
90
+
91
+ td.game-date,
92
+ td.game-hour,
93
+ td.game-round,
94
+ td.game-debug,
95
+ td.round-debug {
96
+ color: $dark-gray;
97
+ font-size: 12px; // ~80%
98
+ * {
99
+ color: $dark-gray;
100
+ font-size: 12px; // ~80%
101
+ }
102
+ }
103
+
104
+ td.game-team1,
105
+ td.game-team2 {
106
+ .game-knockout.game-team-loser
107
+ {
108
+ // color: red; // not working - only changes line-through color
109
+ text-decoration: line-through;
110
+
111
+ // -moz-text-decoration-color: grey;
112
+ // text-decoration-color: grey;
113
+ }
114
+
115
+ .game-team-winner
116
+ {
117
+ font-weight: bold;
118
+ }
119
+ }
120
+
121
+ td {
122
+ white-space: nowrap;
123
+ }
124
+ }
125
+
126
+
127
+
128
+ /////////////////////////
129
+ // version / powered_by
130
+
131
+ .version
132
+ {
133
+ text-align: center;
134
+ margin-top: 10px;
135
+ color: grey;
136
+
137
+ a, span {
138
+ font-size: 12px;
139
+ color: grey
140
+ }
141
+ }
@@ -0,0 +1,6 @@
1
+ module SportDbAdmin
2
+
3
+ class ApplicationController < ActionController::Base
4
+ end
5
+
6
+ end # module SportDbAdmin
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ module SportDbAdmin
4
+
5
+ class CountriesController < ApplicationController
6
+
7
+ # GET /countries
8
+ def index
9
+ @countries = Country.all
10
+ end
11
+
12
+ # GET /:key e.g /at or /us etc.
13
+ def shortcut
14
+ @country = Country.find_by_key!( params[:key] )
15
+ render :show
16
+ end
17
+
18
+ # GET /countries/1
19
+ def show
20
+ @country = Country.find( params[:id] )
21
+ end
22
+
23
+ end # class CountriesController
24
+
25
+ end # module SportDbAdmin
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ module SportDbAdmin
4
+
5
+ class EventsController < ApplicationController
6
+
7
+ # GET /events
8
+ def index
9
+ @events = Event.all
10
+ end
11
+
12
+ # GET /events/1
13
+ def show
14
+ @event = Event.find( params[:id] )
15
+ end
16
+
17
+ # GET /:key e.g /euro.2012 or /at.2011_12 etc.
18
+ def shortcut
19
+ @event = Event.find_by_key!( params[:key].tr('_','/') )
20
+ render :show
21
+ end
22
+
23
+ end # class EventsController
24
+
25
+ end # module SportDbAdmin
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+ module SportDbAdmin
4
+
5
+ class GamesController < ApplicationController
6
+
7
+ # GET /games
8
+ def index
9
+ # find next upcoming games
10
+ limit = params[:limit] || '50'
11
+
12
+ @games = Game.where( 'play_at > ?', Time.now ).order( 'play_at').limit(limit)
13
+ @show_upcoming = true
14
+ end
15
+
16
+ # GET /games/past
17
+ def past
18
+ limit = params[:limit] || '50'
19
+
20
+ if params[:null].present? # e.g. use ?null=t
21
+ ## find all past games w/ missing score
22
+ @games = Game.where( 'play_at < ?', Time.now ).
23
+ where( 'score1 is null or score2 is null').
24
+ order( 'play_at desc').limit(limit)
25
+ else
26
+ @games = Game.where( 'play_at < ?', Time.now ).order( 'play_at desc').limit(limit)
27
+ end
28
+
29
+ @show_upcoming = false
30
+
31
+ render :action => 'index'
32
+ end
33
+
34
+ end # class GamesController
35
+
36
+ end # module SportDbAdmin
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ module SportDbAdmin
4
+
5
+ class PagesController < ApplicationController
6
+ def index
7
+ end
8
+
9
+ def about
10
+ end
11
+ end
12
+
13
+ end # module SportDbAdmin
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ module SportDbAdmin
4
+
5
+ class RegionsController < ApplicationController
6
+
7
+ # GET /countries
8
+ def index
9
+ ## todo: only get countries w/ regions
10
+ @countries = Country.all
11
+ end
12
+
13
+
14
+ end # class RegionsController
15
+
16
+ end # module SportDbAdmin
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ module SportDbAdmin
4
+
5
+ class RoundsController < ApplicationController
6
+
7
+ # GET /rounds
8
+ def index
9
+ @rounds = Round.order( 'start_at desc').all
10
+ end
11
+
12
+
13
+ end # class RoundsController
14
+
15
+ end # module SportDbAdmin
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ module SportDbAdmin
4
+
5
+ class TeamsController < ApplicationController
6
+
7
+ # GET /teams
8
+ def index
9
+ # make clubs default view
10
+ index_clubs
11
+ end
12
+
13
+ def index_national_teams
14
+ # todo: join country table to order by country.key ??
15
+ @teams = Team.where( club: false ).order( 'country_id' ).all
16
+ end
17
+
18
+ def index_clubs
19
+ @teams = Team.where( club: true )
20
+
21
+ if params[:order].present?
22
+ if params[:order] == 'key'
23
+ @teams = @teams.order( 'key' )
24
+ elsif params[:order] == 'title'
25
+ @teams = @teams.order( 'title' )
26
+ elsif params[:order] == 'code'
27
+ @teams = @teams.order( 'code' )
28
+ end
29
+ else
30
+ @teams = @teams.order( 'country_id' )
31
+ end
32
+
33
+ @teams = @teams.all
34
+ end
35
+
36
+ # GET /:key e.g /barcelona or /rapid etc.
37
+ def shortcut
38
+ @team = Team.find_by_key!( params[:key] )
39
+ render :show
40
+ end
41
+
42
+ # GET /teams/1
43
+ def show
44
+ @team = Team.find(params[:id])
45
+ end
46
+
47
+ end # class TeamsController
48
+
49
+ end # module SportDbAdmin
@@ -0,0 +1,50 @@
1
+ module SportDbAdmin
2
+ module ApplicationHelper
3
+
4
+ def game_team1_style_class( game )
5
+ ## fix: move to game model in game.rb
6
+ buf = ''
7
+ buf << game.team1_style_class
8
+ buf << ' game-knockout ' if game.knockout?
9
+ ### fix: loser - add method for checking winner/loser on ko pairs using (1st leg/2nd leg totals)
10
+ buf << ' game-team-loser ' if game.complete? && (game.score1 < game.score2)
11
+ buf
12
+ end
13
+
14
+ def game_team2_style_class( game )
15
+ ## fix: move to game model in game.rb
16
+ buf = ''
17
+ buf << game.team2_style_class
18
+ buf << ' game-knockout ' if game.knockout?
19
+ buf << ' game-team-loser ' if game.complete? && (game.score1 > game.score2)
20
+ buf
21
+ end
22
+
23
+ def powered_by
24
+ ## todo/fix: use version from wettpool module
25
+ content_tag :div do
26
+ link_to( 'Questions? Comments?', 'http://groups.google.com/group/opensport' ) + " | " +
27
+ link_to( "world.db/#{WorldDB::VERSION}", 'https://github.com/geraldb/world.db' ) + ', ' +
28
+ link_to( "sport.db/#{SportDB::VERSION}", 'https://github.com/geraldb/sport.db' ) + ', ' +
29
+ link_to( 'sport.db.admin/1', 'https://github.com/geraldb/sport.db.admin' ) + ' - ' +
30
+ content_tag( :span, "Ruby/#{RUBY_VERSION} (#{RUBY_RELEASE_DATE}/#{RUBY_PLATFORM}) on") + ' ' +
31
+ content_tag( :span, "Rails/#{Rails.version} (#{Rails.env})" ) + " | " +
32
+ link_to( 'Icon Drawer Flags', 'http://www.icondrawer.com' )
33
+ ## content_tag( :span, "#{request.headers['SERVER_SOFTWARE'] || request.headers['SERVER']}" )
34
+ end
35
+ end
36
+
37
+ ### todo/fix: move to format helper
38
+
39
+ def fmt_date_with_week( date )
40
+ if date.nil?
41
+ '-'
42
+ else
43
+ ## e.g. 2012 (Week 22) // Oct/21 Fri
44
+ date.strftime( "%Y (Week %V) // %b/%d %a" )
45
+ end
46
+ end
47
+
48
+
49
+ end # module ApplicationHelper
50
+ end # module SportDbAdmin