esp-auth 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +28 -0
  3. data/Rakefile +28 -0
  4. data/app/assets/images/esp_auth/gh_icons.png +0 -0
  5. data/app/assets/images/esp_auth/inline_error_arrow.png +0 -0
  6. data/app/assets/images/esp_auth/wood.jpg +0 -0
  7. data/app/assets/javascripts/esp_auth/application.js +4 -0
  8. data/app/assets/javascripts/esp_auth/jquery.noisy.min.js +3 -0
  9. data/app/assets/javascripts/esp_auth/permissions.js +62 -0
  10. data/app/assets/stylesheets/esp_auth/application.css +11 -0
  11. data/app/assets/stylesheets/esp_auth/buttons.sass +300 -0
  12. data/app/assets/stylesheets/esp_auth/jquery_ui.sass +1493 -0
  13. data/app/assets/stylesheets/esp_auth/pagination.sass +19 -0
  14. data/app/assets/stylesheets/esp_auth/permissions.sass +150 -0
  15. data/app/assets/stylesheets/esp_auth/shared.sass +84 -0
  16. data/app/controllers/esp_auth/application_controller.rb +11 -0
  17. data/app/controllers/esp_auth/omniauth_callbacks_controller.rb +11 -0
  18. data/app/controllers/esp_auth/permissions_controller.rb +13 -0
  19. data/app/controllers/esp_auth/sessions_controller.rb +16 -0
  20. data/app/controllers/esp_auth/users_controller.rb +24 -0
  21. data/app/models/user_search.rb +13 -0
  22. data/app/views/esp_auth/permissions/new.html.erb +23 -0
  23. data/app/views/esp_auth/shared/_footer.html.erb +12 -0
  24. data/app/views/esp_auth/shared/_header.html.erb +24 -0
  25. data/app/views/esp_auth/users/index.html.erb +53 -0
  26. data/app/views/layouts/esp_auth/application.html.erb +18 -0
  27. data/config/initializers/devise.rb +223 -0
  28. data/config/locales/ru.yml +35 -0
  29. data/config/routes.rb +25 -0
  30. data/lib/esp-auth.rb +19 -0
  31. data/lib/esp_auth/engine.rb +41 -0
  32. data/lib/esp_auth/spec_helper.rb +68 -0
  33. data/lib/esp_auth/version.rb +3 -0
  34. data/lib/generators/esp_auth/install/install_generator.rb +49 -0
  35. data/lib/generators/esp_auth/install/templates/app/controllers/manage/application_controller.rb +3 -0
  36. data/lib/generators/esp_auth/install/templates/app/models/ability.rb +41 -0
  37. data/lib/generators/esp_auth/install/templates/app/models/context.rb +27 -0
  38. data/lib/generators/esp_auth/install/templates/app/models/permission.rb +69 -0
  39. data/lib/generators/esp_auth/install/templates/app/models/subcontext.rb +21 -0
  40. data/lib/generators/esp_auth/install/templates/app/models/user.rb +67 -0
  41. data/lib/generators/esp_auth/install/templates/config/locales/permissions_enum.ru.yml +6 -0
  42. data/lib/generators/esp_auth/install/templates/config/schedule.rb +5 -0
  43. data/lib/generators/esp_auth/install/templates/db/migrate/esp_auth_create_contexts.rb +12 -0
  44. data/lib/generators/esp_auth/install/templates/db/migrate/esp_auth_create_permissions.rb +11 -0
  45. data/lib/generators/esp_auth/install/templates/db/migrate/esp_auth_create_subcontexts.rb +9 -0
  46. data/lib/generators/esp_auth/install/templates/db/migrate/esp_auth_create_users.rb +29 -0
  47. data/lib/generators/esp_auth/install/templates/db/seeds.rb +4 -0
  48. data/lib/generators/esp_auth/install/templates/spec/models/ability_spec.rb +83 -0
  49. data/lib/omniauth/strategies/identity.rb +15 -0
  50. data/lib/tasks/sync.rake +17 -0
  51. metadata +453 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,28 @@
1
+ = EspAuth
2
+
3
+ == Usage
4
+
5
+ Gemfile
6
+
7
+ gem 'esp-auth'
8
+
9
+ Layout
10
+
11
+ <body>
12
+ <%= render :partial => "esp_auth/shared/header" %>
13
+ ...
14
+ <%= yield %>
15
+ ...
16
+ <%= render :partial => "esp_auth/shared/footer" %>
17
+ </body>
18
+
19
+ Stylesheet
20
+
21
+ *= require ...
22
+ *= require esp_auth/shared // common styles
23
+ *= require custom_esp_auth // customize styles
24
+ */
25
+
26
+ == License
27
+
28
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'EspAuth'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+ Bundler::GemHelper.install_tasks
28
+
Binary file
@@ -0,0 +1,4 @@
1
+ //= require jquery
2
+ //= require jquery-ui
3
+ //= require jquery_ujs
4
+ //= require_tree .
@@ -0,0 +1,3 @@
1
+ (function(c){c.fn.noisy=function(b){var b=c.extend({},c.fn.noisy.defaults,b),d,h,a=!1;try{h="localStorage"in window&&window.localStorage!==null}catch(l){h=!1}window.JSON&&h&&(a=localStorage.getItem(window.JSON.stringify(b)));if(a)d=a;else{a=document.createElement("canvas");if(a.getContext){a.width=a.height=b.size;for(var i=a.getContext("2d"),e=i.createImageData(a.width,a.height),j=b.intensity*Math.pow(b.size,2),k=255*b.opacity;j--;){var f=~~(Math.random()*a.width),g=~~(Math.random()*a.height),f=(f+
2
+ g*e.width)*4,g=j%255;e.data[f]=g;e.data[f+1]=b.monochrome?g:~~(Math.random()*255);e.data[f+2]=b.monochrome?g:~~(Math.random()*255);e.data[f+3]=~~(Math.random()*k)}i.putImageData(e,0,0);d=a.toDataURL("image/png");if(d.indexOf("data:image/png")!=0||c.browser.msie&&c.browser.version.substr(0,1)<9&&d.length>32768)d=b.fallback}else d=b.fallback;window.JSON&&h&&localStorage.setItem(window.JSON.stringify(b),d)}return this.each(function(){c(this).css("background-image","url('"+d+"'),"+c(this).css("background-image"))})};
3
+ c.fn.noisy.defaults={intensity:0.9,size:200,opacity:0.08,fallback:"",monochrome:!1}})(jQuery);
@@ -0,0 +1,62 @@
1
+ //= require esp_auth/jquery.noisy.min.js
2
+
3
+ $(function(){
4
+ $('.container').noisy({
5
+   'intensity' : 1,
6
+  'size' : 200,
7
+   'opacity' : 0.08,
8
+   'fallback' : '',
9
+   'monochrome' : false
10
+ });
11
+
12
+ $('.show_permissions').click(function(){
13
+ var $this = $(this);
14
+ var this_permission_list = $this.parent().next('.permission_list');
15
+
16
+ $('.permission_list').not(this_permission_list).slideUp();
17
+ $('.show_permissions').not($this).removeClass('active').html('&darr;&nbsp;Показать права доступа');
18
+
19
+ this_permission_list.slideToggle('slow',function(){
20
+ if ($(this).is(':visible')) {
21
+ $this.addClass('active').html('&uarr;&nbsp;Скрыть права доступа');
22
+ }else{
23
+ $this.removeClass('active').html('&darr;&nbsp;Показать права доступа');
24
+ };
25
+ });
26
+
27
+ return false;
28
+ });
29
+
30
+ $('#permission_user_search').autocomplete({
31
+ source: function( request, response ) {
32
+ $.ajax({
33
+ url: '/auth/users/search?term='+$('#permission_user_search').val(),
34
+ dataType: "json",
35
+ data: request.term,
36
+ success: function(data) {
37
+ response($.map(data, function(item){
38
+ var item_label = item.name
39
+
40
+ if (item.email.length > 0) {
41
+ item_label += ' <' + item.email + '>'
42
+ }
43
+
44
+ return {
45
+ uid: item.uid,
46
+ label: item_label,
47
+ value: item_label,
48
+ name: item.name,
49
+ email: item.email
50
+ }
51
+ }));
52
+ }
53
+ })
54
+ },
55
+ minLength: 2,
56
+ select: function(event, ui){
57
+ $('#permission_user_uid').val(ui.item.uid);
58
+ $('#permission_user_name').val(ui.item.name);
59
+ $('#permission_user_email').val(ui.item.email);
60
+ }
61
+ });
62
+ });
@@ -0,0 +1,11 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require esp_auth/buttons
7
+ *= require esp_auth/jquery_ui
8
+ *= require esp_auth/pagination
9
+ *= require esp_auth/permissions
10
+ *= require esp_auth/shared
11
+ */
@@ -0,0 +1,300 @@
1
+ /* ------------------------------------------
2
+ *CSS3 GITHUB BUTTONS (Nicolas Gallagher)
3
+ *Licensed under Unlicense
4
+ *http://github.com/necolas/css3-github-buttons
5
+ *------------------------------------------
6
+ */
7
+
8
+ /* ------------------------------------------------------------------------------------------------------------- BUTTON
9
+ */
10
+
11
+ @import "compass/css3"
12
+
13
+ button.button,
14
+ input.button,
15
+ a.button,
16
+ #title_bar .action_items a // hack for manage
17
+ position: relative
18
+ overflow: visible
19
+ display: inline-block
20
+ padding: 5px 7px 4px 8px
21
+ border: 1px solid #d4d4d4
22
+ margin: 0
23
+ text-decoration: none
24
+ +single-text-shadow(#fff, 1px, 1px, 0)
25
+ font-family: Helvetica, Arial, Verdana, sans-serif
26
+ font-size: 11px
27
+ font-weight: normal
28
+ color: #333
29
+ white-space: nowrap
30
+ cursor: pointer
31
+ outline: none
32
+ background-color: #ececec
33
+ +background-image(linear-gradient(color-stops(#f4f4f4, #ececec)))
34
+ +background-clip(padding-box)
35
+ /*background-clip: padding-box;
36
+ /* commented out due to Opera 11.10 bug
37
+ +border-radius
38
+ /* IE hacks
39
+ zoom: 1
40
+ *display: inline
41
+ &:hover, &:focus, &:active, &.active
42
+ border-color: #3072b3
43
+ border-bottom-color: #2a65a0
44
+ text-decoration: none
45
+ +single-text-shadow(rgba(0, 0, 0, 0.3), -1px, -1px, 0)
46
+ color: #fff
47
+ background-color: #3C8DDE
48
+ +background-image(linear-gradient(color-stops(#599bdc, #3072b3)))
49
+ &:active, &.active
50
+ border-color: #2a65a0
51
+ border-bottom-color: #3884CF
52
+ background-color: #3072b3
53
+ +background-image(linear-gradient(color-stops(#3072b3, #599bdc)))
54
+ &::-moz-focus-inner
55
+ padding: 0
56
+ border: 0
57
+ &.icon:before
58
+ content: ""
59
+ position: relative
60
+ top: 1px
61
+ float: left
62
+ width: 12px
63
+ height: 12px
64
+ margin: 0 0.75em 0 -0.25em
65
+ background: image_url("esp_auth/gh_icons.png") 0 99px no-repeat
66
+ &.arrowup.icon
67
+ &:before
68
+ background-position: 0 0
69
+ &:hover:before, &:focus:before, &:active:before
70
+ background-position: -12px 0
71
+ &.arrowdown.icon
72
+ &:before
73
+ background-position: 0 -12px
74
+ &:hover:before, &:focus:before, &:active:before
75
+ background-position: -12px -12px
76
+ &.arrowleft.icon
77
+ &:before
78
+ background-position: 0 -24px
79
+ &:hover:before, &:focus:before, &:active:before
80
+ background-position: -12px -24px
81
+ &.arrowright.icon
82
+ &:before
83
+ float: right
84
+ margin: 0 -0.25em 0 0.5em
85
+ background-position: 0 -36px
86
+ &:hover:before, &:focus:before, &:active:before
87
+ background-position: -12px -36px
88
+ &.approve.icon
89
+ &:before
90
+ background-position: 0 -48px
91
+ &:hover:before, &:focus:before, &:active:before
92
+ background-position: -12px -48px
93
+ &.add.icon
94
+ &:before
95
+ background-position: 0 -288px
96
+ &:hover:before, &:focus:before, &:active:before
97
+ background-position: -12px -288px
98
+ &.remove.icon
99
+ &:before
100
+ background-position: 0 -60px
101
+ &:hover:before, &:focus:before, &:active:before
102
+ background-position: -12px -60px
103
+ &.log.icon
104
+ &:before
105
+ background-position: 0 -72px
106
+ &:hover:before, &:focus:before, &:active:before
107
+ background-position: -12px -72px
108
+ &.calendar.icon
109
+ &:before
110
+ background-position: 0 -84px
111
+ &:hover:before, &:focus:before, &:active:before
112
+ background-position: -12px -84px
113
+ &.chat.icon
114
+ &:before
115
+ background-position: 0 -96px
116
+ &:hover:before, &:focus:before, &:active:before
117
+ background-position: -12px -96px
118
+ &.clock.icon
119
+ &:before
120
+ background-position: 0 -108px
121
+ &:hover:before, &:focus:before, &:active:before
122
+ background-position: -12px -108px
123
+ &.settings.icon
124
+ &:before
125
+ background-position: 0 -120px
126
+ &:hover:before, &:focus:before, &:active:before
127
+ background-position: -12px -120px
128
+ &.comment.icon
129
+ &:before
130
+ background-position: 0 -132px
131
+ &:hover:before, &:focus:before, &:active:before
132
+ background-position: -12px -132px
133
+ &.fork.icon
134
+ &:before
135
+ background-position: 0 -144px
136
+ &:hover:before, &:focus:before, &:active:before
137
+ background-position: -12px -144px
138
+ &.like.icon
139
+ &:before
140
+ background-position: 0 -156px
141
+ &:hover:before, &:focus:before, &:active:before
142
+ background-position: -12px -156px
143
+ &.favorite.icon
144
+ &:before
145
+ background-position: 0 -348px
146
+ &:hover:before, &:focus:before, &:active:before
147
+ background-position: -12px -348px
148
+ &.home.icon
149
+ &:before
150
+ background-position: 0 -168px
151
+ &:hover:before, &:focus:before, &:active:before
152
+ background-position: -12px -168px
153
+ &.key.icon
154
+ &:before
155
+ background-position: 0 -180px
156
+ &:hover:before, &:focus:before, &:active:before
157
+ background-position: -12px -180px
158
+ &.lock.icon
159
+ &:before
160
+ background-position: 0 -192px
161
+ &:hover:before, &:focus:before, &:active:before
162
+ background-position: -12px -192px
163
+ &.unlock.icon
164
+ &:before
165
+ background-position: 0 -204px
166
+ &:hover:before, &:focus:before, &:active:before
167
+ background-position: -12px -204px
168
+ &.loop.icon
169
+ &:before
170
+ background-position: 0 -216px
171
+ &:hover:before, &:focus:before, &:active:before
172
+ background-position: -12px -216px
173
+ &.search.icon
174
+ &:before
175
+ background-position: 0 -228px
176
+ &:hover:before, &:focus:before, &:active:before
177
+ background-position: -12px -228px
178
+ &.mail.icon
179
+ &:before
180
+ background-position: 0 -240px
181
+ &:hover:before, &:focus:before, &:active:before
182
+ background-position: -12px -240px
183
+ &.move.icon
184
+ &:before
185
+ background-position: 0 -252px
186
+ &:hover:before, &:focus:before, &:active:before
187
+ background-position: -12px -252px
188
+ &.edit.icon
189
+ &:before
190
+ background-position: 0 -264px
191
+ &:hover:before, &:focus:before, &:active:before
192
+ background-position: -12px -264px
193
+ &.pin.icon
194
+ &:before
195
+ background-position: 0 -276px
196
+ &:hover:before, &:focus:before, &:active:before
197
+ background-position: -12px -276px
198
+ &.reload.icon
199
+ &:before
200
+ background-position: 0 -300px
201
+ &:hover:before, &:focus:before, &:active:before
202
+ background-position: -12px -300px
203
+ &.rss.icon
204
+ &:before
205
+ background-position: 0 -312px
206
+ &:hover:before, &:focus:before, &:active:before
207
+ background-position: -12px -312px
208
+ &.tag.icon
209
+ &:before
210
+ background-position: 0 -324px
211
+ &:hover:before, &:focus:before, &:active:before
212
+ background-position: -12px -324px
213
+ &.trash.icon
214
+ &:before
215
+ background-position: 0 -336px
216
+ &:hover:before, &:focus:before, &:active:before
217
+ background-position: -12px -336px
218
+ &.user.icon
219
+ &:before
220
+ background-position: 0 -360px
221
+ &:hover:before, &:focus:before, &:active:before
222
+ background-position: -12px -360px
223
+ &.primary
224
+ font-weight: bold
225
+ &.danger
226
+ color: #900
227
+ &:hover, &:focus
228
+ border-color: #b53f3a
229
+ border-bottom-color: #a0302a
230
+ color: #fff
231
+ background-color: #dc5f59
232
+ +background-image(linear-gradient(color-stops(#dc5f59, #b33630)))
233
+ &:active
234
+ color: #fff
235
+ border-color: #a0302a
236
+ border-bottom-color: #bf4843
237
+ background-color: #b33630
238
+ +background-image(linear-gradient(color-stops(#b33630, #dc5f59)))
239
+ &.active
240
+ border-color: #a0302a
241
+ border-bottom-color: #bf4843
242
+ background-color: #b33630
243
+ +background-image(linear-gradient(color-stops(#b33630, #dc5f59)))
244
+ &.pill
245
+ +border-radius(50em)
246
+ &.disable
247
+ opacity: 0.5
248
+ &.big
249
+ font-size: 14px
250
+ &.icon:before
251
+ top: 0
252
+
253
+ .button-group
254
+ display: inline-block
255
+ list-style: none
256
+ padding: 0
257
+ margin: 0
258
+ /* IE hacks
259
+ zoom: 1
260
+ *display: inline
261
+
262
+ .button +
263
+ .button, .button-group
264
+ margin-left: 15px
265
+
266
+ .button-group
267
+ +
268
+ .button, .button-group
269
+ margin-left: 15px
270
+ li
271
+ float: left
272
+ padding: 0
273
+ margin: 0
274
+ .button
275
+ float: left
276
+ margin-left: -1px
277
+ > .button:not(:first-child):not(:last-child), li:not(:first-child):not(:last-child) .button
278
+ +border-radius(0)
279
+ > .button:first-child, li:first-child .button
280
+ margin-left: 0
281
+ +border-top-right-radius(0)
282
+ +border-bottom-right-radius(0)
283
+ > .button:last-child, li:last-child > .button
284
+ +border-top-left-radius(0)
285
+ +border-bottom-left-radius(0)
286
+ &.minor-group .button
287
+ border: 1px solid #d4d4d4
288
+ +single-text-shadow(none)
289
+ background-image: none
290
+ background-color: #fff
291
+ &:hover, &:focus
292
+ background-color: #599bdc
293
+ &:active, &.active
294
+ background-color: #3072b3
295
+ &.icon:before
296
+ opacity: 0.8
297
+
298
+ .button-container
299
+ .button, .button-group
300
+ vertical-align: top