ideyabox 0.1.6 → 0.1.7
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/.gitignore +0 -0
- data/Gemfile +0 -0
- data/LICENSE +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/app/assets/images/admin/addphoto.png +0 -0
- data/app/assets/images/admin/background-image.png +0 -0
- data/app/assets/images/admin/rdws_cat.png +0 -0
- data/app/assets/images/admin/search.png +0 -0
- data/app/assets/images/admin/search_button.png +0 -0
- data/app/assets/images/admin/small_button.png +0 -0
- data/app/assets/images/admin/uploadify/#swfobject.js +0 -0
- data/app/assets/images/admin/uploadify/cancel.png +0 -0
- data/app/assets/images/admin/uploadify/jquery.uploadify.min.js +0 -0
- data/app/assets/images/admin/uploadify/uploadify-cancel.png +0 -0
- data/app/assets/images/admin/uploadify/uploadify.css +0 -0
- data/app/assets/images/admin/uploadify/uploadify.swf +0 -0
- data/app/assets/javascripts/chosen.jquery.js +0 -0
- data/app/assets/javascripts/default.js +0 -0
- data/app/assets/javascripts/jquery.mjs.nestedSortable.js +0 -0
- data/app/assets/javascripts/modernizr.js +0 -0
- data/app/assets/stylesheets/chosen.scss.erb +0 -0
- data/app/assets/stylesheets/default.scss.erb +6 -0
- data/app/assets/stylesheets/font-awesome.css +0 -0
- data/app/assets/stylesheets/font_awesome/.gitignore +0 -0
- data/app/helpers/admin_helper.rb +28 -0
- data/app/tasks/reset_db.rake +0 -0
- data/ideyabox.gemspec +0 -0
- data/lib/generators/ideyabox/admin/admin_generator.rb +0 -0
- data/lib/generators/ideyabox/admin/templates/assets/admin.js +0 -0
- data/lib/generators/ideyabox/admin/templates/assets/admin.scss.erb +0 -0
- data/lib/generators/ideyabox/admin/templates/controllers/application_controller.rb +0 -0
- data/lib/generators/ideyabox/admin/templates/locales/devise.ru.yml +0 -0
- data/lib/generators/ideyabox/admin/templates/locales/en.yml +0 -0
- data/lib/generators/ideyabox/admin/templates/locales/ru.yml +0 -0
- data/lib/generators/ideyabox/admin/templates/tasks/seeds.rb +0 -0
- data/lib/generators/ideyabox/assets/assets_generator.rb +0 -0
- data/lib/generators/ideyabox/crop/crop_generator.rb +0 -0
- data/lib/generators/ideyabox/crop/templates/_crop.html.haml +0 -0
- data/lib/generators/ideyabox/images_scaffold/images_scaffold_generator.rb +1 -1
- data/lib/generators/ideyabox/images_scaffold/templates/controllers/controller.rb +3 -3
- data/lib/generators/ideyabox/images_scaffold/templates/uploader.rb +0 -0
- data/lib/generators/ideyabox/images_scaffold/templates/views/_image.html.haml +0 -0
- data/lib/generators/ideyabox/images_scaffold/templates/views/_images.html.haml +0 -1
- data/lib/generators/ideyabox/images_scaffold/templates/views/create.js.haml +0 -0
- data/lib/generators/ideyabox/images_scaffold/templates/views/edit.html.haml +0 -0
- data/lib/generators/ideyabox/many_to_many/many_to_many_generator.rb +289 -0
- data/lib/generators/ideyabox/many_to_many/templates/controllers/controller.rb +54 -0
- data/lib/generators/ideyabox/many_to_many/templates/views/_child.html.haml +8 -0
- data/lib/generators/ideyabox/many_to_many/templates/views/_form.html.haml +9 -0
- data/lib/generators/ideyabox/many_to_many/templates/views/_one_to_one.html.haml +16 -0
- data/lib/generators/ideyabox/many_to_many/templates/views/create.js.erb +3 -0
- data/lib/generators/ideyabox/many_to_many/templates/views/destroy.js.erb +3 -0
- data/lib/generators/ideyabox/scaffold/scaffold_generator.rb +0 -0
- data/lib/generators/ideyabox/scaffold/templates/_index.html.haml +0 -0
- data/lib/generators/ideyabox/scaffold/templates/_sort_buttons.html.haml +0 -0
- data/lib/generators/ideyabox/scaffold/templates/edit.html.haml +0 -0
- data/lib/generators/ideyabox/scaffold/templates/index.html.haml +0 -0
- data/lib/generators/ideyabox/scaffold/templates/index.js.haml +0 -0
- data/lib/generators/ideyabox/tree/templates/edit.html.haml +0 -0
- data/lib/generators/ideyabox/tree/templates/index.html.haml +0 -0
- data/lib/generators/ideyabox/tree/tree_generator.rb +0 -0
- data/lib/ideyabox/engine.rb +0 -0
- data/lib/ideyabox/version.rb +1 -1
- data/lib/ideyabox.rb +0 -0
- metadata +9 -20
- data/app/assets/.DS_Store +0 -0
- data/app/assets/images/.DS_Store +0 -0
- data/app/assets/images/admin/.DS_Store +0 -0
- data/app/assets/javascripts/.DS_Store +0 -0
- data/app/assets/stylesheets/.DS_Store +0 -0
- data/app/helpers/.DS_Store +0 -0
- data/lib/generators/.DS_Store +0 -0
- data/lib/generators/ideyabox/.DS_Store +0 -0
- data/lib/generators/ideyabox/admin/.DS_Store +0 -0
- data/lib/generators/ideyabox/admin/templates/.DS_Store +0 -0
- data/lib/generators/ideyabox/admin/templates/controllers/.DS_Store +0 -0
- data/lib/generators/ideyabox/admin/templates/controllers/admin/.DS_Store +0 -0
- data/lib/generators/ideyabox/admin/templates/views/.DS_Store +0 -0
- data/lib/generators/ideyabox/admin/templates/views/admin/.DS_Store +0 -0
- data/lib/generators/ideyabox/images_scaffold/.DS_Store +0 -0
- data/lib/generators/ideyabox/images_scaffold/templates/.DS_Store +0 -0
- data/lib/generators/ideyabox/scaffold/.DS_Store +0 -0
- data/lib/generators/ideyabox/scaffold/templates/.DS_Store +0 -0
data/.gitignore
CHANGED
|
File without changes
|
data/Gemfile
CHANGED
|
File without changes
|
data/LICENSE
CHANGED
|
File without changes
|
data/README.md
CHANGED
|
File without changes
|
data/Rakefile
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/app/helpers/admin_helper.rb
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
module AdminHelper
|
|
3
|
+
|
|
4
|
+
def multiple_sortable(table_id, url)
|
|
5
|
+
%Q{
|
|
6
|
+
<script type="text/javascript">
|
|
7
|
+
$(document).ready(function() {
|
|
8
|
+
$("##{table_id} tbody").sortable( {
|
|
9
|
+
placeholder: 'ui-sortable-placeholder',
|
|
10
|
+
forcePlaceholderSize: true,
|
|
11
|
+
dropOnEmpty: false,
|
|
12
|
+
cursor: 'crosshair',
|
|
13
|
+
opacity: 0.75,
|
|
14
|
+
items: 'tr',
|
|
15
|
+
handle: '.handle',
|
|
16
|
+
scroll: true,
|
|
17
|
+
update: function() {
|
|
18
|
+
$.ajax( {
|
|
19
|
+
type: 'post',
|
|
20
|
+
data: $("##{table_id} tbody").sortable('serialize') + '&authenticity_token=#{u(form_authenticity_token)}',
|
|
21
|
+
dataType: 'script',
|
|
22
|
+
url: '#{url}'
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
}.gsub(/[\n ]+/, ' ').strip.html_safe
|
|
29
|
+
end
|
|
30
|
+
|
|
3
31
|
def sortable(url)
|
|
4
32
|
%Q{
|
|
5
33
|
<script type="text/javascript">
|
data/app/tasks/reset_db.rake
CHANGED
|
File without changes
|
data/ideyabox.gemspec
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -28,7 +28,7 @@ module Ideyabox
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def add_to_parent_view
|
|
31
|
-
final_string = "\n- content_for(:page_sidebar) do\n - unless @#{parent_name}.new_record?\n = render 'admin/#{plural_resource_name}/#{plural_resource_name}'\n"
|
|
31
|
+
final_string = "\n- content_for(:page_sidebar) do\n - unless @#{parent_name}.new_record?\n %h2 Gallery\n .bordered_box\n = render 'admin/#{plural_resource_name}/#{plural_resource_name}'\n"
|
|
32
32
|
|
|
33
33
|
inject_into_file "app/views/admin/#{plural_parent_name}/edit.html.haml", final_string, :before => "- content_for :page_header do"
|
|
34
34
|
|
|
@@ -3,9 +3,9 @@ class Admin::<%= @model_name.demodulize.pluralize -%>Controller < Admin::Applica
|
|
|
3
3
|
|
|
4
4
|
<%- if column_names.include?("visible") -%>
|
|
5
5
|
def toggleshow
|
|
6
|
-
@<%=
|
|
7
|
-
@<%=
|
|
8
|
-
@<%=
|
|
6
|
+
@<%= resource_name %> = <%= @model_name.demodulize -%>.find(params[:id])
|
|
7
|
+
@<%= resource_name %>.toggle(:visible)
|
|
8
|
+
@<%= resource_name %>.save
|
|
9
9
|
render :nothing => true
|
|
10
10
|
end
|
|
11
11
|
<%- end -%><%- if column_names.include?("position") -%>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
require 'rails/generators'
|
|
2
|
+
require 'rails/generators/generated_attribute'
|
|
3
|
+
|
|
4
|
+
module Ideyabox
|
|
5
|
+
module Generators
|
|
6
|
+
class ManyToManyGenerator < ::Rails::Generators::Base
|
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
8
|
+
argument :controller_path, :type => :string
|
|
9
|
+
argument :child_controller_path, :type => :string
|
|
10
|
+
argument :model_name, :type => :string, :required => false
|
|
11
|
+
argument :layout, :type => :string, :default => "application",
|
|
12
|
+
:banner => "Specify application layout"
|
|
13
|
+
|
|
14
|
+
def initialize(args, *options)
|
|
15
|
+
super(args, *options)
|
|
16
|
+
initialize_views_variables
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def copy_views
|
|
20
|
+
generate_views
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# def add_locale_templates
|
|
24
|
+
# add_to_locales
|
|
25
|
+
# end
|
|
26
|
+
|
|
27
|
+
def add_resources_and_root
|
|
28
|
+
add_resource_route
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def updating_views
|
|
32
|
+
update_views
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def updating_controllers
|
|
36
|
+
update_controllers
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def updating_models
|
|
40
|
+
update_model
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
protected
|
|
44
|
+
|
|
45
|
+
def initialize_views_variables
|
|
46
|
+
@base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(controller_path)
|
|
47
|
+
|
|
48
|
+
@child_contoller_class_nesting = child_controller_path
|
|
49
|
+
|
|
50
|
+
@controller_routing_path = @controller_file_path.gsub(/\//, '_')
|
|
51
|
+
@model_name = @controller_class_nesting + "::#{@base_name.singularize.camelize}" unless @model_name
|
|
52
|
+
@model_name = @model_name.camelize
|
|
53
|
+
|
|
54
|
+
@child_model_name = @child_contoller_class_nesting.singularize.camelize
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def controller_routing_path
|
|
59
|
+
@controller_routing_path
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def singular_controller_routing_path
|
|
63
|
+
@controller_routing_path.singularize
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def model_name
|
|
67
|
+
@model_name.demodulize
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def plural_model_name
|
|
71
|
+
@model_name.pluralize
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
#parent model
|
|
75
|
+
def resource_name
|
|
76
|
+
@model_name.demodulize.underscore
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def plural_resource_name
|
|
80
|
+
resource_name.pluralize
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
#child model
|
|
84
|
+
def child_model
|
|
85
|
+
@child_model_name
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def child_name
|
|
89
|
+
@child_model_name.demodulize.underscore
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def plural_child_name
|
|
93
|
+
child_name.pluralize
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
#linking model
|
|
97
|
+
def linking_model_name
|
|
98
|
+
if ActiveRecord::Base.connection.table_exists? "#{child_name}_#{plural_resource_name}"
|
|
99
|
+
"#{child_name}_#{plural_resource_name}".singularize.camelize
|
|
100
|
+
elsif
|
|
101
|
+
ActiveRecord::Base.connection.table_exists? "#{resource_name}_#{plural_child_name}"
|
|
102
|
+
"#{resource_name}_#{plural_child_name}".singularize.camelize
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def linking_resource_name
|
|
107
|
+
linking_model_name.underscore
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def plural_linking_resource_name
|
|
111
|
+
linking_resource_name.pluralize
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def sort_priority(column_name)
|
|
116
|
+
case column_name
|
|
117
|
+
when "position" then 1
|
|
118
|
+
when "visible" then 2
|
|
119
|
+
when "name" then 3
|
|
120
|
+
when "title" then 3
|
|
121
|
+
else 5
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def columns
|
|
126
|
+
begin
|
|
127
|
+
excluded_column_names = %w[id created_at updated_at]
|
|
128
|
+
@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)}
|
|
129
|
+
rescue NoMethodError
|
|
130
|
+
@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)}
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def column_names
|
|
135
|
+
@model_name.constantize.column_names
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def child_columns
|
|
139
|
+
child_model.constantize.column_names
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def linking_columns
|
|
143
|
+
linking_model_name.constantize.column_names
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def get_title
|
|
147
|
+
if child_columns.include?("title")
|
|
148
|
+
t = 'title'
|
|
149
|
+
elsif child_columns.include?("name")
|
|
150
|
+
t = 'name'
|
|
151
|
+
elsif child_columns.include?("username")
|
|
152
|
+
t = 'username'
|
|
153
|
+
else
|
|
154
|
+
t = 'id'
|
|
155
|
+
end
|
|
156
|
+
t
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def extract_modules(name)
|
|
160
|
+
modules = name.include?('/') ? name.split('/') : name.split('::')
|
|
161
|
+
name = modules.pop
|
|
162
|
+
path = modules.map { |m| m.underscore }
|
|
163
|
+
file_path = (path + [name.underscore]).join('/')
|
|
164
|
+
nesting = modules.map { |m| m.camelize }.join('::')
|
|
165
|
+
[name, path, file_path, nesting, modules.size]
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def generate_views
|
|
169
|
+
views = {
|
|
170
|
+
"views/_form.html.#{ext}" => "app/views/admin/#{plural_linking_resource_name}/_form.html.#{ext}",
|
|
171
|
+
"views/_one_to_one.html.#{ext}" => "app/views/admin/#{plural_linking_resource_name}/_#{linking_resource_name}.html.#{ext}",
|
|
172
|
+
"views/destroy.js.erb" => "app/views/admin/#{plural_linking_resource_name}/destroy.js.haml",
|
|
173
|
+
"views/create.js.erb" => "app/views/admin/#{plural_linking_resource_name}/create.js.haml",
|
|
174
|
+
"views/_child.html.haml" => "app/views/admin/#{plural_resource_name}/_#{plural_child_name}.html.haml",
|
|
175
|
+
}
|
|
176
|
+
views.delete("_sort_buttons.html.#{ext}") unless column_names.include?("position")
|
|
177
|
+
selected_views = views
|
|
178
|
+
options.engine == generate_erb(selected_views)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def generate_erb(views)
|
|
182
|
+
views.each do |template_name, output_path|
|
|
183
|
+
template template_name, output_path
|
|
184
|
+
end
|
|
185
|
+
generate_controller
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def ext
|
|
189
|
+
:haml
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def generate_controller
|
|
193
|
+
template "controllers/controller.rb", "app/controllers/admin/#{plural_linking_resource_name}_controller.rb"
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def update_controllers
|
|
197
|
+
inject_into_file "app/controllers/admin/#{plural_resource_name}_controller.rb", "\n @#{plural_child_name} = #{child_model}.has_not_this_#{resource_name}(params[:id])", :after => "\n def edit"
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def update_model
|
|
201
|
+
inject_into_file "app/models/#{resource_name}.rb", "\n has_many :#{plural_child_name}, :through => :#{plural_linking_resource_name}\n has_many :#{plural_linking_resource_name}\n
|
|
202
|
+
# def self.has_not_this_#{child_name}(#{child_name}_id)
|
|
203
|
+
# h = Hash.new
|
|
204
|
+
# self.order(#{child_model.constantize.column_names.include?('title') ? '\'title\'' : 'created_at'}).each do |p|
|
|
205
|
+
# if p.#{plural_linking_resource_name}.where(:#{child_name}_id=>#{child_name}_id).length == 0
|
|
206
|
+
# h[\"\#{p.#{@model_name.constantize.column_names.include?('title') ? 'title' : 'id'}}\"] = p.id
|
|
207
|
+
# end
|
|
208
|
+
# end
|
|
209
|
+
# return h
|
|
210
|
+
# end
|
|
211
|
+
", :after => "class #{model_name} < ActiveRecord::Base"
|
|
212
|
+
|
|
213
|
+
inject_into_file "app/models/#{child_model}.rb", "\n has_many :#{plural_resource_name}, :through => :#{plural_linking_resource_name}\n has_many :#{plural_linking_resource_name}\n
|
|
214
|
+
def self.has_not_this_#{resource_name}(#{resource_name}_id)
|
|
215
|
+
h = Hash.new
|
|
216
|
+
self.order('#{@model_name.constantize.column_names.include?(get_title.to_s) ? (get_title.to_s) : 'created_at'}').each do |p|
|
|
217
|
+
if p.#{plural_linking_resource_name}.where(:#{resource_name}_id=>#{resource_name}_id).length == 0
|
|
218
|
+
h[\"\#{p.#{get_title.to_s}}\"] = p.id
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
return h
|
|
222
|
+
end
|
|
223
|
+
", :after => "class #{child_model} < ActiveRecord::Base"
|
|
224
|
+
|
|
225
|
+
inject_into_file "app/models/#{linking_resource_name}.rb", "\n belongs_to :#{resource_name}\n belongs_to :#{child_name}\n validates :#{resource_name}_id, :#{child_name}_id, :presence => true", :after => "class #{linking_model_name} < ActiveRecord::Base"
|
|
226
|
+
if linking_columns.include?("position")
|
|
227
|
+
inject_into_file "app/models/#{linking_resource_name}.rb", "\n
|
|
228
|
+
before_create :set_position
|
|
229
|
+
def set_position
|
|
230
|
+
if self.#{resource_name}.#{plural_linking_resource_name}.length > 0 && self.#{resource_name}.#{plural_linking_resource_name}.order('position').last.position
|
|
231
|
+
self.position = self.#{resource_name}.#{plural_linking_resource_name}.order('position').last.position + 1
|
|
232
|
+
else
|
|
233
|
+
self.position = 0
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
", :after => "class #{linking_model_name} < ActiveRecord::Base"
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def update_views
|
|
244
|
+
prepend_to_file "app/views/admin/#{plural_resource_name}/edit.html.haml", "
|
|
245
|
+
- content_for(:page_sidebar) do
|
|
246
|
+
- unless @#{resource_name}.new_record?
|
|
247
|
+
%h2 #{plural_child_name}
|
|
248
|
+
.bordered_box
|
|
249
|
+
= render '#{plural_child_name}'
|
|
250
|
+
"
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def add_resource_route
|
|
254
|
+
resources_string = "\n resources :#{plural_linking_resource_name} do\n"
|
|
255
|
+
sort_string = " post \"sort\", :on => :collection\n"
|
|
256
|
+
toggleshow_string = " get \"toggleshow\", :on => :member\n"
|
|
257
|
+
|
|
258
|
+
if linking_columns.include?("visible") && linking_columns.include?("position")
|
|
259
|
+
final_string = "#{resources_string}#{sort_string}#{toggleshow_string} end\n"
|
|
260
|
+
elsif linking_columns.include?("visible")
|
|
261
|
+
final_string = "#{resources_string}#{toggleshow_string} end\n"
|
|
262
|
+
elsif linking_columns.include?("position")
|
|
263
|
+
final_string = "#{resources_string}#{sort_string} end\n"
|
|
264
|
+
else
|
|
265
|
+
final_string = "\n resources :#{plural_linking_resource_name}\n"
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
inject_into_file "config/routes.rb", final_string, :after => "\n namespace :admin do\n"
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
# def add_to_locales
|
|
272
|
+
# locales = [:ru, :en]
|
|
273
|
+
|
|
274
|
+
# attributes = column_names.collect {|column| " #{column}: \"#{column}\"\n"}
|
|
275
|
+
|
|
276
|
+
# attributes_string = " #{resource_name}:\n#{attributes.join}"
|
|
277
|
+
|
|
278
|
+
# locales.each do |locale|
|
|
279
|
+
# inject_into_file "config/locales/#{locale}.yml", " #{resource_name}: \"#{resource_name}\"\n", :after => "models:\n"
|
|
280
|
+
# inject_into_file "config/locales/#{locale}.yml", attributes_string, :after => "attributes:\n"
|
|
281
|
+
# end
|
|
282
|
+
# end
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#coding: utf-8
|
|
2
|
+
class Admin::<%= linking_model_name.pluralize -%>Controller < Admin::ApplicationController
|
|
3
|
+
<%- if linking_columns.include?("visible") -%>
|
|
4
|
+
def toggleshow
|
|
5
|
+
@<%= linking_resource_name %> = <%= linking_model_name -%>.find(params[:id])
|
|
6
|
+
@<%= linking_resource_name %>.toggle(:visible)
|
|
7
|
+
@<%= linking_resource_name %>.save
|
|
8
|
+
render :nothing => true
|
|
9
|
+
end
|
|
10
|
+
<%- end -%><%- if linking_columns.include?("position") -%>
|
|
11
|
+
def sort
|
|
12
|
+
params[:<%= linking_resource_name %>].each_with_index do |id, idx|
|
|
13
|
+
@<%= linking_resource_name %> = <%= linking_model_name -%>.find(id)
|
|
14
|
+
@<%= linking_resource_name %>.position = idx
|
|
15
|
+
@<%= linking_resource_name %>.save
|
|
16
|
+
end
|
|
17
|
+
render :nothing => true
|
|
18
|
+
end
|
|
19
|
+
<%- end -%>
|
|
20
|
+
|
|
21
|
+
def edit
|
|
22
|
+
@<%= linking_resource_name %> = <%= linking_model_name -%>.find(params[:id])
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def create
|
|
26
|
+
@<%= linking_resource_name %> = <%= linking_model_name %>.create(params[:<%= linking_resource_name %>])
|
|
27
|
+
|
|
28
|
+
@<%=resource_name%> = @<%= linking_resource_name %>.<%=resource_name%>
|
|
29
|
+
@<%=plural_child_name%> = <%=child_model%>.has_not_this_<%=resource_name%>(@<%=resource_name%>.id)
|
|
30
|
+
|
|
31
|
+
#@<%=child_name%> = @<%= linking_resource_name %>.<%=child_name%>
|
|
32
|
+
#@<%=plural_resource_name%> = <%=model_name%>.has_not_this_<%=child_name%>(@<%=child_name%>.id)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def update
|
|
36
|
+
@<%= linking_resource_name %> = <%= linking_model_name -%>.find(params[:id])
|
|
37
|
+
if @<%= linking_resource_name %>.update_attributes(params[:<%= linking_resource_name %>])
|
|
38
|
+
redirect_to [:edit, :admin, @<%= linking_resource_name %>.<%= resource_name %>], :notice => "#{<%= linking_model_name %>.model_name.human} #{t 'flash.notice.was_updated'}"
|
|
39
|
+
else
|
|
40
|
+
render 'edit'
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def destroy
|
|
45
|
+
@<%= linking_resource_name %> = <%= linking_model_name -%>.find(params[:id])
|
|
46
|
+
@<%= linking_resource_name %>.destroy
|
|
47
|
+
|
|
48
|
+
@<%=resource_name%> = @<%= linking_resource_name %>.<%=resource_name%>
|
|
49
|
+
@<%=plural_child_name%> = <%=child_model%>.has_not_this_<%=resource_name%>(@<%=resource_name%>.id)
|
|
50
|
+
|
|
51
|
+
#@<%=child_name%> = @<%= linking_resource_name %>.<%=child_name%>
|
|
52
|
+
#@<%=plural_resource_name%> = <%=model_name%>.has_not_this_<%=child_name%>(@<%=child_name%>.id)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
.<%=plural_linking_resource_name%>_form
|
|
2
|
+
= render 'admin/<%=plural_linking_resource_name%>/form', :<%=plural_child_name%> => @<%=plural_child_name%>, :<%=resource_name%> => @<%=resource_name%>
|
|
3
|
+
%strong Список <%=plural_child_name%>
|
|
4
|
+
%table.<%=plural_child_name%>{:id => "sort-list-<%=plural_linking_resource_name%>"}
|
|
5
|
+
= render @<%=resource_name%>.<%=plural_linking_resource_name%>.order(<%= linking_columns.include?("position") ? '\'position\'' : '\'created_at\'' %>)
|
|
6
|
+
<%- if linking_columns.include?("position") %>
|
|
7
|
+
= multiple_sortable('sort-list-<%=plural_linking_resource_name%>', sort_admin_<%=plural_linking_resource_name%>_path)
|
|
8
|
+
<%end%>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
= form_for [:admin, <%=linking_model_name%>.new], :remote => true do |f|
|
|
2
|
+
%table
|
|
3
|
+
%tr
|
|
4
|
+
%td= f.select :<%=child_name%>_id, <%=plural_child_name%>, {:include_blank => true, :prompt => "add <%=child_name%>" }, :class => "chosen_select"
|
|
5
|
+
%td
|
|
6
|
+
|
|
7
|
+
= f.hidden_field :<%=resource_name%>_id, :value => <%=resource_name%>.id
|
|
8
|
+
|
|
9
|
+
= f.submit "Добавить", :class =>'black_button'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
%tr{:id=> "<%=linking_resource_name%>_#{<%=linking_resource_name%>.id}"}
|
|
2
|
+
<%- if linking_columns.include?("position") -%>
|
|
3
|
+
%td.icon.handle
|
|
4
|
+
%i{:class => "icon-move icon-large"}
|
|
5
|
+
<% end %>
|
|
6
|
+
<%- if linking_columns.include?("visible") -%>
|
|
7
|
+
%td.icon.visibility
|
|
8
|
+
= link_to [:toggleshow, :admin, <%=linking_resource_name%>], :remote => true do
|
|
9
|
+
%i{:class => (<%=linking_resource_name%>.visible? ? "icon-eye-open icon-large" : "icon-eye-close icon-large not-work")}
|
|
10
|
+
<% end %>
|
|
11
|
+
%td= link_to <%=linking_resource_name%>.<%=child_name%>.<%=get_title%>, [:edit,:admin, <%=linking_resource_name%>.<%=child_name%>]
|
|
12
|
+
%td
|
|
13
|
+
%td.right
|
|
14
|
+
= link_to [:admin, <%=linking_resource_name%>], :method => :delete, :confirm => "Точно удалить?", :class => :del, :remote => true do
|
|
15
|
+
%span Удалить
|
|
16
|
+
%i{:class => "icon-trash icon-large"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
$('.<%= plural_child_name%>').append("#{j render @<%=linking_resource_name%>}");
|
|
2
|
+
$('.<%=plural_linking_resource_name%>_form').html("#{j render 'admin/<%=plural_linking_resource_name%>/form', :<%= plural_child_name%> => @<%= plural_child_name%>, :<%= resource_name%> => @<%= resource_name%>}");
|
|
3
|
+
$(".chosen_select").chosen();
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
$('.<%=plural_linking_resource_name%>_form').html("#{j render 'admin/<%=plural_linking_resource_name%>/form', :<%=plural_child_name%> => @<%=plural_child_name%>, :<%=resource_name%> => @<%=resource_name%>}");
|
|
2
|
+
$("#<%=linking_resource_name%>_"+"#{@<%=linking_resource_name%>.id}").remove();
|
|
3
|
+
$(".chosen_select").chosen();
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/ideyabox/engine.rb
CHANGED
|
File without changes
|
data/lib/ideyabox/version.rb
CHANGED
data/lib/ideyabox.rb
CHANGED
|
File without changes
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ideyabox
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.7
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2013-01-06 00:00:00.000000000 Z
|
|
14
14
|
dependencies: []
|
|
15
15
|
description: Write a gem description
|
|
16
16
|
email:
|
|
@@ -25,9 +25,6 @@ files:
|
|
|
25
25
|
- LICENSE
|
|
26
26
|
- README.md
|
|
27
27
|
- Rakefile
|
|
28
|
-
- app/assets/.DS_Store
|
|
29
|
-
- app/assets/images/.DS_Store
|
|
30
|
-
- app/assets/images/admin/.DS_Store
|
|
31
28
|
- app/assets/images/admin/addphoto.png
|
|
32
29
|
- app/assets/images/admin/background-image.png
|
|
33
30
|
- app/assets/images/admin/rdws_cat.png
|
|
@@ -40,7 +37,6 @@ files:
|
|
|
40
37
|
- app/assets/images/admin/uploadify/uploadify-cancel.png
|
|
41
38
|
- app/assets/images/admin/uploadify/uploadify.css
|
|
42
39
|
- app/assets/images/admin/uploadify/uploadify.swf
|
|
43
|
-
- app/assets/javascripts/.DS_Store
|
|
44
40
|
- app/assets/javascripts/chosen.jquery.js
|
|
45
41
|
- app/assets/javascripts/default.js
|
|
46
42
|
- app/assets/javascripts/jquery.Jcrop.min.js
|
|
@@ -49,7 +45,6 @@ files:
|
|
|
49
45
|
- app/assets/javascripts/jquery.uploadify.min.js
|
|
50
46
|
- app/assets/javascripts/modernizr.js
|
|
51
47
|
- app/assets/javascripts/swfobject.js
|
|
52
|
-
- app/assets/stylesheets/.DS_Store
|
|
53
48
|
- app/assets/stylesheets/Jcrop.gif
|
|
54
49
|
- app/assets/stylesheets/chosen.scss.erb
|
|
55
50
|
- app/assets/stylesheets/default.scss.erb
|
|
@@ -61,27 +56,18 @@ files:
|
|
|
61
56
|
- app/assets/stylesheets/font_awesome/font/fontawesome-webfont.woff
|
|
62
57
|
- app/assets/stylesheets/jquery.Jcrop.css
|
|
63
58
|
- app/assets/stylesheets/normalize.css
|
|
64
|
-
- app/helpers/.DS_Store
|
|
65
59
|
- app/helpers/admin_helper.rb
|
|
66
60
|
- app/tasks/reset_db.rake
|
|
67
61
|
- ideyabox.gemspec
|
|
68
|
-
- lib/generators/.DS_Store
|
|
69
|
-
- lib/generators/ideyabox/.DS_Store
|
|
70
|
-
- lib/generators/ideyabox/admin/.DS_Store
|
|
71
62
|
- lib/generators/ideyabox/admin/admin_generator.rb
|
|
72
|
-
- lib/generators/ideyabox/admin/templates/.DS_Store
|
|
73
63
|
- lib/generators/ideyabox/admin/templates/assets/admin.js
|
|
74
64
|
- lib/generators/ideyabox/admin/templates/assets/admin.scss.erb
|
|
75
|
-
- lib/generators/ideyabox/admin/templates/controllers/.DS_Store
|
|
76
|
-
- lib/generators/ideyabox/admin/templates/controllers/admin/.DS_Store
|
|
77
65
|
- lib/generators/ideyabox/admin/templates/controllers/admin/application_controller.rb
|
|
78
66
|
- lib/generators/ideyabox/admin/templates/controllers/application_controller.rb
|
|
79
67
|
- lib/generators/ideyabox/admin/templates/locales/devise.ru.yml
|
|
80
68
|
- lib/generators/ideyabox/admin/templates/locales/en.yml
|
|
81
69
|
- lib/generators/ideyabox/admin/templates/locales/ru.yml
|
|
82
70
|
- lib/generators/ideyabox/admin/templates/tasks/seeds.rb
|
|
83
|
-
- lib/generators/ideyabox/admin/templates/views/.DS_Store
|
|
84
|
-
- lib/generators/ideyabox/admin/templates/views/admin/.DS_Store
|
|
85
71
|
- lib/generators/ideyabox/admin/templates/views/admin/shared/_header.html.haml
|
|
86
72
|
- lib/generators/ideyabox/admin/templates/views/admin/shared/_launchbar.html.haml
|
|
87
73
|
- lib/generators/ideyabox/admin/templates/views/admin/shared/_topbar.html.haml
|
|
@@ -90,9 +76,7 @@ files:
|
|
|
90
76
|
- lib/generators/ideyabox/assets/assets_generator.rb
|
|
91
77
|
- lib/generators/ideyabox/crop/crop_generator.rb
|
|
92
78
|
- lib/generators/ideyabox/crop/templates/_crop.html.haml
|
|
93
|
-
- lib/generators/ideyabox/images_scaffold/.DS_Store
|
|
94
79
|
- lib/generators/ideyabox/images_scaffold/images_scaffold_generator.rb
|
|
95
|
-
- lib/generators/ideyabox/images_scaffold/templates/.DS_Store
|
|
96
80
|
- lib/generators/ideyabox/images_scaffold/templates/controllers/controller.rb
|
|
97
81
|
- lib/generators/ideyabox/images_scaffold/templates/uploader.rb
|
|
98
82
|
- lib/generators/ideyabox/images_scaffold/templates/views/_image.html.haml
|
|
@@ -100,9 +84,14 @@ files:
|
|
|
100
84
|
- lib/generators/ideyabox/images_scaffold/templates/views/create.js.haml
|
|
101
85
|
- lib/generators/ideyabox/images_scaffold/templates/views/destroy.js.haml
|
|
102
86
|
- lib/generators/ideyabox/images_scaffold/templates/views/edit.html.haml
|
|
103
|
-
- lib/generators/ideyabox/
|
|
87
|
+
- lib/generators/ideyabox/many_to_many/many_to_many_generator.rb
|
|
88
|
+
- lib/generators/ideyabox/many_to_many/templates/controllers/controller.rb
|
|
89
|
+
- lib/generators/ideyabox/many_to_many/templates/views/_child.html.haml
|
|
90
|
+
- lib/generators/ideyabox/many_to_many/templates/views/_form.html.haml
|
|
91
|
+
- lib/generators/ideyabox/many_to_many/templates/views/_one_to_one.html.haml
|
|
92
|
+
- lib/generators/ideyabox/many_to_many/templates/views/create.js.erb
|
|
93
|
+
- lib/generators/ideyabox/many_to_many/templates/views/destroy.js.erb
|
|
104
94
|
- lib/generators/ideyabox/scaffold/scaffold_generator.rb
|
|
105
|
-
- lib/generators/ideyabox/scaffold/templates/.DS_Store
|
|
106
95
|
- lib/generators/ideyabox/scaffold/templates/_index.html.haml
|
|
107
96
|
- lib/generators/ideyabox/scaffold/templates/_sort_buttons.html.haml
|
|
108
97
|
- lib/generators/ideyabox/scaffold/templates/controllers/controller.rb
|
data/app/assets/.DS_Store
DELETED
|
Binary file
|
data/app/assets/images/.DS_Store
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/app/helpers/.DS_Store
DELETED
|
Binary file
|
data/lib/generators/.DS_Store
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|