interpret 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/app/controllers/interpret/base_controller.rb +20 -1
  2. data/app/controllers/interpret/tools_controller.rb +7 -0
  3. data/app/controllers/interpret/translations_controller.rb +45 -3
  4. data/app/models/interpret/translation.rb +9 -6
  5. data/app/sweepers/interpret/base_sweeper.rb +4 -0
  6. data/app/sweepers/interpret/translation_sweeper.rb +1 -4
  7. data/app/views/interpret/search/index.html.erb +5 -3
  8. data/app/views/interpret/search/perform.html.erb +2 -4
  9. data/app/views/interpret/tools/index.html.erb +9 -0
  10. data/app/views/interpret/translations/_listing.html.erb +49 -13
  11. data/app/views/interpret/translations/index.html.erb +13 -6
  12. data/app/views/interpret/translations/new.html.erb +15 -0
  13. data/app/views/layouts/interpret.html.erb +13 -25
  14. data/app/views/layouts/interpret_base.html.erb +14 -0
  15. data/config/routes.rb +4 -1
  16. data/lib/generators/interpret/setup_generator.rb +1 -0
  17. data/lib/generators/interpret/templates/migration.rb +1 -0
  18. data/lib/interpret/helpers.rb +19 -8
  19. data/lib/interpret/version.rb +1 -1
  20. data/lib/interpret.rb +11 -13
  21. data/public/javascripts/interpret.js +7 -0
  22. data/public/stylesheets/interpret_style.css +105 -112
  23. data/spec/models/translation_spec.rb +26 -3
  24. data/test_app/app/controllers/application_controller.rb +12 -0
  25. data/test_app/app/models/user.rb +5 -0
  26. data/test_app/app/views/layouts/application.html.erb +4 -4
  27. data/test_app/app/views/pages/index.html.haml +2 -1
  28. data/test_app/config/initializers/interpret.rb +8 -2
  29. data/test_app/db/migrate/{20110209185258_interpret_create_translations.rb → 20110219143622_interpret_create_translations.rb} +1 -0
  30. data/test_app/db/migrate/20110219173536_create_users.rb +13 -0
  31. data/test_app/db/schema.rb +8 -1
  32. data/test_app/db/seeds.rb +4 -0
  33. data/test_app/public/javascripts/interpret.js +7 -0
  34. data/test_app/public/stylesheets/interpret_style.css +105 -112
  35. metadata +9 -11
  36. data/app/views/interpret/translations/_form.html.erb +0 -5
  37. data/app/views/interpret/translations/edit.html.erb +0 -5
  38. data/lib/generators/interpret/views_generator.rb +0 -16
  39. data/test_app/public/index.html +0 -29
  40. data/test_app/public/javascripts/controls.js +0 -965
  41. data/test_app/public/javascripts/dragdrop.js +0 -974
  42. data/test_app/public/javascripts/effects.js +0 -1123
  43. data/test_app/public/javascripts/prototype.js +0 -6001
@@ -8,7 +8,7 @@
8
8
  /* =Containers
9
9
  --------------------------------------------------------------------------------*/
10
10
 
11
- #container
11
+ #interpret_container
12
12
  {
13
13
  width: 92%;
14
14
  margin-left: 4%;
@@ -18,22 +18,22 @@
18
18
  /* =Grid >> Global
19
19
  --------------------------------------------------------------------------------*/
20
20
 
21
- .grid_1,
22
- .grid_2,
23
- .grid_3,
24
- .grid_4,
25
- .grid_5,
26
- .grid_6,
27
- .grid_7,
28
- .grid_8,
29
- .grid_9,
30
- .grid_10,
31
- .grid_11,
32
- .grid_12,
33
- .grid_13,
34
- .grid_14,
35
- .grid_15,
36
- .grid_16
21
+ #interpret_container .grid_1,
22
+ #interpret_container .grid_2,
23
+ #interpret_container .grid_3,
24
+ #interpret_container .grid_4,
25
+ #interpret_container .grid_5,
26
+ #interpret_container .grid_6,
27
+ #interpret_container .grid_7,
28
+ #interpret_container .grid_8,
29
+ #interpret_container .grid_9,
30
+ #interpret_container .grid_10,
31
+ #interpret_container .grid_11,
32
+ #interpret_container .grid_12,
33
+ #interpret_container .grid_13,
34
+ #interpret_container .grid_14,
35
+ #interpret_container .grid_15,
36
+ #interpret_container .grid_16
37
37
  {
38
38
  display: inline;
39
39
  float: left;
@@ -41,22 +41,22 @@
41
41
  margin-right: 1%;
42
42
  }
43
43
 
44
- #container .grid_4
44
+ #interpret_container .grid_4
45
45
  {
46
46
  width: 23%;
47
47
  }
48
48
 
49
- #container .grid_8
49
+ #interpret_container .grid_8
50
50
  {
51
51
  width: 48%;
52
52
  }
53
53
 
54
- #container .grid_12
54
+ #interpret_container .grid_12
55
55
  {
56
56
  width: 73%;
57
57
  }
58
58
 
59
- #container .grid_16
59
+ #interpret_container .grid_16
60
60
  {
61
61
  width: 98%;
62
62
  }
@@ -78,62 +78,62 @@
78
78
  /* =Grid >> 16 Columns
79
79
  --------------------------------------------------------------------------------*/
80
80
 
81
- #container .grid_1
81
+ #interpret_container .grid_1
82
82
  {
83
83
  width: 4.25%;
84
84
  }
85
85
 
86
- #container .grid_2
86
+ #interpret_container .grid_2
87
87
  {
88
88
  width: 10.5%;
89
89
  }
90
90
 
91
- #container .grid_3
91
+ #interpret_container .grid_3
92
92
  {
93
93
  width: 16.75%;
94
94
  }
95
95
 
96
- #container .grid_5
96
+ #interpret_container .grid_5
97
97
  {
98
98
  width: 29.25%;
99
99
  }
100
100
 
101
- #container .grid_6
101
+ #interpret_container .grid_6
102
102
  {
103
103
  width: 35.5%;
104
104
  }
105
105
 
106
- #container .grid_7
106
+ #interpret_container .grid_7
107
107
  {
108
108
  width: 41.75%;
109
109
  }
110
110
 
111
- #container .grid_9
111
+ #interpret_container .grid_9
112
112
  {
113
113
  width: 54.25%;
114
114
  }
115
115
 
116
- #container .grid_10
116
+ #interpret_container .grid_10
117
117
  {
118
118
  width: 60.5%;
119
119
  }
120
120
 
121
- #container .grid_11
121
+ #interpret_container .grid_11
122
122
  {
123
123
  width: 66.75%;
124
124
  }
125
125
 
126
- #container .grid_13
126
+ #interpret_container .grid_13
127
127
  {
128
128
  width: 79.25%;
129
129
  }
130
130
 
131
- #container .grid_14
131
+ #interpret_container .grid_14
132
132
  {
133
133
  width: 85.5%;
134
134
  }
135
135
 
136
- #container .grid_15
136
+ #interpret_container .grid_15
137
137
  {
138
138
  width: 91.75%;
139
139
  }
@@ -141,17 +141,17 @@
141
141
  /* =Prefix Extra Space >> Global
142
142
  --------------------------------------------------------------------------------*/
143
143
 
144
- #container .prefix_4
144
+ #interpret_container .prefix_4
145
145
  {
146
146
  padding-left: 25%;
147
147
  }
148
148
 
149
- #container .prefix_8
149
+ #interpret_container .prefix_8
150
150
  {
151
151
  padding-left: 50%;
152
152
  }
153
153
 
154
- #container .prefix_12
154
+ #interpret_container .prefix_12
155
155
  {
156
156
  padding-left: 75%;
157
157
  }
@@ -159,62 +159,62 @@
159
159
  /* =Prefix Extra Space >> 16 Columns
160
160
  --------------------------------------------------------------------------------*/
161
161
 
162
- #container .prefix_1
162
+ #interpret_container .prefix_1
163
163
  {
164
164
  padding-left: 6.25%;
165
165
  }
166
166
 
167
- #container .prefix_2
167
+ #interpret_container .prefix_2
168
168
  {
169
169
  padding-left: 12.5%;
170
170
  }
171
171
 
172
- #container .prefix_3
172
+ #interpret_container .prefix_3
173
173
  {
174
174
  padding-left: 18.75%;
175
175
  }
176
176
 
177
- #container .prefix_5
177
+ #interpret_container .prefix_5
178
178
  {
179
179
  padding-left: 31.25%;
180
180
  }
181
181
 
182
- #container .prefix_6
182
+ #interpret_container .prefix_6
183
183
  {
184
184
  padding-left: 37.5%;
185
185
  }
186
186
 
187
- #container .prefix_7
187
+ #interpret_container .prefix_7
188
188
  {
189
189
  padding-left: 43.75%;
190
190
  }
191
191
 
192
- #container .prefix_9
192
+ #interpret_container .prefix_9
193
193
  {
194
194
  padding-left: 56.25%;
195
195
  }
196
196
 
197
- #container .prefix_10
197
+ #interpret_container .prefix_10
198
198
  {
199
199
  padding-left: 62.5%;
200
200
  }
201
201
 
202
- #container .prefix_11
202
+ #interpret_container .prefix_11
203
203
  {
204
204
  padding-left: 68.75%;
205
205
  }
206
206
 
207
- #container .prefix_13
207
+ #interpret_container .prefix_13
208
208
  {
209
209
  padding-left: 81.25%;
210
210
  }
211
211
 
212
- #container .prefix_14
212
+ #interpret_container .prefix_14
213
213
  {
214
214
  padding-left: 87.5%;
215
215
  }
216
216
 
217
- #container .prefix_15
217
+ #interpret_container .prefix_15
218
218
  {
219
219
  padding-left: 93.75%;
220
220
  }
@@ -222,17 +222,17 @@
222
222
  /* =Suffix Extra Space >> Global
223
223
  --------------------------------------------------------------------------------*/
224
224
 
225
- #container .suffix_4
225
+ #interpret_container .suffix_4
226
226
  {
227
227
  padding-right: 25%;
228
228
  }
229
229
 
230
- #container .suffix_8
230
+ #interpret_container .suffix_8
231
231
  {
232
232
  padding-right: 50%;
233
233
  }
234
234
 
235
- #container .suffix_12
235
+ #interpret_container .suffix_12
236
236
  {
237
237
  padding-right: 75%;
238
238
  }
@@ -241,62 +241,62 @@
241
241
  /* =Suffix Extra Space >> 16 Columns
242
242
  --------------------------------------------------------------------------------*/
243
243
 
244
- #container .suffix_1
244
+ #interpret_container .suffix_1
245
245
  {
246
246
  padding-right: 6.25%;
247
247
  }
248
248
 
249
- #container .suffix_2
249
+ #interpret_container .suffix_2
250
250
  {
251
251
  padding-right: 16.5%;
252
252
  }
253
253
 
254
- #container .suffix_3
254
+ #interpret_container .suffix_3
255
255
  {
256
256
  padding-right: 18.75%;
257
257
  }
258
258
 
259
- #container .suffix_5
259
+ #interpret_container .suffix_5
260
260
  {
261
261
  padding-right: 31.25%;
262
262
  }
263
263
 
264
- #container .suffix_6
264
+ #interpret_container .suffix_6
265
265
  {
266
266
  padding-right: 37.5%;
267
267
  }
268
268
 
269
- #container .suffix_7
269
+ #interpret_container .suffix_7
270
270
  {
271
271
  padding-right: 43.75%;
272
272
  }
273
273
 
274
- #container .suffix_9
274
+ #interpret_container .suffix_9
275
275
  {
276
276
  padding-right: 56.25%;
277
277
  }
278
278
 
279
- #container .suffix_10
279
+ #interpret_container .suffix_10
280
280
  {
281
281
  padding-right: 62.5%;
282
282
  }
283
283
 
284
- #container .suffix_11
284
+ #interpret_container .suffix_11
285
285
  {
286
286
  padding-right: 68.75%;
287
287
  }
288
288
 
289
- #container .suffix_13
289
+ #interpret_container .suffix_13
290
290
  {
291
291
  padding-right: 81.25%;
292
292
  }
293
293
 
294
- #container .suffix_14
294
+ #interpret_container .suffix_14
295
295
  {
296
296
  padding-right: 87.5%;
297
297
  }
298
298
 
299
- #container .suffix_15
299
+ #interpret_container .suffix_15
300
300
  {
301
301
  padding-right: 93.75%;
302
302
  }
@@ -328,7 +328,7 @@ html body * dd.clear
328
328
 
329
329
  /* http://www.positioniseverything.net/easyclearing.html */
330
330
 
331
- .clearfix:after
331
+ #interpret_container .clearfix:after
332
332
  {
333
333
  clear: both;
334
334
  content: '.';
@@ -337,30 +337,17 @@ html body * dd.clear
337
337
  height: 0;
338
338
  }
339
339
 
340
- .clearfix
341
- {
342
- display: inline-block;
343
- }
344
-
345
- * html .clearfix
346
- {
347
- height: 1%;
348
- }
349
-
350
- .clearfix
340
+ #interpret_container .clearfix
351
341
  {
352
342
  display: block;
343
+ height: 1%;
353
344
  }
354
345
 
355
- body {
346
+ #interpret_container {
356
347
  font-family: "Lucida Grande", Helvetica;
357
348
  }
358
349
 
359
- #container {
360
- border: .3em solid #333;
361
- }
362
-
363
- #header, .header {
350
+ #interpret_container #header, .header {
364
351
  padding: 0 1em;
365
352
  margin-top: 1em;
366
353
  color: #FFF;
@@ -368,81 +355,87 @@ body {
368
355
  border-radius: 5px;
369
356
  }
370
357
 
371
- table {
358
+ #interpret_container table {
372
359
  border-collapse:collapse;
373
360
  width: 100%;
374
361
  border-right: 1px solid #CCC;
375
362
  border-left: 1px solid #CCC;
376
363
  }
377
364
 
378
- td, th {
365
+ #interpret_container td, th {
379
366
  color: #363636;
380
367
  padding: .4em;
381
368
  }
382
369
 
383
- td:first-child, td:first-child {
384
- width: 50%;
370
+ #interpret_container td.key {
371
+ width: 20%;
385
372
  }
386
373
 
387
- td:last-child, td:last-child {
388
- width: 50%;
374
+ #interpret_container td.content {
375
+ text-align:center;
376
+ width: 80%;
389
377
  }
390
378
 
391
- tr {
379
+ #interpret_container tr {
392
380
  border-bottom:1px solid #CCC;
393
381
  cursor: hand;
394
382
  cursor: pointer;
395
383
  }
396
384
 
385
+ #interpret_container tr.protected {
386
+ border: 2px dashed red;
387
+ background-color: #FFEDED;
388
+ }
389
+
397
390
 
398
- tr:hover {
391
+ #interpret_container tr:hover {
399
392
  background-color: #DDD;
400
393
  -moz-transition: background .4s linear;
401
394
  -o-transition: background .4s linear;
402
395
  -webkit-transition: background .4s linear;
403
396
  }
404
397
 
405
- tr.header {
398
+ #interpret_container tr.header {
406
399
  background-color: #555;
407
400
  color: white;
408
401
  height: 2em;
409
402
  cursor: default;
410
403
  }
411
- tr.header:hover {
404
+ #interpret_container tr.header:hover {
412
405
  background: #555;
413
406
  -moz-transition: none;
414
407
  -o-transition: none;
415
408
  -webkit-transition: none;
416
409
  height: 2em;
417
410
  }
418
- tr.header th {;
411
+ #interpret_container tr.header th {;
419
412
  color: #EEE;
420
413
  }
421
414
 
422
- tbody td a {
415
+ #interpret_container tbody td a {
423
416
  color:#363636;
424
417
  text-decoration:none;
425
418
  }
426
419
 
427
- .menu {
420
+ #interpret_container .menu {
428
421
  margin-top: 10px;
429
422
  }
430
423
 
431
- .menu a.current {
424
+ #interpret_container .menu a.current {
432
425
  font-weight: bold;
433
426
  }
434
427
 
435
428
  /* Search Page */
436
429
 
437
- #search {
430
+ #interpret_container #search {
438
431
  border: 1px solid #CCC;
439
432
  padding-left: 3em;
440
433
  }
441
- #search label {
434
+ #interpret_container #search label {
442
435
  font-size: 1.4em;
443
436
  }
444
437
 
445
- #search input {
438
+ #interpret_container #search input {
446
439
  width: 40%;
447
440
  font-size: 1.2em;
448
441
  height: 2em;
@@ -451,17 +444,17 @@ tbody td a {
451
444
  padding-left: .4em;
452
445
  }
453
446
 
454
- #search input:focus {
447
+ #interpret_container #search input:focus {
455
448
  border: .2em solid #555;
456
449
  }
457
450
 
458
- #search input[type="submit"] {
451
+ #interpret_container #search input[type="submit"] {
459
452
  width: 15em;
460
453
  margin-top: 2em;
461
454
  margin-left: 4%;
462
455
  }
463
456
 
464
- #search input[type="submit"]:hover {
457
+ #interpret_container #search input[type="submit"]:hover {
465
458
  background-color: #444;
466
459
  color: #FFF;
467
460
  cursor: hand;
@@ -470,15 +463,15 @@ tbody td a {
470
463
 
471
464
  /* Sidebar for Search page */
472
465
 
473
- #side_search {
466
+ #interpret_container #side_search {
474
467
  border: 1px solid #CCC;
475
468
  padding: .4em 0 .4em .8em;
476
469
  }
477
- #side_search label {
470
+ #interpret_container #side_search label {
478
471
  font-size: .8em;
479
472
  }
480
473
 
481
- #side_search input {
474
+ #interpret_container #side_search input {
482
475
  width: 90%;
483
476
  font-size: .9em;
484
477
  height: 1.5em;
@@ -487,44 +480,44 @@ tbody td a {
487
480
  padding: .2em;
488
481
  }
489
482
 
490
- #side_search input:focus {
483
+ #interpret_container #side_search input:focus {
491
484
  border: .2em solid #555;
492
485
  }
493
486
 
494
- #side_search input[type="submit"] {
487
+ #interpret_container #side_search input[type="submit"] {
495
488
  width: 94%;
496
489
  margin-top: 1.2em;
497
490
  height: 2em;
498
491
  }
499
492
 
500
- #side_search input[type="submit"]:hover {
493
+ #interpret_container #side_search input[type="submit"]:hover {
501
494
  background-color: #444;
502
495
  color: #FFF;
503
496
  cursor: hand;
504
497
  cursor: pointer;
505
498
  }
506
499
 
507
- .best_in_place textarea {
500
+ #interpret_container .best_in_place textarea {
508
501
  width: 100%;
509
502
  border: transparent;
510
503
  font-size: .9em;
511
504
  }
512
505
 
513
- #tree_sidebar ul{
506
+ #interpret_container #tree_sidebar ul{
514
507
  margin: 0;
515
508
  padding: .4em;
516
509
  }
517
- #tree_sidebar li {
510
+ #interpret_container #tree_sidebar li {
518
511
  list-style-image: url("/stylesheets/folder.png");
519
512
  font-weight: normal;
520
513
  padding-bottom: 5px;
521
514
  letter-spacing: 1px;
522
515
  }
523
516
 
524
- #tree_sidebar a {
517
+ #interpret_container #tree_sidebar a {
525
518
  text-decoration: none;
526
519
  color: #222;
527
520
  }
528
- #tree_sidebar a:hover {
521
+ #interpret_container #tree_sidebar a:hover {
529
522
  text-decoration: underline;
530
523
  }
@@ -214,13 +214,36 @@ es:
214
214
  @file = new_en_yml
215
215
  end
216
216
 
217
- it "should dump the contents for the given file into database" do
217
+ it "should update the contents of the database from the given file" do
218
+ Interpret::Translation.delete_all
218
219
  file2db(en_yml)
219
220
  @file.stub!(:content_type).and_return("text/plain")
220
221
  Interpret::Translation.import(@file)
221
222
 
222
- en_trans = Interpret::Translation.locale('en').all
223
- Interpret::Translation.export(en_trans).should == YAML.load(new_en_yml)
223
+ trans = Interpret::Translation.locale('en').find_by_key("p1")
224
+ trans.value.should == "Hello modified world! This new translation should not be copied into database"
225
+ end
226
+
227
+ it "should not create new keys" do
228
+ Interpret::Translation.delete_all
229
+ file2db(en_yml)
230
+ howm_before = Interpret::Translation.locale('en').count
231
+
232
+ @file.stub!(:content_type).and_return("text/plain")
233
+ Interpret::Translation.import(@file)
234
+
235
+ howm_after = Interpret::Translation.locale('en').count
236
+ howm_before.should == howm_after
237
+ end
238
+
239
+ it "should not touch translations not present in the file" do
240
+ Interpret::Translation.delete_all
241
+ file2db(en_yml)
242
+ @file.stub!(:content_type).and_return("text/plain")
243
+ Interpret::Translation.import(@file)
244
+
245
+ trans = Interpret::Translation.locale('en').find_by_key("folder1.content")
246
+ trans.value.should == "Some large text content"
224
247
  end
225
248
 
226
249
  it "should not modify the database contents for other languages" do
@@ -1,3 +1,15 @@
1
1
  class ApplicationController < ActionController::Base
2
2
  protect_from_forgery
3
+ before_filter :set_current_user
4
+ helper_method :current_user
5
+
6
+ def current_user
7
+ session[:user_id] ? User.find(session[:user_id]) : User.first
8
+ end
9
+
10
+ def set_current_user
11
+ if params[:admin]
12
+ session[:user_id] = params[:admin] == "true" ? User.where(:admin => true).first : User.where(:admin => false).first
13
+ end
14
+ end
3
15
  end
@@ -0,0 +1,5 @@
1
+ class User < ActiveRecord::Base
2
+ def admin?
3
+ admin
4
+ end
5
+ end
@@ -3,13 +3,13 @@
3
3
  <head>
4
4
  <title>Cuca</title>
5
5
  <%= stylesheet_link_tag :all %>
6
- <%= javascript_include_tag :defaults %>
6
+ <%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" %>
7
+ <%= javascript_include_tag :all %>
7
8
  <%= csrf_meta_tag %>
8
9
  </head>
9
10
  <body>
10
- This is the APPLICATION main Layout
11
- <%= yield %>
12
-
11
+ This is the APPLICATION main Layout
12
+ <%= yield %>
13
13
  </body>
14
14
  </html>
15
15
 
@@ -6,4 +6,5 @@
6
6
  %p= t ".line3"
7
7
  %p= t ".line4_html"
8
8
 
9
- = link_to "Traduccions", interpret_root_path
9
+ = link_to "Login to interpret as admin", interpret_root_path(:admin => "true")
10
+ = link_to "Login to interpret as user", interpret_root_path(:admin => "false")
@@ -1,2 +1,8 @@
1
- Interpret.sweeper = "page_sweeper"
2
- Interpret.registered_envs = [:production, :development]
1
+ Interpret.configure do |config|
2
+ config.sweeper = "page_sweeper"
3
+ config.registered_envs = [:production, :development]
4
+ config.parent_controller = "application_controller"
5
+ config.current_user = "current_user"
6
+ config.admin = "admin?"
7
+ config.layout = "application"
8
+ end
@@ -6,6 +6,7 @@ class InterpretCreateTranslations < ActiveRecord::Migration
6
6
  t.text :value
7
7
  t.text :interpolations
8
8
  t.boolean :is_proc, :default => false
9
+ t.boolean :protected, :default => false
9
10
  end
10
11
  end
11
12
 
@@ -0,0 +1,13 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :users do |t|
4
+ t.boolean :admin, :default => false, :null => false
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :users
12
+ end
13
+ end