Skip to content

Commit

Permalink
add some navigation, add episode context
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaltom committed Sep 22, 2014
1 parent 3e7ac30 commit 8d7caa8
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 17 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ bundle install
* Create the database
```shell
rake db:setup
rake db:seed
```
* Run the search server
```shell
Expand Down
19 changes: 10 additions & 9 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
before_filter :store_location
before_filter :authenticate_user!
before_filter :load_news
before_filter :set_episode
before_filter :set_current_episode


before_filter do
Expand All @@ -18,11 +18,11 @@ class ApplicationController < ActionController::Base
protected

def howto
render :layout => "application"
render :layout => 'application'
end

def awards
render :layout => "application"
render :layout => 'application'
end

def after_sign_out_path_for(resource_or_scope)
Expand All @@ -32,7 +32,7 @@ def after_sign_out_path_for(resource_or_scope)
def store_location
if user_signed_in?
if not request.fullpath === new_user_ichain_session_path and request.get?
session["user_return_to"] = request.fullpath
session['user_return_to'] = request.fullpath
end
end
end
Expand All @@ -58,13 +58,14 @@ def parameter_empty
flash["alert-warning"] = 'Parameter missing...'
end

def set_episode
if !params[:episode].blank?
@episode = Episode.find_by(id: params[:episode])
def set_current_episode
if params[:episode].kind_of? String
@current_episode = Episode.find(params[:episode])
elsif session[:episode]
@episode = Episode.find_by(id: session[:episode])
@current_episode = Episode.find(session[:episode])
end
@current_episode = Episode.last unless @current_episode
# and then we save the ID to the session
session[:episode] = @episode
session[:episode] = @current_episode
end
end
6 changes: 5 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ def bootstrap_class_for flash_type
end

def days_to_launch
DateTime.new(2014,10,20).mjd - DateTime.now.mjd
if @current_episode
@current_episode.start_date.mjd - DateTime.now.mjd
else
'//'
end
end

end
Empty file removed app/models/.gitkeep
Empty file.
16 changes: 12 additions & 4 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@

#left-menu.menu
%ul.list-unstyled
- unless @user
- unless @current_user
%li.menu-btn-login
%a{:href => new_user_ichain_session_path}
.outerCircle
.innerCircle
- else
%li
= "Logged in as #{@user.name}"
My projects
Logout
= 'Logged in as '
= link_to @current_user.name, me_users_path
= link_to 'Log out', destroy_user_ichain_session_path, :method => :delete

%li.menu-btn-twitter.row
.col-xs-4
Expand All @@ -58,6 +58,14 @@

/ Right Menu - navigation
%nav#right-menu.menu
%ul
- if @current_episode
%li
= link_to @current_episode.name, episode_path(@current_episode)

%li= link_to 'Announcements', announcements_path
%li= link_to 'All Episodes', episodes_path
%li= link_to 'All Projects', projects_path

/ Go Home button and contact
#home-menu-contact
Expand Down
2 changes: 1 addition & 1 deletion app/views/projects/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
%i.fa.fa-group
= pluralize(p.memberships.count, 'dev')
%i.fa.fa-thumbs-up
= p.likes.count
= p.likes.count
13 changes: 13 additions & 0 deletions config/initializers/quiet_assets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do

def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index('/assets/') == 0
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
end
end
alias_method_chain :call, :quiet_assets

end
4 changes: 2 additions & 2 deletions spec/features/collaboration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
click_link "Join this project"
}.to change(Project.populated, :count).by(1)
expect(page).to have_css("#user#{user.id}-gravatar")
expect(page).to have_text("Welcome to the project #{user.name}!")
expect(page).to have_text("Leave this project")
end

scenario "User leaves a project" do
Expand Down Expand Up @@ -53,4 +53,4 @@
expect(page).not_to have_css("dislike-#{project.to_param}")
end

end
end

0 comments on commit 8d7caa8

Please sign in to comment.