Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
re-add acts_as_list gem to enable auto-position setting on project cr…
Browse files Browse the repository at this point in the history
…eation
  • Loading branch information
Matt Wright committed Feb 22, 2012
1 parent c263194 commit 7aa98c0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 17 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 18,7 @@ gem 'tinymce-rails'
gem 'jquery-rails'
gem 'friendly_id', :git => 'git://github.com/norman/friendly_id.git'
gem 'bcrypt-ruby'
gem 'acts_as_list' # enables automatic position setting on creation for projects & images

# Gems used only for assets and not required
# in production environments by default.
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 44,7 @@ GEM
activesupport (3.2.1)
i18n (~> 0.6)
multi_json (~> 1.0)
acts_as_list (0.1.4)
arel (3.0.0)
aws-sdk (1.3.3)
httparty (~> 0.7)
Expand Down Expand Up @@ -136,6 137,7 @@ PLATFORMS
ruby

DEPENDENCIES
acts_as_list
aws-sdk
bcrypt-ruby
coffee-rails (~> 3.2.1)
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 1,8 @@
module ApplicationHelper
def show_top_nav
!current_page?(admin_setup_path) && (!current_page?(new_admin_project_path) && Project.count > 0)
end

def show_project_nav
(controller.controller_name == 'projects' && controller.action_name == 'show') || controller.controller_name == 'images'
end
Expand Down
1 change: 1 addition & 0 deletions app/models/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 3,7 @@ class Image < ActiveRecord::Base
friendly_id :position
belongs_to :project
validates_attachment_presence :file
acts_as_list :scope => :project
has_attached_file :file,
:styles => { :default => "720x576>", :thumb => "223x223>" },
:default_style => :default,
Expand Down
1 change: 1 addition & 0 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 5,7 @@ class Project < ActiveRecord::Base
validates_presence_of :title, :slug, :images
has_many :images, :order => 'position ASC', :dependent => :destroy
accepts_nested_attributes_for :images, :allow_destroy => true
acts_as_list
after_create :set_front_project
after_save :reset_front_project

Expand Down
36 changes: 19 additions & 17 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 17,25 @@
<header class="group">
<h1><%= link_to (Settings.site_name || 'Porto'), root_path %></h1>

<nav>
<ul id="nav">
<% if Settings.show_blog == 'true' %>
<li id="news-link"><%= link_to Settings.blog_title, page_path(Settings.blog_title.parameterize) %></li>
<% end %>
<% if Settings.show_about == 'true' %>
<li id="bio-link"><%= link_to Settings.about_title, page_path(Settings.about_title.parameterize) %></li>
<% end %>
<% if Settings.show_contact == 'true' %>
<li id="contact-link"><%= link_to Settings.contact_title, page_path(Settings.contact_title.parameterize) %></li>
<% end %>
<% if current_user && !current_page?(admin_setup_path) %>
<li><%= link_to 'Admin', admin_path, :class => 'admin-link' %></li>
<li><%= link_to 'Log out', session_path, :confirm => 'Are you sure you want to log out?', :method => :delete, :class => 'admin-link' %></li>
<% end %>
</ul>
</nav>
<% if show_top_nav %>
<nav>
<ul id="nav">
<% if Settings.show_blog == 'true' %>
<li id="news-link"><%= link_to Settings.blog_title, page_path(Settings.blog_title.parameterize) %></li>
<% end %>
<% if Settings.show_about == 'true' %>
<li id="bio-link"><%= link_to Settings.about_title, page_path(Settings.about_title.parameterize) %></li>
<% end %>
<% if Settings.show_contact == 'true' %>
<li id="contact-link"><%= link_to Settings.contact_title, page_path(Settings.contact_title.parameterize) %></li>
<% end %>
<% if current_user %>
<li><%= link_to 'Admin', admin_path, :class => 'admin-link' %></li>
<li><%= link_to 'Log out', session_path, :confirm => 'Are you sure you want to log out?', :method => :delete, :class => 'admin-link' %></li>
<% end %>
</ul>
</nav>
<% end %>

<% if show_project_nav %>
<nav id="project-nav">
Expand Down

0 comments on commit 7aa98c0

Please sign in to comment.