Skip to content

Commit

Permalink
Ability to activate / deactivate the about page
Browse files Browse the repository at this point in the history
  • Loading branch information
marcgg committed Feb 20, 2012
1 parent 1af2776 commit 1f7159d
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Expand Up @@ -48,7 +48,7 @@ GEM
faraday (0.5.7) faraday (0.5.7)
addressable (~> 2.2.4) addressable (~> 2.2.4)
multipart-post (~> 1.1.0) multipart-post (~> 1.1.0)
rack (< 2, >= 1.1.0) rack (>= 1.1.0, < 2)
faraday_middleware (0.3.2) faraday_middleware (0.3.2)
faraday (~> 0.5.4) faraday (~> 0.5.4)
fssm (0.2.7) fssm (0.2.7)
Expand Down Expand Up @@ -123,7 +123,7 @@ GEM
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
tzinfo (0.3.29) tzinfo (0.3.29)
webmock (1.7.6) webmock (1.7.6)
addressable (> 2.2.5, ~> 2.2) addressable (~> 2.2, > 2.2.5)
crack (>= 0.1.7) crack (>= 0.1.7)


PLATFORMS PLATFORMS
Expand Down
1 change: 1 addition & 0 deletions app/controllers/front_controller.rb
Expand Up @@ -15,6 +15,7 @@ def single_photo
end end


def about def about
redirect_to root_path unless @portfolio.about_page
end end


private private
Expand Down
5 changes: 3 additions & 2 deletions app/views/front/_nav.html.haml
Expand Up @@ -3,5 +3,6 @@
.nav-link-wrapper{:class => ((!@category.nil? and @category.id == category.id) ? " selected " : "") + "category-order-#{i}"} .nav-link-wrapper{:class => ((!@category.nil? and @category.id == category.id) ? " selected " : "") + "category-order-#{i}"}
= link_to category.title, showcase_path(:slug => @portfolio.slug, :category_slug => category.slug) = link_to category.title, showcase_path(:slug => @portfolio.slug, :category_slug => category.slug)


.nav-link-wrapper#about{:class => (@category.nil? ? "selected" : "")} - if @portfolio.about_page
= link_to "About", about_path(:slug => @portfolio.slug) .nav-link-wrapper#about{:class => (@category.nil? ? "selected" : "")}
= link_to "About", about_path(:slug => @portfolio.slug)
3 changes: 3 additions & 0 deletions app/views/portfolios/_form.html.haml
Expand Up @@ -4,6 +4,9 @@
= f.label :description = f.label :description
= f.text_area :description = f.text_area :description


= f.label :about_page
= f.check_box :about_page

- unless simple - unless simple
= f.label :slug = f.label :slug
= f.text_field :slug = f.text_field :slug
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Expand Up @@ -228,6 +228,7 @@ en:
description: "Description used in the 'about' page*" description: "Description used in the 'about' page*"
flickr_user_email: "Email used on Flickr*" flickr_user_email: "Email used on Flickr*"
slug: Slug* slug: Slug*
about_page: "Show the 'about' page"
google_analytics_code: "Google Analytics Code (e.g. UA-25132842-1)" google_analytics_code: "Google Analytics Code (e.g. UA-25132842-1)"
facebook_share: "Show a Facebook like button on the about page" facebook_share: "Show a Facebook like button on the about page"


Expand Down
9 changes: 9 additions & 0 deletions db/migrate/20120220190612_add_about_page_to_portfolios.rb
@@ -0,0 +1,9 @@
class AddAboutPageToPortfolios < ActiveRecord::Migration
def self.up
add_column :portfolios, :about_page, :boolean, :default => false
end

def self.down
remove_column :portfolios, :about_page
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Expand Up @@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.


ActiveRecord::Schema.define(:version => 20111016180006) do ActiveRecord::Schema.define(:version => 20120220190612) do


create_table "beta_codes", :force => true do |t| create_table "beta_codes", :force => true do |t|
t.string "code" t.string "code"
Expand Down Expand Up @@ -70,6 +70,7 @@
t.string "slug" t.string "slug"
t.string "google_analytics_code" t.string "google_analytics_code"
t.boolean "facebook_share", :default => false t.boolean "facebook_share", :default => false
t.boolean "about_page", :default => false
end end


create_table "remote_accounts", :force => true do |t| create_table "remote_accounts", :force => true do |t|
Expand Down
7 changes: 7 additions & 0 deletions spec/controllers/front_controller_spec.rb
Expand Up @@ -17,12 +17,19 @@


describe "GET about" do describe "GET about" do
it "should display the about page" do it "should display the about page" do
@portfolio.update_attributes(:about_page => true)
get "about", :slug => @portfolio.slug get "about", :slug => @portfolio.slug
response.should be_success response.should be_success
response.should render_template :about response.should render_template :about
assigns(:category).should be_nil assigns(:category).should be_nil
assigns(:portfolio).should == @portfolio assigns(:portfolio).should == @portfolio
end end

it "should not display the about page if deactivated" do
@portfolio.update_attributes(:about_page => false)
get "about", :slug => @portfolio.slug
response.should redirect_to root_path
end
end end


describe "GET showcase" do describe "GET showcase" do
Expand Down

0 comments on commit 1f7159d

Please sign in to comment.