cantango_editor 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. data/.rspec +2 -0
  2. data/Gemfile +26 -0
  3. data/Gemfile.lock +177 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +80 -0
  6. data/Rakefile +54 -0
  7. data/VERSION +1 -0
  8. data/app/assets/images/cantango_editor/+.png +0 -0
  9. data/app/assets/images/cantango_editor/-.png +0 -0
  10. data/app/assets/images/cantango_editor/.gitkeep +0 -0
  11. data/app/assets/images/cantango_editor/bg-1.gif +0 -0
  12. data/app/assets/images/cantango_editor/bg-2.gif +0 -0
  13. data/app/assets/images/cantango_editor/bg-model.png +0 -0
  14. data/app/assets/images/cantango_editor/bg.gif +0 -0
  15. data/app/assets/images/cantango_editor/bg_action.gif +0 -0
  16. data/app/assets/images/cantango_editor/bg_action.png +0 -0
  17. data/app/assets/images/cantango_editor/bg_can.gif +0 -0
  18. data/app/assets/images/cantango_editor/bg_can.png +0 -0
  19. data/app/assets/images/cantango_editor/bg_cannot.gif +0 -0
  20. data/app/assets/images/cantango_editor/bg_cannot.png +0 -0
  21. data/app/assets/images/cantango_editor/button-top-r.png +0 -0
  22. data/app/assets/images/cantango_editor/button-top.png +0 -0
  23. data/app/assets/images/cantango_editor/cantangologo.png +0 -0
  24. data/app/assets/images/cantango_editor/cantangologo_big.png +0 -0
  25. data/app/assets/images/cantango_editor/cantangologo_big2.png +0 -0
  26. data/app/assets/images/cantango_editor/cantangologo_big3.png +0 -0
  27. data/app/assets/images/cantango_editor/ico-uc.png +0 -0
  28. data/app/assets/images/cantango_editor/images/ui-bg_diagonal-maze_20_6e4f1c_10x10.png +0 -0
  29. data/app/assets/images/cantango_editor/images/ui-bg_diagonal-maze_40_000000_10x10.png +0 -0
  30. data/app/assets/images/cantango_editor/images/ui-bg_fine-grain_10_eceadf_60x60.png +0 -0
  31. data/app/assets/images/cantango_editor/images/ui-bg_fine-grain_10_f8f7f6_60x60.png +0 -0
  32. data/app/assets/images/cantango_editor/images/ui-bg_fine-grain_15_eceadf_60x60.png +0 -0
  33. data/app/assets/images/cantango_editor/images/ui-bg_fine-grain_15_f7f3de_60x60.png +0 -0
  34. data/app/assets/images/cantango_editor/images/ui-bg_fine-grain_15_ffffff_60x60.png +0 -0
  35. data/app/assets/images/cantango_editor/images/ui-bg_fine-grain_65_654b24_60x60.png +0 -0
  36. data/app/assets/images/cantango_editor/images/ui-bg_fine-grain_68_b83400_60x60.png +0 -0
  37. data/app/assets/images/cantango_editor/images/ui-icons_222222_256x240.png +0 -0
  38. data/app/assets/images/cantango_editor/images/ui-icons_3572ac_256x240.png +0 -0
  39. data/app/assets/images/cantango_editor/images/ui-icons_8c291d_256x240.png +0 -0
  40. data/app/assets/images/cantango_editor/images/ui-icons_b83400_256x240.png +0 -0
  41. data/app/assets/images/cantango_editor/images/ui-icons_fbdb93_256x240.png +0 -0
  42. data/app/assets/images/cantango_editor/images/ui-icons_ffffff_256x240.png +0 -0
  43. data/app/assets/images/cantango_editor/line2.png +0 -0
  44. data/app/assets/images/cantango_editor/line3.png +0 -0
  45. data/app/assets/images/cantango_editor/panel-l.gif +0 -0
  46. data/app/assets/images/cantango_editor/panel-l.png +0 -0
  47. data/app/assets/images/cantango_editor/panel-r.gif +0 -0
  48. data/app/assets/images/cantango_editor/panel-r.png +0 -0
  49. data/app/assets/images/cantango_editor/panel.gif +0 -0
  50. data/app/assets/images/cantango_editor/panel.png +0 -0
  51. data/app/assets/images/cantango_editor/remember.png +0 -0
  52. data/app/assets/images/cantango_editor/sexy.png +0 -0
  53. data/app/assets/images/cantango_editor/x.png +0 -0
  54. data/app/assets/images/cantango_editor/xx.png +0 -0
  55. data/app/assets/javascripts/cantango_editor/application.js +59 -0
  56. data/app/assets/javascripts/cantango_editor/jquery.collapse.js +149 -0
  57. data/app/assets/javascripts/cantango_editor/jquery.cookie.js +96 -0
  58. data/app/assets/javascripts/cantango_editor/jquery.ui/jquery-ui-1.8.16.custom.js +996 -0
  59. data/app/assets/javascripts/cantango_editor/jquery.ui/jquery.ui.selectmenu.js +802 -0
  60. data/app/assets/stylesheets/cantango_editor/.main.css +157 -0
  61. data/app/assets/stylesheets/cantango_editor/application.css +7 -0
  62. data/app/assets/stylesheets/cantango_editor/areset.css +53 -0
  63. data/app/assets/stylesheets/cantango_editor/clearing.css +52 -0
  64. data/app/assets/stylesheets/cantango_editor/jquery-ui-1.8.16.custom.css +290 -0
  65. data/app/assets/stylesheets/cantango_editor/jquery.ui.selectmenu.css +30 -0
  66. data/app/assets/stylesheets/cantango_editor/main.css +294 -0
  67. data/app/assets/stylesheets/cantango_editor/text.css +97 -0
  68. data/app/controllers/cantango_editor/application_controller.rb +12 -0
  69. data/app/controllers/cantango_editor/permissions_controller.rb +47 -0
  70. data/app/helpers/cantango_editor/application_helper.rb +49 -0
  71. data/app/models/cantango_editor/categories.rb +52 -0
  72. data/app/models/cantango_editor/category.rb +21 -0
  73. data/app/models/cantango_editor/permissions.rb +119 -0
  74. data/app/views/cantango_editor/permissions/_footer.html.erb +4 -0
  75. data/app/views/cantango_editor/permissions/_header.html.erb +7 -0
  76. data/app/views/cantango_editor/permissions/_menu.html.erb +7 -0
  77. data/app/views/cantango_editor/permissions/_new_categories_select.html.erb +5 -0
  78. data/app/views/cantango_editor/permissions/_new_custom_targets.html.erb +5 -0
  79. data/app/views/cantango_editor/permissions/_new_targets_select.html.erb +5 -0
  80. data/app/views/cantango_editor/permissions/_permissions_form.html.erb +63 -0
  81. data/app/views/cantango_editor/permissions/index.html.erb +5 -0
  82. data/app/views/cantango_editor/permissions/index.js.erb +2 -0
  83. data/app/views/cantango_editor/permissions/new_category.js.erb +3 -0
  84. data/app/views/cantango_editor/permissions/new_custom_target.js.erb +2 -0
  85. data/app/views/cantango_editor/permissions/new_target.js.erb +4 -0
  86. data/app/views/cantango_editor/permissions/notes.html.erb +19 -0
  87. data/app/views/cantango_editor/permissions/preview_raw.html.erb +3 -0
  88. data/app/views/cantango_editor/permissions/temp _permissions_form.html.erb +55 -0
  89. data/app/views/layouts/cantango_editor/application.html.erb +14 -0
  90. data/cantango_editor.gemspec +258 -0
  91. data/config/routes.rb +15 -0
  92. data/lib/array.rb +11 -0
  93. data/lib/cantango_editor.rb +25 -0
  94. data/lib/cantango_editor/configuration.rb +34 -0
  95. data/lib/cantango_editor/engine.rb +11 -0
  96. data/lib/cantango_editor/version.rb +3 -0
  97. data/lib/permissions_hash.rb +80 -0
  98. data/lib/tasks/cantango-editor_tasks.rake +4 -0
  99. data/lib/time_precise.rb +7 -0
  100. data/script/rails +6 -0
  101. data/spec/cantango_editor/configuration/configuration_spec.rb +33 -0
  102. data/spec/cantango_editor/models/permissions_spec.rb +9 -0
  103. data/spec/cantango_editor_spec.rb +17 -0
  104. data/spec/dummy/Rakefile +7 -0
  105. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  106. data/spec/dummy/app/assets/javascripts/main.js +2 -0
  107. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  108. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  109. data/spec/dummy/app/controllers/main_controller.rb +5 -0
  110. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  111. data/spec/dummy/app/helpers/main_helper.rb +2 -0
  112. data/spec/dummy/app/mailers/.gitkeep +0 -0
  113. data/spec/dummy/app/models/.gitkeep +0 -0
  114. data/spec/dummy/app/models/admin.rb +5 -0
  115. data/spec/dummy/app/models/article.rb +2 -0
  116. data/spec/dummy/app/models/comment.rb +2 -0
  117. data/spec/dummy/app/models/concerto.rb +2 -0
  118. data/spec/dummy/app/models/guest.rb +14 -0
  119. data/spec/dummy/app/models/improvisation.rb +2 -0
  120. data/spec/dummy/app/models/post.rb +2 -0
  121. data/spec/dummy/app/models/song.rb +2 -0
  122. data/spec/dummy/app/models/tune.rb +2 -0
  123. data/spec/dummy/app/models/user.rb +11 -0
  124. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  125. data/spec/dummy/app/views/main/index.html.erb +3 -0
  126. data/spec/dummy/config.ru +4 -0
  127. data/spec/dummy/config/application.rb +53 -0
  128. data/spec/dummy/config/boot.rb +10 -0
  129. data/spec/dummy/config/categories.yml +10 -0
  130. data/spec/dummy/config/database.yml +25 -0
  131. data/spec/dummy/config/environment.rb +5 -0
  132. data/spec/dummy/config/environments/development.rb +30 -0
  133. data/spec/dummy/config/environments/production.rb +60 -0
  134. data/spec/dummy/config/environments/test.rb +39 -0
  135. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  136. data/spec/dummy/config/initializers/cantango.rb +4 -0
  137. data/spec/dummy/config/initializers/cantango_editor.rb +4 -0
  138. data/spec/dummy/config/initializers/devise.rb +210 -0
  139. data/spec/dummy/config/initializers/inflections.rb +10 -0
  140. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  141. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  142. data/spec/dummy/config/initializers/session_store.rb +8 -0
  143. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  144. data/spec/dummy/config/locales/devise.en.yml +58 -0
  145. data/spec/dummy/config/locales/en.yml +5 -0
  146. data/spec/dummy/config/permissions.yml.save +59 -0
  147. data/spec/dummy/config/routes.rb +15 -0
  148. data/spec/dummy/db/development.sqlite3 +0 -0
  149. data/spec/dummy/db/migrate/20111018203622_create_posts.rb +9 -0
  150. data/spec/dummy/db/migrate/20111018203648_create_articles.rb +9 -0
  151. data/spec/dummy/db/migrate/20111018203800_create_comments.rb +9 -0
  152. data/spec/dummy/db/migrate/20111018203817_create_songs.rb +9 -0
  153. data/spec/dummy/db/migrate/20111018203827_create_tunes.rb +9 -0
  154. data/spec/dummy/db/migrate/20111018203859_create_concertos.rb +9 -0
  155. data/spec/dummy/db/migrate/20111018203917_create_improvisations.rb +9 -0
  156. data/spec/dummy/db/migrate/20111019122217_devise_create_users.rb +28 -0
  157. data/spec/dummy/db/schema.rb +58 -0
  158. data/spec/dummy/db/test.sqlite3 +0 -0
  159. data/spec/dummy/lib/assets/.gitkeep +0 -0
  160. data/spec/dummy/log/.gitkeep +0 -0
  161. data/spec/dummy/public/404.html +26 -0
  162. data/spec/dummy/public/422.html +26 -0
  163. data/spec/dummy/public/500.html +26 -0
  164. data/spec/dummy/public/favicon.ico +0 -0
  165. data/spec/dummy/script/rails +6 -0
  166. data/spec/integration/navigation_spec.rb +18 -0
  167. data/spec/permissions_hash_spec.rb +63 -0
  168. data/spec/requests/requests_spec.rb +9 -0
  169. data/spec/spec_helper.rb +16 -0
  170. metadata +416 -0
@@ -0,0 +1,49 @@
1
+ module CantangoEditor
2
+ module ApplicationHelper
3
+
4
+ def model_tag model
5
+ case model
6
+ when regex = /\/(.*)\//
7
+ model = model[regex][$1]
8
+ slash_tag = content_tag :span, '/', :class => "model_regex_slash"
9
+ modeltag = content_tag :span, model, :class => "model_regex"
10
+ slash_tag + modeltag + slash_tag
11
+ when regex = /^\^(\w+)/ # a category is prefixed with a '^<D-^>s'
12
+ model = model[regex][$1]
13
+ model = model.humanize
14
+
15
+ # TODO: category aliases here
16
+ content_tag :span, "`#{model}`", :class => "model_category"
17
+ when regex = /\w+#\w+=.+/
18
+ match = model[/(\w+)#(\w+)=(.+)/]
19
+ model = match[$1]
20
+ lstat = match[$2]
21
+ rstat = match[$3]
22
+
23
+ lstat_tag = content_tag :span, lstat, :class => "model_relationship_lstat"
24
+ rstat_tag = content_tag :span, rstat, :class => "model_relationship_rstat"
25
+ modeltag = content_tag :span, model, :class => "model_relationship_model"
26
+ equals_tag = content_tag :span, '=', :class => "model_relationship_equals"
27
+ sharp_tag = content_tag :span, '#', :class => "model_relationship_sharp"
28
+
29
+ modeltag + sharp_tag + lstat_tag + equals_tag + rstat_tag
30
+
31
+ when regex = /\w+#\w+/
32
+ match = model[/(\w+)#(\w+)/]
33
+ model = match[$1]
34
+ owner = match[$2]
35
+
36
+ modeltag = content_tag :span, model, :class => "model_ownership_model"
37
+ owner_tag = content_tag :span, owner, :class => "model_ownership_owner"
38
+ sharp_tag = content_tag :span, '#', :class => "model_ownership_sharp"
39
+
40
+ modeltag + sharp_tag + owner_tag
41
+ else
42
+ model
43
+ end
44
+ end
45
+
46
+ private
47
+
48
+ end
49
+ end
@@ -0,0 +1,52 @@
1
+ module CantangoEditor
2
+ module Categories
3
+ extend self
4
+
5
+ attr_accessor :available
6
+
7
+ def available_except existing_targets = []
8
+ available.select{|c| (available_names - existing_targets).include? c.name}
9
+ end
10
+
11
+ def available_names
12
+ available.map{|c| c.name}
13
+ end
14
+
15
+ def available
16
+ yml_file_content.inject([]) do |categories, (category, targets)|
17
+ categories << Category.new(category, targets)
18
+ end
19
+ end
20
+
21
+ def yml_file_content
22
+ yml_content = YAML.load_file(categories_file)
23
+ validate_content yml_content
24
+
25
+ yml_content || {}
26
+ rescue => e
27
+ raise e
28
+ end
29
+
30
+ def validate_content content
31
+ end
32
+
33
+ def categories_file
34
+ create_empty_categories_file if !File.file? categories_file_path
35
+
36
+ categories_file_path
37
+ end
38
+
39
+ def create_empty_categories_file
40
+ File.open(categories_file_path, 'w') do |file|
41
+ YAML.dump({}, file)
42
+ end
43
+
44
+ categories_file_path
45
+ end
46
+
47
+ def categories_file_path
48
+ File.join Rails.root + "config/" + "categories.yml"
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,21 @@
1
+ module CantangoEditor
2
+ class Category
3
+
4
+ attr_reader :name
5
+
6
+ # TODO: Should we opt aliases in the categories.yml?
7
+
8
+ def initialize category_name, targets_string
9
+ @category_name = category_name
10
+ #@targets = targets_string
11
+ end
12
+
13
+ def name
14
+ "^" << @category_name
15
+ end
16
+
17
+ def human_name
18
+ name.gsub(/\^/,'').humanize
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,119 @@
1
+ module CantangoEditor
2
+ class Permissions
3
+ class << self
4
+
5
+ attr_accessor :permissions
6
+
7
+ configuration_methods = [ :models_available,
8
+ :permission_types_available,
9
+ :permission_groups_available,
10
+ :actions_available ]
11
+
12
+ delegate *configuration_methods, :to => :configuration
13
+
14
+ def configuration
15
+ CantangoEditor::Configuration
16
+ end
17
+
18
+ def models_available_names
19
+ models_available.map(&:name).unshift "all"
20
+ end
21
+
22
+ def permission_types_nil_hash
23
+ permission_types_available.inject({}) do |result_hash, pt|
24
+ roles_hash = (permission_groups_available[pt] || []).inject({}) do |rh, r|
25
+ rh.merge({r.to_s => nil})
26
+ end
27
+
28
+ result_hash.merge!({pt.to_s => roles_hash})
29
+ end
30
+ end
31
+
32
+ def permissions
33
+ @permissions ||= yml_file_content
34
+ end
35
+
36
+ def update_permissions! params
37
+ save_new_permissions params[:new_permissions]
38
+ remove_and_save_permissions params[:delete_permissions]
39
+ end
40
+
41
+ def update_new_permissions permissions_hash
42
+ permissions.deep_merge_permissions! permissions_hash
43
+ end
44
+
45
+ def update_remove_permissions permissions_hash
46
+ permissions.deep_remove_permissions! permissions_hash
47
+ end
48
+
49
+ def remove_and_save_permissions permissions_hash
50
+ return unless permissions_hash
51
+
52
+ update_remove_permissions permissions_hash
53
+ persist_permissions!
54
+ end
55
+
56
+ def save_new_permissions permissions_hash
57
+ return unless permissions_hash
58
+
59
+ update_new_permissions permissions_hash
60
+ persist_permissions!
61
+ end
62
+
63
+ def persist_permissions!
64
+
65
+ yml = YAML.dump(permissions)
66
+
67
+ # Sanitize permissions hash
68
+ yml.gsub!(/\!map.*\s/,"\n")
69
+
70
+ File.open(permissions_file, 'w') do |out|
71
+ out.write yml
72
+ end
73
+ end
74
+
75
+ def raw_file_content
76
+ raw_content = ""
77
+ File.open(permissions_file, 'r') do |f|
78
+ raw_content = f.read
79
+ end
80
+
81
+ raw_content
82
+ rescue => e
83
+ raise e
84
+ end
85
+
86
+ def yml_file_content
87
+ yml_content = YAML.load_file(permissions_file)
88
+ validate_content yml_content
89
+
90
+ PermissionsHash[yml_content]
91
+ rescue => e
92
+ raise e
93
+ end
94
+
95
+ def validate_content yml_content
96
+ raise "#{permissions_file} should contain Hash-based information" unless yml_content.is_a?(Hash)
97
+ raise "#{permissions_file} should not contain permission_types not listed in #permission_types_available" if (yml_content.keys - permission_types_available.to_strings).size > 0
98
+ end
99
+
100
+ def permissions_file
101
+ create_empty_permissions_file if !File.file? permissions_file_path
102
+
103
+ permissions_file_path
104
+ end
105
+
106
+ def create_empty_permissions_file
107
+ File.open(permissions_file_path, 'w') do |file|
108
+ YAML.dump(permission_types_nil_hash, file)
109
+ end
110
+
111
+ permissions_file_path
112
+ end
113
+
114
+ def permissions_file_path
115
+ File.join Rails.root + "config/" + "permissions.yml"
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,4 @@
1
+ <div class="footer">
2
+ <div class="remember">Remember: in CanTango rules are logically OR’ed!</div>
3
+ <div class="logo"></div>
4
+ </div>
@@ -0,0 +1,7 @@
1
+ <div class="header">
2
+ <div class="header-l"></div>
3
+ <h1><%= link_to app_name, main_app.root_path %> <span><%= link_to "Permissions", permissions_path %></span></h1>
4
+ <div class="header-r"></div>
5
+ <%= render :partial => 'menu' %>
6
+ </div>
7
+
@@ -0,0 +1,7 @@
1
+ <ul class="topmenu">
2
+ <li>
3
+ <%= link_to preview_raw_permissions_path, :target => "_blank" do %>
4
+ <b>Preview</b> raw permissions.yml
5
+ <% end %>
6
+ </li>
7
+ </ul>
@@ -0,0 +1,5 @@
1
+ <div class="models_select_block">
2
+ <%= select("new_permissions", "select", @new_categories_available.map{|p| [ p.human_name, p.name ] }, { :include_blank => false, :prompt => "Choose a category" }, {:name => "new_permissions[#{@ptype}][#{@pgroup}][#{@can_action}][#{@crud_action}][]", :class => "models_select"} ) %>
3
+
4
+ <%= link_to "", "#", :class => "models_select_close_link" %>
5
+ </div>
@@ -0,0 +1,5 @@
1
+ <div class="models_select_block">
2
+ <%= text_field_tag "new_permissions", nil, {:name => "new_permissions[#{@ptype}][#{@pgroup}][#{@can_action}][#{@crud_action}][]", :class => "models_select"} %>
3
+
4
+ <%= link_to "", "#", :class => "models_select_close_link" %>
5
+ </div>
@@ -0,0 +1,5 @@
1
+ <div class="models_select_block">
2
+ <%= select("new_permissions", "select", @new_targets_available.map{|p| [ p, p ] }, { :include_blank => false, :prompt => "Choose a model" }, {:name => "new_permissions[#{@ptype}][#{@pgroup}][#{@can_action}][#{@crud_action}][]", :class => "models_select"} ) %>
3
+
4
+ <%= link_to "", "#", :class => "models_select_close_link" %>
5
+ </div>
@@ -0,0 +1,63 @@
1
+ <%= form_tag permissions_path, :class => 'permissions_form', :remote => true, :method => :post do %>
2
+ <!-- submit_tag -->
3
+
4
+ <% @permission_types.each do |ptype| %>
5
+
6
+ <h2 class="permissions_type"><%= ptype %>:</h2>
7
+
8
+ <% (@permission_groups[ptype] || []).each do |pgroup| %>
9
+
10
+ <div class="permission_group_section wrapper">
11
+
12
+ <h3><%= pgroup %></h3>
13
+
14
+ <div class="section_line_wr">
15
+ <div class="section_line">
16
+ <div class="section_h_action"></div>
17
+ <div class="section_h_can"><b>can</b></div>
18
+ <div class="section_h_cannot"><b>cannot</b></div>
19
+ </div>
20
+
21
+ <% @actions.each do |crud_action| %>
22
+ <div class="section_line">
23
+ <div class="section_line_action">
24
+ <%= crud_action %>
25
+ </div>
26
+
27
+ <% [:can, :cannot].each do |can_action| %>
28
+ <div class="section_line_null"></div>
29
+ <div class="section_line_<%= can_action %> models_cell">
30
+ <div class="models_ololo">
31
+ <% (targets = @permissions[ptype][pgroup][can_action][crud_action]).each do |model| %>
32
+ <div class="models_line <%= (targets.first? model) ? "first" : "" %> <%= (targets.last? model) ? "last" : "" %>">
33
+ <%= model_tag model %>
34
+ <span class="delete_target_section">
35
+ <%= hidden_field_tag "delete_target_field", model, :class => "delete_target_field", :name => "delete_permissions[#{ptype}][#{pgroup}][#{can_action}][#{crud_action}][]", :disabled => "disabled" %>
36
+ <%= link_to "", "#", :class => "delete_target_link" %>
37
+ </span>
38
+ </div>
39
+ <div class="clearfix"></div>
40
+ <% end %>
41
+ </div>
42
+ <div id="new_target_area" class="new_target_area"> </div>
43
+ <div class="sexy_buttons">
44
+ <%= link_to "", new_target_permissions_path(:ptype => ptype, :pgroup => pgroup, :can_action => can_action, :crud_action => crud_action, :existing_targets => targets), :remote => true, :class => "new_target_link add_model" %>
45
+ <%= link_to "", new_category_permissions_path(:ptype => ptype, :pgroup => pgroup, :can_action => can_action, :crud_action => crud_action, :existing_targets => targets), :remote => true, :class => "new_target_link add_category" %>
46
+ <%= link_to "", new_custom_target_permissions_path(:ptype => ptype, :pgroup => pgroup, :can_action => can_action, :crud_action => crud_action, :existing_targets => targets), :remote => true, :class => "new_target_link add_custom" %>
47
+ </div>
48
+ </div>
49
+ <% end %>
50
+ </div>
51
+ <div class="clearfix"></div>
52
+
53
+ <% end %>
54
+
55
+ </div>
56
+ </div>
57
+
58
+ <% end %>
59
+
60
+ <% end %>
61
+
62
+ <% end %>
63
+
@@ -0,0 +1,5 @@
1
+ <%= render :partial => "header" %>
2
+
3
+ <%= render :partial => 'permissions_form' %>
4
+
5
+ <%= render :partial => "footer" %>
@@ -0,0 +1,2 @@
1
+ $('form').replaceWith('<%= escape_javascript(render :partial => "permissions_form") %>')
2
+
@@ -0,0 +1,3 @@
1
+ $('.link_processing').parents('.sexy_buttons').prev().html('<%= escape_javascript(render :partial => "new_categories_select") %>');
2
+ $('.link_processing').parents('.sexy_buttons').prev().children('.models_select_block').children('.models_select').trigger('ajaxLoad');
3
+ $('.link_processing').removeClass("link_processing");
@@ -0,0 +1,2 @@
1
+ $('.link_processing').parents('.sexy_buttons').prev().html('<%= escape_javascript(render :partial => "new_custom_targets") %>');
2
+ $('.link_processing').removeClass("link_processing");
@@ -0,0 +1,4 @@
1
+ $('.link_processing').parents('.sexy_buttons').prev().html('<%= escape_javascript(render :partial => "new_targets_select") %>');
2
+ $('.link_processing').parents('.sexy_buttons').prev().children('.models_select_block').children('.models_select').trigger('ajaxLoad');
3
+
4
+ $('.link_processing').removeClass("link_processing");
@@ -0,0 +1,19 @@
1
+ <%= render :partial => 'header' %>
2
+
3
+ <br/>
4
+
5
+ TODO:
6
+ <ul>
7
+ <li>Validations - client- or server-side?</li>
8
+ <li>Extract loader from permissions - use it then by Permissions and Categories</li>
9
+ <li style="text-decoration: line-through">Categories - load from yml</li>
10
+ <li>Configuration class proxying to Cantango's one</li>
11
+ <li style="text-decoration: line-through;">Styles by @mettta</li>
12
+ <li>
13
+ Categories - Possible convention for categories (prefixed with "^"): ^complex_music - "Complex music" as its human readable alias! (#humanize)
14
+ </li>
15
+ </ul>
16
+
17
+
18
+ And here are possible Cantango logos (updated oct, 31's night ;))
19
+ <div class="logobig"></div><div class="logobig2"></div><div class="logobig3"></div>
@@ -0,0 +1,3 @@
1
+ <%= content_tag :pre do %>
2
+ <%= @permissions_content %>
3
+ <% end %>
@@ -0,0 +1,55 @@
1
+ <%= form_tag permissions_path, :class => 'permissions_form', :remote => true, :method => :post do %>
2
+ <!-- submit_tag -->
3
+
4
+ <% @permissions_types.each do |ptype| %>
5
+
6
+ <h2 class="permissions_type"><%= ptype %>:</h2>
7
+
8
+ <% @permissions_groups[ptype].each do |pgroup| %>
9
+
10
+ <div class="permission_group_section wrapper">
11
+
12
+ <h3><%= pgroup %></h3>
13
+
14
+ <div class="section_line_wr">
15
+ <div class="section_h_action"></div>
16
+ <div class="section_h_can"><b>can</b></div>
17
+ <div class="section_h_cannot"><b>cannot</b></div>
18
+ <div class="clearfix"></div>
19
+
20
+ <% @actions.each do |crud_action| %>
21
+
22
+ <div class="section_line_action">
23
+ <%= crud_action %>
24
+ </div>
25
+ <% [:can, :cannot].each do |can_action| %>
26
+ <div class="section_line_<%= can_action %> models_cell">
27
+ <% (targets = @permissions[ptype][pgroup][can_action][crud_action]).each do |model| %>
28
+ <%= model_tag model %>
29
+ &nbsp;
30
+ <!-- TODO: Options for applying '//', '^' or others to given model -->
31
+ <!--small>- more options -</small-->
32
+ <span class="delete_target_section">
33
+ <%= hidden_field_tag "delete_target_field", model, :class => "delete_target_field", :name => "delete_permissions[#{ptype}][#{pgroup}][#{can_action}][#{crud_action}][]", :disabled => "disabled" %>
34
+ <%= link_to "x", "#", :class => "delete_target_link" %>
35
+ </span>
36
+ <br/>
37
+ <% end %>
38
+ <div id="new_target_area"></div>
39
+ <%= link_to "+model", new_target_permissions_path(:ptype => ptype, :pgroup => pgroup, :can_action => can_action, :crud_action => crud_action, :existing_targets => targets), :remote => true, :class => "new_target_link" %>
40
+ <%= link_to "+category", new_category_permissions_path(:ptype => ptype, :pgroup => pgroup, :can_action => can_action, :crud_action => crud_action, :existing_targets => targets), :remote => true, :class => "new_target_link" %>
41
+ <%= link_to "+custom", new_custom_target_permissions_path(:ptype => ptype, :pgroup => pgroup, :can_action => can_action, :crud_action => crud_action, :existing_targets => targets), :remote => true, :class => "new_target_link" %>
42
+ </div>
43
+ <% end %>
44
+ <div class="clearfix"></div>
45
+ <% end %>
46
+
47
+ </div>
48
+ </div>
49
+
50
+ <% end %>
51
+
52
+ <% end %>
53
+
54
+ <% end %>
55
+