alchemy_cms 2.1.beta6 → 2.1.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. data/.gitignore +3 -1
  2. data/Gemfile +10 -2
  3. data/Guardfile +16 -0
  4. data/README.md +3 -3
  5. data/Rakefile +0 -5
  6. data/alchemy_cms.gemspec +1 -9
  7. data/app/assets/javascripts/alchemy/alchemy.base.js +5 -4
  8. data/app/assets/javascripts/alchemy/{alchemy.dragndrop.js.erb → alchemy.dragndrop.js} +0 -0
  9. data/app/assets/javascripts/alchemy/alchemy.elements_window.js +96 -0
  10. data/app/assets/javascripts/alchemy/alchemy.image_cropper.js +48 -50
  11. data/app/assets/javascripts/alchemy/alchemy.jquery_loader.js +41 -0
  12. data/app/assets/javascripts/alchemy/alchemy.js +2 -0
  13. data/app/assets/javascripts/alchemy/alchemy.menubar.js +55 -0
  14. data/app/assets/javascripts/alchemy/alchemy.preview.js +94 -139
  15. data/app/assets/javascripts/alchemy/alchemy.preview_window.js +98 -0
  16. data/app/assets/javascripts/alchemy/alchemy.windows.js +1 -174
  17. data/app/assets/javascripts/alchemy/menubar.js +2 -0
  18. data/app/assets/javascripts/alchemy/preview.js +2 -1
  19. data/app/assets/stylesheets/alchemy/_defaults.scss +7 -8
  20. data/app/assets/stylesheets/alchemy/base.css.scss +29 -33
  21. data/app/assets/stylesheets/alchemy/elements.css.scss +4 -4
  22. data/app/assets/stylesheets/alchemy/jquery-ui.alchemy.css.scss +1 -1
  23. data/app/assets/stylesheets/alchemy/jquery.Jcrop.css.scss +1 -1
  24. data/app/assets/stylesheets/alchemy/jquery.sb.css.scss +19 -4
  25. data/app/assets/stylesheets/alchemy/menubar.css.scss +85 -0
  26. data/app/assets/stylesheets/alchemy/standard_set.css +3 -5
  27. data/app/assets/stylesheets/alchemy/tinymce_content.css.scss +1 -1
  28. data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +1 -1
  29. data/app/controllers/alchemy/admin/attachments_controller.rb +2 -18
  30. data/app/controllers/alchemy/admin/base_controller.rb +1 -1
  31. data/app/controllers/alchemy/admin/elements_controller.rb +2 -2
  32. data/app/controllers/alchemy/admin/essence_files_controller.rb +4 -2
  33. data/app/controllers/alchemy/admin/pictures_controller.rb +6 -20
  34. data/app/controllers/alchemy/admin/resources_controller.rb +7 -5
  35. data/app/controllers/alchemy/base_controller.rb +14 -4
  36. data/app/controllers/alchemy/messages_controller.rb +4 -4
  37. data/app/controllers/alchemy/pages_controller.rb +51 -32
  38. data/app/controllers/alchemy/pictures_controller.rb +0 -3
  39. data/app/controllers/alchemy/user_sessions_controller.rb +1 -1
  40. data/app/helpers/alchemy/admin/base_helper.rb +6 -4
  41. data/app/helpers/alchemy/base_helper.rb +26 -0
  42. data/app/helpers/alchemy/pages_helper.rb +42 -22
  43. data/app/models/alchemy/attachment.rb +10 -2
  44. data/app/models/alchemy/cell.rb +1 -0
  45. data/app/models/alchemy/content.rb +8 -6
  46. data/app/models/alchemy/element.rb +1 -1
  47. data/app/models/alchemy/essence_audio.rb +1 -8
  48. data/app/models/alchemy/essence_date.rb +2 -9
  49. data/app/models/alchemy/essence_file.rb +1 -8
  50. data/app/models/alchemy/essence_flash.rb +0 -7
  51. data/app/models/alchemy/essence_html.rb +1 -8
  52. data/app/models/alchemy/essence_picture.rb +0 -11
  53. data/app/models/alchemy/essence_richtext.rb +4 -12
  54. data/app/models/alchemy/essence_text.rb +1 -13
  55. data/app/models/alchemy/essence_video.rb +1 -8
  56. data/app/models/alchemy/page.rb +28 -22
  57. data/app/models/alchemy/picture.rb +19 -0
  58. data/app/sweepers/alchemy/pages_sweeper.rb +17 -6
  59. data/app/sweepers/alchemy/pictures_sweeper.rb +1 -3
  60. data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +2 -2
  61. data/app/views/alchemy/admin/attachments/_attachment.html.erb +1 -1
  62. data/app/views/alchemy/admin/attachments/_file_to_assign.html.erb +2 -2
  63. data/app/views/alchemy/admin/attachments/_files_list.html.erb +13 -11
  64. data/app/views/alchemy/admin/attachments/create.js.erb +1 -1
  65. data/app/views/alchemy/admin/attachments/edit.html.erb +2 -2
  66. data/app/views/alchemy/admin/elements/_new_element_form.html.erb +1 -2
  67. data/app/views/alchemy/admin/elements/new.html.erb +1 -1
  68. data/app/views/alchemy/admin/essence_files/edit.html.erb +32 -32
  69. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +29 -29
  70. data/app/views/alchemy/admin/essence_pictures/update.js.erb +13 -12
  71. data/app/views/alchemy/admin/pages/_create_language_form.html.erb +4 -1
  72. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +1 -1
  73. data/app/views/alchemy/admin/pages/edit.html.erb +8 -8
  74. data/app/views/alchemy/admin/pages/index.html.erb +1 -1
  75. data/app/views/alchemy/admin/pages/new.html.erb +1 -1
  76. data/app/views/alchemy/admin/pages/update.js.erb +19 -12
  77. data/app/views/alchemy/admin/pictures/_picture.html.erb +1 -1
  78. data/app/views/alchemy/admin/pictures/_pictures_list.html.erb +8 -6
  79. data/app/views/alchemy/admin/pictures/show_in_window.html.erb +6 -1
  80. data/app/views/alchemy/admin/resources/_table.html.erb +1 -1
  81. data/app/views/alchemy/admin/users/_table.html.erb +13 -13
  82. data/app/views/alchemy/admin/users/_user.html.erb +1 -1
  83. data/app/views/alchemy/admin/users/index.html.erb +2 -2
  84. data/app/views/alchemy/elements/_contactform_view.html.erb +78 -78
  85. data/app/views/alchemy/elements/_download_editor.html.erb +1 -0
  86. data/app/views/alchemy/elements/_download_view.html.erb +3 -0
  87. data/app/views/alchemy/essences/_essence_date_editor.html.erb +1 -1
  88. data/app/views/alchemy/essences/_essence_file_editor.html.erb +1 -0
  89. data/app/views/alchemy/essences/_essence_file_view.html.erb +6 -2
  90. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +3 -2
  91. data/app/views/alchemy/essences/_essence_picture_view.html.erb +1 -1
  92. data/app/views/alchemy/navigation/_link.html.erb +1 -2
  93. data/app/views/alchemy/notifications/admin_user_created.text.erb +7 -7
  94. data/app/views/alchemy/notifications/registered_user_created.text.erb +5 -5
  95. data/app/views/alchemy/user_sessions/login.html.erb +34 -35
  96. data/app/views/layouts/alchemy/login.html.erb +3 -8
  97. data/app/views/layouts/alchemy/pages.html.erb +1 -0
  98. data/bin/alchemy +43 -75
  99. data/config/alchemy/config.yml +10 -0
  100. data/config/alchemy/elements.yml +5 -0
  101. data/config/alchemy/page_layouts.yml +1 -1
  102. data/config/locales/alchemy.de.yml +21 -8
  103. data/config/locales/alchemy.en.yml +20 -4
  104. data/config/routes.rb +25 -20
  105. data/db/migrate/{20111116125112_namespace_models.rb → 20111116125112_namespace_alchemy_models.rb} +1 -1
  106. data/lib/alchemy/capistrano.rb +4 -17
  107. data/lib/alchemy/engine.rb +2 -0
  108. data/lib/alchemy/essence.rb +29 -41
  109. data/lib/alchemy/i18n.rb +1 -1
  110. data/lib/alchemy/mount_point.rb +10 -0
  111. data/lib/alchemy/page_layout.rb +7 -7
  112. data/lib/alchemy/seeder.rb +85 -47
  113. data/lib/alchemy/upgrader.rb +115 -0
  114. data/lib/alchemy/version.rb +1 -1
  115. data/lib/alchemy_cms.rb +4 -3
  116. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +6 -2
  117. data/lib/tasks/ferret.rake +12 -0
  118. data/lib/tasks/install.rake +16 -105
  119. data/lib/tasks/routes.rake +29 -0
  120. data/lib/tasks/upgrade.rake +5 -67
  121. data/spec/controllers/admin/pages_controller_spec.rb +1 -1
  122. data/spec/controllers/pages_controller_spec.rb +31 -0
  123. data/spec/factories.rb +24 -15
  124. data/spec/helpers/admin/base_helper_spec.rb +0 -7
  125. data/spec/helpers/pages_helper_spec.rb +54 -29
  126. data/spec/helpers/url_helpers_spec.rb +40 -0
  127. data/spec/integration/admin/pages_controller_spec.rb +3 -3
  128. data/spec/integration/pages_controller_spec.rb +80 -6
  129. data/spec/integration/security_spec.rb +2 -2
  130. data/spec/models/content_spec.rb +24 -0
  131. data/spec/models/page_spec.rb +174 -47
  132. data/spec/models/picture_spec.rb +54 -0
  133. data/spec/page_layout_spec.rb +2 -2
  134. data/spec/routing_spec.rb +205 -1
  135. data/spec/spec_helper.rb +53 -32
  136. metadata +51 -46
  137. data/lib/alchemy/file_utilz.rb +0 -73
@@ -422,7 +422,7 @@ a.icon_button.linked {
422
422
  }
423
423
 
424
424
  .edit_images_bottom a.disabled {
425
- @include opacity(50);
425
+ @include opacity(30);
426
426
  cursor: default;
427
427
  }
428
428
 
@@ -535,7 +535,7 @@ div.file_icon span.icon {
535
535
  div.file_icon a.assign_file {
536
536
  display: block;
537
537
  height: 16px;
538
- background: image-url('alchemy/icons.png') no-repeat -240px -24px;
538
+ background: image-url('alchemy/icons.png') no-repeat -480px -40px;
539
539
  width: 16px;
540
540
  margin: $default-margin;
541
541
  }
@@ -565,11 +565,11 @@ div.essence_file_tools a{
565
565
  }
566
566
 
567
567
  div.essence_file_tools a.assign_file {
568
- background: image-url('alchemy/icons.png') -256px -24px;
568
+ background: image-url('alchemy/icons.png') -512px -40px;
569
569
  }
570
570
 
571
571
  div.essence_file_tools a.edit_file {
572
- background: image-url('alchemy/icons.png') -16px -24px;
572
+ background: image-url('alchemy/icons.png') -160px -167px;
573
573
  }
574
574
 
575
575
  td.content_editor_essence_type {
@@ -1,4 +1,4 @@
1
- @import "alchemy/defaults";
1
+ @import "defaults";
2
2
 
3
3
  /*
4
4
  * jQuery UI CSS Framework 1.8.7
@@ -1,4 +1,4 @@
1
- @import "alchemy/defaults";
1
+ @import "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 "alchemy/defaults";
1
+ @import "defaults";
2
2
 
3
3
  /* always visible styles */
4
4
 
@@ -42,7 +42,7 @@
42
42
  text-shadow: $button-text-shadow;
43
43
  }
44
44
 
45
- #alchemy .selectbox .display.long {
45
+ #alchemy .selectbox .display {
46
46
  width: 190px;
47
47
  }
48
48
 
@@ -54,6 +54,14 @@
54
54
  width: 100px;
55
55
  }
56
56
 
57
+ #alchemy .selectbox .display.long {
58
+ width: 220px;
59
+ }
60
+
61
+ #alchemy .selectbox .display.very_long {
62
+ width: 280px;
63
+ }
64
+
57
65
  #alchemy .selectbox.disabled .display {
58
66
  color: #999;
59
67
  }
@@ -71,7 +79,6 @@
71
79
  background: $button-hover-bg-color image-url('alchemy/shading.png') repeat-x 50% -75px;
72
80
  }
73
81
 
74
-
75
82
  #alchemy .selectbox .display:active .arrow_btn {
76
83
  background-color: #e5e5e5;
77
84
  }
@@ -149,10 +156,18 @@
149
156
  width: 128px;
150
157
  }
151
158
 
152
- #alchemy .items.long {
159
+ #alchemy .items {
153
160
  width: 218px;
154
161
  }
155
162
 
163
+ #alchemy .items.long {
164
+ width: 248px;
165
+ }
166
+
167
+ #alchemy .items.very_long {
168
+ width: 308px;
169
+ }
170
+
156
171
  #alchemy .items.full_width {
157
172
  width: 431px;
158
173
  }
@@ -0,0 +1,85 @@
1
+ /*
2
+ *= require_self
3
+ */
4
+
5
+ @import "defaults";
6
+
7
+ @mixin transition {
8
+ -webkit-transition: left 0.15s ease;
9
+ -moz-transition: left 0.15s ease;
10
+ -ms-transition: left 0.15s ease;
11
+ -o-transition: left 0.15s ease;
12
+ transition: left 0.15s ease;
13
+ }
14
+
15
+ @mixin bottom-right-rounded-border {
16
+ $side: bottom-right;
17
+ $radius: 3px;
18
+ -webkit-border-#{$side}-radius: $radius;
19
+ -moz-border-radius-#{$side}: $radius;
20
+ -ms-border-#{$side}-radius: $radius;
21
+ -o-border-#{$side}-radius: $radius;
22
+ border-#{$side}-radius: $radius;
23
+ }
24
+
25
+ @mixin box-shadow {
26
+ $shadow: 0px 0px 4px $dark-gray;
27
+ -webkit-box-shadow: $shadow;
28
+ -moz-box-shadow: $shadow;
29
+ -ms-box-shadow: $shadow;
30
+ -o-box-shadow: $shadow;
31
+ box-shadow: $shadow;
32
+ }
33
+
34
+ #alchemy_menubar {
35
+ position: fixed;
36
+ top: 0;
37
+ left: -318px;
38
+ width: 312px;
39
+ z-index: 10000;
40
+ background: $light-gray;
41
+ @include transition;
42
+ @include bottom-right-rounded-border;
43
+ @include box-shadow;
44
+ border-right: $default-border;
45
+ border-bottom: $default-border;
46
+ line-height: 8*$default-padding;
47
+ height: 8*$default-padding;
48
+ padding: 4px 40px 4px 8px;
49
+ overflow: hidden;
50
+ &:hover {
51
+ left: 0;
52
+ @include transition;
53
+ };
54
+ &:after {
55
+ content: '';
56
+ width: 24px;
57
+ height: 24px;
58
+ position: absolute;
59
+ right: 10px;
60
+ top: 8px;
61
+ background: image-url('alchemy/icons.png') -240px 0;
62
+ };
63
+ ul {
64
+ padding: 6px 0;
65
+ margin: 0;
66
+ li {
67
+ line-height: normal;
68
+ margin-right: $default-padding;
69
+ display: inline;
70
+ display: inline-block;
71
+ list-style-type: none;
72
+ a {
73
+ display: block;
74
+ text-align: center;
75
+ padding: 2px 4px;
76
+ width: 90px;
77
+ text-decoration: none;
78
+ @include button-styles;
79
+ &:hover {
80
+ @include button-hover-styles;
81
+ };
82
+ }
83
+ }
84
+ }
85
+ }
@@ -1,5 +1,3 @@
1
- /* @override http://localhost:3000/stylesheets/alchemy/standard_set.css */
2
-
3
1
  body {
4
2
  margin: 0;
5
3
  padding: 0;
@@ -342,7 +340,7 @@ td.field {
342
340
  }
343
341
 
344
342
  input.field.short {
345
- width: 105px;
343
+ width: 97px;
346
344
  }
347
345
 
348
346
  input.field.medium {
@@ -354,11 +352,11 @@ td.label {
354
352
  }
355
353
 
356
354
  textarea {
357
- width: 310px;
355
+ width: 314px;
358
356
  padding: 2px;
359
357
  font: 12px "Lucida Grande", Lucida, Verdana, sans-serif;
360
358
  border: 1px solid silver;
361
- margin-left: 137px;
359
+ margin-left: 126px;
362
360
  height: 10em;
363
361
  margin-top: 2em;
364
362
  margin-bottom: 1em;
@@ -1,4 +1,4 @@
1
- @import "alchemy/defaults";
1
+ @import "defaults";
2
2
 
3
3
  body, td, pre {
4
4
  color: $text-color;
@@ -1,4 +1,4 @@
1
- @import "alchemy/defaults";
1
+ @import "defaults";
2
2
 
3
3
  /* Generic */
4
4
 
@@ -8,15 +8,7 @@ module Alchemy
8
8
  if in_overlay?
9
9
  archive_overlay
10
10
  else
11
- cond = "name LIKE '%#{params[:query]}%' OR filename LIKE '%#{params[:query]}%'"
12
- if params[:per_page] == 'all'
13
- @attachments = Attachment.where(cond).order(:name)
14
- else
15
- @attachments = Attachment.where(cond).paginate(
16
- :page => (params[:page] || 1),
17
- :per_page => per_page_value_for_screen_size
18
- ).order(:name)
19
- end
11
+ @attachments = Attachment.find_paginated(params, per_page_value_for_screen_size)
20
12
  end
21
13
  end
22
14
 
@@ -35,21 +27,13 @@ module Alchemy
35
27
  @attachment = Attachment.new(:uploaded_data => params[:Filedata])
36
28
  @attachment.name = @attachment.filename
37
29
  @attachment.save
38
- cond = "name LIKE '%#{params[:query]}%' OR filename LIKE '%#{params[:query]}%'"
39
- if params[:per_page] == 'all'
40
- @attachments = Attachment.where(cond).order(:name)
41
- else
42
- @attachments = Attachment.where(cond).paginate(
43
- :page => (params[:page] || 1),
44
- :per_page => (params[:per_page] || 20)
45
- ).order(:name)
46
- end
47
30
  if in_overlay?
48
31
  @while_assigning = true
49
32
  @content = Content.find(params[:content_id], :select => 'id') if !params[:content_id].blank?
50
33
  @swap = params[:swap]
51
34
  @options = hashified_options
52
35
  end
36
+ @attachments = Attachment.find_paginated(params, per_page_value_for_screen_size)
53
37
  @message = t('File %{name} uploaded succesfully', :name => @attachment.name)
54
38
  # Are we using the Flash uploader? Or the plain html file uploader?
55
39
  if params[Rails.application.config.session_options[:key]].blank?
@@ -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) - 6
113
+ (screen_height / 30) - 12
114
114
  end
115
115
 
116
116
  end
@@ -69,7 +69,7 @@ module Alchemy
69
69
  @element_validated = @element.save!
70
70
  else
71
71
  @element_validated = false
72
- @notice = t('Validation failed.')
72
+ @notice = t('Validation failed')
73
73
  @error_message = "<h2>#{@notice}</h2><p>#{t('Please check contents below.')}</p>".html_safe
74
74
  end
75
75
  end
@@ -77,7 +77,7 @@ module Alchemy
77
77
  # Trashes the Element instead of deleting it.
78
78
  def trash
79
79
  @element = Element.find(params[:id])
80
- @page_id = @element.page.id
80
+ @page_id = @element.page_id
81
81
  @element.trash
82
82
  end
83
83
 
@@ -2,6 +2,8 @@ module Alchemy
2
2
  module Admin
3
3
  class EssenceFilesController < Alchemy::Admin::BaseController
4
4
 
5
+ helper "Alchemy::Admin::Contents"
6
+
5
7
  def edit
6
8
  @content = Content.find(params[:id])
7
9
  @essence_file = @content.essence
@@ -17,8 +19,8 @@ module Alchemy
17
19
  @content = Content.find_by_id(params[:id])
18
20
  @attachment = Attachment.find_by_id(params[:attachment_id])
19
21
  @content.essence.attachment = @attachment
20
- @content.essence.save
21
- @content.save
22
+ # @content.essence.save
23
+ # @content.save
22
24
  @options = params[:options]
23
25
  end
24
26
 
@@ -9,14 +9,7 @@ module Alchemy
9
9
 
10
10
  def index
11
11
  @size = params[:size] || 'medium'
12
- if params[:per_page] == 'all'
13
- @pictures = Picture.where("name LIKE '%#{params[:query]}%'").order(:name)
14
- else
15
- @pictures = Picture.where("name LIKE '%#{params[:query]}%'").paginate(
16
- :page => params[:page] || 1,
17
- :per_page => pictures_per_page_for_size(@size)
18
- ).order(:name)
19
- end
12
+ @pictures = Picture.find_paginated(params, pictures_per_page_for_size(@size))
20
13
  if in_overlay?
21
14
  archive_overlay
22
15
  else
@@ -41,7 +34,7 @@ module Alchemy
41
34
 
42
35
  def create
43
36
  @picture = Picture.new(:image_file => params[:Filedata])
44
- @picture.name = @picture.image_filename
37
+ @picture.name = @picture.humanized_name
45
38
  @picture.save
46
39
  @size = params[:size] || 'medium'
47
40
  if in_overlay?
@@ -52,14 +45,7 @@ module Alchemy
52
45
  @page = params[:page] || 1
53
46
  @per_page = pictures_per_page_for_size(@size)
54
47
  end
55
- if params[:per_page] == 'all'
56
- @pictures = Picture.where("name LIKE '%#{params[:query]}%'").order(:name)
57
- else
58
- @pictures = Picture.where("name LIKE '%#{params[:query]}%'").paginate(
59
- :page => (params[:page] || 1),
60
- :per_page => pictures_per_page_for_size(@size)
61
- ).order(:name)
62
- end
48
+ @pictures = Picture.find_paginated(params, pictures_per_page_for_size(@size))
63
49
  @message = t('Picture uploaded succesfully', :name => @picture.name)
64
50
  # Are we using the Flash uploader? Or the plain html file uploader?
65
51
  if params[Rails.application.config.session_options[:key]].blank?
@@ -107,11 +93,11 @@ module Alchemy
107
93
  def pictures_per_page_for_size(size)
108
94
  case size
109
95
  when 'small'
110
- per_page = in_overlay? ? 35 : (per_page_value_for_screen_size * 2.95).floor # 50
96
+ per_page = in_overlay? ? 35 : (per_page_value_for_screen_size * 2.9).floor # 50
111
97
  when 'large'
112
- per_page = in_overlay? ? 4 : (per_page_value_for_screen_size / 2.1).floor # 8
98
+ per_page = in_overlay? ? 4 : (per_page_value_for_screen_size / 1.7).floor # 8
113
99
  else
114
- per_page = in_overlay? ? 12 : (per_page_value_for_screen_size / 0.95).ceil # 18
100
+ per_page = in_overlay? ? 12 : (per_page_value_for_screen_size / 0.8).ceil # 18
115
101
  end
116
102
  return per_page
117
103
  end
@@ -10,11 +10,9 @@ module Alchemy
10
10
 
11
11
  def index
12
12
  if !params[:query].blank?
13
- items = resource_model.where(resource_attributes.map { |attribute|
14
- if attribute[:type] == :string
15
- "`#{resources_name}`.#{attribute[:name]} LIKE '%#{params[:query]}%'"
16
- end
17
- }.compact.join(" OR "))
13
+ items = resource_model.where(searchable_resource_attributes.map { |attribute|
14
+ "`#{namespaced_resources_name}`.`#{attribute[:name]}` LIKE '%#{params[:query]}%'"
15
+ }.join(" OR "))
18
16
  else
19
17
  items = resource_model
20
18
  end
@@ -106,6 +104,10 @@ module Alchemy
106
104
  end.compact
107
105
  end
108
106
 
107
+ def searchable_resource_attributes
108
+ resource_attributes.select{ |a| a[:type] == :string }
109
+ end
110
+
109
111
  def resource_window_size
110
112
  @resource_window_size ||= "400x#{100 + resource_attributes.length * 35}"
111
113
  end
@@ -106,20 +106,30 @@ module Alchemy
106
106
  end
107
107
  end
108
108
 
109
+ def layout_for_page
110
+ if !params[:layout].blank? && params[:layout] != 'none'
111
+ params[:layout]
112
+ elsif File.exist?(Rails.root.join('app/views/layouts', 'application.html.erb'))
113
+ 'application'
114
+ else
115
+ 'alchemy/pages'
116
+ end
117
+ end
118
+
109
119
  protected
110
120
 
111
121
  def permission_denied
112
122
  if current_user
113
123
  if current_user.role == 'registered'
114
- redirect_to root_path
124
+ redirect_to alchemy.root_path
115
125
  else
116
- if request.referer == login_url
126
+ if request.referer == alchemy.login_url
117
127
  render :file => File.join(Rails.root.to_s, 'public', '422.html'), :status => 422, :layout => false
118
128
  elsif request.xhr?
119
129
  render :partial => 'alchemy/admin/partials/flash', :locals => {:message => t('You are not authorized'), :flash_type => 'warning'}
120
130
  else
121
131
  flash[:error] = t('You are not authorized')
122
- redirect_to admin_dashboard_path
132
+ redirect_to alchemy.admin_dashboard_path
123
133
  end
124
134
  end
125
135
  else
@@ -128,7 +138,7 @@ module Alchemy
128
138
  render :action => :permission_denied
129
139
  else
130
140
  store_location
131
- redirect_to login_path
141
+ redirect_to alchemy.login_path
132
142
  end
133
143
  end
134
144
  end
@@ -53,7 +53,7 @@ module Alchemy
53
53
 
54
54
  def new#:nodoc:
55
55
  @message = Message.new
56
- render :template => '/pages/show', :layout => 'pages'
56
+ render :template => 'alchemy/pages/show', :layout => layout_for_page
57
57
  end
58
58
 
59
59
  def create#:nodoc:
@@ -65,7 +65,7 @@ module Alchemy
65
65
  Messages.contact_form_mail(@message, mail_to, mail_from, subject).deliver
66
66
  redirect_to_success_page
67
67
  else
68
- render :template => '/pages/show', :layout => 'pages'
68
+ render :template => 'alchemy/pages/show', :layout => layout_for_page
69
69
  end
70
70
  end
71
71
 
@@ -106,9 +106,9 @@ module Alchemy
106
106
  end
107
107
 
108
108
  def get_page
109
- @page = Page.find_by_page_layout(mailer_config[:form_layout_name])
110
- @root_page = @page.get_language_root
109
+ @page = Page.find_by_page_layout_and_language_id(mailer_config[:page_layout_name], session[:language_id])
111
110
  raise "Page for page_layout #{mailer_config[:page_layout_name]} not found" if @page.blank?
111
+ @root_page = @page.get_language_root
112
112
  end
113
113
 
114
114
  end