comfy-admin-constructor 0.1.19 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -19,10 +19,9 @@ Requirements
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
21
  * You access CMS at **/admin** and not /cms-admin
22
- * You use HAML and SASS
23
22
  * You don't store your models in sub-directories
24
23
  * Your admin controllers and views are stored in **controllers/admin** and **views/admin**, respectively
25
- * Your CMS initializer will need to specify a custom navigation template at **views/admin/_navigation.html.haml***
24
+ * Your CMS initializer will need to specify a custom navigation template at **/admin/_navigation**
26
25
 
27
26
  Planned Features
28
27
  ----------------
@@ -62,10 +61,10 @@ CAC will automatically generate a bunch of files for us:
62
61
 
63
62
  So, what happened there?
64
63
 
65
- * The EventListing model was generated, with basic **:presence => :true** validation for all attributes
64
+ * The EventListing model was generated
66
65
  * A migration was generated to create the necessary table for our database (Note: Migrations are **never** run automatically. That's on you.)
67
66
  * A controller, complete with ActiveRecord rescues, success/failure flash messages, and more.
68
- * Views for all the operations we'll need, along with a form.
67
+ * Views for all the operations we'll need, along with a form. (Uses HAML if available, ERB if not)
69
68
  * Added a new route
70
69
  * Appended a new link to the navigation template
71
70
 
@@ -73,5 +72,6 @@ That's it! CAC gives you all the basics. If you need to do something a little mo
73
72
 
74
73
  ---
75
74
 
76
- ComfortableMexicanSofa is released under the [MIT license](https://github.com/bgilham/comfy-admin-constructor/blob/master/LICENSE)
75
+ ComfyAdminConstructor is released under the [MIT license](https://github.com/bgilham/comfy-admin-constructor/blob/master/LICENSE)
76
+
77
77
  Copyright 2012 Brian Gilham, [The Working Group Inc](http://www.twg.ca)
@@ -1,7 +1,7 @@
1
1
  module Comfy
2
2
  module Admin
3
3
  module Constructor
4
- VERSION = "0.1.19"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
7
7
  end
@@ -37,12 +37,12 @@ class CmsAdminGenerator < Rails::Generators::Base
37
37
  end
38
38
 
39
39
  def create_form
40
- template "views/_form.html.haml", "app/views/admin/#{plural_name}/_form.html.haml"
40
+ template "views/_form#{template_file_type}", "app/views/admin/#{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}.html.haml", "app/views/admin/#{plural_name}/#{action}.html.haml"
45
+ template "views/#{action}#{template_file_type}", "app/views/admin/#{plural_name}/#{action}#{template_file_type}"
46
46
  end
47
47
  end
48
48
 
@@ -55,13 +55,18 @@ 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.html.haml")
59
- template "partials/_navigation.html.haml", "app/views/admin/_navigation.html.haml"
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}"
60
60
  end
61
61
  end
62
62
 
63
63
  def append_to_nav_template
64
- File.open(destination_path("app/views/admin/_navigation.html.haml"), "a") {|f| f.write("\n%li= link_to '#{class_name.underscore.humanize.downcase.titleize.pluralize}', admin_#{class_name.underscore.downcase.pluralize}_path\n")}
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"
66
+ else
67
+ append = "\n<li><%= link_to '#{class_name.underscore.humanize.downcase.titleize.pluralize}', admin_#{class_name.underscore.downcase.pluralize}_path %></li>"
68
+ end
69
+ File.open(destination_path("app/views/admin/_navigation#{template_file_type}"), "a") {|f| f.write(append)}
65
70
  end
66
71
 
67
72
  private
@@ -120,4 +125,16 @@ class CmsAdminGenerator < Rails::Generators::Base
120
125
  File.join(destination_root, path)
121
126
  end
122
127
 
128
+ def haml_present?
129
+ defined?(Haml)
130
+ end
131
+
132
+ def template_file_type
133
+ if haml_present?
134
+ ".html.haml"
135
+ else
136
+ ".html.erb"
137
+ end
138
+ end
139
+
123
140
  end
@@ -12,9 +12,6 @@ class <%= class_name %> < ActiveRecord::Base
12
12
 
13
13
  # == Validations ==========================================================
14
14
 
15
- validates <%= model_attributes.map { |a| ":#{a.name}" }.join(", ") %>,
16
- :presence => true
17
-
18
15
  # == Scopes ===============================================================
19
16
 
20
17
  # == Callbacks ============================================================
@@ -0,0 +1,7 @@
1
+ <%- for attribute in model_attributes -%>
2
+ <%%= form.<%= attribute.field_type %> :<%= attribute.name %>%>
3
+ <%- end -%>
4
+
5
+ <%%= form.simple_field(nil, nil, :class => 'submit_element') do %>
6
+ <%%= form.submit @<%= class_name.underscore.downcase %>.new_record? ? 'create' : 'update', :disable_builder => true %>
7
+ <%%- end %>
@@ -0,0 +1,5 @@
1
+ <h1>Edit <%= class_name.underscore.humanize.downcase.titleize %></h1>
2
+
3
+ <%%= comfy_form_for(@<%= class_name.underscore.downcase %>, :as => :<%= class_name.underscore.downcase %>, :url => { :action => :update }) do |form| %>
4
+ <%%= render(:partial => 'form', :object => form) %>
5
+ <%%- end %>
@@ -0,0 +1,30 @@
1
+ <%%= link_to "New <%= class_name.underscore.humanize.downcase.titleize %>", new_admin_<%= class_name.underscore.downcase %>_path, :class => 'big button' %>
2
+
3
+ <h1><%= class_name.underscore.humanize.downcase.titleize.pluralize %></h1>
4
+
5
+ <ul class="list">
6
+ <%%- if @<%= class_name.underscore.downcase.pluralize %>.empty? %>
7
+ <li>
8
+ <div class="item">
9
+ <div class="sublabel">
10
+ No <%= class_name.underscore.humanize.downcase.titleize.pluralize %> Found
11
+ </div>
12
+ </div>
13
+ </li>
14
+ <%%- else %>
15
+ <%%- @<%= class_name.underscore.downcase.pluralize %>.each do |<%= class_name.underscore.downcase %>| %>
16
+ <li>
17
+ <div class="item">
18
+ <div class="icon"></div>
19
+ <div class="action_links">
20
+ <%%= link_to "Edit", edit_admin_<%= class_name.underscore.downcase %>_path(<%= class_name.underscore.downcase %>) %>
21
+ <%%= link_to "Delete", admin_<%= class_name.underscore.downcase %>_path(<%= class_name.underscore.downcase %>), :method => :delete, :data => { :confirm => 'Are you sure?' } %>
22
+ </div>
23
+ <div class="label">
24
+ <%%= <%= class_name.underscore.downcase %>.<%= model_attributes.first.name %> %>
25
+ </div>
26
+ </div>
27
+ </li>
28
+ <%%- end %>
29
+ <%%- end %>
30
+ </ul>
@@ -0,0 +1,5 @@
1
+ <h1>New <%= class_name.underscore.humanize.downcase.titleize.pluralize %></h1>
2
+
3
+ <%%= comfy_form_for(@<%= class_name.underscore.downcase %>, :as => :<%= class_name.underscore.downcase %>, :url => {:action => :create}) do |form| %>
4
+ <%%= render :partial => "form", :object => form %>
5
+ <%%- 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.1.19
4
+ version: 0.2.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-21 00:00:00.000000000Z
12
+ date: 2012-07-26 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.
@@ -39,12 +39,17 @@ files:
39
39
  - lib/generators/cms_admin/templates/controller.rb
40
40
  - lib/generators/cms_admin/templates/migration.rb
41
41
  - lib/generators/cms_admin/templates/model.rb
42
+ - lib/generators/cms_admin/templates/partials/_navigation.html.erb
42
43
  - lib/generators/cms_admin/templates/partials/_navigation.html.haml
43
44
  - lib/generators/cms_admin/templates/protected/build.rb
44
45
  - lib/generators/cms_admin/templates/protected/load.rb
46
+ - lib/generators/cms_admin/templates/views/_form.html.erb
45
47
  - lib/generators/cms_admin/templates/views/_form.html.haml
48
+ - lib/generators/cms_admin/templates/views/edit.html.erb
46
49
  - lib/generators/cms_admin/templates/views/edit.html.haml
50
+ - lib/generators/cms_admin/templates/views/index.html.erb
47
51
  - lib/generators/cms_admin/templates/views/index.html.haml
52
+ - lib/generators/cms_admin/templates/views/new.html.erb
48
53
  - lib/generators/cms_admin/templates/views/new.html.haml
49
54
  homepage: https://github.com/bgilham/comfy-admin-constructor
50
55
  licenses: []
@@ -66,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
71
  version: '0'
67
72
  requirements: []
68
73
  rubyforge_project:
69
- rubygems_version: 1.8.17
74
+ rubygems_version: 1.8.24
70
75
  signing_key:
71
76
  specification_version: 3
72
77
  summary: Comfy Admin Constructor - Create CMS admin sections in one line