alchemy_cms 2.1.beta5 → 2.1.beta6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/Gemfile +1 -1
  2. data/README.md +14 -0
  3. data/alchemy_cms.gemspec +1 -1
  4. data/app/assets/javascripts/alchemy/alchemy.base.js +8 -2
  5. data/app/assets/javascripts/alchemy/alchemy.dragndrop.js.erb +1 -1
  6. data/app/assets/javascripts/alchemy/alchemy.link_overlay.js +1 -10
  7. data/app/assets/javascripts/alchemy/alchemy.routes.js.erb +9 -9
  8. data/app/assets/stylesheets/alchemy/base.css.scss +68 -66
  9. data/app/assets/stylesheets/alchemy/elements.css.scss +3 -2
  10. data/app/assets/stylesheets/alchemy/jquery-ui.alchemy.css.scss +1 -1
  11. data/app/assets/stylesheets/alchemy/jquery.Jcrop.css.scss +1 -1
  12. data/app/assets/stylesheets/alchemy/jquery.sb.css.scss +1 -1
  13. data/app/assets/stylesheets/alchemy/tinymce_content.css.scss +1 -1
  14. data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +1 -1
  15. data/app/controllers/alchemy/admin/base_controller.rb +1 -1
  16. data/app/controllers/alchemy/admin/contents_controller.rb +1 -1
  17. data/app/controllers/alchemy/admin/elements_controller.rb +2 -1
  18. data/app/controllers/alchemy/admin/pages_controller.rb +18 -8
  19. data/app/controllers/alchemy/admin/resources_controller.rb +1 -1
  20. data/app/controllers/alchemy/pages_controller.rb +14 -2
  21. data/app/helpers/alchemy/admin/base_helper.rb +2 -2
  22. data/app/helpers/alchemy/admin/elements_helper.rb +1 -1
  23. data/app/helpers/alchemy/admin/essences_helper.rb +1 -1
  24. data/app/helpers/alchemy/base_helper.rb +0 -8
  25. data/app/helpers/alchemy/essences_helper.rb +1 -2
  26. data/app/helpers/alchemy/pages_helper.rb +3 -3
  27. data/app/models/alchemy/content.rb +27 -3
  28. data/app/models/alchemy/element.rb +2 -2
  29. data/app/models/alchemy/page.rb +4 -4
  30. data/app/models/alchemy/user.rb +5 -1
  31. data/app/views/alchemy/admin/clipboard/insert.js.erb +9 -9
  32. data/app/views/alchemy/admin/dashboard/index.html.erb +1 -1
  33. data/app/views/alchemy/admin/elements/create.js.erb +26 -19
  34. data/app/views/alchemy/admin/essence_pictures/assign.js.erb +1 -1
  35. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +4 -4
  36. data/app/views/alchemy/admin/essence_pictures/update.js.erb +1 -1
  37. data/app/views/alchemy/admin/layoutpages/index.html.erb +1 -14
  38. data/app/views/alchemy/admin/pages/_external_link.html.erb +3 -13
  39. data/app/views/alchemy/admin/pages/index.html.erb +1 -14
  40. data/app/views/alchemy/admin/partials/_language_tree_select.html.erb +22 -0
  41. data/app/views/alchemy/admin/partials/_pagination_links.html.erb +3 -1
  42. data/app/views/alchemy/admin/pictures/update.js.erb +2 -0
  43. data/app/views/alchemy/admin/trash/index.html.erb +1 -1
  44. data/app/views/alchemy/admin/users/_user.html.erb +1 -1
  45. data/config/locales/alchemy.de.yml +29 -17
  46. data/config/locales/alchemy.en.yml +5 -4
  47. data/lib/alchemy/capistrano.rb +5 -0
  48. data/lib/alchemy/i18n.rb +1 -1
  49. data/lib/alchemy/page_layout.rb +1 -1
  50. data/lib/alchemy/scoped_pagination_link_renderer.rb +27 -0
  51. data/lib/alchemy/version.rb +1 -1
  52. data/lib/alchemy_cms.rb +1 -1
  53. data/spec/controllers/admin/contents_controller_spec.rb +19 -0
  54. data/spec/controllers/admin/pages_controller_spec.rb +19 -0
  55. data/spec/controllers/base_controller_spec.rb +1 -1
  56. data/spec/controllers/pages_controller_spec.rb +62 -0
  57. data/spec/dummy/app/views/layouts/.gitkeep +0 -0
  58. data/spec/integration/admin/pages_controller_spec.rb +42 -13
  59. data/spec/integration/pages_controller_spec.rb +2 -2
  60. data/spec/models/content_spec.rb +40 -0
  61. data/spec/models/element_spec.rb +50 -0
  62. data/spec/models/page_spec.rb +45 -1
  63. data/spec/routing_spec.rb +27 -29
  64. data/spec/spec_helper.rb +2 -2
  65. metadata +40 -36
  66. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gem 'declarative_authorization', :git => 'git://github.com/stffn/declarative_aut
7
7
  group :test do
8
8
  gem 'factory_girl_rails'
9
9
  gem "capybara"
10
- #gem 'capybara-webkit'
10
+ gem 'capybara-webkit'
11
11
  gem "launchy"
12
12
  gem "database_cleaner"
13
13
  gem "fuubar"
data/README.md CHANGED
@@ -76,6 +76,20 @@ Start the local server:
76
76
 
77
77
  Then just switch to your browser and open `http://localhost:3000`
78
78
 
79
+ Upgrading
80
+ ------------
81
+
82
+ Projects running with Alchemy CMS version < 2.1 needs to be upgraded.
83
+
84
+ Otherwise errors will be raised like this:
85
+ `uninitialized constant EssenceText`
86
+
87
+ You have to use the following Upgrade-Task.
88
+ Run in terminal:
89
+
90
+ rake alchemy:upgrade
91
+
92
+
79
93
  Add to existing Rails project
80
94
  -----------------------------
81
95
 
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
30
30
  s.add_runtime_dependency(%q<magiclabs-userstamp>, ["~> 2.0.2"])
31
31
  s.add_runtime_dependency(%q<dynamic_form>, ["~> 1.1"])
32
32
  s.add_runtime_dependency(%q<jquery-rails>, ["~> 1.0.16"])
33
- s.add_runtime_dependency(%q<attachment_magic>, ["~> 0.2"])
33
+ s.add_runtime_dependency(%q<attachment_magic>, ["~> 0.2.1"])
34
34
 
35
35
  s.add_development_dependency(%q<rspec-rails>, ["~> 2.7"])
36
36
  s.add_development_dependency(%q<sqlite3>)
@@ -27,7 +27,8 @@ if (typeof(Alchemy) === 'undefined') {
27
27
  url: Alchemy.routes.admin_picture_path(id),
28
28
  type: 'PUT',
29
29
  data: {
30
- name: value
30
+ name: value,
31
+ size: Alchemy.getUrlParam('size')
31
32
  }
32
33
  });
33
34
  return false;
@@ -211,8 +212,13 @@ if (typeof(Alchemy) === 'undefined') {
211
212
  console.debug(e);
212
213
  console.trace();
213
214
  }
215
+ },
216
+
217
+ getUrlParam : function(name){
218
+ var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
219
+ return results[1] || 0;
214
220
  }
215
-
221
+
216
222
  });
217
223
 
218
224
  })(jQuery);
@@ -71,7 +71,7 @@ if (typeof(Alchemy) === 'undefined') {
71
71
  tolerance: 'pointer',
72
72
  containment: 'parent',
73
73
  update: function(event, ui) {
74
- var ids = $.map($(event.target).children('div.dragable_picture'), function (child) {
74
+ var ids = $.map($(this).children('div.dragable_picture'), function (child) {
75
75
  return child.id.replace(/essence_picture_/, '');
76
76
  });
77
77
  $(event.originalTarget).css("cursor", "progress");
@@ -144,16 +144,7 @@ if (typeof(Alchemy) === 'undefined') {
144
144
  // Handling an external link.
145
145
  if (link.className == 'external') {
146
146
  $('#overlay_tabs').tabs("select", '#overlay_tab_external_link');
147
- var protocols = [];
148
- $('#url_protocol option').map(function() {
149
- protocols.push($(this).attr('value'));
150
- });
151
- $(protocols).each(function(index, value) {
152
- if (link.href.beginsWith(value)) {
153
- $('#external_url').val(link.href.replace(value, ""));
154
- $('#url_protocol').val(value);
155
- }
156
- });
147
+ $('#external_url').val(link.href);
157
148
  }
158
149
 
159
150
  // Handling a file link.
@@ -1,6 +1,6 @@
1
1
  // This object provides dynamically generated Rails routes in Javascript.
2
2
  // A little bit hacky, but the best solution so far. ^_^
3
- <% alchemy_routes = Alchemy::Engine.routes %>
3
+ <% self.class.send(:include, Alchemy::Engine.routes.url_helpers) %>
4
4
  if (typeof(Alchemy) === 'undefined') {
5
5
  var Alchemy = {};
6
6
  }
@@ -13,25 +13,25 @@ if (typeof(Alchemy) === 'undefined') {
13
13
  Alchemy.routes = {
14
14
 
15
15
  admin_picture_path: function(id) {
16
- return '<%= alchemy_routes.generate(:controller => "alchemy/admin/pictures", :action => "update", :id => 1).first %>'.replace(/1/, id);
16
+ return '<%= admin_picture_path(:id => 1) %>'.replace(/1/, id);
17
17
  },
18
18
 
19
19
  admin_trash_path : function(page_id) {
20
- var url = '<%= alchemy_routes.generate(:controller => "alchemy/admin/trash", :action => "index").first %>';
20
+ var url = '<%= admin_trash_path %>';
21
21
  if (page_id)
22
22
  url += '?page_id=' + page_id;
23
23
  return url;
24
24
  },
25
25
 
26
26
  fold_admin_element_path: function(id) {
27
- return '<%= alchemy_routes.generate(:controller => "alchemy/admin/elements", :action => "fold", :id => 1).first %>'.replace(/1/, id);
27
+ return '<%= fold_admin_element_path(:id => 1) %>'.replace(/1/, id);
28
28
  },
29
29
 
30
- list_admin_elements_path: '<%= alchemy_routes.generate(:controller => "alchemy/admin/elements", :action => "list").first %>',
31
- order_admin_contents_path: '<%= alchemy_routes.generate(:controller => "alchemy/admin/contents", :action => "order").first %>',
32
- order_admin_elements_path: '<%= alchemy_routes.generate(:controller => "alchemy/admin/elements", :action => "order").first %>',
33
- order_admin_pages_path: '<%= alchemy_routes.generate(:controller => "alchemy/admin/pages", :action => "order").first %>',
34
- link_admin_pages_path: '<%= alchemy_routes.generate(:controller => "alchemy/admin/pages", :action => "link").first %>'
30
+ list_admin_elements_path: '<%= list_admin_elements_path %>',
31
+ order_admin_contents_path: '<%= order_admin_contents_path %>',
32
+ order_admin_elements_path: '<%= order_admin_elements_path %>',
33
+ order_admin_pages_path: '<%= order_admin_pages_path %>',
34
+ link_admin_pages_path: '<%= link_admin_pages_path %>'
35
35
 
36
36
  }
37
37
 
@@ -1,4 +1,4 @@
1
- @import "defaults";
1
+ @import "alchemy/defaults";
2
2
 
3
3
  html {
4
4
  height: 100%;
@@ -1282,18 +1282,18 @@ div#user_list_legend {
1282
1282
  }
1283
1283
 
1284
1284
  #toolbar div.button_with_label form label {
1285
- margin-top: 5px;
1285
+ margin-top: $default-margin;
1286
1286
  }
1287
1287
 
1288
1288
  #toolbar div.search_field {
1289
1289
  position: relative;
1290
1290
  float: left;
1291
- margin-bottom: 4px;
1291
+ margin-bottom: $default-margin;
1292
1292
  }
1293
1293
 
1294
1294
  #toolbar div p {
1295
1295
  float: right;
1296
- margin: 3px 4px 0 0;
1296
+ margin: 3px $default-margin 0 0;
1297
1297
  padding: 0;
1298
1298
  }
1299
1299
 
@@ -1303,8 +1303,8 @@ div#toolbar div.toolbar_spacer {
1303
1303
  height: 37px;
1304
1304
  border-right-style: dotted;
1305
1305
  border-right-width: 1px;
1306
- margin-right: 8px;
1307
- margin-left: 4px;
1306
+ margin-right: 2*$default-margin;
1307
+ margin-left: $default-margin;
1308
1308
  }
1309
1309
 
1310
1310
  div#toolbar a.button {
@@ -2484,23 +2484,65 @@ div.button_with_label {
2484
2484
  margin-left: 8px;
2485
2485
  float: left;
2486
2486
  min-width: 70px;
2487
- }
2488
-
2489
- div.button_with_label.active .icon_button {
2490
- background-color: #cdd6db;
2491
- border-style: inset;
2492
- border-color: #bfbfbf;
2493
- }
2494
-
2495
- div.button_with_label.active label{
2496
- color: black;
2497
- text-shadow: white 0 0 2px;
2498
- }
2499
-
2500
- div.button_with_label.disabled {
2501
- position: relative;
2502
- @include opacity(50);
2503
- cursor: default;
2487
+ line-height: 0;
2488
+
2489
+ &.active {
2490
+ .icon_button {
2491
+ background-color: #cdd6db;
2492
+ border-style: inset;
2493
+ border-color: #bfbfbf;
2494
+ }
2495
+ label {
2496
+ color: black;
2497
+ text-shadow: white 0 0 2px;
2498
+ }
2499
+ }
2500
+
2501
+ .disabledButton {
2502
+ position: absolute;
2503
+ top: 0;
2504
+ left: 0;
2505
+ width: 100%;
2506
+ height: 100%;
2507
+ z-index: 1;
2508
+ }
2509
+
2510
+ a.icon_button {
2511
+ float: none;
2512
+ margin-right: auto;
2513
+ margin-left: auto;
2514
+ display: inline-block;
2515
+ position: relative;
2516
+ }
2517
+
2518
+ &.disabled {
2519
+ position: relative;
2520
+ @include opacity(50);
2521
+ cursor: default;
2522
+
2523
+ a:hover, a:active {
2524
+ cursor: default;
2525
+ background-color: #f7f7f7;
2526
+ border: 1px solid #9a9a9a;
2527
+ }
2528
+
2529
+ &:before {
2530
+ content: '';
2531
+ position: absolute;
2532
+ z-index: 1;
2533
+ width: 100%;
2534
+ height: 100%;
2535
+ background-color: transparent;
2536
+ @include opacity(50);
2537
+ }
2538
+
2539
+ &:hover label {
2540
+ color: $text-color;
2541
+ cursor: default;
2542
+ }
2543
+
2544
+ }
2545
+
2504
2546
  }
2505
2547
 
2506
2548
  .icon_button.disabled span {
@@ -2515,50 +2557,10 @@ div.button_with_label.disabled {
2515
2557
  cursor: default;
2516
2558
  }
2517
2559
 
2518
- div.button_with_label.disabled:before {
2519
- content: '';
2520
- position: absolute;
2521
- z-index: 1;
2522
- width: 100%;
2523
- height: 100%;
2524
- background-color: transparent;
2525
- @include opacity(50);
2526
- }
2527
-
2528
- div.button_with_label.disabled a:hover,
2529
- div.button_with_label.disabled a:active {
2530
- cursor: default;
2531
- background-color: #f7f7f7;
2532
- border: 1px solid #9a9a9a;
2533
- }
2534
-
2535
- div.button_with_label.disabled:hover label {
2536
- color: $text-color;
2537
- cursor: default;
2538
- }
2539
-
2540
- div.button_with_label .disabledButton {
2541
- position: absolute;
2542
- top: 0;
2543
- left: 0;
2544
- width: 100%;
2545
- height: 100%;
2546
- z-index: 1;
2547
- }
2548
-
2549
- div.button_with_label a.icon_button {
2550
- float: none;
2551
- margin-right: auto;
2552
- margin-left: auto;
2553
- display: inline-block;
2554
- position: relative;
2555
- }
2556
-
2557
- div#toolbar label,
2558
- div#overlay_toolbar label {
2560
+ div#toolbar label, div#overlay_toolbar label {
2559
2561
  font-size: 10px;
2560
2562
  text-shadow: #fff 0 1px 2px;
2561
- margin-top: 2px;
2563
+ margin-top: $default-margin;
2562
2564
  display: block;
2563
2565
  line-height: 13px;
2564
2566
  }
@@ -2572,7 +2574,7 @@ div.button_with_label:hover label {
2572
2574
  padding: $default-padding;
2573
2575
  border: 1px solid #9a9a9a;
2574
2576
  @include rounded-corner;
2575
- margin-right: 4px;
2577
+ margin-right: $default-margin;
2576
2578
  background: #fff image-url('alchemy/shading.png') repeat-x 0 -75px;
2577
2579
  text-decoration: none;
2578
2580
  }
@@ -1,4 +1,4 @@
1
- @import "defaults";
1
+ @import "alchemy/defaults";
2
2
 
3
3
  #alchemy div.content_editor input.text_with_icon.auto_resize.thin_border {
4
4
  padding-right: 52px;
@@ -426,7 +426,7 @@ a.icon_button.linked {
426
426
  cursor: default;
427
427
  }
428
428
 
429
- div.content_editor.essence_picture_editor {
429
+ div.essence_picture_editor {
430
430
  position: relative;
431
431
  float: left;
432
432
  margin: 0;
@@ -444,6 +444,7 @@ div.essence_picture_editor.validation_failed .picture_thumbnail {
444
444
  border-color: #931f23;
445
445
  -webkit-box-shadow: #931f23 0px 1px 3px;
446
446
  -moz-box-shadow: #931f23 0px 1px 3px;
447
+ -ms-box-shadow: #931f23 0px 1px 3px;
447
448
  -o-box-shadow: #931f23 0px 1px 3px;
448
449
  box-shadow: #931f23 0px 1px 3px;
449
450
  }
@@ -1,4 +1,4 @@
1
- @import "defaults";
1
+ @import "alchemy/defaults";
2
2
 
3
3
  /*
4
4
  * jQuery UI CSS Framework 1.8.7
@@ -1,4 +1,4 @@
1
- @import "defaults";
1
+ @import "alchemy/defaults";
2
2
  /* Fixes issue here http://code.google.com/p/jcrop/issues/detail?id=1 */
3
3
  .jcrop-holder { text-align: left; }
4
4
 
@@ -1,4 +1,4 @@
1
- @import "defaults";
1
+ @import "alchemy/defaults";
2
2
 
3
3
  /* always visible styles */
4
4
 
@@ -1,4 +1,4 @@
1
- @import "defaults";
1
+ @import "alchemy/defaults";
2
2
 
3
3
  body, td, pre {
4
4
  color: $text-color;
@@ -1,4 +1,4 @@
1
- @import "defaults";
1
+ @import "alchemy/defaults";
2
2
 
3
3
  /* Generic */
4
4
 
@@ -110,7 +110,7 @@ module Alchemy
110
110
  def per_page_value_for_screen_size
111
111
  return 25 if session[:screen_size].blank?
112
112
  screen_height = session[:screen_size].split('x').last.to_i
113
- (screen_height / 35) - 5
113
+ (screen_height / 35) - 6
114
114
  end
115
115
 
116
116
  end
@@ -34,7 +34,7 @@ module Alchemy
34
34
  end
35
35
 
36
36
  def order
37
- for id in params[:content_ids]
37
+ params[:content_ids].each do |id|
38
38
  content = Content.find(id)
39
39
  content.move_to_bottom
40
40
  end
@@ -42,8 +42,9 @@ module Alchemy
42
42
  source_element = Element.find(element_from_clipboard[:id])
43
43
  @element = Element.copy(source_element, {:page_id => @page.id})
44
44
  if element_from_clipboard[:action] == 'cut'
45
- source_element.destroy
45
+ @cutted_element_id = source_element.id
46
46
  @clipboard.delete_if { |i| i[:id].to_i == source_element.id }
47
+ source_element.destroy
47
48
  end
48
49
  else
49
50
  @element = Element.new_from_scratch(params[:element])
@@ -54,7 +54,7 @@ module Alchemy
54
54
  else
55
55
  page = Page.create(params[:page])
56
56
  end
57
- render_errors_or_redirect(page, parent.layoutpage? ? admin_layoutpages_path : admin_pages_path, t("Page created.", :name => page.name), 'form#new_page_form button.button')
57
+ render_errors_or_redirect(page, parent.layoutpage? ? admin_layoutpages_path : admin_pages_path, t("Page created", :name => page.name), 'form#new_page_form button.button')
58
58
  end
59
59
 
60
60
  # Edit the content of the page and all its elements and contents.
@@ -210,7 +210,7 @@ module Alchemy
210
210
 
211
211
  def switch_language
212
212
  set_language_from(params[:language_id])
213
- redirect_path = params[:layoutpages] ? admin_layoutpages_path : admin_pages_path
213
+ redirect_path = request.referer.include?('admin/layoutpages') ? admin_layoutpages_path : admin_pages_path
214
214
  if request.xhr?
215
215
  @redirect_url = redirect_path
216
216
  render :action => :redirect
@@ -240,12 +240,22 @@ module Alchemy
240
240
 
241
241
  def expire_page(page)
242
242
  return if page.do_not_sweep
243
- expire_action(
244
- :controller => '/pages',
245
- :action => :show,
246
- :urlname => page.urlname_was,
247
- :lang => multi_language? ? page.language_code : nil
248
- )
243
+ # TODO: We should change this back to expire_action after Rails 3.2 was released.
244
+ # expire_action(
245
+ # alchemy.show_page_url(
246
+ # :urlname => page.urlname_was,
247
+ # :lang => multi_language? ? page.language_code : nil
248
+ # )
249
+ # )
250
+ # Temporarily fix for Rails 3 bug
251
+ expire_fragment(ActionController::Caching::Actions::ActionCachePath.new(
252
+ self,
253
+ alchemy.show_page_url(
254
+ :urlname => page.urlname_was,
255
+ :lang => multi_language? ? page.language_code : nil
256
+ ),
257
+ false
258
+ ).path)
249
259
  end
250
260
 
251
261
  end