interpret 0.2.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/.gitignore +2 -4
  2. data/Gemfile +2 -3
  3. data/README.md +1 -10
  4. data/{public/stylesheets → app/assets/images}/folder.png +0 -0
  5. data/{public → app/assets}/javascripts/interpret.js +0 -0
  6. data/{public/stylesheets/interpret_style.css → app/assets/stylesheets/interpret_style.css.erb} +1 -1
  7. data/app/controllers/interpret/base_controller.rb +1 -1
  8. data/app/controllers/interpret/search_controller.rb +8 -2
  9. data/app/controllers/interpret/tools_controller.rb +5 -5
  10. data/app/controllers/interpret/translations_controller.rb +59 -69
  11. data/app/models/interpret/translation.rb +1 -0
  12. data/app/views/interpret/missing_translations/blank.html.erb +1 -1
  13. data/app/views/interpret/missing_translations/index.html.erb +1 -1
  14. data/app/views/interpret/missing_translations/stale.html.erb +2 -2
  15. data/app/views/interpret/search/_blank_search.html.erb +1 -1
  16. data/app/views/interpret/search/_filled_search.html.erb +1 -1
  17. data/app/views/interpret/tools/index.html.erb +2 -2
  18. data/app/views/interpret/translations/_listing.html.erb +3 -3
  19. data/app/views/interpret/translations/new.html.erb +2 -2
  20. data/app/views/layouts/interpret/interpret.html.erb +55 -0
  21. data/app/views/layouts/{interpret_base.html.erb → interpret/interpret_base.html.erb} +0 -0
  22. data/config/routes.rb +19 -21
  23. data/{lib/generators/interpret/templates/migration.rb → db/migrate/20111108094329_create_translations.rb} +3 -4
  24. data/interpret.gemspec +3 -3
  25. data/lib/interpret/engine.rb +6 -4
  26. data/lib/interpret/helpers.rb +4 -53
  27. data/lib/interpret/version.rb +1 -1
  28. data/lib/interpret.rb +0 -4
  29. data/script/rails +5 -0
  30. data/spec/integration/missing_translations_spec.rb +8 -8
  31. data/spec/integration/search_spec.rb +8 -8
  32. data/spec/integration/stale_translations_spec.rb +5 -5
  33. data/spec/integration/tools_spec.rb +9 -9
  34. data/spec/integration/translations_spec.rb +2 -2
  35. data/spec/spec_helper.rb +2 -9
  36. data/spec/support/load_routes.rb +6 -0
  37. data/test_app/Gemfile +11 -6
  38. data/test_app/{public → app/assets}/images/a1.gif +0 -0
  39. data/test_app/{public → app/assets}/images/a10.jpg +0 -0
  40. data/test_app/{public → app/assets}/images/a16.gif +0 -0
  41. data/test_app/{public → app/assets}/images/a18.gif +0 -0
  42. data/test_app/{public → app/assets}/images/a22.gif +0 -0
  43. data/test_app/{public → app/assets}/images/a26.gif +0 -0
  44. data/test_app/{public → app/assets}/images/a33.gif +0 -0
  45. data/test_app/{public → app/assets}/images/a36.gif +0 -0
  46. data/test_app/{public → app/assets}/images/a38.gif +0 -0
  47. data/test_app/{public → app/assets}/images/a41.gif +0 -0
  48. data/test_app/{public → app/assets}/images/a47.gif +0 -0
  49. data/test_app/{public → app/assets}/images/a50.gif +0 -0
  50. data/test_app/{public → app/assets}/images/a8.gif +0 -0
  51. data/test_app/{public → app/assets}/images/abg.gif +0 -0
  52. data/test_app/{public → app/assets}/images/pic1.jpg +0 -0
  53. data/test_app/{public → app/assets}/images/pic2.jpg +0 -0
  54. data/test_app/{public → app/assets}/images/spacer.gif +0 -0
  55. data/test_app/{public → app/assets}/images/upbg.gif +0 -0
  56. data/test_app/app/assets/javascripts/application.js +4 -0
  57. data/test_app/{public → app/assets}/stylesheets/.gitkeep +0 -0
  58. data/test_app/{public/stylesheets/default.css → app/assets/stylesheets/default.css.erb} +16 -16
  59. data/test_app/{public → app/assets}/stylesheets/private.css +0 -0
  60. data/test_app/app/controllers/admin/dashboard_controller.rb +6 -0
  61. data/test_app/app/views/admin/dashboard/index.html.erb +1 -0
  62. data/test_app/app/views/layouts/application.html.erb +3 -13
  63. data/test_app/app/views/layouts/backoffice.html.erb +3 -4
  64. data/test_app/app/views/pages/index.html.erb +2 -2
  65. data/test_app/config/application.rb +12 -3
  66. data/test_app/config/environments/development.rb +0 -1
  67. data/test_app/config/initializers/interpret.rb +0 -1
  68. data/test_app/config/routes.rb +10 -1
  69. data/test_app/db/migrate/{20111021100344_interpret_create_translations.rb → 20111108094455_create_translations.rb} +3 -4
  70. data/test_app/db/schema.rb +3 -0
  71. metadata +60 -78
  72. data/app/views/interpret/translations/live_edit.html.erb +0 -11
  73. data/app/views/layouts/interpret.html.erb +0 -56
  74. data/lib/generators/interpret/migration_generator.rb +0 -25
  75. data/lib/generators/interpret/setup_generator.rb +0 -21
  76. data/lib/interpret/capistrano.rb +0 -18
  77. data/lib/interpret/controller_filter.rb +0 -12
  78. data/public/javascripts/facebox-1.3/closelabel.png +0 -0
  79. data/public/javascripts/facebox-1.3/facebox.css +0 -80
  80. data/public/javascripts/facebox-1.3/facebox.js +0 -309
  81. data/public/javascripts/facebox-1.3/loading.gif +0 -0
  82. data/public/stylesheets/interpret_live_edit_style.css +0 -38
  83. data/test_app/config/deploy.rb +0 -24
  84. data/test_app/config/initializers/rack_patch.rb +0 -13
  85. data/test_app/public/javascripts/application.js +0 -2
  86. data/test_app/public/javascripts/best_in_place.js +0 -456
  87. data/test_app/public/javascripts/facebox-1.3/closelabel.png +0 -0
  88. data/test_app/public/javascripts/facebox-1.3/facebox.css +0 -80
  89. data/test_app/public/javascripts/facebox-1.3/facebox.js +0 -309
  90. data/test_app/public/javascripts/facebox-1.3/loading.gif +0 -0
  91. data/test_app/public/javascripts/interpret.js +0 -4
  92. data/test_app/public/javascripts/rails.js +0 -134
  93. data/test_app/public/stylesheets/folder.png +0 -0
  94. data/test_app/public/stylesheets/interpret_live_edit_style.css +0 -38
  95. data/test_app/public/stylesheets/interpret_style.css +0 -535
@@ -1,309 +0,0 @@
1
- /*
2
- * Facebox (for jQuery)
3
- * version: 1.2 (05/05/2008)
4
- * @requires jQuery v1.2 or later
5
- *
6
- * Examples at http://famspam.com/facebox/
7
- *
8
- * Licensed under the MIT:
9
- * http://www.opensource.org/licenses/mit-license.php
10
- *
11
- * Copyright 2007, 2008 Chris Wanstrath [ chris@ozmm.org ]
12
- *
13
- * Usage:
14
- *
15
- * jQuery(document).ready(function() {
16
- * jQuery('a[rel*=facebox]').facebox()
17
- * })
18
- *
19
- * <a href="#terms" rel="facebox">Terms</a>
20
- * Loads the #terms div in the box
21
- *
22
- * <a href="terms.html" rel="facebox">Terms</a>
23
- * Loads the terms.html page in the box
24
- *
25
- * <a href="terms.png" rel="facebox">Terms</a>
26
- * Loads the terms.png image in the box
27
- *
28
- *
29
- * You can also use it programmatically:
30
- *
31
- * jQuery.facebox('some html')
32
- * jQuery.facebox('some html', 'my-groovy-style')
33
- *
34
- * The above will open a facebox with "some html" as the content.
35
- *
36
- * jQuery.facebox(function($) {
37
- * $.get('blah.html', function(data) { $.facebox(data) })
38
- * })
39
- *
40
- * The above will show a loading screen before the passed function is called,
41
- * allowing for a better ajaxy experience.
42
- *
43
- * The facebox function can also display an ajax page, an image, or the contents of a div:
44
- *
45
- * jQuery.facebox({ ajax: 'remote.html' })
46
- * jQuery.facebox({ ajax: 'remote.html' }, 'my-groovy-style')
47
- * jQuery.facebox({ image: 'stairs.jpg' })
48
- * jQuery.facebox({ image: 'stairs.jpg' }, 'my-groovy-style')
49
- * jQuery.facebox({ div: '#box' })
50
- * jQuery.facebox({ div: '#box' }, 'my-groovy-style')
51
- *
52
- * Want to close the facebox? Trigger the 'close.facebox' document event:
53
- *
54
- * jQuery(document).trigger('close.facebox')
55
- *
56
- * Facebox also has a bunch of other hooks:
57
- *
58
- * loading.facebox
59
- * beforeReveal.facebox
60
- * reveal.facebox (aliased as 'afterReveal.facebox')
61
- * init.facebox
62
- * afterClose.facebox
63
- *
64
- * Simply bind a function to any of these hooks:
65
- *
66
- * $(document).bind('reveal.facebox', function() { ...stuff to do after the facebox and contents are revealed... })
67
- *
68
- */
69
- (function($) {
70
- $.facebox = function(data, klass) {
71
- $.facebox.loading()
72
-
73
- if (data.ajax) fillFaceboxFromAjax(data.ajax, klass)
74
- else if (data.image) fillFaceboxFromImage(data.image, klass)
75
- else if (data.div) fillFaceboxFromHref(data.div, klass)
76
- else if ($.isFunction(data)) data.call($)
77
- else $.facebox.reveal(data, klass)
78
- }
79
-
80
- /*
81
- * Public, $.facebox methods
82
- */
83
-
84
- $.extend($.facebox, {
85
- settings: {
86
- opacity : 0.2,
87
- overlay : true,
88
- loadingImage : '/javascripts/facebox-1.3/loading.gif',
89
- closeImage : '/javascripts/facebox-1.3/closelabel.png',
90
- imageTypes : [ 'png', 'jpg', 'jpeg', 'gif' ],
91
- faceboxHtml : '\
92
- <div id="facebox" style="display:none;"> \
93
- <div class="popup"> \
94
- <div class="content"> \
95
- </div> \
96
- <a href="#" class="close"><img src="/javascripts/facebox-1.3/closelabel.png" title="close" class="close_image" /></a> \
97
- </div> \
98
- </div>'
99
- },
100
-
101
- loading: function() {
102
- init()
103
- if ($('#facebox .loading').length == 1) return true
104
- showOverlay()
105
-
106
- $('#facebox .content').empty()
107
- $('#facebox .body').children().hide().end().
108
- append('<div class="loading"><img src="'+$.facebox.settings.loadingImage+'"/></div>')
109
-
110
- $('#facebox').css({
111
- top: getPageScroll()[1] + (getPageHeight() / 10),
112
- left: $(window).width() / 2 - 205
113
- }).show()
114
-
115
- $(document).bind('keydown.facebox', function(e) {
116
- if (e.keyCode == 27) $.facebox.close()
117
- return true
118
- })
119
- $(document).trigger('loading.facebox')
120
- },
121
-
122
- reveal: function(data, klass) {
123
- $(document).trigger('beforeReveal.facebox')
124
- if (klass) $('#facebox .content').addClass(klass)
125
- $('#facebox .content').append(data)
126
- $('#facebox .loading').remove()
127
- $('#facebox .body').children().fadeIn('normal')
128
- $('#facebox').css('left', $(window).width() / 2 - ($('#facebox .popup').width() / 2))
129
- $(document).trigger('reveal.facebox').trigger('afterReveal.facebox')
130
- },
131
-
132
- close: function() {
133
- $(document).trigger('close.facebox')
134
- return false
135
- }
136
- })
137
-
138
- /*
139
- * Public, $.fn methods
140
- */
141
-
142
- $.fn.facebox = function(settings) {
143
- if ($(this).length == 0) return
144
-
145
- init(settings)
146
-
147
- function clickHandler() {
148
- $.facebox.loading(true)
149
-
150
- // support for rel="facebox.inline_popup" syntax, to add a class
151
- // also supports deprecated "facebox[.inline_popup]" syntax
152
- var klass = this.rel.match(/facebox\[?\.(\w+)\]?/)
153
- if (klass) klass = klass[1]
154
-
155
- fillFaceboxFromHref(this.href, klass)
156
- return false
157
- }
158
-
159
- return this.bind('click.facebox', clickHandler)
160
- }
161
-
162
- /*
163
- * Private methods
164
- */
165
-
166
- // called one time to setup facebox on this page
167
- function init(settings) {
168
- if ($.facebox.settings.inited) return true
169
- else $.facebox.settings.inited = true
170
-
171
- $(document).trigger('init.facebox')
172
- makeCompatible()
173
-
174
- var imageTypes = $.facebox.settings.imageTypes.join('|')
175
- $.facebox.settings.imageTypesRegexp = new RegExp('\.(' + imageTypes + ')$', 'i')
176
-
177
- if (settings) $.extend($.facebox.settings, settings)
178
- $('body').append($.facebox.settings.faceboxHtml)
179
-
180
- var preload = [ new Image(), new Image() ]
181
- preload[0].src = $.facebox.settings.closeImage
182
- preload[1].src = $.facebox.settings.loadingImage
183
-
184
- $('#facebox').find('.b:first, .bl').each(function() {
185
- preload.push(new Image())
186
- preload.slice(-1).src = $(this).css('background-image').replace(/url\((.+)\)/, '$1')
187
- })
188
-
189
- $('#facebox .close').click($.facebox.close)
190
- $('#facebox .close_image').attr('src', $.facebox.settings.closeImage)
191
- }
192
-
193
- // getPageScroll() by quirksmode.com
194
- function getPageScroll() {
195
- var xScroll, yScroll;
196
- if (self.pageYOffset) {
197
- yScroll = self.pageYOffset;
198
- xScroll = self.pageXOffset;
199
- } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
200
- yScroll = document.documentElement.scrollTop;
201
- xScroll = document.documentElement.scrollLeft;
202
- } else if (document.body) {// all other Explorers
203
- yScroll = document.body.scrollTop;
204
- xScroll = document.body.scrollLeft;
205
- }
206
- return new Array(xScroll,yScroll)
207
- }
208
-
209
- // Adapted from getPageSize() by quirksmode.com
210
- function getPageHeight() {
211
- var windowHeight
212
- if (self.innerHeight) { // all except Explorer
213
- windowHeight = self.innerHeight;
214
- } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
215
- windowHeight = document.documentElement.clientHeight;
216
- } else if (document.body) { // other Explorers
217
- windowHeight = document.body.clientHeight;
218
- }
219
- return windowHeight
220
- }
221
-
222
- // Backwards compatibility
223
- function makeCompatible() {
224
- var $s = $.facebox.settings
225
-
226
- $s.loadingImage = $s.loading_image || $s.loadingImage
227
- $s.closeImage = $s.close_image || $s.closeImage
228
- $s.imageTypes = $s.image_types || $s.imageTypes
229
- $s.faceboxHtml = $s.facebox_html || $s.faceboxHtml
230
- }
231
-
232
- // Figures out what you want to display and displays it
233
- // formats are:
234
- // div: #id
235
- // image: blah.extension
236
- // ajax: anything else
237
- function fillFaceboxFromHref(href, klass) {
238
- // div
239
- if (href.match(/#/)) {
240
- var url = window.location.href.split('#')[0]
241
- var target = href.replace(url,'')
242
- if (target == '#') return
243
- $.facebox.reveal($(target).html(), klass)
244
-
245
- // image
246
- } else if (href.match($.facebox.settings.imageTypesRegexp)) {
247
- fillFaceboxFromImage(href, klass)
248
- // ajax
249
- } else {
250
- fillFaceboxFromAjax(href, klass)
251
- }
252
- }
253
-
254
- function fillFaceboxFromImage(href, klass) {
255
- var image = new Image()
256
- image.onload = function() {
257
- $.facebox.reveal('<div class="image"><img src="' + image.src + '" /></div>', klass)
258
- }
259
- image.src = href
260
- }
261
-
262
- function fillFaceboxFromAjax(href, klass) {
263
- $.get(href, function(data) { $.facebox.reveal(data, klass) })
264
- }
265
-
266
- function skipOverlay() {
267
- return $.facebox.settings.overlay == false || $.facebox.settings.opacity === null
268
- }
269
-
270
- function showOverlay() {
271
- if (skipOverlay()) return
272
-
273
- if ($('#facebox_overlay').length == 0)
274
- $("body").append('<div id="facebox_overlay" class="facebox_hide"></div>')
275
-
276
- $('#facebox_overlay').hide().addClass("facebox_overlayBG")
277
- .css('opacity', $.facebox.settings.opacity)
278
- .click(function() { $(document).trigger('close.facebox') })
279
- .fadeIn(200)
280
- return false
281
- }
282
-
283
- function hideOverlay() {
284
- if (skipOverlay()) return
285
-
286
- $('#facebox_overlay').fadeOut(200, function(){
287
- $("#facebox_overlay").removeClass("facebox_overlayBG")
288
- $("#facebox_overlay").addClass("facebox_hide")
289
- $("#facebox_overlay").remove()
290
- })
291
-
292
- return false
293
- }
294
-
295
- /*
296
- * Bindings
297
- */
298
-
299
- $(document).bind('close.facebox', function() {
300
- $(document).unbind('keydown.facebox')
301
- $('#facebox').fadeOut(function() {
302
- $('#facebox .content').removeClass().addClass('content')
303
- $('#facebox .loading').remove()
304
- $(document).trigger('afterClose.facebox')
305
- })
306
- hideOverlay()
307
- })
308
-
309
- })(jQuery);
@@ -1,4 +0,0 @@
1
- $(document).ready(function() {
2
- /* Activating Best In Place */
3
- $("#interpret_container .best_in_place").best_in_place()
4
- });
@@ -1,134 +0,0 @@
1
- /**
2
- * Unobtrusive scripting adapter for jQuery
3
- *
4
- * Requires jQuery 1.4.3 or later.
5
- * https://github.com/rails/jquery-ujs
6
- */
7
-
8
- (function($) {
9
- // Triggers an event on an element and returns the event result
10
- function fire(obj, name, data) {
11
- var event = new $.Event(name);
12
- obj.trigger(event, data);
13
- return event.result !== false;
14
- }
15
-
16
- // Submits "remote" forms and links with ajax
17
- function handleRemote(element) {
18
- var method, url, data,
19
- dataType = element.attr('data-type') || ($.ajaxSettings && $.ajaxSettings.dataType);
20
-
21
- if (element.is('form')) {
22
- method = element.attr('method') || 'POST';
23
- url = element.attr('action');
24
- data = element.serializeArray();
25
- // memoized value from clicked submit button
26
- var button = element.data('ujs:submit-button');
27
- if (button) data.push(button);
28
- } else {
29
- method = element.attr('data-method') || 'GET';
30
- url = element.attr('href');
31
- data = null;
32
- }
33
-
34
- $.ajax({
35
- url: url, type: method, data: data, dataType: dataType,
36
- // stopping the "ajax:beforeSend" event will cancel the ajax request
37
- beforeSend: function(xhr, settings) {
38
- if (settings.dataType === undefined) {
39
- xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
40
- }
41
- return fire(element, 'ajax:beforeSend', [xhr, settings]);
42
- },
43
- success: function(data, status, xhr) {
44
- element.trigger('ajax:success', [data, status, xhr]);
45
- },
46
- complete: function(xhr, status) {
47
- element.trigger('ajax:complete', [xhr, status]);
48
- },
49
- error: function(xhr, status, error) {
50
- element.trigger('ajax:error', [xhr, status, error]);
51
- }
52
- });
53
- }
54
-
55
- // Handles "data-method" on links such as:
56
- // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
57
- function handleMethod(link) {
58
- var href = link.attr('href'),
59
- method = link.attr('data-method'),
60
- csrf_token = $('meta[name=csrf-token]').attr('content'),
61
- csrf_param = $('meta[name=csrf-param]').attr('content'),
62
- form = $('<form method="post" action="' + href + '"></form>'),
63
- metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
64
-
65
- if (csrf_param !== undefined && csrf_token !== undefined) {
66
- metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
67
- }
68
-
69
- form.hide().append(metadata_input).appendTo('body');
70
- form.submit();
71
- }
72
-
73
- function allowAction(element) {
74
- var message = element.attr('data-confirm');
75
- return !message || (fire(element, 'confirm') && confirm(message));
76
- }
77
-
78
- $('a[data-confirm], a[data-method], a[data-remote]').live('click.rails', function(e) {
79
- var link = $(this);
80
- if (!allowAction(link)) return false;
81
-
82
- if (link.attr('data-remote')) {
83
- handleRemote(link);
84
- return false;
85
- } else if (link.attr('data-method')) {
86
- handleMethod(link);
87
- return false;
88
- }
89
- });
90
-
91
- $('form').live('submit.rails', function(e) {
92
- var form = $(this);
93
- if (!allowAction(form)) return false;
94
-
95
- if (form.attr('data-remote')) {
96
- handleRemote(form);
97
- return false;
98
- }
99
- });
100
-
101
- $('form input[type=submit], form button[type=submit], form button:not([type])').live('click', function() {
102
- var button = $(this);
103
- if (!allowAction(button)) return false;
104
- // register the pressed submit button
105
- var name = button.attr('name'), data = name ? {name:name, value:button.val()} : null;
106
- button.closest('form').data('ujs:submit-button', data);
107
- });
108
-
109
- /**
110
- * disable-with handlers
111
- */
112
- var disable_with_input_selector = 'input[data-disable-with]',
113
- disable_with_form_remote_selector = 'form[data-remote]:has(' + disable_with_input_selector + ')',
114
- disable_with_form_not_remote_selector = 'form:not([data-remote]):has(' + disable_with_input_selector + ')';
115
-
116
- var disable_with_input_function = function() {
117
- $(this).find(disable_with_input_selector).each(function() {
118
- var input = $(this);
119
- input.data('enable-with', input.val())
120
- .attr('value', input.attr('data-disable-with'))
121
- .attr('disabled', 'disabled');
122
- });
123
- };
124
-
125
- $(disable_with_form_remote_selector).live('ajax:before.rails', disable_with_input_function);
126
- $(disable_with_form_not_remote_selector).live('submit.rails', disable_with_input_function);
127
-
128
- $(disable_with_form_remote_selector).live('ajax:complete.rails', function() {
129
- $(this).find(disable_with_input_selector).each(function() {
130
- var input = $(this);
131
- input.removeAttr('disabled').val(input.data('enable-with'));
132
- });
133
- });
134
- })( jQuery );
Binary file
@@ -1,38 +0,0 @@
1
- #interpret_live_edit {
2
- padding-top: 15px;
3
- padding-right: 16px;
4
- width: 700px;
5
- min-height: 300px;
6
- text-align: center;
7
- }
8
-
9
- #interpret_live_edit textarea {
10
- width: 100%;
11
- height: 31em;
12
- }
13
-
14
- #interpret_live_edit input[type=submit] {
15
- background-color: #555;
16
- color: #FFF;
17
- border: none;
18
- font-size: 1em;
19
- margin-top: .5em;
20
- padding: .6em 1.5em;
21
- cursor: hand;
22
- cursor: pointer;
23
- border-radius: 5px;
24
- }
25
-
26
- #interpret_live_edit input[type=submit]:hover {
27
- background-color: #777;
28
- }
29
-
30
- .interpret_editable {
31
- background-color: #F8FD7D;
32
- cursor: hand;
33
- cursor: pointer;
34
- }
35
- .interpret_editable:hover {
36
- background-color: #FCF305;
37
- }
38
-