spree_essentials 0.2.3 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/README.md +14 -20
  2. data/Rakefile +3 -14
  3. data/{public → app/assets}/images/admin/icons/pages.png +0 -0
  4. data/{public → app/assets}/images/blog/rss.png +0 -0
  5. data/{public → app/assets}/images/markitup/bg-container.png +0 -0
  6. data/{public → app/assets}/images/markitup/bg-editor.png +0 -0
  7. data/{public → app/assets}/images/markitup/bg-picker.png +0 -0
  8. data/{public → app/assets}/images/markitup/bold.png +0 -0
  9. data/{public → app/assets}/images/markitup/code.png +0 -0
  10. data/{public → app/assets}/images/markitup/h1.png +0 -0
  11. data/{public → app/assets}/images/markitup/h2.png +0 -0
  12. data/{public → app/assets}/images/markitup/h3.png +0 -0
  13. data/{public → app/assets}/images/markitup/h4.png +0 -0
  14. data/{public → app/assets}/images/markitup/h5.png +0 -0
  15. data/{public → app/assets}/images/markitup/h6.png +0 -0
  16. data/{public → app/assets}/images/markitup/handle.png +0 -0
  17. data/{public → app/assets}/images/markitup/image-picker.png +0 -0
  18. data/{public → app/assets}/images/markitup/italic.png +0 -0
  19. data/{public → app/assets}/images/markitup/link.png +0 -0
  20. data/{public → app/assets}/images/markitup/list-bullet.png +0 -0
  21. data/{public → app/assets}/images/markitup/list-numeric.png +0 -0
  22. data/{public → app/assets}/images/markitup/menu.png +0 -0
  23. data/{public → app/assets}/images/markitup/more-tag.png +0 -0
  24. data/{public → app/assets}/images/markitup/picture.png +0 -0
  25. data/{public → app/assets}/images/markitup/preview.png +0 -0
  26. data/{public → app/assets}/images/markitup/quotes.png +0 -0
  27. data/{public → app/assets}/images/markitup/submenu.png +0 -0
  28. data/{public → app/assets}/javascripts/date.js +0 -0
  29. data/{public → app/assets}/javascripts/jquery.autodate.js +0 -0
  30. data/{public → app/assets}/javascripts/jquery.markitup.js +51 -32
  31. data/{public → app/assets}/javascripts/markdown.set.js +0 -0
  32. data/{public/stylesheets/markitup.css → app/assets/stylesheets/markitup.css.erb} +28 -28
  33. data/app/controllers/admin/uploads_controller.rb +1 -1
  34. data/app/helpers/admin/spree_essentials_helper.rb +25 -0
  35. data/app/models/{asset_decorator.rb → image_decorator.rb} +2 -2
  36. data/app/models/upload.rb +18 -4
  37. data/app/overrides/spree_essentials.rb +5 -0
  38. data/app/views/admin/shared/_contents_sub_menu.html.erb +4 -6
  39. data/app/views/admin/shared/_contents_tab.html.erb +1 -2
  40. data/app/views/admin/uploads/index.html.erb +1 -1
  41. data/lib/generators/essentials_base.rb +12 -3
  42. data/lib/spree_essentials.rb +11 -10
  43. data/lib/spree_essentials/test_helper.rb +10 -1
  44. data/lib/spree_essentials/version.rb +1 -1
  45. metadata +58 -79
  46. data/app/helpers/admin/base_helper_decorator.rb +0 -18
data/README.md CHANGED
@@ -27,7 +27,7 @@ If you don't already have an existing Spree site, [click here](https://gist.gith
27
27
 
28
28
  Spree Essentials can be installed by itself by adding the following to your Gemfile:
29
29
 
30
- gem 'spree_essentials', '>= 0.2.3'
30
+ gem 'spree_essentials', '>= 0.3.1""
31
31
 
32
32
  This isn't necessary if you're using spree_essentials based extensions. If that's the case, just include the extensions normally:
33
33
 
@@ -78,7 +78,7 @@ Setting up an essential aware extension is easy. In your `lib/[extension_name].r
78
78
  module SpreeEssentialPress
79
79
 
80
80
  def self.tab
81
- [:press, { :route => :admin_press_index }]
81
+ { :label => "Press", :route => :admin_press_index }
82
82
  end
83
83
 
84
84
  def self.sub_tab
@@ -92,10 +92,7 @@ Setting up an essential aware extension is easy. In your `lib/[extension_name].r
92
92
 
93
93
  end
94
94
 
95
- if SpreeEssentialPress.independent?
96
- # your own admin tab would be here
97
- require 'spree_essential_press/custom_hooks'
98
- else
95
+ unless SpreeEssentialPress.independent?
99
96
  # register with Spree Essentials and reside under the "Content" tab
100
97
  SpreeEssentials.register :press, SpreeEssentialPress
101
98
  end
@@ -114,7 +111,7 @@ Please let me know if you find any bugs or have feature requests you'd like to s
114
111
  Testing
115
112
  -------
116
113
 
117
- The test suite is very limited at the moment but can be run like so:
114
+ The test suite can be run like so:
118
115
 
119
116
  git clone git://github.com/citrus/spree_essentials.git
120
117
  cd spree_essentials
@@ -122,16 +119,6 @@ The test suite is very limited at the moment but can be run like so:
122
119
  bundle exec dummier
123
120
  rake
124
121
 
125
-
126
- You can also boot spork to run the tests much faster
127
-
128
- # in one window
129
- cd spree_essentials
130
- spork
131
-
132
- # in another window
133
- testdrb test/**/*_test.rb
134
-
135
122
 
136
123
  Demo
137
124
  ----
@@ -160,9 +147,16 @@ To Do
160
147
  Change Log
161
148
  ----------
162
149
 
163
- **0.2.3 - 2012/1/6**
150
+ **0.3.1 - 2011/12/13**
151
+
152
+ * Fix broken markitup editor
153
+ * Rework 'selected' class on content tab
154
+
155
+
156
+ **0.3.0 - 2011/12/13**
164
157
 
165
- * Removed automatic attachment config with SpreeHeroku
158
+ * Upgrade to Spree 0.70.x
159
+ * Remove spork dependency
166
160
 
167
161
 
168
162
  **0.2.2 - 2011/7/22**
@@ -210,4 +204,4 @@ If you'd like to help out feel free to fork and send me pull requests!
210
204
  License
211
205
  -------
212
206
 
213
- Copyright (c) 2011 Spencer Steffen, released under the New BSD License All rights reserved.
207
+ Copyright (c) 2011 Spencer Steffen & Citrus, released under the New BSD License All rights reserved.
data/Rakefile CHANGED
@@ -1,21 +1,10 @@
1
1
  # encoding: UTF-8
2
- require 'rubygems'
3
- begin
4
- require 'bundler/setup'
5
- rescue LoadError
6
- puts 'You must run `gem install bundler` and `bundle install` to run rake tasks'
7
- end
8
-
9
- require 'rake'
2
+ require "bundler/gem_tasks"
10
3
  require 'rake/testtask'
11
4
 
12
- Bundler::GemHelper.install_tasks
13
-
14
- Rake::TestTask.new(:test) do |t|
15
- t.libs << 'lib'
16
- t.libs << 'test'
5
+ Rake::TestTask.new do |t|
6
+ t.libs << 'lib' << 'test'
17
7
  t.pattern = 'test/**/*_test.rb'
18
- t.verbose = false
19
8
  end
20
9
 
21
10
  task :default => :test
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -3,7 +3,7 @@
3
3
  // v 1.1.x
4
4
  // Dual licensed under the MIT and GPL licenses.
5
5
  // ----------------------------------------------------------------------------
6
- // Copyright (C) 2007-2010 Jay Salvat
6
+ // Copyright (C) 2007-2011 Jay Salvat
7
7
  // http://markitup.jaysalvat.com/
8
8
  // ----------------------------------------------------------------------------
9
9
  // Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -35,7 +35,8 @@
35
35
  previewInWindow: '', // 'width=800, height=600, resizable=yes, scrollbars=yes'
36
36
  previewAutoRefresh: true,
37
37
  previewPosition: 'after',
38
- previewTemplatePath: '',
38
+ previewTemplatePath: '~/templates/preview.html',
39
+ previewParser: false,
39
40
  previewParserPath: '',
40
41
  previewParserVar: 'data',
41
42
  resizeHandle: true,
@@ -164,7 +165,7 @@
164
165
  return false;
165
166
  }).bind("focusin", function(){
166
167
  $$.focus();
167
- }).mousedown(function() {
168
+ }).mouseup(function() {
168
169
  if (button.call) {
169
170
  eval(button.call)();
170
171
  }
@@ -233,22 +234,38 @@
233
234
 
234
235
  // build block to insert
235
236
  function build(string) {
236
- var openWith = prepare(clicked.openWith);
237
- var placeHolder = prepare(clicked.placeHolder);
238
- var replaceWith = prepare(clicked.replaceWith);
239
- var closeWith = prepare(clicked.closeWith);
237
+ var openWith = prepare(clicked.openWith);
238
+ var placeHolder = prepare(clicked.placeHolder);
239
+ var replaceWith = prepare(clicked.replaceWith);
240
+ var closeWith = prepare(clicked.closeWith);
241
+ var openBlockWith = prepare(clicked.openBlockWith);
242
+ var closeBlockWith = prepare(clicked.closeBlockWith);
243
+ var multiline = clicked.multiline;
244
+
240
245
  if (replaceWith !== "") {
241
246
  block = openWith + replaceWith + closeWith;
242
247
  } else if (selection === '' && placeHolder !== '') {
243
248
  block = openWith + placeHolder + closeWith;
244
249
  } else {
245
- string = string || selection;
246
- if (string.match(/ $/)) {
247
- block = openWith + string.replace(/ $/, '') + closeWith + ' ';
248
- } else {
249
- block = openWith + string + closeWith;
250
+ string = string || selection;
251
+
252
+ var lines = selection.split(/\r?\n/), blocks = [];
253
+
254
+ for (var l=0; l < lines.length; l++) {
255
+ line = lines[l];
256
+ var trailingSpaces;
257
+ if (trailingSpaces = line.match(/ *$/)) {
258
+ blocks.push(openWith + line.replace(/ *$/g, '') + closeWith + trailingSpaces);
259
+ } else {
260
+ blocks.push(openWith + line + closeWith);
261
+ }
250
262
  }
263
+
264
+ block = blocks.join("\n");
251
265
  }
266
+
267
+ block = openBlockWith + block + closeBlockWith;
268
+
252
269
  return { block:block,
253
270
  openWith:openWith,
254
271
  replaceWith:replaceWith,
@@ -262,7 +279,6 @@
262
279
  var len, j, n, i;
263
280
  hash = clicked = button;
264
281
  get();
265
-
266
282
  $.extend(hash, { line:"",
267
283
  root:options.root,
268
284
  textarea:textarea,
@@ -276,12 +292,12 @@
276
292
  // callbacks before insertion
277
293
  prepare(options.beforeInsert);
278
294
  prepare(clicked.beforeInsert);
279
- if (ctrlKey === true && shiftKey === true) {
295
+ if ((ctrlKey === true && shiftKey === true) || button.multiline === true) {
280
296
  prepare(clicked.beforeMultiInsert);
281
297
  }
282
298
  $.extend(hash, { line:1 });
283
-
284
- if (ctrlKey === true && shiftKey === true) {
299
+
300
+ if ((ctrlKey === true && shiftKey === true)) {
285
301
  lines = selection.split(/\r?\n/);
286
302
  for (j = 0, n = lines.length, i = 0; i < n; i++) {
287
303
  if ($.trim(lines[i]) !== '') {
@@ -333,7 +349,7 @@
333
349
  $.extend(hash, { line:'', selection:selection });
334
350
 
335
351
  // callbacks after insertion
336
- if (ctrlKey === true && shiftKey === true) {
352
+ if ((ctrlKey === true && shiftKey === true) || button.multiline === true) {
337
353
  prepare(clicked.afterMultiInsert);
338
354
  }
339
355
  prepare(clicked.afterInsert);
@@ -358,7 +374,7 @@
358
374
  // Substract linefeed in IE
359
375
  function fixIeBug(string) {
360
376
  if ($.browser.msie) {
361
- return string.length - string.replace(/\r/g, '').length;
377
+ return string.length - string.replace(/\r*/g, '').length;
362
378
  }
363
379
  return 0;
364
380
  }
@@ -398,21 +414,21 @@
398
414
 
399
415
  scrollPosition = textarea.scrollTop;
400
416
  if (document.selection) {
401
- selection = document.selection;
402
- if ($.browser.msie) { // ie
403
- var range = selection.createRange();
404
- var stored_range = range.duplicate();
405
- stored_range.moveToElementText(textarea);
406
- stored_range.setEndPoint('EndToEnd', range);
407
- var s = stored_range.text.length - range.text.length;
408
-
409
- caretPosition = s - (textarea.value.substr(0, s).length - textarea.value.substr(0, s).replace(/\r/g, '').length);
410
- selection = range.text;
417
+ selection = document.selection.createRange().text;
418
+ if ($.browser.msie) { // ie
419
+ var range = document.selection.createRange(), rangeCopy = range.duplicate();
420
+ rangeCopy.moveToElementText(textarea);
421
+ caretPosition = -1;
422
+ while(rangeCopy.inRange(range)) {
423
+ rangeCopy.moveStart('character');
424
+ caretPosition ++;
425
+ }
411
426
  } else { // opera
412
427
  caretPosition = textarea.selectionStart;
413
428
  }
414
429
  } else { // gecko & webkit
415
430
  caretPosition = textarea.selectionStart;
431
+
416
432
  selection = textarea.value.substring(caretPosition, textarea.selectionEnd);
417
433
  }
418
434
  return selection;
@@ -458,7 +474,10 @@
458
474
 
459
475
  function renderPreview() {
460
476
  var phtml;
461
- if (options.previewParserPath !== '') {
477
+ if (options.previewParser && typeof options.previewParser === 'function') {
478
+ var data = options.previewParser( $$.val() );
479
+ writeInPreview( localize(data, 1) );
480
+ } else if (options.previewParserPath !== '') {
462
481
  $.ajax({
463
482
  type: 'POST',
464
483
  dataType: 'text',
@@ -502,15 +521,15 @@
502
521
  function keyPressed(e) {
503
522
  shiftKey = e.shiftKey;
504
523
  altKey = e.altKey;
505
- ctrlKey = (!(e.altKey && e.ctrlKey)) ? e.ctrlKey : false;
524
+ ctrlKey = (!(e.altKey && e.ctrlKey)) ? (e.ctrlKey || e.metaKey) : false;
506
525
 
507
526
  if (e.type === 'keydown') {
508
527
  if (ctrlKey === true) {
509
- li = $("a[accesskey="+String.fromCharCode(e.keyCode)+"]", header).parent('li');
528
+ li = $('a[accesskey="'+String.fromCharCode(e.keyCode)+'"]', header).parent('li');
510
529
  if (li.length !== 0) {
511
530
  ctrlKey = false;
512
531
  setTimeout(function() {
513
- li.triggerHandler('mousedown');
532
+ li.triggerHandler('mouseup');
514
533
  },1);
515
534
  return false;
516
535
  }
File without changes
@@ -19,7 +19,7 @@
19
19
  }
20
20
  .markItUpContainer {
21
21
  border:1px solid #3C769D;
22
- background:#FFF url(../images/markitup/bg-container.png) repeat-x top left;
22
+ background:#FFF url(<%= asset_path('markitup/bg-container.png') %>) repeat-x top left;
23
23
  padding:5px 27px 2px 5px;
24
24
  font:11px Verdana, Arial, Helvetica, sans-serif;
25
25
  }
@@ -29,7 +29,7 @@
29
29
  border:1px solid #3C769D;
30
30
  width:100%;
31
31
  height:320px;
32
- background:#FFF url(../images/markitup/bg-editor.png) repeat-x top right;
32
+ background:#FFF url(<%= asset_path('markitup/bg-editor.png') %>) repeat-x top right;
33
33
  clear:both;
34
34
  line-height:18px;
35
35
  overflow:auto;
@@ -54,7 +54,7 @@
54
54
  width:22px; height:5px;
55
55
  margin-left:auto;
56
56
  margin-right:auto;
57
- background-image:url(../images/markitup/handle.png);
57
+ background-image:url(<%= asset_path('markitup/handle.png') %>);
58
58
  cursor:n-resize;
59
59
  }
60
60
  /***************************************************************************************/
@@ -71,7 +71,7 @@
71
71
  display:block;
72
72
  }
73
73
  .markItUpHeader ul .markItUpDropMenu {
74
- background:transparent url(../images/markitup/menu.png) no-repeat 115% 50%;
74
+ background:transparent url(<%= asset_path('markitup/menu.png') %>) no-repeat 115% 50%;
75
75
  margin-right:5px;
76
76
  }
77
77
  .markItUpHeader ul .markItUpDropMenu li {
@@ -102,7 +102,7 @@
102
102
  border-bottom:1px solid #3C769D;
103
103
  }
104
104
  .markItUpHeader ul ul .markItUpDropMenu {
105
- background:#F5F5F5 url(../images/markitup/submenu.png) no-repeat 100% 50%;
105
+ background:#F5F5F5 url(<%= asset_path('markitup/submenu.png') %>) no-repeat 100% 50%;
106
106
  }
107
107
  /* next rows of buttons */
108
108
  .markItUpHeader ul ul ul {
@@ -134,20 +134,20 @@
134
134
  }
135
135
  /***************************************************************************************/
136
136
  .html .markItUpEditor {
137
- background-image:url(../images/markitup/bg-editor-html.png);
137
+ background-image:url(<%= asset_path('markitup/bg-editor-html.png') %>);
138
138
  }
139
139
  .markdown .markItUpEditor {
140
- background-image:url(../images/markitup/bg-editor-markdown.png);
140
+ background-image:url(<%= asset_path('markitup/bg-editor-markdown.png') %>);
141
141
  }
142
142
  .textile .markItUpEditor {
143
- background-image:url(../images/markitup/bg-editor-textile.png);
143
+ background-image:url(<%= asset_path('markitup/bg-editor-textile.png') %>);
144
144
  }
145
145
  .bbcode .markItUpEditor {
146
- background-image:url(../images/markitup/bg-editor-bbcode.png);
146
+ background-image:url(<%= asset_path('markitup/bg-editor-bbcode.png') %>);
147
147
  }
148
148
  .wiki .markItUpEditor,
149
149
  .dotclear .markItUpEditor {
150
- background-image:url(../images/markitup/bg-editor-wiki.png);
150
+ background-image:url(<%= asset_path('markitup/bg-editor-wiki.png') %>);
151
151
  }
152
152
 
153
153
 
@@ -157,59 +157,59 @@
157
157
  // By Jay Salvat - http://markitup.jaysalvat.com/
158
158
  // ------------------------------------------------------------------*/
159
159
  .markItUp .markItUpButton1 a {
160
- background-image:url(../images/markitup/h1.png);
160
+ background-image:url(<%= asset_path('markitup/h1.png') %>);
161
161
  }
162
162
  .markItUp .markItUpButton2 a {
163
- background-image:url(../images/markitup/h2.png);
163
+ background-image:url(<%= asset_path('markitup/h2.png') %>);
164
164
  }
165
165
  .markItUp .markItUpButton3 a {
166
- background-image:url(../images/markitup/h3.png);
166
+ background-image:url(<%= asset_path('markitup/h3.png') %>);
167
167
  }
168
168
  .markItUp .markItUpButton4 a {
169
- background-image:url(../images/markitup/h4.png);
169
+ background-image:url(<%= asset_path('markitup/h4.png') %>);
170
170
  }
171
171
  .markItUp .markItUpButton5 a {
172
- background-image:url(../images/markitup/h5.png);
172
+ background-image:url(<%= asset_path('markitup/h5.png') %>);
173
173
  }
174
174
  .markItUp .markItUpButton6 a {
175
- background-image:url(../images/markitup/h6.png);
175
+ background-image:url(<%= asset_path('markitup/h6.png') %>);
176
176
  }
177
177
 
178
178
  .markItUp .markItUpButton7 a {
179
- background-image:url(../images/markitup/bold.png);
179
+ background-image:url(<%= asset_path('markitup/bold.png') %>);
180
180
  }
181
181
  .markItUp .markItUpButton8 a {
182
- background-image:url(../images/markitup/italic.png);
182
+ background-image:url(<%= asset_path('markitup/italic.png') %>);
183
183
  }
184
184
 
185
185
  .markItUp .markItUpButton9 a {
186
- background-image:url(../images/markitup/list-bullet.png);
186
+ background-image:url(<%= asset_path('markitup/list-bullet.png') %>);
187
187
  }
188
188
  .markItUp .markItUpButton10 a {
189
- background-image:url(../images/markitup/list-numeric.png);
189
+ background-image:url(<%= asset_path('markitup/list-numeric.png') %>);
190
190
  }
191
191
 
192
192
  .markItUp .markItUpButton11 a {
193
- background-image:url(../images/markitup/picture.png);
193
+ background-image:url(<%= asset_path('markitup/picture.png') %>);
194
194
  }
195
195
  .markItUp .markItUpButton12 a {
196
- background-image:url(../images/markitup/link.png);
196
+ background-image:url(<%= asset_path('markitup/link.png') %>);
197
197
  }
198
198
 
199
199
  .markItUp .markItUpButton13 a {
200
- background-image:url(../images/markitup/quotes.png);
200
+ background-image:url(<%= asset_path('markitup/quotes.png') %>);
201
201
  }
202
202
  .markItUp .markItUpButton14 a {
203
- background-image:url(../images/markitup/code.png);
203
+ background-image:url(<%= asset_path('markitup/code.png') %>);
204
204
  }
205
205
  .markItUp .markItUpButton15 a {
206
- background-image:url(../images/markitup/more-tag.png);
206
+ background-image:url(<%= asset_path('markitup/more-tag.png') %>);
207
207
  }
208
208
  .markItUp .markItUpButton16 a {
209
- background-image:url(../images/markitup/image-picker.png);
209
+ background-image:url(<%= asset_path('markitup/image-picker.png') %>);
210
210
  }
211
211
  .markItUp .markItUpButton17 a {
212
- background-image:url(../images/markitup/preview.png);
212
+ background-image:url(<%= asset_path('markitup/preview.png') %>);
213
213
  }
214
214
 
215
215
 
@@ -222,7 +222,7 @@ div.image-picker {
222
222
  width: 100%;
223
223
  height: 0;
224
224
  overflow: hidden;
225
- background: #fff url(../images/markitup/bg-picker.png) repeat-x bottom left;
225
+ background: #fff url(<%= asset_path('markitup/bg-picker.png') %>) repeat-x bottom left;
226
226
  border: 1px solid #ccc;
227
227
  }
228
228
  div.image-picker ul,
@@ -14,7 +14,7 @@ class Admin::UploadsController < Admin::ResourceController
14
14
  params[:search] ||= {}
15
15
  params[:search][:meta_sort] ||= "created_at.desc"
16
16
  @search = Upload.metasearch(params[:search])
17
- @collection = @search.paginate(:per_page => Spree::Config[:orders_per_page], :page => params[:page])
17
+ @collection = @search.page(params[:page]).per(Spree::Config[:orders_per_page])
18
18
  end
19
19
 
20
20
  end
@@ -0,0 +1,25 @@
1
+ module Admin::SpreeEssentialsHelper
2
+
3
+ def contents_tab
4
+ routes = SpreeEssentials.essentials.map do |key, cls|
5
+ route = cls.tab[:route] || "admin_#{key}"
6
+ send("#{route}_path") rescue "##{key}"
7
+ end
8
+ routes.push admin_uploads_path
9
+ cls = request.path.scan(Regexp.new(routes.join("|"))).empty? ? nil : 'selected'
10
+ content_tag :li, :class => cls do
11
+ link_to I18n.t('admin.shared.contents_tab.content'), routes.first
12
+ end
13
+ end
14
+
15
+ def markdown_helper
16
+ content_tag('em', :class => 'small') do
17
+ [
18
+ "&nbsp;",
19
+ t('essentials.parsed_with'),
20
+ link_to("Markdown", "http://daringfireball.net/projects/markdown/basics", :onclick => 'window.open(this.href); return false')
21
+ ].join(" ").html_safe
22
+ end
23
+ end
24
+
25
+ end
@@ -1,7 +1,7 @@
1
- Asset.class_eval do
1
+ Image.class_eval do
2
2
 
3
3
  def has_alt?
4
4
  !alt.blank?
5
5
  end
6
6
 
7
- end
7
+ end
data/app/models/upload.rb CHANGED
@@ -1,12 +1,26 @@
1
1
  class Upload < Asset
2
2
 
3
- default_scope where(:type => "Upload")
3
+ default_scope where(:type => "Upload") if table_exists?
4
4
 
5
5
  validate :no_attachement_errors
6
6
 
7
- has_attached_file :attachment,
8
- :styles => Proc.new{ |clip| clip.instance.attachment_sizes },
9
- :default_style => :medium
7
+ # Check for spree_heroku
8
+ # https://github.com/paxer/spree-heroku
9
+ #
10
+ if defined?(SpreeHeroku)
11
+ has_attached_file :attachment,
12
+ :styles => Proc.new{ |clip| clip.instance.attachment_sizes },
13
+ :default_style => :medium,
14
+ :path => "assets/uploads/:id/:style/:basename.:extension",
15
+ :storage => "s3",
16
+ :s3_credentials => "#{Rails.root}/config/s3.yml"
17
+ else
18
+ has_attached_file :attachment,
19
+ :styles => Proc.new{ |clip| clip.instance.attachment_sizes },
20
+ :default_style => :medium,
21
+ :url => "/assets/uploads/:id/:style/:basename.:extension",
22
+ :path => ":rails_root/public/assets/uploads/:id/:style/:basename.:extension"
23
+ end
10
24
 
11
25
  def image_content?
12
26
  attachment_content_type.match(/\/(jpeg|png|gif|tiff|x-photoshop)/)
@@ -0,0 +1,5 @@
1
+ Deface::Override.new(:virtual_path => "layouts/admin",
2
+ :name => "spree_essential_admin_tabs",
3
+ :insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]",
4
+ :partial => "admin/shared/contents_tab",
5
+ :disabled => false)
@@ -1,10 +1,8 @@
1
1
  <% content_for :sub_menu do %>
2
- <ul id="sub_nav">
3
- <%= hook :admin_contents_sub_tabs do %>
4
- <% SpreeEssentials.essentials.each_pair do |name, cls| %>
5
- <%= tab *cls.sub_tab if defined?(cls.sub_tab) %>
6
- <% end %>
7
- <%= tab :uploads, :label => 'admin.subnav.uploads' %>
2
+ <ul id="sub_nav" data-hook="essentials_sub_nav">
3
+ <% SpreeEssentials.essentials.each_pair do |name, cls| %>
4
+ <%= tab *cls.sub_tab if defined?(cls.sub_tab) %>
8
5
  <% end %>
6
+ <%= tab :uploads, :label => 'admin.subnav.uploads' %>
9
7
  </ul>
10
8
  <% end %>
@@ -1,2 +1 @@
1
- <%= tab *[SpreeEssentials.essentials.map{|key, cls| cls.tab if defined?(cls.tab) }, :uploads, { :label => '.content' }].flatten %>
2
-
1
+ <%= contents_tab %>
@@ -31,7 +31,7 @@
31
31
 
32
32
  </table>
33
33
 
34
- <%= will_paginate(:prev => "&#171; #{t('previous')}", :next => "#{t('next')} &#187;") %>
34
+ <%= paginate @uploads %>
35
35
 
36
36
  <div id="images"></div>
37
37
  <br/>
@@ -4,15 +4,24 @@ module SpreeEssentials
4
4
 
5
5
  include Rails::Generators::Migration
6
6
 
7
- def self.count!
7
+ def self.count
8
8
  @count ||= 0
9
9
  (@count += 1) * 3
10
10
  end
11
+
12
+ def self.new_migration_number
13
+ (Time.new.utc + self.count).strftime("%Y%m%d%H%M%S")
14
+ end
11
15
 
12
16
  def self.next_migration_number(path)
13
17
  @time ||= Time.new.utc
14
18
  if ActiveRecord::Base.timestamped_migrations
15
- (@time + self.count!).strftime("%Y%m%d%H%M%S")
19
+ files = Dir.entries(Rails.root.join("db/migrate"))
20
+ migration = new_migration_number
21
+ while files.join.include?(migration)
22
+ migration = new_migration_number
23
+ end
24
+ migration
16
25
  else
17
26
  "%.3d" % (current_migration_number(dirname) + 1)
18
27
  end
@@ -20,4 +29,4 @@ module SpreeEssentials
20
29
 
21
30
  end
22
31
  end
23
- end
32
+ end
@@ -30,17 +30,18 @@ module SpreeEssentials
30
30
  app.middleware.insert_before ::Rack::Lock, ::ActionDispatch::Static, "#{config.root}/public"
31
31
  end
32
32
 
33
- def self.activate
34
- Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator.rb")) do |c|
35
- Rails.env.production? ? require(c) : load(c)
33
+ config.to_prepare do
34
+ #loads application's model / class decorators
35
+ Dir.glob File.expand_path("../../app/**/*_decorator*.rb") do |c|
36
+ Rails.configuration.cache_classes ? require(c) : load(c)
36
37
  end
37
- end
38
38
 
39
- config.to_prepare &method(:activate).to_proc
40
- end
41
-
42
- class CustomHooks < Spree::ThemeSupport::HookListener
43
- insert_after :admin_tabs, 'admin/shared/contents_tab'
39
+ #loads application's deface view overrides
40
+ Dir.glob File.expand_path("../../app/overrides/*.rb", __FILE__) do |c|
41
+ Rails.application.config.cache_classes ? require(c) : load(c)
42
+ end
43
+ end
44
+
44
45
  end
45
-
46
+
46
47
  end
@@ -21,9 +21,18 @@ Capybara.default_selector = :css
21
21
  # Define a bare test case to use with Capybara
22
22
  class ActiveSupport::IntegrationCase < ActiveSupport::TestCase
23
23
 
24
- include Capybara
24
+ include Capybara::DSL
25
25
  include Rails.application.routes.url_helpers
26
26
 
27
+
28
+ # Extreme hax! wtf is this for anyways.. and why is it erroring?
29
+ def testmail_admin_mail_method_url(*args)
30
+ "#wtf"
31
+ end
32
+ alias :testmail_admin_mail_method_path :testmail_admin_mail_method_url
33
+
34
+
35
+
27
36
  self.use_transactional_fixtures = false
28
37
 
29
38
  # Checks for missing translations after each test
@@ -1,3 +1,3 @@
1
1
  module SpreeEssentials
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_essentials
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-06 00:00:00.000000000Z
12
+ date: 2011-12-15 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spree_core
16
- requirement: &70343609052760 !ruby/object:Gem::Requirement
16
+ requirement: &70108455614680 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.60.0
21
+ version: 0.70.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70343609052760
24
+ version_requirements: *70108455614680
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdiscount
27
- requirement: &70343609052140 !ruby/object:Gem::Requirement
27
+ requirement: &70108455614020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,84 +32,62 @@ dependencies:
32
32
  version: 1.6.8
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70343609052140
35
+ version_requirements: *70108455614020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: shoulda
38
- requirement: &70343609051340 !ruby/object:Gem::Requirement
38
+ requirement: &70108455613300 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
42
42
  - !ruby/object:Gem::Version
43
- version: 2.11.3
43
+ version: 3.0.0.beta2
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70343609051340
46
+ version_requirements: *70108455613300
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: dummier
49
- requirement: &70343609050500 !ruby/object:Gem::Requirement
49
+ requirement: &70108455612720 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.2.0
54
+ version: 0.2.4
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70343609050500
57
+ version_requirements: *70108455612720
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: factory_girl
60
- requirement: &70343609050020 !ruby/object:Gem::Requirement
60
+ requirement: &70108455611860 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
64
64
  - !ruby/object:Gem::Version
65
- version: 2.0.0.beta4
65
+ version: 2.3.2
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70343609050020
68
+ version_requirements: *70108455611860
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: capybara
71
- requirement: &70343609049440 !ruby/object:Gem::Requirement
71
+ requirement: &70108455610640 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
75
75
  - !ruby/object:Gem::Version
76
- version: 1.0.0
76
+ version: 1.1.2
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70343609049440
79
+ version_requirements: *70108455610640
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: sqlite3
82
- requirement: &70343609048820 !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
87
- version: 1.3.3
88
- type: :development
89
- prerelease: false
90
- version_requirements: *70343609048820
91
- - !ruby/object:Gem::Dependency
92
- name: spork
93
- requirement: &70343609048360 !ruby/object:Gem::Requirement
94
- none: false
95
- requirements:
96
- - - ! '>='
97
- - !ruby/object:Gem::Version
98
- version: 0.9.0.rc9
99
- type: :development
100
- prerelease: false
101
- version_requirements: *70343609048360
102
- - !ruby/object:Gem::Dependency
103
- name: spork-testunit
104
- requirement: &70343609047760 !ruby/object:Gem::Requirement
82
+ requirement: &70108455598500 !ruby/object:Gem::Requirement
105
83
  none: false
106
84
  requirements:
107
85
  - - ! '>='
108
86
  - !ruby/object:Gem::Version
109
- version: 0.0.5
87
+ version: 1.3.4
110
88
  type: :development
111
89
  prerelease: false
112
- version_requirements: *70343609047760
90
+ version_requirements: *70108455598500
113
91
  description: Spree Essentials provides a base for several other Spree Commerce extensions.
114
92
  The idea is to provide other extensions with common functionality such as an asset-upload
115
93
  interface, a markdown editor, and a common admin-navigation tab.
@@ -129,11 +107,42 @@ files:
129
107
  - lib/spree_essentials/test_helper.rb
130
108
  - lib/spree_essentials/version.rb
131
109
  - lib/spree_essentials.rb
110
+ - app/assets/images/admin/icons/pages.png
111
+ - app/assets/images/blog/rss.png
112
+ - app/assets/images/markitup/bg-container.png
113
+ - app/assets/images/markitup/bg-editor.png
114
+ - app/assets/images/markitup/bg-picker.png
115
+ - app/assets/images/markitup/bold.png
116
+ - app/assets/images/markitup/code.png
117
+ - app/assets/images/markitup/h1.png
118
+ - app/assets/images/markitup/h2.png
119
+ - app/assets/images/markitup/h3.png
120
+ - app/assets/images/markitup/h4.png
121
+ - app/assets/images/markitup/h5.png
122
+ - app/assets/images/markitup/h6.png
123
+ - app/assets/images/markitup/handle.png
124
+ - app/assets/images/markitup/image-picker.png
125
+ - app/assets/images/markitup/italic.png
126
+ - app/assets/images/markitup/link.png
127
+ - app/assets/images/markitup/list-bullet.png
128
+ - app/assets/images/markitup/list-numeric.png
129
+ - app/assets/images/markitup/menu.png
130
+ - app/assets/images/markitup/more-tag.png
131
+ - app/assets/images/markitup/picture.png
132
+ - app/assets/images/markitup/preview.png
133
+ - app/assets/images/markitup/quotes.png
134
+ - app/assets/images/markitup/submenu.png
135
+ - app/assets/javascripts/date.js
136
+ - app/assets/javascripts/jquery.autodate.js
137
+ - app/assets/javascripts/jquery.markitup.js
138
+ - app/assets/javascripts/markdown.set.js
139
+ - app/assets/stylesheets/markitup.css.erb
132
140
  - app/controllers/admin/markdown_controller.rb
133
141
  - app/controllers/admin/uploads_controller.rb
134
- - app/helpers/admin/base_helper_decorator.rb
135
- - app/models/asset_decorator.rb
142
+ - app/helpers/admin/spree_essentials_helper.rb
143
+ - app/models/image_decorator.rb
136
144
  - app/models/upload.rb
145
+ - app/overrides/spree_essentials.rb
137
146
  - app/validators/datetime_validator.rb
138
147
  - app/views/admin/shared/_contents_sub_menu.html.erb
139
148
  - app/views/admin/shared/_contents_tab.html.erb
@@ -142,36 +151,6 @@ files:
142
151
  - app/views/admin/uploads/index.html.erb
143
152
  - app/views/admin/uploads/new.html.erb
144
153
  - app/views/admin/uploads/picker.html.erb
145
- - public/images/admin/icons/pages.png
146
- - public/images/blog/rss.png
147
- - public/images/markitup/bg-container.png
148
- - public/images/markitup/bg-editor.png
149
- - public/images/markitup/bg-picker.png
150
- - public/images/markitup/bold.png
151
- - public/images/markitup/code.png
152
- - public/images/markitup/h1.png
153
- - public/images/markitup/h2.png
154
- - public/images/markitup/h3.png
155
- - public/images/markitup/h4.png
156
- - public/images/markitup/h5.png
157
- - public/images/markitup/h6.png
158
- - public/images/markitup/handle.png
159
- - public/images/markitup/image-picker.png
160
- - public/images/markitup/italic.png
161
- - public/images/markitup/link.png
162
- - public/images/markitup/list-bullet.png
163
- - public/images/markitup/list-numeric.png
164
- - public/images/markitup/menu.png
165
- - public/images/markitup/more-tag.png
166
- - public/images/markitup/picture.png
167
- - public/images/markitup/preview.png
168
- - public/images/markitup/quotes.png
169
- - public/images/markitup/submenu.png
170
- - public/javascripts/date.js
171
- - public/javascripts/jquery.autodate.js
172
- - public/javascripts/jquery.markitup.js
173
- - public/javascripts/markdown.set.js
174
- - public/stylesheets/markitup.css
175
154
  - Rakefile
176
155
  homepage: https://github.com/citrus/spree_essentials
177
156
  licenses: []
@@ -187,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
187
166
  version: '0'
188
167
  segments:
189
168
  - 0
190
- hash: -4112717621804391650
169
+ hash: -706572084736491213
191
170
  required_rubygems_version: !ruby/object:Gem::Requirement
192
171
  none: false
193
172
  requirements:
@@ -196,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
175
  version: '0'
197
176
  segments:
198
177
  - 0
199
- hash: -4112717621804391650
178
+ hash: -706572084736491213
200
179
  requirements: []
201
180
  rubyforge_project:
202
181
  rubygems_version: 1.8.10
@@ -1,18 +0,0 @@
1
- Spree::BaseHelper.class_eval do
2
-
3
- def markdown_helper
4
- content_tag('em', :class => 'small') do
5
- [
6
- "&nbsp;",
7
- t('essentials.parsed_with'),
8
- link_to("Markdown", "http://daringfireball.net/projects/markdown/basics", :onclick => 'window.open(this.href); return false')
9
- ].join(" ").html_safe
10
- end
11
- end
12
-
13
- def method_missing(method, *args, &block)
14
- return super unless method.to_s =~ /_path$/
15
- "/" + method.to_s.sub(/_path$/, '').gsub('_', '-')
16
- end
17
-
18
- end