redde 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,8 +10,6 @@ module Redde
10
10
 
11
11
  def generate_layout
12
12
 
13
-
14
-
15
13
  # copy layouts
16
14
  %w{ admin login }.each do |layout|
17
15
  template "layouts/#{layout}#{ext}", "app/views/layouts/#{layout}#{ext}"
@@ -34,6 +32,9 @@ module Redde
34
32
  end
35
33
  directory "assets/stylesheets/admin", "app/assets/stylesheets/admin"
36
34
 
35
+ # copy helpers
36
+ template "helpers/admin_helper.rb", "app/helpers/admin_helper.rb"
37
+
37
38
  # copy images
38
39
  directory "assets/images/admin", "app/assets/images/admin"
39
40
 
@@ -34,4 +34,59 @@ module AdminHelper
34
34
  return content_for(:js,html)
35
35
  end
36
36
 
37
+ def show_tree(c)
38
+ html = ""
39
+ html << "<li id=\"list_#{c.id}\"><div>#{link_to c.name, edit_admin_category_path(c)}<p>"
40
+ html << " #{link_to "Удал",[:admin, c], data: { confirm: 'Точно удалить?' }, :method => :delete, class: "del"}</p></div>"
41
+ unless c.children.empty?
42
+ html << "<ol#{" class='sortable'" if c.id == 1}>"
43
+ c.children.order('position').each do |ch|
44
+ html << show_tree(ch)
45
+ end
46
+ html << "</ol>"
47
+ end
48
+ html << "</li>"
49
+ return raw(html)
50
+ end
51
+
52
+ def sort_tree(url, maxLevels = 2)
53
+ %Q{
54
+ <script type="text/javascript">
55
+ $(document).ready(function(){
56
+
57
+ $('ol.sortable').nestedSortable({
58
+ disableNesting: 'no-nest',
59
+ forcePlaceholderSize: true,
60
+ handle: 'div',
61
+ helper: 'clone',
62
+ items: 'li',
63
+ maxLevels: #{maxLevels},
64
+ opacity: .6,
65
+ placeholder: 'placeholder',
66
+ revert: 250,
67
+ tabSize: 25,
68
+ tolerance: 'pointer',
69
+ toleranceElement: '> div',
70
+ update: function(){
71
+ var serialized = $(this).nestedSortable('serialize');
72
+ $.ajax({url: '#{url}', data: serialized});
73
+ }
74
+ });
75
+ });
76
+ </script>
77
+ }.gsub(/[\n ]+/, ' ').strip.html_safe
78
+ end
79
+
80
+ def tsingular model
81
+ model.model_name.human
82
+ end
83
+
84
+ def tgenetive model_name
85
+ t("activerecord.models.#{model_name}.gen")
86
+ end
87
+
88
+ def tplural model
89
+ model.model_name.human(:count => 'other')
90
+ end
91
+
37
92
  end
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- class Admin::<%= plural_resource_name.capitalize -%>Controller < Admin::BaseController
2
+ class Admin::<%= model_name.demodulize -%>Controller < Admin::BaseController
3
3
 
4
4
  def index
5
5
  @<%= plural_resource_name %> = <%= model_name.demodulize -%>.all
@@ -28,7 +28,7 @@
28
28
  <%- elsif column.name != "position" -%>
29
29
  %tr
30
30
  %th= f.label :<%= column.name %>
31
- %td= f.<%= column.field_type -%> :<%= column.name %>
31
+ %td= f.<%= column.field_type -%> :<%= column.name %>
32
32
  <%- end -%>
33
33
  <%- end -%>
34
34
  .actions
@@ -12,7 +12,7 @@
12
12
  %thead
13
13
  %tr
14
14
  <%- columns.each do |column| -%>
15
- %th<%- unless ["position", "visible"].include? column.name %>= <%= resource_name.capitalize %>.human_attribute_name("<%= column.name %>")<% end %>
15
+ %th<%- unless ["position", "visible"].include? column.name %>= <%= model_name.demodulize %>.human_attribute_name("<%= column.name %>")<% end %>
16
16
  <%- end -%>
17
17
  %th
18
18
  - @<%= plural_resource_name %>.each do |<%= resource_name %>|
data/lib/redde/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Redde
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+
3
+ class UrlGenerator
4
+
5
+ def initialize id, name = nil
6
+ @id = id
7
+ @name = name
8
+ end
9
+
10
+ def url
11
+ "#{@id}#-{formatted_name}".downcase
12
+ end
13
+
14
+ def translitted_name
15
+ Russian.translit(@name).gsub(' ','-').gsub(/[^\x00-\x7F]+/, '').gsub(/[^\w_ \-]+/i, '').gsub(/[ \-]+/i, '-').gsub(/^\-|\-$/i, '')
16
+ end
17
+
18
+ def formatted_name
19
+ @name.nil? ? '' : translitted_name
20
+ end
21
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redde
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
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: 2013-09-25 00:00:00.000000000 Z
12
+ date: 2013-10-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: russian
@@ -291,6 +291,7 @@ files:
291
291
  - lib/generators/redde/scaffold/templates/index.html.haml
292
292
  - lib/redde.rb
293
293
  - lib/redde/version.rb
294
+ - lib/url_generator.rb
294
295
  - redde.gemspec
295
296
  - spec/deploy_generator_spec.rb
296
297
  - spec/layout_generator_spec.rb