redde 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. data/.gitignore +20 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +4 -0
  4. data/Guardfile +24 -0
  5. data/LICENSE +22 -0
  6. data/README.md +57 -0
  7. data/Rakefile +2 -0
  8. data/lib/generators/redde/deploy/deploy_generator.rb +34 -0
  9. data/lib/generators/redde/deploy/templates/Capfile +4 -0
  10. data/lib/generators/redde/deploy/templates/deploy.rb +33 -0
  11. data/lib/generators/redde/deploy/templates/recipes/base.rb +16 -0
  12. data/lib/generators/redde/deploy/templates/recipes/check.rb +13 -0
  13. data/lib/generators/redde/deploy/templates/recipes/database.rb +66 -0
  14. data/lib/generators/redde/deploy/templates/recipes/imagemagick.rb +8 -0
  15. data/lib/generators/redde/deploy/templates/recipes/memcached.rb +10 -0
  16. data/lib/generators/redde/deploy/templates/recipes/monit.rb +35 -0
  17. data/lib/generators/redde/deploy/templates/recipes/nginx.rb +26 -0
  18. data/lib/generators/redde/deploy/templates/recipes/nodejs.rb +10 -0
  19. data/lib/generators/redde/deploy/templates/recipes/postfix.rb +37 -0
  20. data/lib/generators/redde/deploy/templates/recipes/rbenv.rb +17 -0
  21. data/lib/generators/redde/deploy/templates/recipes/templates/database.yml.erb +8 -0
  22. data/lib/generators/redde/deploy/templates/recipes/templates/dkim-filter.conf.erb +57 -0
  23. data/lib/generators/redde/deploy/templates/recipes/templates/dkim-filter.defaults.erb +11 -0
  24. data/lib/generators/redde/deploy/templates/recipes/templates/dkim-keys.conf.erb +2 -0
  25. data/lib/generators/redde/deploy/templates/recipes/templates/gemrc.erb +1 -0
  26. data/lib/generators/redde/deploy/templates/recipes/templates/main.cf.erb +43 -0
  27. data/lib/generators/redde/deploy/templates/recipes/templates/memcached.erb +47 -0
  28. data/lib/generators/redde/deploy/templates/recipes/templates/monit_monitrc.erb +21 -0
  29. data/lib/generators/redde/deploy/templates/recipes/templates/monit_nginx.erb +5 -0
  30. data/lib/generators/redde/deploy/templates/recipes/templates/monit_unicorn.erb +14 -0
  31. data/lib/generators/redde/deploy/templates/recipes/templates/nginx_unicorn.erb +28 -0
  32. data/lib/generators/redde/deploy/templates/recipes/templates/unicorn.rb.erb +36 -0
  33. data/lib/generators/redde/deploy/templates/recipes/templates/unicorn_init.erb +84 -0
  34. data/lib/generators/redde/deploy/templates/recipes/unicorn.rb +27 -0
  35. data/lib/generators/redde/layout/layout_generator.rb +57 -0
  36. data/lib/generators/redde/layout/templates/assets/images/admin/addphoto.png +0 -0
  37. data/lib/generators/redde/layout/templates/assets/images/admin/ajaxloader2.gif +0 -0
  38. data/lib/generators/redde/layout/templates/assets/images/admin/arrow_down.png +0 -0
  39. data/lib/generators/redde/layout/templates/assets/images/admin/arrow_enter.png +0 -0
  40. data/lib/generators/redde/layout/templates/assets/images/admin/arrow_right.png +0 -0
  41. data/lib/generators/redde/layout/templates/assets/images/admin/coins.png +0 -0
  42. data/lib/generators/redde/layout/templates/assets/images/admin/confirm.png +0 -0
  43. data/lib/generators/redde/layout/templates/assets/images/admin/del.png +0 -0
  44. data/lib/generators/redde/layout/templates/assets/images/admin/delete.png +0 -0
  45. data/lib/generators/redde/layout/templates/assets/images/admin/email.png +0 -0
  46. data/lib/generators/redde/layout/templates/assets/images/admin/error.png +0 -0
  47. data/lib/generators/redde/layout/templates/assets/images/admin/fio.png +0 -0
  48. data/lib/generators/redde/layout/templates/assets/images/admin/folder.png +0 -0
  49. data/lib/generators/redde/layout/templates/assets/images/admin/folder_.png +0 -0
  50. data/lib/generators/redde/layout/templates/assets/images/admin/icon_eye.gif +0 -0
  51. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/css/jquery.lightbox-0.5.css +101 -0
  52. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/images/lightbox-blank.gif +0 -0
  53. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/images/lightbox-btn-close.gif +0 -0
  54. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/images/lightbox-btn-next.gif +0 -0
  55. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/images/lightbox-btn-prev.gif +0 -0
  56. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/images/lightbox-ico-loading.gif +0 -0
  57. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/js/jquery.js +32 -0
  58. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/js/jquery.lightbox-0.5.js +477 -0
  59. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/js/jquery.lightbox-0.5.min.js +42 -0
  60. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/js/jquery.lightbox-0.5.pack.js +14 -0
  61. data/lib/generators/redde/layout/templates/assets/images/admin/logo.png +0 -0
  62. data/lib/generators/redde/layout/templates/assets/images/admin/logo_reddeshop.png +0 -0
  63. data/lib/generators/redde/layout/templates/assets/images/admin/move_handler.png +0 -0
  64. data/lib/generators/redde/layout/templates/assets/images/admin/phone.png +0 -0
  65. data/lib/generators/redde/layout/templates/assets/images/admin/photo_ico.png +0 -0
  66. data/lib/generators/redde/layout/templates/assets/images/admin/print.png +0 -0
  67. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/css/docstyle.css +123 -0
  68. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/css/redactor.css +369 -0
  69. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/css/style.css +119 -0
  70. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/css/wym.css +136 -0
  71. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/img/icons.png +0 -0
  72. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/by.js +72 -0
  73. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/de.js +75 -0
  74. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/en.js +76 -0
  75. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/es.js +76 -0
  76. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/fr.js +74 -0
  77. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/hu.js +76 -0
  78. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/it.js +76 -0
  79. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/ja.js +76 -0
  80. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/lv.js +74 -0
  81. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/nl.js +76 -0
  82. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/pl.js +75 -0
  83. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/pt_br.js +81 -0
  84. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/ru.js +75 -0
  85. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/sq.js +76 -0
  86. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/tr.js +76 -0
  87. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/ua.js +75 -0
  88. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/zh_cn.js +77 -0
  89. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/plugins/file.html +3 -0
  90. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/plugins/image.html +39 -0
  91. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/plugins/image_edit.html +35 -0
  92. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/plugins/link.html +74 -0
  93. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/plugins/table.html +25 -0
  94. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/plugins/video.html +15 -0
  95. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/redactor.js.erb +2260 -0
  96. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/redactor.min.js +1 -0
  97. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/toolbars/default.js +219 -0
  98. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/toolbars/mini.js +103 -0
  99. data/lib/generators/redde/layout/templates/assets/images/admin/reddebox/_jquery.reddebox.js.erb +214 -0
  100. data/lib/generators/redde/layout/templates/assets/images/admin/reddebox/close.png +0 -0
  101. data/lib/generators/redde/layout/templates/assets/images/admin/reddebox/jquery.reddebox.js.erb +246 -0
  102. data/lib/generators/redde/layout/templates/assets/images/admin/reddebox/jquery.reddebox.scss +31 -0
  103. data/lib/generators/redde/layout/templates/assets/images/admin/reddebox/next.png +0 -0
  104. data/lib/generators/redde/layout/templates/assets/images/admin/reddebox/prev.png +0 -0
  105. data/lib/generators/redde/layout/templates/assets/images/admin/refresh.png +0 -0
  106. data/lib/generators/redde/layout/templates/assets/images/admin/submit.png +0 -0
  107. data/lib/generators/redde/layout/templates/assets/images/admin/submit_hover.png +0 -0
  108. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/change-log.txt +19 -0
  109. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/check-exists.php +15 -0
  110. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/index.php +50 -0
  111. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/jquery.uploadifive.js +888 -0
  112. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/jquery.uploadifive.min.js +6 -0
  113. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/license-standard.txt +71 -0
  114. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/uploadifive-cancel.png +0 -0
  115. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/uploadifive-image-only.php +66 -0
  116. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/uploadifive.css +100 -0
  117. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/uploadifive.php +33 -0
  118. data/lib/generators/redde/layout/templates/assets/images/admin/uploadify/#swfobject.js +4 -0
  119. data/lib/generators/redde/layout/templates/assets/images/admin/uploadify/cancel.png +0 -0
  120. data/lib/generators/redde/layout/templates/assets/images/admin/uploadify/jquery.uploadify.min.js +315 -0
  121. data/lib/generators/redde/layout/templates/assets/images/admin/uploadify/uploadify-cancel.png +0 -0
  122. data/lib/generators/redde/layout/templates/assets/images/admin/uploadify/uploadify.css +66 -0
  123. data/lib/generators/redde/layout/templates/assets/images/admin/uploadify/uploadify.swf +0 -0
  124. data/lib/generators/redde/layout/templates/assets/images/admin/view.png +0 -0
  125. data/lib/generators/redde/layout/templates/assets/images/admin/view_mk.png +0 -0
  126. data/lib/generators/redde/layout/templates/assets/javascripts/admin/jquery.ui.nestedSortable.js +390 -0
  127. data/lib/generators/redde/layout/templates/assets/javascripts/admin/swfobject.js +4 -0
  128. data/lib/generators/redde/layout/templates/assets/javascripts/admin/zen_textarea.min.js +17 -0
  129. data/lib/generators/redde/layout/templates/assets/javascripts/admin.js +88 -0
  130. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/_reset.scss +32 -0
  131. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/blocks/_list.scss +22 -0
  132. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/blocks/_notice.scss +39 -0
  133. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/blocks/_orders.scss +22 -0
  134. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/blocks/_partners.scss +15 -0
  135. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/blocks/_photos.scss +31 -0
  136. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/blocks/_sortable.scss +17 -0
  137. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/default.scss +127 -0
  138. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/defaults/_input.scss +43 -0
  139. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/defaults/_table.scss +24 -0
  140. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/layouts/_header.scss +57 -0
  141. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/layouts/_launchbar.scss +35 -0
  142. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/layouts/_login.scss +10 -0
  143. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/layouts/_main.scss +59 -0
  144. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/layouts/_sidebar.scss +35 -0
  145. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/shop/_filter.scss +16 -0
  146. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/shop/_order-sh.scss +59 -0
  147. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/shop/_pe.scss +43 -0
  148. data/lib/generators/redde/layout/templates/assets/stylesheets/admin.scss +12 -0
  149. data/lib/generators/redde/layout/templates/controllers/base_controller.rb +6 -0
  150. data/lib/generators/redde/layout/templates/helpers/admin_helper.rb +37 -0
  151. data/lib/generators/redde/layout/templates/layouts/admin.html.haml +30 -0
  152. data/lib/generators/redde/layout/templates/layouts/login.html.haml +32 -0
  153. data/lib/generators/redde/layout/templates/shared/_header.html.haml +13 -0
  154. data/lib/generators/redde/layout/templates/shared/_launchbar.html.haml +9 -0
  155. data/lib/generators/redde/layout/templates/shared/_sidebar.html.haml +23 -0
  156. data/lib/generators/redde/scaffold/scaffold_generator.rb +114 -0
  157. data/lib/generators/redde/scaffold/templates/controllers/controller.rb +55 -0
  158. data/lib/generators/redde/scaffold/templates/edit.html.haml +36 -0
  159. data/lib/generators/redde/scaffold/templates/index.html.haml +37 -0
  160. data/lib/redde/version.rb +3 -0
  161. data/lib/redde.rb +4 -0
  162. data/redde.gemspec +26 -0
  163. data/spec/deploy_generator_spec.rb +29 -0
  164. data/spec/layout_generator_spec.rb +41 -0
  165. data/spec/scaffold_generator_spec.rb +25 -0
  166. data/spec/spec_helper.rb +10 -0
  167. metadata +327 -0
@@ -0,0 +1,23 @@
1
+ - a = controller.controller_name
2
+ %ul#nav
3
+ -case @active
4
+ -when :shop then
5
+ %li{:class => "#{'active' if a == 'products'}"}= link_to "Товары", admin_products_path
6
+ %li{:class => "#{'active' if a == 'categories'}"}= link_to "Категории", admin_categories_path
7
+ %li{:class => "#{'active' if a == 'countries'}"}= link_to "Страны", admin_countries_path
8
+ %li{:class => "#{'active' if a == 'regions'}"}= link_to "Регионы", admin_regions_path
9
+ %li{:class => "#{'active' if a == 'brands'}"}= link_to "Производители", [:admin, :brands]
10
+ %li{:class => "#{'active' if a == 'sliders' && params[:slider_block] == "1"}"}= link_to "Слайдер", admin_sliders_path(slider_block: 1)
11
+ %li{:class => "#{'active' if a == 'sliders' && params[:slider_block] == "3"}"}= link_to "Баннеры (маленькие)", admin_sliders_path(slider_block: 3)
12
+ %li{:class => "#{'active' if a == 'orders'}"}= link_to "Заказы", [:admin, :orders]
13
+
14
+
15
+ -when :materials then
16
+ %li{:class => "#{'active' if a == 'articles'}"}= link_to "Статьи", [:admin, :articles]
17
+ %li{:class => "#{'active' if a == 'categories'}"}= link_to "Категории", [:admin, :categories]
18
+ %li{:class => "#{'active' if a == 'works'}"}= link_to "Портфолио", [:admin, :works]
19
+
20
+
21
+
22
+ -when :system
23
+ %li{:class => "#{'active' if a == 'users'}"}= link_to "Пользователи", admin_users_path
@@ -0,0 +1,114 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/generated_attribute'
3
+
4
+ module Redde
5
+ module Generators
6
+ class ScaffoldGenerator < ::Rails::Generators::Base
7
+ source_root File.expand_path('../templates', __FILE__)
8
+ argument :controller_path, :type => :string
9
+ argument :model_name, :type => :string, :required => false
10
+ argument :layout, :type => :string, :default => "application",
11
+ :banner => "Specify application layout"
12
+
13
+ def initialize(args, *options)
14
+ super(args, *options)
15
+ initialize_views_variables
16
+ end
17
+
18
+ def copy_views
19
+ generate_views
20
+ end
21
+
22
+ protected
23
+
24
+ def initialize_views_variables
25
+ @base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(controller_path)
26
+ @controller_routing_path = @controller_file_path.gsub(/\//, '_')
27
+ @model_name = @controller_class_nesting + "::#{@base_name.singularize.camelize}" unless @model_name
28
+ @model_name = @model_name.camelize
29
+ end
30
+
31
+ def controller_routing_path
32
+ @controller_routing_path
33
+ end
34
+
35
+ def singular_controller_routing_path
36
+ @controller_routing_path.singularize
37
+ end
38
+
39
+ def model_name
40
+ @model_name
41
+ end
42
+
43
+ def plural_model_name
44
+ @model_name.pluralize
45
+ end
46
+
47
+ def resource_name
48
+ @model_name.demodulize.underscore
49
+ end
50
+
51
+ def plural_resource_name
52
+ resource_name.pluralize
53
+ end
54
+
55
+ def sort_priority(column_name)
56
+ case column_name
57
+ when "position" then 1
58
+ when "visible" then 2
59
+ when "name" then 3
60
+ when "title" then 3
61
+ else 5
62
+ end
63
+ end
64
+
65
+ def columns
66
+ begin
67
+ excluded_column_names = %w[id created_at updated_at]
68
+ @model_name.constantize.columns.reject{|c| excluded_column_names.include?(c.name) || c.name.index("_id") }.sort{|a, b| sort_priority(a.name) <=> sort_priority(b.name)}.collect{|c| ::Rails::Generators::GeneratedAttribute.new(c.name, c.type)}
69
+ rescue NoMethodError
70
+ @model_name.constantize.fields.collect{|c| c[1]}.reject{|c| excluded_column_names.include?(c.name) || c.name.index("_id") }.collect{|c| ::Rails::Generators::GeneratedAttribute.new(c.name, c.type.to_s)}
71
+ end
72
+ end
73
+
74
+ def column_names
75
+ @model_name.constantize.column_names
76
+ end
77
+
78
+ def extract_modules(name)
79
+ modules = name.include?('/') ? name.split('/') : name.split('::')
80
+ name = modules.pop
81
+ path = modules.map { |m| m.underscore }
82
+ file_path = (path + [name.underscore]).join('/')
83
+ nesting = modules.map { |m| m.camelize }.join('::')
84
+ [name, path, file_path, nesting, modules.size]
85
+ end
86
+
87
+ def generate_views
88
+ views = {
89
+ "index.html.#{ext}" => "app/views/admin/#{@controller_file_path}/index.html.#{ext}",
90
+ "edit.html.#{ext}" => "app/views/admin/#{@controller_file_path}/edit.html.#{ext}"
91
+ }
92
+ selected_views = views
93
+ options.engine == generate_erb(selected_views)
94
+ end
95
+
96
+
97
+ def generate_erb(views)
98
+ views.each do |template_name, output_path|
99
+ template template_name, output_path
100
+ end
101
+ generate_controller
102
+ end
103
+
104
+ def ext
105
+ :haml
106
+ end
107
+
108
+ def generate_controller
109
+ template "controllers/controller.rb", "app/controllers/admin/#{plural_resource_name}_controller.rb"
110
+ end
111
+
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,55 @@
1
+ # coding: utf-8
2
+ class Admin::<%= plural_resource_name.capitalize -%>Controller < Admin::BaseController
3
+
4
+ def index
5
+ @<%= plural_resource_name %> = <%= model_name.demodulize -%>.all
6
+ end
7
+ <%- if column_names.include?("position") -%>
8
+ def sort
9
+ params[:pos].each_with_index do |id, idx|
10
+ p = <%= model_name.demodulize -%>.find(id)
11
+ p.position = idx
12
+ p.save
13
+ end
14
+ render :nothing => true
15
+ end
16
+ <%- end -%>
17
+ def new
18
+ @<%= resource_name %> = <%= model_name.demodulize -%>.new
19
+ render 'edit'
20
+ end
21
+
22
+ def edit
23
+ @<%= resource_name %> = <%= model_name.demodulize -%>.find(params[:id])
24
+ end
25
+
26
+ def create
27
+ @<%= resource_name %> = <%= model_name.demodulize -%>.new(<%= resource_name %>_params)
28
+ if @<%= resource_name %>.save
29
+ redirect_to params[:commit] == "Применить" ? [:edit, :admin, @<%= resource_name %>] : [:admin, :<%= plural_resource_name %>], :notice => "#{<%= model_name.demodulize -%>.model_name.human} добавлен."
30
+ else
31
+ render 'edit'
32
+ end
33
+ end
34
+
35
+ def update
36
+ @<%= resource_name %> = <%= model_name.demodulize -%>.find(params[:id])
37
+ if @<%= resource_name %>.update_attributes(<%= resource_name %>_params)
38
+ redirect_to params[:commit] == "Применить" ? [:edit, :admin, @<%= resource_name %>] : [:admin, :<%= plural_resource_name %>], :notice => "#{<%= model_name.demodulize -%>.model_name.human} отредактирован."
39
+ else
40
+ render 'edit'
41
+ end
42
+ end
43
+
44
+ def destroy
45
+ @<%= resource_name %> = <%= model_name.demodulize -%>.find(params[:id])
46
+ @<%= resource_name %>.destroy
47
+ redirect_to admin_<%= plural_resource_name %>_path, :notice => "#{<%= model_name.demodulize -%>.model_name.human} удален."
48
+ end
49
+
50
+ private
51
+ def <%= resource_name %>_params
52
+ params.require(:<%= resource_name %>).permit(<%= column_names.select {|c| !(['id', 'updated_at', 'created_at'].include? c) }.map {|c| ":#{c}"}.join(', ') %>)
53
+ end
54
+
55
+ end
@@ -0,0 +1,36 @@
1
+ - content_for :page_header do
2
+ %h1
3
+ - if @<%= resource_name %>.new_record?
4
+ Добавить #{tgenetive(:<%= resource_name %>)}
5
+ - else
6
+ Редактировать #{tgenetive(:<%= resource_name %>)}
7
+
8
+ = form_for [:admin, @<%= resource_name %>] do |f|
9
+ - if @<%= resource_name %>.errors.any?
10
+ #error_explanation
11
+ %h2= "Ошибки при сохранении: #{@<%= resource_name %>.errors.count}"
12
+ %ul
13
+ - @<%= resource_name %>.errors.full_messages.each do |msg|
14
+ %li= msg
15
+ %table
16
+ <%- columns.each do |column| -%>
17
+ <%- if column.field_type.to_s == "text_area" -%>
18
+ %tr
19
+ %td{colspan: 2}
20
+ = f.label :<%= column.name %>
21
+ %br
22
+ = f.<%= column.field_type -%> :<%= column.name %>
23
+ <%- elsif column.field_type.to_s == "check_box" -%>
24
+ %tr
25
+ %th{colspan: 2}
26
+ = f.<%= column.field_type -%> :<%= column.name %>
27
+ = f.label :<%= column.name %>
28
+ <%- elsif column.name != "position" -%>
29
+ %tr
30
+ %th= f.label :<%= column.name %>
31
+ %td= f.<%= column.field_type -%> :<%= column.name %>
32
+ <%- end -%>
33
+ <%- end -%>
34
+ .actions
35
+ = f.submit "Сохранить"
36
+ = f.submit "Применить"
@@ -0,0 +1,37 @@
1
+ - content_for(:page_header) do
2
+ %h1= tplural(<%= resource_name.capitalize %>)
3
+ %p= link_to "Добавить #{tgenetive('<%= resource_name %>')}", [:new, :admin, :<%= resource_name %>]
4
+
5
+ - unless @<%= plural_resource_name %>.empty?
6
+ %table.list<%= ".sortable" if column_names.include?("position") %>
7
+ %colgroup
8
+ <%- columns.each do |column| -%>
9
+ %col<%= ".w1" if ["position", "visible"].include? column.name %>
10
+ <%- end -%>
11
+ %col.w1
12
+ %thead
13
+ %tr
14
+ <%- columns.each do |column| -%>
15
+ %th<%- unless ["position", "visible"].include? column.name %>= <%= resource_name.capitalize %>.human_attribute_name("<%= column.name %>")<% end %>
16
+ <%- end -%>
17
+ %th
18
+ - @<%= plural_resource_name %>.each do |<%= resource_name %>|
19
+ <%- if column_names.include?("position") -%>
20
+ %tr{id: "pos_#{<%= resource_name %>.id}"}
21
+ <%- else -%>
22
+ %tr
23
+ <%- end -%>
24
+ <%- columns.each do |column| -%>
25
+ <%- if column.name == "position" -%>
26
+ %td.handle= image_tag asset_path("admin/move_handler.png")
27
+ <%- elsif column.name == "visible" -%>
28
+ %td.show= link_to "", admin_<%= singular_controller_routing_path %>_path(<%= resource_name %>, <%= resource_name %>: {visible: !<%= resource_name %>.visible}), :class => <%= resource_name %>.visible ? nil : "not-show", data: {method: 'put'}
29
+ <%- else -%>
30
+ %td= link_to <%= resource_name %>.<%= column.name %>, [:edit, :admin, <%= resource_name %>]
31
+ <%- end -%>
32
+ <%- end -%>
33
+ %td= link_to "Удалить", [:admin, <%= resource_name %>], :method => :delete, :confirm => "Удалить?", class: :del
34
+
35
+ <%- if column_names.include?("position") -%>
36
+ = sortable sort_admin_<%= plural_resource_name %>_path
37
+ <%- end -%>
@@ -0,0 +1,3 @@
1
+ module Redde
2
+ VERSION = "0.0.3"
3
+ end
data/lib/redde.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "redde/version"
2
+ module Redde
3
+ # Your code goes here...
4
+ end
data/redde.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path('../lib/redde/version', __FILE__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.authors = ["Oleg Bovykin"]
7
+ gem.email = ["oleg.bovykin@gmail.com"]
8
+ gem.description = %q{Simple admin scaffold generator}
9
+ gem.summary = %q{Admin scaffold generator for redde shop engine}
10
+ gem.homepage = "http://github.com/redde/redde"
11
+
12
+ gem.files = `git ls-files`.split($\)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.name = "redde"
16
+ gem.require_paths = ["lib"]
17
+ gem.version = Redde::VERSION
18
+
19
+ gem.add_runtime_dependency 'russian', '>= 0.6.0'
20
+ gem.add_runtime_dependency 'haml-rails'
21
+ gem.add_runtime_dependency 'compass-rails'
22
+ gem.add_development_dependency 'rails', '>= 3.1'
23
+ gem.add_development_dependency 'rspec-rails', '>= 2.7'
24
+ gem.add_development_dependency 'guard-rspec'
25
+ gem.add_development_dependency 'generator_spec'
26
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Redde::Generators::DeployGenerator do
4
+ include GeneratorSpec::TestCase
5
+ destination File.expand_path("../../tmp", __FILE__)
6
+ arguments %w(127.0.0.1 redde.ru)
7
+
8
+ before(:all) do
9
+ prepare_destination
10
+ run_generator
11
+ end
12
+
13
+ after(:all) do
14
+ FileUtils.rm_rf 'tmp'
15
+ end
16
+
17
+ describe "deploy" do
18
+
19
+ it "creates a test initializer" do
20
+ # check capfile and deploy.rb
21
+ assert_file "Capfile"
22
+ assert_file "config/deploy.rb"
23
+
24
+ assert_directory "config/recipes"
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Redde::Generators::LayoutGenerator do
4
+ include GeneratorSpec::TestCase
5
+ destination File.expand_path("../../tmp", __FILE__)
6
+ arguments %w(something)
7
+
8
+ before(:all) do
9
+ prepare_destination
10
+ run_generator
11
+ end
12
+
13
+ after(:all) do
14
+ FileUtils.rm_rf 'tmp'
15
+ end
16
+
17
+ describe "layout" do
18
+
19
+ it "creates a test initializer" do
20
+ # check layouts
21
+ assert_file "app/views/layouts/admin.html.haml"
22
+ assert_file "app/views/layouts/login.html.haml"
23
+
24
+ # check shared
25
+ assert_file "app/views/admin/shared/_launchbar.html.haml"
26
+ assert_file "app/views/admin/shared/_sidebar.html.haml"
27
+ assert_file "app/views/admin/shared/_header.html.haml"
28
+
29
+ # check js and css
30
+ assert_file "app/assets/javascripts/admin.js"
31
+ assert_file "app/assets/stylesheets/admin.scss"
32
+
33
+ #check images
34
+ assert_directory "app/assets/images/admin"
35
+ assert_directory "app/assets/javascripts/admin"
36
+ assert_directory "app/assets/stylesheets/admin"
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Redde::Generators::ScaffoldGenerator do
4
+ include GeneratorSpec::TestCase
5
+ destination File.expand_path("../../tmp", __FILE__)
6
+ # arguments 'CategoryValues'
7
+
8
+ before(:all) do
9
+ prepare_destination
10
+ run_generator
11
+ end
12
+
13
+ after(:all) do
14
+ FileUtils.rm_rf 'tmp'
15
+ end
16
+
17
+ describe "scaffold" do
18
+
19
+ it "Test scaffold generator" do
20
+
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,10 @@
1
+ require 'bundler/setup'
2
+ require 'rails/all'
3
+ require 'active_record'
4
+ require 'rspec'
5
+ require 'generator_spec/test_case'
6
+ require 'generators/redde/layout/layout_generator'
7
+ require 'generators/redde/scaffold/scaffold_generator'
8
+ require 'generators/redde/deploy/deploy_generator'
9
+ Dir[Pathname.new(File.expand_path('../', __FILE__)).join('support/**/*.rb')].each {|f| require f}
10
+