From b344e9a816302f7e5f1417a2ababe3d2255e24d2 Mon Sep 17 00:00:00 2001 From: "Jesse C. Fisher" Date: Wed, 11 Nov 2015 04:09:46 -0800 Subject: [PATCH] stash --- Gemfile | 2 + Gemfile.lock | 9 ++ GuardfileServer | 39 ++++++++ app/assets/javascripts/components/game.js.jsx | 7 +- .../javascripts/components/inventory.js.jsx | 33 +++---- .../components/player_controls.js.jsx | 2 +- app/assets/stylesheets/application.css | 20 ---- app/assets/stylesheets/application.css.sass | 91 +++++++++++++++++++ app/assets/stylesheets/game.css.sass | 12 +++ app/assets/stylesheets/games.css.sass | 31 +++++-- app/policies/game_policy.rb | 25 +++++ app/views/games/index.html.haml | 28 +++--- app/views/games/show.html.haml | 2 +- app/views/games/show.json.jbuilder | 2 +- app/views/layouts/_navigation_links.html.erb | 36 ++++---- app/views/layouts/application.html.erb | 4 +- app/views/visitors/index.html.erb | 2 - app/views/visitors/index.html.haml | 7 ++ config/environments/development.rb | 3 + spec/features/visitors/home_page_spec.rb | 6 +- spec/features/visitors/quick_play_spec.rb | 2 +- 21 files changed, 271 insertions(+), 92 deletions(-) delete mode 100644 app/assets/stylesheets/application.css create mode 100644 app/assets/stylesheets/application.css.sass create mode 100644 app/assets/stylesheets/game.css.sass create mode 100644 app/policies/game_policy.rb delete mode 100644 app/views/visitors/index.html.erb create mode 100644 app/views/visitors/index.html.haml diff --git a/Gemfile b/Gemfile index 2958540..4607baf 100644 --- a/Gemfile +++ b/Gemfile @@ -37,6 +37,8 @@ group :development do gem 'guard-bundler' gem 'guard-rails' gem 'guard-rspec' + gem 'guard-livereload', '~> 2.4', require: false + gem "rack-livereload" gem 'html2haml' gem 'hub', require: nil gem 'quiet_assets' diff --git a/Gemfile.lock b/Gemfile.lock index 736d925..e2f1b11 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,6 +140,11 @@ GEM guard-ctags-bundler (1.4.0) guard (>= 2.0) guard-compat (>= 0.1.0) + guard-livereload (2.5.1) + em-websocket (~> 0.5) + guard (~> 2.8) + guard-compat (~> 1.0) + multi_json (~> 1.8) guard-rails (0.7.2) guard (~> 2.11) guard-compat (~> 1.0) @@ -229,6 +234,8 @@ GEM quiet_assets (1.1.0) railties (>= 3.1, < 5.0) rack (1.5.5) + rack-livereload (0.3.16) + rack rack-test (0.6.3) rack (>= 1.0) rails (4.1.8) @@ -394,6 +401,7 @@ DEPENDENCIES faker guard-bundler guard-ctags-bundler + guard-livereload (~> 2.4) guard-rails guard-rspec haml-lint @@ -411,6 +419,7 @@ DEPENDENCIES puma pundit quiet_assets + rack-livereload rails (= 4.1.8) rails_layout rb-fchange diff --git a/GuardfileServer b/GuardfileServer index 897ff03..021fc0c 100644 --- a/GuardfileServer +++ b/GuardfileServer @@ -98,3 +98,42 @@ guard 'ctags-bundler', src_path: ["app", "lib", "spec/support"], project_file: " watch(/^(app|lib|spec\/support)\/.*\.rb$/) watch('Gemfile.lock') end + +guard 'livereload' do + extensions = { + css: :css, + scss: :css, + sass: :css, + js: :js, + coffee: :js, + html: :html, + png: :png, + gif: :gif, + jpg: :jpg, + jpeg: :jpeg, + # less: :less, # uncomment if you want LESS stylesheets done in browser + } + + rails_view_exts = %w(erb haml slim) + + # file types LiveReload may optimize refresh for + compiled_exts = extensions.values.uniq + watch(%r{public/.+\.(#{compiled_exts * '|'})}) + + extensions.each do |ext, type| + watch(%r{ + (?:app|vendor) + (?:/assets/\w+/(?[^.]+) # path+base without extension + (?\.#{ext})) # matching extension (must be first encountered) + (?:\.\w+|$) # other extensions + }x) do |m| + path = m[1] + "/assets/#{path}.#{type}" + end + end + + # file needing a full reload of the page anyway + watch(%r{app/views/.+\.(#{rails_view_exts * '|'})$}) + watch(%r{app/helpers/.+\.rb}) + watch(%r{config/locales/.+\.yml}) +end diff --git a/app/assets/javascripts/components/game.js.jsx b/app/assets/javascripts/components/game.js.jsx index fb775da..15a63a2 100644 --- a/app/assets/javascripts/components/game.js.jsx +++ b/app/assets/javascripts/components/game.js.jsx @@ -89,9 +89,12 @@ var Game = React.createClass({ return
Loading...
; } return ( -
+
Title: {this.state.data.title}
-
Id: {this.state.data.id}
+
Game Id: {this.state.data.id}
Current Player: {this.state.data.controlling_player_id}
Hand to beat: {this.state.data.play_to_beat_string}
diff --git a/app/assets/javascripts/components/inventory.js.jsx b/app/assets/javascripts/components/inventory.js.jsx index f349ea2..4cd733a 100644 --- a/app/assets/javascripts/components/inventory.js.jsx +++ b/app/assets/javascripts/components/inventory.js.jsx @@ -12,24 +12,21 @@ var Inventory = React.createClass({ render: function() { if (this.props.cards) { return ( -
- Inventory: -
    - {this.props.cards.map(function(card) { - return
  • - -
  • ; - })} -
-
+
    + {this.props.cards.map(function(card) { + return
  • + +
  • ; + })} +
); } else { diff --git a/app/assets/javascripts/components/player_controls.js.jsx b/app/assets/javascripts/components/player_controls.js.jsx index 194eed8..486c6b4 100644 --- a/app/assets/javascripts/components/player_controls.js.jsx +++ b/app/assets/javascripts/components/player_controls.js.jsx @@ -26,7 +26,7 @@ var PlayerControls = React.createClass({ onSubmit={this.handleSubmit}> -
+ :delete, :data => { :confirm => 'Are you sure?' } +.button= link_to 'New Game', new_game_path -%br +.games-container + - @games.each do |game| + .game + .title= link_to game.title, game + .player-count= "#{game.players.count} Players" + + - if policy(game).update? + .owner-controls + = link_to 'Edit', edit_game_path(game) + = link_to 'Destroy', game, :method => :delete, :data => { :confirm => 'Are you sure?' } -= link_to 'New Game', new_game_path diff --git a/app/views/games/show.html.haml b/app/views/games/show.html.haml index c080bd8..4a6af38 100644 --- a/app/views/games/show.html.haml +++ b/app/views/games/show.html.haml @@ -1,4 +1,4 @@ -= react_component 'Game', url: "#{game_path @game}" +#game-component= react_component 'Game', url: "#{game_path @game}" -# TODO: Remove deprecated commented out code -#%p diff --git a/app/views/games/show.json.jbuilder b/app/views/games/show.json.jbuilder index f2fb579..ef6d6bd 100644 --- a/app/views/games/show.json.jbuilder +++ b/app/views/games/show.json.jbuilder @@ -10,7 +10,7 @@ json.winner_player_id @game.winner_player_id json.is_joinable @game.joinable?(current_user) json.is_started !@game.status.nil? json.is_startable @game.startable? -json.current_user_id current_user.id +json.current_user_id current_user.try(:id) json.players @game.players do |player| json.id player.id diff --git a/app/views/layouts/_navigation_links.html.erb b/app/views/layouts/_navigation_links.html.erb index b82b705..fcea7cc 100644 --- a/app/views/layouts/_navigation_links.html.erb +++ b/app/views/layouts/_navigation_links.html.erb @@ -1,17 +1,19 @@ -
  • <%= link_to 'Home', root_path %>
  • -
  • <%= link_to 'Games', games_path %>
  • -
  • <%= link_to 'Quick Play', quick_play_path %>
  • -<% if user_signed_in? %> -
  • <%= link_to 'Edit account', edit_user_registration_path %>
  • -
  • <%= link_to 'Sign out', destroy_user_session_path, :method=>'delete' %>
  • -<% else %> -
  • <%= link_to 'Sign in', new_user_session_path %>
  • -
  • <%= link_to 'Sign up', new_user_registration_path %>
  • -<% end %> -<% if user_signed_in? %> - <% if current_user.admin? %> -
  • <%= link_to 'Admin', '/admin' %>
  • -
  • <%= link_to 'Users', users_path %>
  • - <% end %> -<% end %> -
  • <%= link_to 'Debug', '#showDebugTools', id: 'showDebugTools' %>
  • + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index cf98df0..53a3cf3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -14,7 +14,9 @@ <%= render "layouts/flashmessages" %> - <%= yield %> +
    + <%= yield %> +
    diff --git a/app/views/visitors/index.html.erb b/app/views/visitors/index.html.erb deleted file mode 100644 index 5854d00..0000000 --- a/app/views/visitors/index.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

    Welcome

    -

    <%= link_to 'Users:', users_path %> <%= User.count %> registered

    diff --git a/app/views/visitors/index.html.haml b/app/views/visitors/index.html.haml new file mode 100644 index 0000000..aca68a3 --- /dev/null +++ b/app/views/visitors/index.html.haml @@ -0,0 +1,7 @@ +#home-headline + %h1 Thirteen
    Tien Len + +#main-menu + = link_to 'Play Now', '#' + = link_to 'Browse Tables', '#' + = link_to 'Tutorial', '#' diff --git a/config/environments/development.rb b/config/environments/development.rb index 84d058a..d582577 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -50,4 +50,7 @@ Rails.application.configure do # Raises error for missing translations # config.action_view.raise_on_missing_translations = true + + # Add Rack::LiveReload to the bottom of the middleware stack with the default options. + config.middleware.insert_after ActionDispatch::Static, Rack::LiveReload end diff --git a/spec/features/visitors/home_page_spec.rb b/spec/features/visitors/home_page_spec.rb index 4ac018e..35f8778 100644 --- a/spec/features/visitors/home_page_spec.rb +++ b/spec/features/visitors/home_page_spec.rb @@ -6,9 +6,11 @@ feature 'Home page' do # Scenario: Visit the home page # Given I am a visitor # When I visit the home page - # Then I see 'Welcome' + # Then I see the main menu scenario 'visit the home page' do visit root_path - expect(page).to have_content 'Welcome' + expect(page).to have_link 'Play Now' + expect(page).to have_link 'Browse Tables' + expect(page).to have_link 'Tutorial' end end diff --git a/spec/features/visitors/quick_play_spec.rb b/spec/features/visitors/quick_play_spec.rb index 71599f5..5cb09c5 100644 --- a/spec/features/visitors/quick_play_spec.rb +++ b/spec/features/visitors/quick_play_spec.rb @@ -10,7 +10,7 @@ feature 'Quick play', :devise do scenario 'visitor can join a quick play game' do pending('#EXPECT VISITOR TO JOIN FIRST OPEN QUICK PLAY GAME') visit root_path - click_link 'Quick Play' + click_link 'Play Now' # EXPECT VISITOR TO JOIN FIRST OPEN QUICK PLAY TABLE expect(fail) end