comfy-admin-constructor 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -18,15 +18,12 @@ Requirements
18
18
 
19
19
  There are plans to make CAC more flexible in the future, but right now it assumes a few things about your CMS install:
20
20
 
21
- * You access CMS at **/admin** and not /cms-admin
22
21
  * You don't store your models in sub-directories
23
- * Your admin controllers and views are stored in **controllers/admin** and **views/admin**, respectively
24
- * Your CMS initializer will need to specify a custom navigation template at **/admin/_navigation**
22
+ * Your CMS initializer specifies a custom navigation template at **/admin/_navigation**
25
23
 
26
- Planned Features
24
+ Upcoming Features
27
25
  ----------------
28
26
 
29
- * More flexibility in where/how things are created
30
27
  * Basic passing tests
31
28
 
32
29
  Quick Start Guide
@@ -61,6 +58,7 @@ CAC will automatically generate a bunch of files for us:
61
58
 
62
59
  So, what happened there?
63
60
 
61
+ * CAC checked which admin_prefix we are using in CMS. (Defaults to **cms-admin**)
64
62
  * The EventListing model was generated
65
63
  * A migration was generated to create the necessary table for our database (Note: Migrations are **never** run automatically. That's on you.)
66
64
  * A controller, complete with ActiveRecord rescues, success/failure flash messages, and more.
@@ -1,7 +1,7 @@
1
1
  module Comfy
2
2
  module Admin
3
3
  module Constructor
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
6
6
  end
7
7
  end
@@ -33,21 +33,21 @@ class CmsAdminGenerator < Rails::Generators::Base
33
33
  end
34
34
 
35
35
  def create_controller
36
- template 'controller.rb', "app/controllers/admin/#{plural_name}_controller.rb"
36
+ template 'controller.rb', "app/controllers/#{admin_prefix}/#{plural_name}_controller.rb"
37
37
  end
38
38
 
39
39
  def create_form
40
- template "views/_form#{template_file_type}", "app/views/admin/#{plural_name}/_form#{template_file_type}"
40
+ template "views/_form#{template_file_type}", "app/views/#{admin_prefix}/#{plural_name}/_form#{template_file_type}"
41
41
  end
42
42
 
43
43
  def create_views
44
44
  %w[edit index new].each do |action|
45
- template "views/#{action}#{template_file_type}", "app/views/admin/#{plural_name}/#{action}#{template_file_type}"
45
+ template "views/#{action}#{template_file_type}", "app/views/#{admin_prefix}/#{plural_name}/#{action}#{template_file_type}"
46
46
  end
47
47
  end
48
48
 
49
49
  def create_route
50
- namespaces = ["admin", class_name.underscore.downcase.pluralize]
50
+ namespaces = [admin_prefix, class_name.underscore.downcase.pluralize]
51
51
  resource = namespaces.pop
52
52
  route namespaces.reverse.inject("resources :#{resource}, :except => [:show]") { |acc, namespace|
53
53
  "namespace(:#{namespace}){ #{acc} }"
@@ -55,21 +55,21 @@ class CmsAdminGenerator < Rails::Generators::Base
55
55
  end
56
56
 
57
57
  def create_nav_template_if_needed
58
- if !File.exist? destination_path("app/views/admin/_navigation#{template_file_type}")
59
- template "partials/_navigation#{template_file_type}", "app/views/admin/_navigation#{template_file_type}"
58
+ if !File.exist? destination_path("app/views/#{admin_prefix}/_navigation#{template_file_type}")
59
+ template "partials/_navigation#{template_file_type}", "app/views/#{admin_prefix}/_navigation#{template_file_type}"
60
60
  end
61
61
  end
62
62
 
63
63
  def append_to_nav_template
64
64
  if haml_present?
65
- append = "\n%li= link_to '#{class_name.underscore.humanize.downcase.titleize.pluralize}', admin_#{class_name.underscore.downcase.pluralize}_path\n"
65
+ append = "\n%li= link_to '#{class_name.underscore.humanize.downcase.titleize.pluralize}', #{admin_prefix}_#{class_name.underscore.downcase.pluralize}_path\n"
66
66
  else
67
- append = "\n<li><%= link_to '#{class_name.underscore.humanize.downcase.titleize.pluralize}', admin_#{class_name.underscore.downcase.pluralize}_path %></li>"
67
+ append = "\n<li><%= link_to '#{class_name.underscore.humanize.downcase.titleize.pluralize}', ${admin_prefix}_#{class_name.underscore.downcase.pluralize}_path %></li>"
68
68
  end
69
- File.open(destination_path("app/views/admin/_navigation#{template_file_type}"), "a") {|f| f.write(append)}
69
+ File.open(destination_path("app/views/#{admin_prefix}/_navigation#{template_file_type}"), "a") {|f| f.write(append)}
70
70
  end
71
71
 
72
- private
72
+ private
73
73
 
74
74
  def model_path
75
75
  model_name.underscore
@@ -91,8 +91,6 @@ class CmsAdminGenerator < Rails::Generators::Base
91
91
  model_attributes.inspect
92
92
  end
93
93
 
94
- # FIXME: Should be proxied to ActiveRecord::Generators::Base
95
- # Implement the required interface for Rails::Generators::Migration.
96
94
  def self.next_migration_number(dirname) #:nodoc:
97
95
  if ActiveRecord::Base.timestamped_migrations
98
96
  Time.now.utc.strftime("%Y%m%d%H%M%S")
@@ -137,4 +135,8 @@ class CmsAdminGenerator < Rails::Generators::Base
137
135
  end
138
136
  end
139
137
 
138
+ def admin_prefix
139
+ ComfortableMexicanSofa.config.admin_route_prefix
140
+ end
141
+
140
142
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comfy-admin-constructor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-26 00:00:00.000000000 Z
12
+ date: 2012-07-27 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ComfyAdminConstructor allows you to quickly and easily build basic admin
15
15
  interfaces in ComfortableMexicanSofa.