merb-admin 0.8.1 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/.gitignore +29 -27
  2. data/Gemfile +24 -22
  3. data/Gemfile.lock +86 -0
  4. data/LICENSE +20 -20
  5. data/README.rdoc +54 -58
  6. data/Rakefile +11 -44
  7. data/app/controllers/application.rb +6 -6
  8. data/app/controllers/main.rb +191 -191
  9. data/app/helpers/application_helper.rb +64 -64
  10. data/app/helpers/main_helper.rb +167 -167
  11. data/app/models/.gitkeep +0 -0
  12. data/app/views/layout/_message.html.erb +10 -10
  13. data/app/views/layout/dashboard.html.erb +34 -34
  14. data/app/views/layout/form.html.erb +48 -48
  15. data/app/views/layout/list.html.erb +42 -42
  16. data/app/views/main/_belongs_to.html.erb +29 -29
  17. data/app/views/main/_big_decimal.html.erb +12 -12
  18. data/app/views/main/_boolean.html.erb +7 -7
  19. data/app/views/main/_date.html.erb +12 -12
  20. data/app/views/main/_datetime.html.erb +12 -12
  21. data/app/views/main/_float.html.erb +12 -12
  22. data/app/views/main/_has_many.html.erb +16 -16
  23. data/app/views/main/_has_one.html.erb +30 -30
  24. data/app/views/main/_integer.html.erb +12 -12
  25. data/app/views/main/_properties.html.erb +18 -18
  26. data/app/views/main/_string.html.erb +15 -15
  27. data/app/views/main/_text.html.erb +11 -11
  28. data/app/views/main/_time.html.erb +12 -12
  29. data/app/views/main/_timestamp.html.erb +12 -12
  30. data/app/views/main/delete.html.erb +28 -28
  31. data/app/views/main/edit.html.erb +19 -19
  32. data/app/views/main/index.html.erb +22 -22
  33. data/app/views/main/list.html.erb +93 -93
  34. data/app/views/main/new.html.erb +16 -16
  35. data/config/init.rb +30 -0
  36. data/config/router.rb +4 -0
  37. data/lib/abstract_model.rb +84 -86
  38. data/lib/active_record_support.rb +147 -147
  39. data/lib/datamapper_support.rb +139 -140
  40. data/lib/generic_support.rb +13 -13
  41. data/lib/merb-admin.rb +99 -99
  42. data/lib/merb-admin/merbtasks.rb +103 -103
  43. data/lib/merb-admin/slicetasks.rb +174 -174
  44. data/lib/merb-admin/spectasks.rb +55 -55
  45. data/lib/merb-admin/version.rb +3 -0
  46. data/lib/sequel_support.rb +275 -275
  47. data/merb-admin.gemspec +42 -232
  48. data/public/javascripts/CollapsedFieldsets.js +85 -85
  49. data/public/javascripts/DateTimeShortcuts.js +255 -255
  50. data/public/javascripts/RelatedObjectLookups.js +96 -96
  51. data/public/javascripts/SelectBox.js +111 -111
  52. data/public/javascripts/SelectFilter2.js +113 -113
  53. data/public/javascripts/actions.js +39 -39
  54. data/public/javascripts/calendar.js +143 -143
  55. data/public/javascripts/core.js +176 -176
  56. data/public/javascripts/dateparse.js +233 -233
  57. data/public/javascripts/getElementsBySelector.js +167 -167
  58. data/public/javascripts/i18n.js +33 -33
  59. data/public/javascripts/ordering.js +137 -137
  60. data/public/javascripts/timeparse.js +94 -94
  61. data/public/javascripts/urlify.js +140 -140
  62. data/public/stylesheets/base.css +746 -746
  63. data/public/stylesheets/changelists.css +269 -269
  64. data/public/stylesheets/dashboard.css +24 -24
  65. data/public/stylesheets/forms.css +327 -327
  66. data/public/stylesheets/global.css +142 -142
  67. data/public/stylesheets/ie.css +50 -50
  68. data/public/stylesheets/layout.css +29 -29
  69. data/public/stylesheets/login.css +54 -54
  70. data/public/stylesheets/master.css +1 -1
  71. data/public/stylesheets/patch-iewin.css +7 -7
  72. data/public/stylesheets/rtl.css +206 -206
  73. data/public/stylesheets/widgets.css +506 -506
  74. data/screenshots/create.png +0 -0
  75. data/screenshots/delete.png +0 -0
  76. data/screenshots/edit.png +0 -0
  77. data/screenshots/index.png +0 -0
  78. data/screenshots/list.png +0 -0
  79. data/screenshots/new.png +0 -0
  80. data/spec/controllers/main_spec.rb +25 -25
  81. data/spec/migrations/activerecord/001_create_divisions_migration.rb +13 -13
  82. data/spec/migrations/activerecord/002_create_drafts_migration.rb +19 -19
  83. data/spec/migrations/activerecord/003_create_leagues_migration.rb +12 -12
  84. data/spec/migrations/activerecord/004_create_players_migration.rb +19 -20
  85. data/spec/migrations/activerecord/005_create_teams_migration.rb +22 -22
  86. data/spec/migrations/sequel/001_create_divisions_migration.rb +15 -15
  87. data/spec/migrations/sequel/002_create_drafts_migration.rb +21 -21
  88. data/spec/migrations/sequel/003_create_leagues_migration.rb +14 -14
  89. data/spec/migrations/sequel/004_create_players_migration.rb +21 -22
  90. data/spec/migrations/sequel/005_create_teams_migration.rb +24 -24
  91. data/spec/models/activerecord/division.rb +7 -7
  92. data/spec/models/activerecord/draft.rb +11 -11
  93. data/spec/models/activerecord/league.rb +6 -6
  94. data/spec/models/activerecord/player.rb +8 -8
  95. data/spec/models/activerecord/team.rb +13 -13
  96. data/spec/models/datamapper/division.rb +12 -12
  97. data/spec/models/datamapper/draft.rb +18 -18
  98. data/spec/models/datamapper/league.rb +11 -11
  99. data/spec/models/datamapper/player.rb +20 -21
  100. data/spec/models/datamapper/team.rb +22 -22
  101. data/spec/models/sequel/division.rb +15 -15
  102. data/spec/models/sequel/draft.rb +19 -19
  103. data/spec/models/sequel/league.rb +14 -14
  104. data/spec/models/sequel/player.rb +18 -18
  105. data/spec/models/sequel/team.rb +21 -21
  106. data/spec/requests/main_spec.rb +763 -763
  107. data/spec/spec_helper.rb +113 -112
  108. metadata +247 -41
  109. data/VERSION +0 -1
@@ -1,233 +1,233 @@
1
- /* 'Magic' date parsing, by Simon Willison (6th October 2003)
2
- http://simon.incutio.com/archive/2003/10/06/betterDateInput
3
- Adapted for 6newslawrence.com, 28th January 2004
4
- */
5
-
6
- /* Finds the index of the first occurence of item in the array, or -1 if not found */
7
- if (typeof Array.prototype.indexOf == 'undefined') {
8
- Array.prototype.indexOf = function(item) {
9
- var len = this.length;
10
- for (var i = 0; i < len; i++) {
11
- if (this[i] == item) {
12
- return i;
13
- }
14
- }
15
- return -1;
16
- };
17
- }
18
- /* Returns an array of items judged 'true' by the passed in test function */
19
- if (typeof Array.prototype.filter == 'undefined') {
20
- Array.prototype.filter = function(test) {
21
- var matches = [];
22
- var len = this.length;
23
- for (var i = 0; i < len; i++) {
24
- if (test(this[i])) {
25
- matches[matches.length] = this[i];
26
- }
27
- }
28
- return matches;
29
- };
30
- }
31
-
32
- var monthNames = gettext("January February March April May June July August September October November December").split(" ");
33
- var weekdayNames = gettext("Sunday Monday Tuesday Wednesday Thursday Friday Saturday").split(" ");
34
-
35
- /* Takes a string, returns the index of the month matching that string, throws
36
- an error if 0 or more than 1 matches
37
- */
38
- function parseMonth(month) {
39
- var matches = monthNames.filter(function(item) {
40
- return new RegExp("^" + month, "i").test(item);
41
- });
42
- if (matches.length == 0) {
43
- throw new Error("Invalid month string");
44
- }
45
- if (matches.length > 1) {
46
- throw new Error("Ambiguous month");
47
- }
48
- return monthNames.indexOf(matches[0]);
49
- }
50
- /* Same as parseMonth but for days of the week */
51
- function parseWeekday(weekday) {
52
- var matches = weekdayNames.filter(function(item) {
53
- return new RegExp("^" + weekday, "i").test(item);
54
- });
55
- if (matches.length == 0) {
56
- throw new Error("Invalid day string");
57
- }
58
- if (matches.length > 1) {
59
- throw new Error("Ambiguous weekday");
60
- }
61
- return weekdayNames.indexOf(matches[0]);
62
- }
63
-
64
- /* Array of objects, each has 're', a regular expression and 'handler', a
65
- function for creating a date from something that matches the regular
66
- expression. Handlers may throw errors if string is unparseable.
67
- */
68
- var dateParsePatterns = [
69
- // Today
70
- { re: /^tod/i,
71
- handler: function() {
72
- return new Date();
73
- }
74
- },
75
- // Tomorrow
76
- { re: /^tom/i,
77
- handler: function() {
78
- var d = new Date();
79
- d.setDate(d.getDate() + 1);
80
- return d;
81
- }
82
- },
83
- // Yesterday
84
- { re: /^yes/i,
85
- handler: function() {
86
- var d = new Date();
87
- d.setDate(d.getDate() - 1);
88
- return d;
89
- }
90
- },
91
- // 4th
92
- { re: /^(\d{1,2})(st|nd|rd|th)?$/i,
93
- handler: function(bits) {
94
- var d = new Date();
95
- d.setDate(parseInt(bits[1], 10));
96
- return d;
97
- }
98
- },
99
- // 4th Jan
100
- { re: /^(\d{1,2})(?:st|nd|rd|th)? (\w+)$/i,
101
- handler: function(bits) {
102
- var d = new Date();
103
- d.setDate(parseInt(bits[1], 10));
104
- d.setMonth(parseMonth(bits[2]));
105
- return d;
106
- }
107
- },
108
- // 4th Jan 2003
109
- { re: /^(\d{1,2})(?:st|nd|rd|th)? (\w+),? (\d{4})$/i,
110
- handler: function(bits) {
111
- var d = new Date();
112
- d.setDate(parseInt(bits[1], 10));
113
- d.setMonth(parseMonth(bits[2]));
114
- d.setYear(bits[3]);
115
- return d;
116
- }
117
- },
118
- // Jan 4th
119
- { re: /^(\w+) (\d{1,2})(?:st|nd|rd|th)?$/i,
120
- handler: function(bits) {
121
- var d = new Date();
122
- d.setDate(parseInt(bits[2], 10));
123
- d.setMonth(parseMonth(bits[1]));
124
- return d;
125
- }
126
- },
127
- // Jan 4th 2003
128
- { re: /^(\w+) (\d{1,2})(?:st|nd|rd|th)?,? (\d{4})$/i,
129
- handler: function(bits) {
130
- var d = new Date();
131
- d.setDate(parseInt(bits[2], 10));
132
- d.setMonth(parseMonth(bits[1]));
133
- d.setYear(bits[3]);
134
- return d;
135
- }
136
- },
137
- // next Tuesday - this is suspect due to weird meaning of "next"
138
- { re: /^next (\w+)$/i,
139
- handler: function(bits) {
140
- var d = new Date();
141
- var day = d.getDay();
142
- var newDay = parseWeekday(bits[1]);
143
- var addDays = newDay - day;
144
- if (newDay <= day) {
145
- addDays += 7;
146
- }
147
- d.setDate(d.getDate() + addDays);
148
- return d;
149
- }
150
- },
151
- // last Tuesday
152
- { re: /^last (\w+)$/i,
153
- handler: function(bits) {
154
- throw new Error("Not yet implemented");
155
- }
156
- },
157
- // mm/dd/yyyy (American style)
158
- { re: /(\d{1,2})\/(\d{1,2})\/(\d{4})/,
159
- handler: function(bits) {
160
- var d = new Date();
161
- d.setYear(bits[3]);
162
- d.setDate(parseInt(bits[2], 10));
163
- d.setMonth(parseInt(bits[1], 10) - 1); // Because months indexed from 0
164
- return d;
165
- }
166
- },
167
- // yyyy-mm-dd (ISO style)
168
- { re: /(\d{4})-(\d{1,2})-(\d{1,2})/,
169
- handler: function(bits) {
170
- var d = new Date();
171
- d.setYear(parseInt(bits[1]));
172
- d.setMonth(parseInt(bits[2], 10) - 1);
173
- d.setDate(parseInt(bits[3], 10));
174
- return d;
175
- }
176
- },
177
- ];
178
-
179
- function parseDateString(s) {
180
- for (var i = 0; i < dateParsePatterns.length; i++) {
181
- var re = dateParsePatterns[i].re;
182
- var handler = dateParsePatterns[i].handler;
183
- var bits = re.exec(s);
184
- if (bits) {
185
- return handler(bits);
186
- }
187
- }
188
- throw new Error("Invalid date string");
189
- }
190
-
191
- function fmt00(x) {
192
- // fmt00: Tags leading zero onto numbers 0 - 9.
193
- // Particularly useful for displaying results from Date methods.
194
- //
195
- if (Math.abs(parseInt(x)) < 10){
196
- x = "0"+ Math.abs(x);
197
- }
198
- return x;
199
- }
200
-
201
- function parseDateStringISO(s) {
202
- try {
203
- var d = parseDateString(s);
204
- return d.getFullYear() + '-' + (fmt00(d.getMonth() + 1)) + '-' + fmt00(d.getDate())
205
- }
206
- catch (e) { return s; }
207
- }
208
- function magicDate(input) {
209
- var messagespan = input.id + 'Msg';
210
- try {
211
- var d = parseDateString(input.value);
212
- input.value = d.getFullYear() + '-' + (fmt00(d.getMonth() + 1)) + '-' +
213
- fmt00(d.getDate());
214
- input.className = '';
215
- // Human readable date
216
- if (document.getElementById(messagespan)) {
217
- document.getElementById(messagespan).firstChild.nodeValue = d.toDateString();
218
- document.getElementById(messagespan).className = 'normal';
219
- }
220
- }
221
- catch (e) {
222
- input.className = 'error';
223
- var message = e.message;
224
- // Fix for IE6 bug
225
- if (message.indexOf('is null or not an object') > -1) {
226
- message = 'Invalid date string';
227
- }
228
- if (document.getElementById(messagespan)) {
229
- document.getElementById(messagespan).firstChild.nodeValue = message;
230
- document.getElementById(messagespan).className = 'error';
231
- }
232
- }
233
- }
1
+ /* 'Magic' date parsing, by Simon Willison (6th October 2003)
2
+ http://simon.incutio.com/archive/2003/10/06/betterDateInput
3
+ Adapted for 6newslawrence.com, 28th January 2004
4
+ */
5
+
6
+ /* Finds the index of the first occurence of item in the array, or -1 if not found */
7
+ if (typeof Array.prototype.indexOf == 'undefined') {
8
+ Array.prototype.indexOf = function(item) {
9
+ var len = this.length;
10
+ for (var i = 0; i < len; i++) {
11
+ if (this[i] == item) {
12
+ return i;
13
+ }
14
+ }
15
+ return -1;
16
+ };
17
+ }
18
+ /* Returns an array of items judged 'true' by the passed in test function */
19
+ if (typeof Array.prototype.filter == 'undefined') {
20
+ Array.prototype.filter = function(test) {
21
+ var matches = [];
22
+ var len = this.length;
23
+ for (var i = 0; i < len; i++) {
24
+ if (test(this[i])) {
25
+ matches[matches.length] = this[i];
26
+ }
27
+ }
28
+ return matches;
29
+ };
30
+ }
31
+
32
+ var monthNames = gettext("January February March April May June July August September October November December").split(" ");
33
+ var weekdayNames = gettext("Sunday Monday Tuesday Wednesday Thursday Friday Saturday").split(" ");
34
+
35
+ /* Takes a string, returns the index of the month matching that string, throws
36
+ an error if 0 or more than 1 matches
37
+ */
38
+ function parseMonth(month) {
39
+ var matches = monthNames.filter(function(item) {
40
+ return new RegExp("^" + month, "i").test(item);
41
+ });
42
+ if (matches.length == 0) {
43
+ throw new Error("Invalid month string");
44
+ }
45
+ if (matches.length > 1) {
46
+ throw new Error("Ambiguous month");
47
+ }
48
+ return monthNames.indexOf(matches[0]);
49
+ }
50
+ /* Same as parseMonth but for days of the week */
51
+ function parseWeekday(weekday) {
52
+ var matches = weekdayNames.filter(function(item) {
53
+ return new RegExp("^" + weekday, "i").test(item);
54
+ });
55
+ if (matches.length == 0) {
56
+ throw new Error("Invalid day string");
57
+ }
58
+ if (matches.length > 1) {
59
+ throw new Error("Ambiguous weekday");
60
+ }
61
+ return weekdayNames.indexOf(matches[0]);
62
+ }
63
+
64
+ /* Array of objects, each has 're', a regular expression and 'handler', a
65
+ function for creating a date from something that matches the regular
66
+ expression. Handlers may throw errors if string is unparseable.
67
+ */
68
+ var dateParsePatterns = [
69
+ // Today
70
+ { re: /^tod/i,
71
+ handler: function() {
72
+ return new Date();
73
+ }
74
+ },
75
+ // Tomorrow
76
+ { re: /^tom/i,
77
+ handler: function() {
78
+ var d = new Date();
79
+ d.setDate(d.getDate() + 1);
80
+ return d;
81
+ }
82
+ },
83
+ // Yesterday
84
+ { re: /^yes/i,
85
+ handler: function() {
86
+ var d = new Date();
87
+ d.setDate(d.getDate() - 1);
88
+ return d;
89
+ }
90
+ },
91
+ // 4th
92
+ { re: /^(\d{1,2})(st|nd|rd|th)?$/i,
93
+ handler: function(bits) {
94
+ var d = new Date();
95
+ d.setDate(parseInt(bits[1], 10));
96
+ return d;
97
+ }
98
+ },
99
+ // 4th Jan
100
+ { re: /^(\d{1,2})(?:st|nd|rd|th)? (\w+)$/i,
101
+ handler: function(bits) {
102
+ var d = new Date();
103
+ d.setDate(parseInt(bits[1], 10));
104
+ d.setMonth(parseMonth(bits[2]));
105
+ return d;
106
+ }
107
+ },
108
+ // 4th Jan 2003
109
+ { re: /^(\d{1,2})(?:st|nd|rd|th)? (\w+),? (\d{4})$/i,
110
+ handler: function(bits) {
111
+ var d = new Date();
112
+ d.setDate(parseInt(bits[1], 10));
113
+ d.setMonth(parseMonth(bits[2]));
114
+ d.setYear(bits[3]);
115
+ return d;
116
+ }
117
+ },
118
+ // Jan 4th
119
+ { re: /^(\w+) (\d{1,2})(?:st|nd|rd|th)?$/i,
120
+ handler: function(bits) {
121
+ var d = new Date();
122
+ d.setDate(parseInt(bits[2], 10));
123
+ d.setMonth(parseMonth(bits[1]));
124
+ return d;
125
+ }
126
+ },
127
+ // Jan 4th 2003
128
+ { re: /^(\w+) (\d{1,2})(?:st|nd|rd|th)?,? (\d{4})$/i,
129
+ handler: function(bits) {
130
+ var d = new Date();
131
+ d.setDate(parseInt(bits[2], 10));
132
+ d.setMonth(parseMonth(bits[1]));
133
+ d.setYear(bits[3]);
134
+ return d;
135
+ }
136
+ },
137
+ // next Tuesday - this is suspect due to weird meaning of "next"
138
+ { re: /^next (\w+)$/i,
139
+ handler: function(bits) {
140
+ var d = new Date();
141
+ var day = d.getDay();
142
+ var newDay = parseWeekday(bits[1]);
143
+ var addDays = newDay - day;
144
+ if (newDay <= day) {
145
+ addDays += 7;
146
+ }
147
+ d.setDate(d.getDate() + addDays);
148
+ return d;
149
+ }
150
+ },
151
+ // last Tuesday
152
+ { re: /^last (\w+)$/i,
153
+ handler: function(bits) {
154
+ throw new Error("Not yet implemented");
155
+ }
156
+ },
157
+ // mm/dd/yyyy (American style)
158
+ { re: /(\d{1,2})\/(\d{1,2})\/(\d{4})/,
159
+ handler: function(bits) {
160
+ var d = new Date();
161
+ d.setYear(bits[3]);
162
+ d.setDate(parseInt(bits[2], 10));
163
+ d.setMonth(parseInt(bits[1], 10) - 1); // Because months indexed from 0
164
+ return d;
165
+ }
166
+ },
167
+ // yyyy-mm-dd (ISO style)
168
+ { re: /(\d{4})-(\d{1,2})-(\d{1,2})/,
169
+ handler: function(bits) {
170
+ var d = new Date();
171
+ d.setYear(parseInt(bits[1]));
172
+ d.setMonth(parseInt(bits[2], 10) - 1);
173
+ d.setDate(parseInt(bits[3], 10));
174
+ return d;
175
+ }
176
+ },
177
+ ];
178
+
179
+ function parseDateString(s) {
180
+ for (var i = 0; i < dateParsePatterns.length; i++) {
181
+ var re = dateParsePatterns[i].re;
182
+ var handler = dateParsePatterns[i].handler;
183
+ var bits = re.exec(s);
184
+ if (bits) {
185
+ return handler(bits);
186
+ }
187
+ }
188
+ throw new Error("Invalid date string");
189
+ }
190
+
191
+ function fmt00(x) {
192
+ // fmt00: Tags leading zero onto numbers 0 - 9.
193
+ // Particularly useful for displaying results from Date methods.
194
+ //
195
+ if (Math.abs(parseInt(x)) < 10){
196
+ x = "0"+ Math.abs(x);
197
+ }
198
+ return x;
199
+ }
200
+
201
+ function parseDateStringISO(s) {
202
+ try {
203
+ var d = parseDateString(s);
204
+ return d.getFullYear() + '-' + (fmt00(d.getMonth() + 1)) + '-' + fmt00(d.getDate())
205
+ }
206
+ catch (e) { return s; }
207
+ }
208
+ function magicDate(input) {
209
+ var messagespan = input.id + 'Msg';
210
+ try {
211
+ var d = parseDateString(input.value);
212
+ input.value = d.getFullYear() + '-' + (fmt00(d.getMonth() + 1)) + '-' +
213
+ fmt00(d.getDate());
214
+ input.className = '';
215
+ // Human readable date
216
+ if (document.getElementById(messagespan)) {
217
+ document.getElementById(messagespan).firstChild.nodeValue = d.toDateString();
218
+ document.getElementById(messagespan).className = 'normal';
219
+ }
220
+ }
221
+ catch (e) {
222
+ input.className = 'error';
223
+ var message = e.message;
224
+ // Fix for IE6 bug
225
+ if (message.indexOf('is null or not an object') > -1) {
226
+ message = 'Invalid date string';
227
+ }
228
+ if (document.getElementById(messagespan)) {
229
+ document.getElementById(messagespan).firstChild.nodeValue = message;
230
+ document.getElementById(messagespan).className = 'error';
231
+ }
232
+ }
233
+ }