diff --git a/app/controllers/smithy/content_pieces_controller.rb b/app/controllers/smithy/content_resources_controller.rb
similarity index 92%
rename from app/controllers/smithy/content_pieces_controller.rb
rename to app/controllers/smithy/content_resources_controller.rb
index 7318ad4..5942766 100644
--- a/app/controllers/smithy/content_pieces_controller.rb
+++ b/app/controllers/smithy/content_resources_controller.rb
@@ -1,6 +1,6 @@
require_dependency "smithy/base_controller"
-class Smithy::ContentPiecesController < Smithy::BaseController
+class Smithy::ContentResourcesController < Smithy::BaseController
before_filter :set_controller_path
respond_to :html, :json
@@ -56,7 +56,7 @@ def destroy
private
def klass
# override to provide an object for each class
- raise "You must inherit from this Smithy::ContentPiecesController and provide a private #klass method"
+ raise "You must inherit from this Smithy::ContentResourcesController and provide a private #klass method"
end
def klass_name
diff --git a/app/views/layouts/smithy/shared/_nav.html.erb b/app/views/layouts/smithy/shared/_nav.html.erb
index 299fc7b..caf8ed9 100644
--- a/app/views/layouts/smithy/shared/_nav.html.erb
+++ b/app/views/layouts/smithy/shared/_nav.html.erb
@@ -14,6 +14,9 @@
- <%= link_to " Manage Content".html_safe, pages_path %>
- <%= link_to " Images & Files".html_safe, assets_path %>
+ <% Smithy::ContentResources::Registry.content_resources.each do |controller_name, title| %>
+ - <%= link_to title, controller_name.to_sym %>
+ <% end %>
- <%= link_to " View Site".html_safe, root_path %>
diff --git a/app/views/smithy/content_pieces/edit.html.erb b/app/views/smithy/content_resources/edit.html.erb
similarity index 100%
rename from app/views/smithy/content_pieces/edit.html.erb
rename to app/views/smithy/content_resources/edit.html.erb
diff --git a/app/views/smithy/content_pieces/index.html.erb b/app/views/smithy/content_resources/index.html.erb
similarity index 100%
rename from app/views/smithy/content_pieces/index.html.erb
rename to app/views/smithy/content_resources/index.html.erb
diff --git a/app/views/smithy/content_pieces/new.html.erb b/app/views/smithy/content_resources/new.html.erb
similarity index 100%
rename from app/views/smithy/content_pieces/new.html.erb
rename to app/views/smithy/content_resources/new.html.erb
diff --git a/lib/smithy.rb b/lib/smithy.rb
index 1f12f1c..9bf3869 100644
--- a/lib/smithy.rb
+++ b/lib/smithy.rb
@@ -9,13 +9,12 @@
require 'smithy/formatter'
#
require 'smithy/content_blocks'
+require 'smithy/content_resources'
module Smithy
-
def self.log(*args)
level = args.size == 1 ? 'info' : args.first
message = args.size == 1 ? args.first : args.last
::Smithy::Logger.send(level.to_sym, message)
end
-
end
diff --git a/lib/smithy/content_pieces/registry.rb b/lib/smithy/content_pieces/registry.rb
deleted file mode 100644
index 76d092e..0000000
--- a/lib/smithy/content_pieces/registry.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require 'active_support/concern'
-
-module Smithy
- module ContentPieces
- class Registry
- @@content_pieces = []
-
- class << self
- def clear
- @@content_pieces = []
- end
-
- def content_pieces
- @@content_pieces
- end
-
- def register(content_piece)
- content_piece = content_piece.to_sym
- return if @@content_pieces.include?(content_piece)
- @@content_pieces << content_piece
- Smithy::Engine.routes.prepend do
- scope '/smithy/content_pieces' do
- resources content_piece
- end
- end
- @@content_pieces
- end
- end
- end
- end
-end
-
-Smithy::Engine.routes.draw do
- namespace :smithy do
- scope "/content_pieces" do
- resources :store_locations
- end
- end
-end
diff --git a/lib/smithy/content_resources.rb b/lib/smithy/content_resources.rb
new file mode 100644
index 0000000..5e489bc
--- /dev/null
+++ b/lib/smithy/content_resources.rb
@@ -0,0 +1,2 @@
+require 'smithy/content_resources/base'
+require 'smithy/content_resources/registry'
diff --git a/lib/smithy/content_pieces/base.rb b/lib/smithy/content_resources/base.rb
similarity index 57%
rename from lib/smithy/content_pieces/base.rb
rename to lib/smithy/content_resources/base.rb
index f40d687..8d239ef 100644
--- a/lib/smithy/content_pieces/base.rb
+++ b/lib/smithy/content_resources/base.rb
@@ -1,9 +1,9 @@
module Smithy
- module ContentPieces
+ module ContentResources
module Base
extend ActiveSupport::Concern
included do
- Smithy::ContentPieces::Registry.register self
+ Smithy::ContentResources::Registry.register self
end
end
end
diff --git a/lib/smithy/content_resources/registry.rb b/lib/smithy/content_resources/registry.rb
new file mode 100644
index 0000000..81c7dd5
--- /dev/null
+++ b/lib/smithy/content_resources/registry.rb
@@ -0,0 +1,31 @@
+require 'active_support/concern'
+
+module Smithy
+ module ContentResources
+ class Registry
+ @@content_resources = []
+
+ class << self
+ def clear
+ @@content_resources = []
+ end
+
+ def content_resources
+ @@content_resources
+ end
+
+ def register(content_resource_model_name, navigation_title=nil)
+ return if @@content_resources.include?(content_resource_model_name)
+ navigation_title ||= content_resource_model_name.to_s.titleize.pluralize
+ @@content_resources << [content_resource_model_name.to_s.tableize, navigation_title]
+ Smithy::Engine.routes.prepend do
+ scope '/smithy/content_resources' do
+ resources content_resource_model_name.to_s.tableize
+ end
+ end
+ @@content_resources
+ end
+ end
+ end
+ end
+end