kryptonite 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/Gemfile +1 -0
  2. data/MIT-LICENSE +20 -0
  3. data/PUBLIC_VERSION.yml +4 -0
  4. data/README.rdoc +209 -0
  5. data/Rakefile +40 -0
  6. data/app/controllers/kryptonite/kryptonite_controller.rb +72 -0
  7. data/app/controllers/kryptonite/password_resets_controller.rb +66 -0
  8. data/app/controllers/kryptonite/user_sessions_controller.rb +40 -0
  9. data/app/controllers/kryptonite/users_controller.rb +102 -0
  10. data/app/helpers/kryptonite/kryptonite_helper.rb +200 -0
  11. data/app/mailers/kryptonite/kryptonite_notification.rb +39 -0
  12. data/app/models/kryptonite/user.rb +55 -0
  13. data/app/models/kryptonite/user_session.rb +8 -0
  14. data/app/views/kryptonite/kryptonite/blank.html.erb +1 -0
  15. data/app/views/kryptonite/kryptonite_notification/generate_new_password.erb +12 -0
  16. data/app/views/kryptonite/kryptonite_notification/new_user_information.erb +12 -0
  17. data/app/views/kryptonite/kryptonite_notification/password_reset_instructions.erb +11 -0
  18. data/app/views/kryptonite/password_resets/edit.html.erb +48 -0
  19. data/app/views/kryptonite/user_sessions/new.html.erb +66 -0
  20. data/app/views/kryptonite/users/index.html.erb +35 -0
  21. data/app/views/kryptonite/users/new.html.erb +46 -0
  22. data/app/views/kryptonite/users/show.html.erb +94 -0
  23. data/app/views/layouts/kryptonite_auth.html.erb +24 -0
  24. data/app/views/layouts/kryptonite_main.html.erb +67 -0
  25. data/config/routes.rb +20 -0
  26. data/lib/generators/kryptonite/install/USAGE +1 -0
  27. data/lib/generators/kryptonite/install/install_generator.rb +37 -0
  28. data/lib/generators/kryptonite/install/templates/app/helpers/kryptonite/config_helper.rb +46 -0
  29. data/lib/generators/kryptonite/install/templates/app/views/kryptonite/layouts/_left_navigation.html.erb +2 -0
  30. data/lib/generators/kryptonite/install/templates/app/views/kryptonite/layouts/_right_navigation.html.erb +1 -0
  31. data/lib/generators/kryptonite/install/templates/db/migrate/kryptonite_create_users.rb +30 -0
  32. data/lib/generators/kryptonite/install/templates/public/casein/javascripts/custom.js +2 -0
  33. data/lib/generators/kryptonite/install/templates/public/casein/stylesheets/custom.css +2 -0
  34. data/lib/generators/kryptonite/install/templates/public/robots.txt +5 -0
  35. data/lib/generators/kryptonite/scaffold/USAGE +1 -0
  36. data/lib/generators/kryptonite/scaffold/scaffold_generator.rb +99 -0
  37. data/lib/generators/kryptonite/scaffold/templates/controller.rb +60 -0
  38. data/lib/generators/kryptonite/scaffold/templates/migration.rb +13 -0
  39. data/lib/generators/kryptonite/scaffold/templates/model.rb +3 -0
  40. data/lib/generators/kryptonite/scaffold/templates/views/_form.html.erb +9 -0
  41. data/lib/generators/kryptonite/scaffold/templates/views/_table.html.erb +17 -0
  42. data/lib/generators/kryptonite/scaffold/templates/views/index.html.erb +11 -0
  43. data/lib/generators/kryptonite/scaffold/templates/views/new.html.erb +18 -0
  44. data/lib/generators/kryptonite/scaffold/templates/views/show.html.erb +18 -0
  45. data/lib/generators/kryptonite/update/USAGE +1 -0
  46. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/casein.png +0 -0
  47. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/header.png +0 -0
  48. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/icons/add.png +0 -0
  49. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/icons/delete.png +0 -0
  50. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/icons/table.png +0 -0
  51. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/login/alertBg.png +0 -0
  52. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/login/background.png +0 -0
  53. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/login/bottom.png +0 -0
  54. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/login/loginBoxBg.png +0 -0
  55. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/login/loginBoxBottom.png +0 -0
  56. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/login/loginBoxTop.png +0 -0
  57. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/login/loginSubmit.png +0 -0
  58. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/login/recoverSubmit.png +0 -0
  59. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/login/top.png +0 -0
  60. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/nav.png +0 -0
  61. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/rightNav.png +0 -0
  62. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/rightNavButton.png +0 -0
  63. data/lib/generators/kryptonite/update/templates/public/kryptonite/images/visitSiteNav.png +0 -0
  64. data/lib/generators/kryptonite/update/templates/public/kryptonite/javascripts/jquery.js +154 -0
  65. data/lib/generators/kryptonite/update/templates/public/kryptonite/javascripts/kryptonite.js +25 -0
  66. data/lib/generators/kryptonite/update/templates/public/kryptonite/javascripts/login.js +24 -0
  67. data/lib/generators/kryptonite/update/templates/public/kryptonite/javascripts/rails.js +132 -0
  68. data/lib/generators/kryptonite/update/templates/public/kryptonite/stylesheets/elements.css +307 -0
  69. data/lib/generators/kryptonite/update/templates/public/kryptonite/stylesheets/login.css +137 -0
  70. data/lib/generators/kryptonite/update/templates/public/kryptonite/stylesheets/screen.css +224 -0
  71. data/lib/generators/kryptonite/update/update_generator.rb +40 -0
  72. data/lib/kryptonite.rb +3 -0
  73. data/lib/kryptonite/engine.rb +22 -0
  74. data/lib/railties/tasks.rake +31 -0
  75. metadata +169 -0
@@ -0,0 +1,25 @@
1
+ jQuery(document).ready(function()
2
+ {
3
+ var contentHeight = Math.round(jQuery(window).height() - 130);
4
+
5
+ resizeContent(contentHeight);
6
+
7
+ window.onresize = function()
8
+ {
9
+ contentHeight = Math.round(jQuery(window).height() - 130);
10
+ resizeContent(contentHeight);
11
+ };
12
+
13
+ if(jQuery("#notice"))
14
+ {
15
+ setTimeout(function()
16
+ {
17
+ jQuery("#notice").fadeOut(500);
18
+ }, 20000);
19
+ };
20
+ });
21
+
22
+ resizeContent = function(newHeight)
23
+ {
24
+ jQuery("#content").css({"height": newHeight+"px"});
25
+ }
@@ -0,0 +1,24 @@
1
+ jQuery(document).ready(function()
2
+ {
3
+ if(jQuery("#notice"))
4
+ {
5
+ setTimeout(function()
6
+ {
7
+ jQuery("#notice").fadeOut(500);
8
+ }, 20000);
9
+ };
10
+ });
11
+
12
+ toggleDiv = function(div)
13
+ {
14
+ switch ($("#"+div).css('display'))
15
+ {
16
+ case "none":
17
+ $("#"+div).fadeIn(300);
18
+ break;
19
+
20
+ case "block":
21
+ $("#"+div).fadeOut(300);
22
+ break;
23
+ }
24
+ }
@@ -0,0 +1,132 @@
1
+ jQuery(function ($) {
2
+ var csrf_token = $('meta[name=csrf-token]').attr('content'),
3
+ csrf_param = $('meta[name=csrf-param]').attr('content');
4
+
5
+ $.fn.extend({
6
+ /**
7
+ * Triggers a custom event on an element and returns the event result
8
+ * this is used to get around not being able to ensure callbacks are placed
9
+ * at the end of the chain.
10
+ *
11
+ * TODO: deprecate with jQuery 1.4.2 release, in favor of subscribing to our
12
+ * own events and placing ourselves at the end of the chain.
13
+ */
14
+ triggerAndReturn: function (name, data) {
15
+ var event = new $.Event(name);
16
+ this.trigger(event, data);
17
+
18
+ return event.result !== false;
19
+ },
20
+
21
+ /**
22
+ * Handles execution of remote calls firing overridable events along the way
23
+ */
24
+ callRemote: function () {
25
+ var el = this,
26
+ method = el.attr('method') || el.attr('data-method') || 'GET',
27
+ url = el.attr('action') || el.attr('href'),
28
+ dataType = el.attr('data-type') || 'script';
29
+
30
+ if (url === undefined) {
31
+ throw "No URL specified for remote call (action or href must be present).";
32
+ } else {
33
+ if (el.triggerAndReturn('ajax:before')) {
34
+ var data = el.is('form') ? el.serializeArray() : [];
35
+ $.ajax({
36
+ url: url,
37
+ data: data,
38
+ dataType: dataType,
39
+ type: method.toUpperCase(),
40
+ beforeSend: function (xhr) {
41
+ el.trigger('ajax:loading', xhr);
42
+ },
43
+ success: function (data, status, xhr) {
44
+ el.trigger('ajax:success', [data, status, xhr]);
45
+ },
46
+ complete: function (xhr) {
47
+ el.trigger('ajax:complete', xhr);
48
+ },
49
+ error: function (xhr, status, error) {
50
+ el.trigger('ajax:failure', [xhr, status, error]);
51
+ }
52
+ });
53
+ }
54
+
55
+ el.trigger('ajax:after');
56
+ }
57
+ }
58
+ });
59
+
60
+ /**
61
+ * confirmation handler
62
+ */
63
+ $('a[data-confirm],input[data-confirm]').live('click', function () {
64
+ var el = $(this);
65
+ if (el.triggerAndReturn('confirm')) {
66
+ if (!confirm(el.attr('data-confirm'))) {
67
+ return false;
68
+ }
69
+ }
70
+ });
71
+
72
+
73
+ /**
74
+ * remote handlers
75
+ */
76
+ $('form[data-remote]').live('submit', function (e) {
77
+ $(this).callRemote();
78
+ e.preventDefault();
79
+ });
80
+
81
+ $('a[data-remote],input[data-remote]').live('click', function (e) {
82
+ $(this).callRemote();
83
+ e.preventDefault();
84
+ });
85
+
86
+ $('a[data-method]:not([data-remote])').live('click', function (e){
87
+ var link = $(this),
88
+ href = link.attr('href'),
89
+ method = link.attr('data-method'),
90
+ form = $('<form method="post" action="'+href+'"></form>'),
91
+ metadata_input = '<input name="_method" value="'+method+'" type="hidden" />';
92
+
93
+ if (csrf_param != null && csrf_token != null) {
94
+ metadata_input += '<input name="'+csrf_param+'" value="'+csrf_token+'" type="hidden" />';
95
+ }
96
+
97
+ form.hide()
98
+ .append(metadata_input)
99
+ .appendTo('body');
100
+
101
+ e.preventDefault();
102
+ form.submit();
103
+ });
104
+
105
+ /**
106
+ * disable-with handlers
107
+ */
108
+ var disable_with_input_selector = 'input[data-disable-with]';
109
+ var disable_with_form_remote_selector = 'form[data-remote]:has(' + disable_with_input_selector + ')';
110
+ var disable_with_form_not_remote_selector = 'form:not([data-remote]):has(' + disable_with_input_selector + ')';
111
+
112
+ var disable_with_input_function = function () {
113
+ $(this).find(disable_with_input_selector).each(function () {
114
+ var input = $(this);
115
+ input.data('enable-with', input.val())
116
+ .attr('value', input.attr('data-disable-with'))
117
+ .attr('disabled', 'disabled');
118
+ });
119
+ };
120
+
121
+ $(disable_with_form_remote_selector).live('ajax:before', disable_with_input_function);
122
+ $(disable_with_form_not_remote_selector).live('submit', disable_with_input_function);
123
+
124
+ $(disable_with_form_remote_selector).live('ajax:complete', function () {
125
+ $(this).find(disable_with_input_selector).each(function () {
126
+ var input = $(this);
127
+ input.removeAttr('disabled')
128
+ .val(input.data('enable-with'));
129
+ });
130
+ });
131
+
132
+ });
@@ -0,0 +1,307 @@
1
+ /* KRYPTONITE */
2
+
3
+ .icon {
4
+ height: 16px;
5
+ width: 16px;
6
+ padding: 0px 9px 0px 9px;
7
+ display: block;
8
+ float: left;
9
+ }
10
+
11
+ .iconRow {
12
+ height: 16px;
13
+ width: 16px;
14
+ padding: 0px;
15
+ display: block;
16
+ float: left;
17
+ }
18
+
19
+ #content {
20
+ position: fixed;
21
+ font-size: 12px;
22
+ bottom: 0;
23
+ left: 0;
24
+ right: 318px;
25
+ background: #fff;
26
+ z-index: 10;
27
+ overflow: auto;
28
+ }
29
+
30
+ #content p {
31
+ font-size: 12px;
32
+ margin: 1em 0;
33
+ }
34
+
35
+ #data {
36
+ padding: 15px 25px 25px 25px;
37
+ }
38
+
39
+ #content h1 {
40
+ border-bottom: 2px solid #DDDDDD;
41
+ color: #111111;
42
+ font-size: 1.2em;
43
+ font-weight: normal;
44
+ margin: 0 0 15px 0;
45
+ padding: 0 0 5px 0;
46
+ }
47
+
48
+ #content h2, #preview h2 {
49
+ font-size: 15px;
50
+ font-weight: normal;
51
+ color: #111;
52
+ border-bottom: 2px solid #ddd;
53
+ padding: 0 0 5px 0;
54
+ margin: 0 0 15px 0;
55
+ position: relative;
56
+ }
57
+
58
+ #content h2 img, #preview h2 img {
59
+ position: absolute;
60
+ top: 0;
61
+ right: 0;
62
+ cursor: pointer;
63
+ }
64
+
65
+ #content .openFolder {
66
+ border-bottom: 1px solid #ddd;
67
+ background: url(/kryptonite/images/icons/folder.png) no-repeat center left;
68
+ font-weight: bold;
69
+ cursor: pointer;
70
+ }
71
+
72
+ #content .itemList {
73
+ width: 100%;
74
+ border-bottom: 3px solid #666;
75
+ }
76
+
77
+ #content .itemList .center {
78
+ text-align: center;
79
+ }
80
+
81
+ #content .itemList .icon {
82
+ width: 16px;
83
+ }
84
+
85
+ #content .itemList th {
86
+ text-align: left;
87
+ font-size: 11px;
88
+ padding: 7px 8px 6px 8px;
89
+ border-bottom: 3px solid #666;
90
+ }
91
+
92
+ #content .itemList th a {
93
+ color: #000;
94
+ }
95
+
96
+ #content .delete {
97
+ width: 16px;
98
+ height: 16px;
99
+ padding: 0px;
100
+ }
101
+
102
+ #content .delete a {
103
+ float: left;
104
+ padding: 0px;
105
+ }
106
+
107
+ #content .itemList td {
108
+ font-size: 11px;
109
+ color: #333;
110
+ border-bottom: 1px solid #ddd;
111
+ }
112
+
113
+ #content .itemList td a {
114
+ display: block;
115
+ padding: 9px 8px 7px 8px;
116
+ line-height: 11px;
117
+ color: #333;
118
+ text-decoration: none;
119
+ }
120
+
121
+ #content .itemList td div.noLink {
122
+ padding: 9px 8px 7px 8px;
123
+ }
124
+
125
+ #content .itemList tr.hover:hover {
126
+ background: #eee;
127
+ border-bottom: 1px solid #ccc;
128
+ cursor: pointer;
129
+ }
130
+
131
+ #content .even {
132
+ background: #e7edfc;
133
+ }
134
+
135
+ #content .tfContainer {
136
+ width: 45%;
137
+ min-height: 60px;
138
+ float: left;
139
+ padding: 0 5% 12px 0;
140
+ }
141
+
142
+ #content .tfContainer p {
143
+ margin: 0;
144
+ }
145
+
146
+ #content .tfContainer div {
147
+ float: left;
148
+ margin: 0 10px 0 0;
149
+ }
150
+
151
+ #content .tfContainer .kryptoniteDateSelectWrapper div {
152
+ float: none;
153
+ margin: 0px;
154
+ margin-top: 4px;
155
+ }
156
+
157
+ #content .tfContainerSecond {
158
+ padding: 0 0 12px 4%;
159
+ }
160
+
161
+ #content .tfContainerFullWidth {
162
+ width: 100%;
163
+ padding-right: 0px;
164
+ }
165
+
166
+ #content .help {
167
+ border-bottom: 5px solid #fce701;
168
+ background: #fff9bb;
169
+ padding: 12px 20px 8px 20px;
170
+ font-size: 12px;
171
+ color: #111111;
172
+ margin: 0 0 20px 0;
173
+ font-style: italic;
174
+ }
175
+
176
+ #content label {
177
+ font-size: 12px;
178
+ color: #333;
179
+ }
180
+
181
+ #content #error {
182
+ border-bottom: 5px solid #f48e8e;
183
+ background: #f7b7b7;
184
+ padding: 12px 20px 8px 20px;
185
+ font-size: 12px;
186
+ color: #801616;
187
+ margin: 0 0 20px 0;
188
+ }
189
+
190
+ #content #notice {
191
+ border-bottom: 5px solid #95ccef;
192
+ background: #d9ebf6;
193
+ padding: 12px 20px 8px 20px;
194
+ font-size: 12px;
195
+ color: #245574;
196
+ margin: 0 0 20px 0;
197
+ }
198
+
199
+ #content .tfContainer .kryptoniteTextField {
200
+ width: 100%;
201
+ font-size: 12px;
202
+ padding: 6px 0 5px 0;
203
+ margin: 3px 0 0 0;
204
+ }
205
+
206
+ .formError {
207
+ padding: 7px 0 0 0;
208
+ color: #801616;
209
+ }
210
+
211
+ .formError > input, .formError > textarea {
212
+ border: 1px solid #801616;
213
+ }
214
+
215
+ #content .extraOptions {
216
+ font-size: 11px;
217
+ padding: 10px 0;
218
+ cursor: pointer;
219
+ width: 100px;
220
+ }
221
+
222
+ #content .extras {
223
+ padding: 15px;
224
+ border-top: 2px solid #ddd;
225
+ border-bottom: 2px solid #ddd;
226
+ margin: 5px 0;
227
+ background: #eee;
228
+ position: relative;
229
+ }
230
+
231
+ #content .extras .checkboxOptions {
232
+ padding: 20px 0 20px 0;
233
+ font-size: 11px;
234
+ color: #222;
235
+ font-weight: bold;
236
+ }
237
+
238
+ #content .invalidForm {
239
+ color: #993333;
240
+ border: 1px solid #ff6666;
241
+ }
242
+
243
+ #content .tfContainer .kryptoniteSelect {
244
+ width: 100%;
245
+ margin: 5px 0 0 0;
246
+ }
247
+
248
+ #content .tfContainer .kryptoniteDateTimeSelect {
249
+ width: auto;
250
+ margin: 5px 0 0 0;
251
+ }
252
+
253
+ #content .tfContainer .kryptoniteFileFieldContainer {
254
+ width: 350px;
255
+ padding: 3px 5px 4px 5px;
256
+ margin: 3px 0 0 0;
257
+ border: 1px solid #ccc;
258
+ }
259
+
260
+ #content .kryptoniteTextArea, #content .kryptoniteTextAreaBig {
261
+ width: 100%;
262
+ height: 120px;
263
+ font-family: "Lucida Grande", "Trebuchet MS", Helvetica, Arial, sans-serif;
264
+ font-size: 12px;
265
+ padding: 6px 0 5px 0;
266
+ margin: 3px 0 0 0;
267
+ }
268
+
269
+ #content .kryptoniteTextAreaBig {
270
+ height: 300px;
271
+ }
272
+
273
+ #content .rcText {
274
+ font-size: 11px;
275
+ color: #333;
276
+ }
277
+
278
+ #content .submits {
279
+ text-align: right;
280
+ font-size: 12px;
281
+ padding: 10px 10px;
282
+ background-color: #ddd;
283
+ }
284
+
285
+ #content .cancel, #content a.negative:link, #content a.negative:visited {
286
+ color: #ff0000;
287
+ }
288
+
289
+ #content .cancel:hover, #content a.negative:visited:hover {
290
+ color: #990000;
291
+ }
292
+
293
+ #content .pagination {
294
+ text-align: center;
295
+ margin: 20px 0px 0px 0px;
296
+ font-size: 12px;
297
+ padding: 10px 10px;
298
+ background-color: #ddd;
299
+ }
300
+
301
+ #content .pagination a:link, a:visited {
302
+ color: #555;
303
+ }
304
+
305
+ #content .pagination a:hover, a:visited:hover {
306
+ color: #000;
307
+ }