Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/sterrym/smithycms
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Glen committed Feb 18, 2015
2 parents 5cc1c91 + 280e996 commit fbb075a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 14 deletions.
9 changes: 7 additions & 2 deletions app/controllers/smithy/content_pieces_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Smithy::ContentPiecesController < Smithy::BaseController

helper_method :accessible_attributes
helper_method :klass_name
helper_method :klass_table_name
helper_method :readable_attributes

def index
Expand All @@ -28,7 +29,7 @@ def create
@record.save
flash.notice = "Your #{klass_name} was created" if @record.persisted?
respond_with @record do |format|
format.html { @record.persisted? ? redirect_to([:edit, @record]) : render(:action => 'new') }
format.html { @record.persisted? ? redirect_to(:action => :index) : render(:action => 'new') }
end
end

Expand Down Expand Up @@ -67,6 +68,10 @@ def klass_name
@klass_name ||= klass.name.sub(/^Smithy::/, '').titleize
end

def klass_table_name
klass.name.sub(/^Smithy::/, '').underscore.pluralize
end

def new_record
klass.new(filtered_params)
end
Expand All @@ -92,6 +97,6 @@ def readable_attributes
end

def accessible_attributes
klass.accessible_attributes.select(&:present?).map(&:to_sym)
permitted_params.send("#{klass.name.sub(/^Smithy::/, '').underscore}_attributes".to_sym)
end
end
7 changes: 6 additions & 1 deletion app/views/smithy/content_pieces/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
<%= f.inputs do %>
<%= f.inputs *accessible_attributes %>
<% end %>
<%= f.actions :submit %>
<%= f.actions do %>
<%= link_to([ klass_table_name ], class: 'btn btn-default') do %>
<span class="fa fa-arrow-left"></span> <%= "Back to #{klass_name.pluralize}" %>
<% end %>
<%= f.action :submit %>
<% end %>
<% end %>
Expand Down
4 changes: 4 additions & 0 deletions app/views/smithy/content_pieces/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<% content_for :title, "#{klass_name}" %>
<%= content_tag :p, link_to("New #{klass_name}", [:new, klass_table_name.singularize ], class: 'btn btn-primary') %></p>

<table border="0" cellpadding="4" class="table table-hover table-bordered">
<thead>
<tr>
Expand All @@ -11,6 +14,7 @@
<tr>
<td>
<%= link_to "Edit", [:edit, record], :class => "btn btn-default btn-xs" %>
<%= link_to("Delete", record, method: :delete, data: { confirm: "Are you sure you want to delete this #{klass_name}?" }, class: 'btn btn-danger btn-xs') if record.persisted? %>
</td>
<%- readable_attributes.map(&:to_sym).each do |attribute| %>
<td><%= record[attribute] %></td>
Expand Down
7 changes: 6 additions & 1 deletion app/views/smithy/content_pieces/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@
<%= f.inputs do %>
<%= f.inputs *accessible_attributes %>
<% end %>
<%= f.actions :submit %>
<%= f.actions do %>
<%= link_to([ klass_table_name ], class: 'btn btn-default') do %>
<span class="fa fa-arrow-left"></span> <%= "Back to #{klass_name.pluralize}" %>
<% end %>
<%= f.action :submit %>
<% end %>
<% end %>
8 changes: 0 additions & 8 deletions lib/smithy/content_pieces/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,3 @@ def register(content_piece)
end
end
end

Smithy::Engine.routes.draw do
namespace :smithy do
scope "/content_pieces" do
resources :store_locations
end
end
end
2 changes: 1 addition & 1 deletion lib/smithy/dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'awesome_nested_set'
require 'dragonfly'
require 'fog'
require 'font-awesome-sass-rails'
require 'font-awesome-sass'
require 'formtastic'
require 'formtastic-bootstrap'
require 'friendly_id'
Expand Down
3 changes: 2 additions & 1 deletion smithycms.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Gem::Specification.new do |s|
s.add_dependency 'bootstrap-sass', '~> 3.2.0'
s.add_dependency 'dragonfly', '~> 1.0.7'
s.add_dependency 'dragonfly-s3_data_store', '~> 1.0.4'
s.add_dependency 'font-awesome-sass-rails', '~> 3.0.2'
s.add_dependency 'font-awesome-sass', '~> 4.2'
s.add_dependency 'fog', '~> 1.20.0'
s.add_dependency 'formtastic', '~> 2.3.1' # as of writing, formtastic-bootstrap is only compatible with 2.3.x
s.add_dependency 'formtastic-bootstrap', '~> 3.0.0'
Expand All @@ -37,6 +37,7 @@ Gem::Specification.new do |s|
s.add_dependency 'json', '~> 1.8.1'
s.add_dependency 'kaminari', '~> 0.16.1'
s.add_dependency 'liquid', '~> 2.6.1'
s.add_dependency 'sass-rails'
s.add_dependency 'slodown'
s.add_dependency 'rack-cache'

Expand Down

0 comments on commit fbb075a

Please sign in to comment.