refinerycms-generators 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/gemspec.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- version = '1.0.1'
2
+ version = '1.0.2'
3
3
  raise "Could not get version so gemspec can not be built" if version.nil?
4
4
  files = Dir.glob("**/*").flatten.reject do |file|
5
5
  file =~ /\.gem$/
@@ -0,0 +1,3 @@
1
+ - case
2
+ - class
3
+ - switch
@@ -10,6 +10,14 @@ class RefineryEngineGenerator < Rails::Generators::NamedBase
10
10
  argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
11
11
 
12
12
  def generate
13
+ clash_file = Pathname.new(File.expand_path('../clash_keywords.yml', __FILE__))
14
+ clash_keywords = File.open(clash_file) { |f| doc = YAML.load(f) }
15
+ if clash_keywords.member?(singular_name.downcase)
16
+ puts "Please choose a different name. Generated code would fail for class '#{singular_name}'"
17
+ puts ""
18
+ exit(1)
19
+ end
20
+
13
21
  if singular_name == plural_name
14
22
  puts ""
15
23
  if singular_name.singularize != singular_name
@@ -70,6 +78,10 @@ class RefineryEngineGenerator < Rails::Generators::NamedBase
70
78
  current_path.open('w+') { |f| f.puts new_contents } unless new_contents.nil?
71
79
  end
72
80
 
81
+ if File.exist?(lib_file = engine_path_for(File.expand_path("../templates/lib/refinerycms-#{engine.pluralize}.rb", __FILE__), engine))
82
+ append_file lib_file, "require File.expand_path('../refinerycms-#{plural_name}', __FILE__)"
83
+ end
84
+
73
85
  tmp_directories.uniq.each{|d| d.rmtree unless d.nil? or !d.exist?}
74
86
  end
75
87
 
@@ -3,7 +3,7 @@ module Admin
3
3
 
4
4
  crudify :<%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? and title.name != 'title' %>,
5
5
  :title_attribute => '<%= title.name %>'<% end %><% if plural_name == singular_name %>,
6
- :redirect_to_url => :admin_<%= singular_name %>_index_url
6
+ :redirect_to_url => :admin_<%= singular_name %>_index_path
7
7
  <% end %>, :xhr_paging => true
8
8
 
9
9
  end
@@ -3,23 +3,23 @@
3
3
  <li>
4
4
  <%%= render :partial => "/shared/admin/search",
5
5
  :locals => {
6
- :url => admin_<%= plural_name %><%= "_index" if plural_name == singular_name%>_url
6
+ :url => admin_<%= plural_name %><%= "_index" if plural_name == singular_name%>_path
7
7
  } %>
8
8
  </li>
9
9
  <%% end %>
10
10
  <li>
11
- <%%= link_to t('.create_new'), new_admin_<%= singular_name %>_url,
11
+ <%%= link_to t('.create_new'), new_admin_<%= singular_name %>_path,
12
12
  :class => "add_icon" %>
13
13
  </li>
14
14
  <%% if !searching? and Admin::<%= class_name.pluralize %>Controller.sortable? and <%= class_name %>.count > 1 %>
15
15
  <li>
16
16
  <%%= link_to t('.reorder', :what => "<%= singular_name.titleize.pluralize %>"),
17
- admin_<%= plural_name %><%= "_index" if plural_name == singular_name%>_url,
17
+ admin_<%= plural_name %><%= "_index" if plural_name == singular_name%>_path,
18
18
  :id => "reorder_action",
19
19
  :class => "reorder_icon" %>
20
20
 
21
21
  <%%= link_to t('.reorder_done', :what => "<%= singular_name.titleize.pluralize %>"),
22
- admin_<%= plural_name %><%= "_index" if plural_name == singular_name%>_url,
22
+ admin_<%= plural_name %><%= "_index" if plural_name == singular_name%>_path,
23
23
  :id => "reorder_action_done",
24
24
  :style => "display: none;",
25
25
  :class => "reorder_icon" %>
@@ -8,7 +8,7 @@
8
8
  :include_object_name => true
9
9
  } %>
10
10
  <% attributes.each_with_index do |attribute, index| %>
11
- <% unless attribute.field_type.to_s == 'text_area' -%>
11
+ <% if attribute.field_type.to_s != 'text_area' -%>
12
12
  <div class='field'>
13
13
  <%%= f.label :<%= attribute.name %> -%>
14
14
  <% end -%>
@@ -44,11 +44,10 @@
44
44
  <%% end %>
45
45
  </div>
46
46
  </div>
47
+ </div>
47
48
  <% generated_text_areas = true -%>
48
49
  <% elsif attribute.field_type.to_s != 'text_area' -%>
49
- <%%= f.<%= attribute.field_type -%> :<%= attribute.name -%><%= ", :class => 'larger widest'" if (index == 0 && attribute.field_type == :text_field) -%> -%>
50
- <% end -%>
51
- <% if attribute.field_type.to_s != 'text_area' -%>
50
+ <%%= f.<%= attribute.field_type -%> :<%= attribute.name -%><%= ", :class => 'larger widest'" if (index == 0 && attribute.field_type == :text_field) -%><%= ", :checked => @#{singular_name}[:#{attribute.name}]" if attribute.field_type == :check_box %> -%>
52
51
  </div>
53
52
  <% end -%>
54
53
  <% end %>
@@ -68,4 +67,4 @@
68
67
  });
69
68
  </script>
70
69
  <%% end %>
71
- <% end -%>
70
+ <% end -%>
@@ -4,7 +4,7 @@
4
4
  <span class="preview">&nbsp;</span>
5
5
  </span>
6
6
  <span class='actions'>
7
- <%%= link_to refinery_icon_tag("application_go.png"), <%= singular_name %>_url(<%= singular_name %>),
7
+ <%%= link_to refinery_icon_tag("application_go.png"), <%= singular_name %>_path(<%= singular_name %>),
8
8
  :title => t('.view_live_html'),
9
9
  :target => "_blank" %>
10
10
  <%%= link_to refinery_icon_tag("application_edit.png"), edit_admin_<%= singular_name %>_path(<%= singular_name %>),
@@ -2,7 +2,7 @@
2
2
  <ul id="<%= plural_name %>">
3
3
  <%% @<%= "all_" if plural_name == singular_name%><%= plural_name %>.each do |<%= singular_name %>| %>
4
4
  <li>
5
- <%%= link_to <%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>.<%= title.name %><% end %>, <%= singular_name %>_url(<%= singular_name %>) %>
5
+ <%%= link_to <%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>.<%= title.name %><% end %>, <%= singular_name %>_path(<%= singular_name %>) %>
6
6
  </li>
7
7
  <%% end %>
8
8
  </ul>
@@ -25,7 +25,7 @@
25
25
  <ul id="<%= plural_name %>">
26
26
  <%% @<%= "all_" if plural_name == singular_name%><%= plural_name %>.each do |<%= singular_name %>| %>
27
27
  <li>
28
- <%%= link_to <%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>.<%= title.name %><% else %>.title<% end %>, <%= singular_name %>_url(<%= singular_name %>) %>
28
+ <%%= link_to <%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>.<%= title.name %><% else %>.title<% end %>, <%= singular_name %>_path(<%= singular_name %>) %>
29
29
  </li>
30
30
  <%% end %>
31
31
  </ul>
@@ -0,0 +1,25 @@
1
+ fr:
2
+ shared:
3
+ admin:
4
+ image_picker:
5
+ image: image
6
+ plugins:
7
+ <%= class_name.pluralize.underscore.downcase %>:
8
+ title: <%= plural_name.titleize %>
9
+ admin:
10
+ <%= plural_name %>:
11
+ actions:
12
+ create_new: Créer un(e) nouve(au/l/lle) <%= singular_name.titleize %>
13
+ reorder: Réordonner les <%= singular_name.titleize.pluralize %>
14
+ reorder_done: Fin de réordonnancement des <%= singular_name.titleize.pluralize %>
15
+ records:
16
+ title: <%= plural_name.titleize %>
17
+ sorry_no_results: "Désolé ! Aucun résultat."
18
+ no_items_yet: 'Il n''y a actuellement aucun(e) <%= singular_name.titleize %>. Cliquer sur "Créer un(e) nouve(au/l/lle) <%= singular_name.titleize %>" pour créer votre premi(er/ère) <%= singular_name.titleize.downcase %>.'
19
+ <%= singular_name %>:
20
+ view_live_html: Voir ce(t/tte) <%= singular_name.titleize.downcase %> <br/><em>(Ouvre une nouvelle fenêtre)</em>
21
+ edit: Modifier ce(t/tte) <%= singular_name.titleize.downcase %>
22
+ delete: Supprimer définitivement ce(t/tte) <%= singular_name.titleize.downcase %>
23
+ <%= plural_name %>:
24
+ show:
25
+ other: Autres <%= singular_name.titleize.pluralize %>
@@ -1,4 +1,4 @@
1
- Refinery::Application.routes.draw do
1
+ ::Refinery::Application.routes.draw do
2
2
  resources :<%= class_name.pluralize.underscore.downcase %>, :only => [:index, :show]
3
3
 
4
4
  scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
@@ -23,9 +23,13 @@ class Create<%= class_name.pluralize %> < ActiveRecord::Migration
23
23
  end
24
24
 
25
25
  def self.down
26
- UserPlugin.destroy_all({:name => "<%= class_name.pluralize.underscore.downcase %>"})
26
+ if defined?(UserPlugin)
27
+ UserPlugin.destroy_all({:name => "<%= class_name.pluralize.underscore.downcase %>"})
28
+ end
27
29
 
28
- Page.delete_all({:link_url => "/<%= plural_name %>"})
30
+ if defined?(Page)
31
+ Page.delete_all({:link_url => "/<%= plural_name %>"})
32
+ end
29
33
 
30
34
  drop_table :<%= table_name %>
31
35
  end
@@ -1,17 +1,21 @@
1
- User.all.each do |user|
2
- if user.plugins.where(:name => '<%= class_name.pluralize.underscore.downcase %>').blank?
3
- user.plugins.create(:name => '<%= class_name.pluralize.underscore.downcase %>',
4
- :position => (user.plugins.maximum(:position) || -1) +1)
1
+ if defined?(User)
2
+ User.all.each do |user|
3
+ if user.plugins.where(:name => '<%= class_name.pluralize.underscore.downcase %>').blank?
4
+ user.plugins.create(:name => '<%= class_name.pluralize.underscore.downcase %>',
5
+ :position => (user.plugins.maximum(:position) || -1) +1)
6
+ end
5
7
  end
6
8
  end
7
9
 
8
- page = Page.create(
9
- :title => '<%= class_name.pluralize.underscore.titleize %>',
10
- :link_url => '/<%= plural_name %>',
11
- :deletable => false,
12
- :position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
13
- :menu_match => '^/<%= plural_name %>(\/|\/.+?|)$'
14
- )
15
- Page.default_parts.each do |default_page_part|
16
- page.parts.create(:title => default_page_part, :body => nil)
17
- end
10
+ if defined?(Page)
11
+ page = Page.create(
12
+ :title => '<%= class_name.pluralize.underscore.titleize %>',
13
+ :link_url => '/<%= plural_name %>',
14
+ :deletable => false,
15
+ :position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
16
+ :menu_match => '^/<%= plural_name %>(\/|\/.+?|)$'
17
+ )
18
+ Page.default_parts.each do |default_page_part|
19
+ page.parts.create(:title => default_page_part, :body => nil)
20
+ end
21
+ end
@@ -12,8 +12,8 @@ module Refinery
12
12
  plugin.name = "<%= class_name.pluralize.underscore.downcase %>"
13
13
  plugin.activity = {
14
14
  :class => <%= class_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? and title.name != 'title' %>,
15
- :title => '<%= title.name %>'
16
- <% end %>}
15
+ :title => '<%= title.name %>'<% end %>
16
+ }
17
17
  end
18
18
  end
19
19
  end
@@ -3,7 +3,7 @@
3
3
  ## How to build this engine as a gem
4
4
 
5
5
  cd vendor/engines/<%= plural_name %>
6
- gem build refinerycms-<%= plural_name %>.gempspec
6
+ gem build refinerycms-<%= plural_name %>.gemspec
7
7
  gem install refinerycms-<%= plural_name %>.gem
8
8
 
9
9
  # Sign up for a http://rubygems.org/ account and publish the gem
data/readme.md CHANGED
@@ -67,7 +67,7 @@ Now you have a fully managed products section in Refinery, nice.
67
67
 
68
68
  If you want to modify your generated engine you need to understand the basic structure of how they work.
69
69
 
70
- See: [The Structure of an Engine](http://github.com/resolve/refinerycms/blob/master/vendor/refinerycms/core/engines.md)
70
+ See: [The Structure of an Engine](https://github.com/resolve/refinerycms/blob/master/doc/engines.md)
71
71
 
72
72
  ## Nesting Engines: Generating Engines Inside Engines
73
73
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{refinerycms-generators}
3
- s.version = %q{1.0.1}
4
- s.date = %q{2011-03-24}
3
+ s.version = %q{1.0.2}
4
+ s.date = %q{2011-06-03}
5
5
  s.summary = %q{Core generators for the Refinery CMS project.}
6
6
  s.description = %q{Core generators for Refinery CMS including refinery_engine.}
7
7
  s.homepage = %q{http://refinerycms.com}
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  'lib/gemspec.rb',
22
22
  'lib/generators',
23
23
  'lib/generators/refinery_engine',
24
+ 'lib/generators/refinery_engine/clash_keywords.yml',
24
25
  'lib/generators/refinery_engine/refinery_engine_generator.rb',
25
26
  'lib/generators/refinery_engine/templates',
26
27
  'lib/generators/refinery_engine/templates/app',
@@ -48,6 +49,7 @@ Gem::Specification.new do |s|
48
49
  'lib/generators/refinery_engine/templates/config',
49
50
  'lib/generators/refinery_engine/templates/config/locales',
50
51
  'lib/generators/refinery_engine/templates/config/locales/en.yml',
52
+ 'lib/generators/refinery_engine/templates/config/locales/fr.yml',
51
53
  'lib/generators/refinery_engine/templates/config/locales/lolcat.yml',
52
54
  'lib/generators/refinery_engine/templates/config/locales/nb.yml',
53
55
  'lib/generators/refinery_engine/templates/config/locales/nl.yml',
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: refinerycms-generators
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.1
5
+ version: 1.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Resolve Digital
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-24 00:00:00 +13:00
13
+ date: 2011-06-03 00:00:00 +12:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -28,6 +28,7 @@ files:
28
28
  - features/step_definitions/generator_steps.rb
29
29
  - features/support/paths.rb
30
30
  - lib/gemspec.rb
31
+ - lib/generators/refinery_engine/clash_keywords.yml
31
32
  - lib/generators/refinery_engine/refinery_engine_generator.rb
32
33
  - lib/generators/refinery_engine/templates/app/controllers/admin/plural_name_controller.rb
33
34
  - lib/generators/refinery_engine/templates/app/controllers/plural_name_controller.rb
@@ -44,6 +45,7 @@ files:
44
45
  - lib/generators/refinery_engine/templates/app/views/plural_name/index.html.erb
45
46
  - lib/generators/refinery_engine/templates/app/views/plural_name/show.html.erb
46
47
  - lib/generators/refinery_engine/templates/config/locales/en.yml
48
+ - lib/generators/refinery_engine/templates/config/locales/fr.yml
47
49
  - lib/generators/refinery_engine/templates/config/locales/lolcat.yml
48
50
  - lib/generators/refinery_engine/templates/config/locales/nb.yml
49
51
  - lib/generators/refinery_engine/templates/config/locales/nl.yml
@@ -90,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
92
  requirements: []
91
93
 
92
94
  rubyforge_project:
93
- rubygems_version: 1.6.1
95
+ rubygems_version: 1.6.2
94
96
  signing_key:
95
97
  specification_version: 3
96
98
  summary: Core generators for the Refinery CMS project.