alchemy_cms 2.5.0.b5 → 2.5.0.b9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. data/README.md +1 -1
  2. data/alchemy_cms.gemspec +2 -2
  3. data/app/assets/javascripts/alchemy/alchemy.base.js +0 -24
  4. data/app/assets/javascripts/alchemy/alchemy.growler.js +2 -4
  5. data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +0 -1
  6. data/app/assets/javascripts/alchemy/alchemy.page_sorter.js +1 -1
  7. data/app/assets/stylesheets/alchemy/base.scss +4 -20
  8. data/app/assets/stylesheets/alchemy/elements.scss +19 -31
  9. data/app/assets/stylesheets/alchemy/flash.scss +11 -0
  10. data/app/assets/stylesheets/alchemy/form_elements.scss +2 -14
  11. data/app/assets/stylesheets/alchemy/menubar.css.scss +1 -0
  12. data/app/assets/stylesheets/alchemy/mixins.scss +37 -2
  13. data/app/assets/stylesheets/alchemy/notices.scss +1 -0
  14. data/app/assets/stylesheets/alchemy/sitemap.scss +30 -0
  15. data/app/assets/stylesheets/alchemy/tables.scss +20 -27
  16. data/app/controllers/alchemy/admin/attachments_controller.rb +3 -3
  17. data/app/controllers/alchemy/admin/base_controller.rb +1 -1
  18. data/app/controllers/alchemy/admin/contents_controller.rb +2 -2
  19. data/app/controllers/alchemy/admin/elements_controller.rb +3 -3
  20. data/app/controllers/alchemy/admin/essence_pictures_controller.rb +2 -2
  21. data/app/controllers/alchemy/admin/pages_controller.rb +16 -9
  22. data/app/controllers/alchemy/admin/pictures_controller.rb +8 -8
  23. data/app/controllers/alchemy/admin/resources_controller.rb +1 -1
  24. data/app/controllers/alchemy/admin/tags_controller.rb +4 -4
  25. data/app/controllers/alchemy/admin/users_controller.rb +3 -3
  26. data/app/controllers/alchemy/base_controller.rb +10 -12
  27. data/app/controllers/alchemy/messages_controller.rb +2 -2
  28. data/app/controllers/alchemy/pages_controller.rb +4 -1
  29. data/app/controllers/alchemy/pictures_controller.rb +1 -4
  30. data/app/controllers/alchemy/user_sessions_controller.rb +5 -5
  31. data/app/helpers/alchemy/admin/attachments_helper.rb +1 -1
  32. data/app/helpers/alchemy/admin/base_helper.rb +13 -13
  33. data/app/helpers/alchemy/admin/contents_helper.rb +6 -6
  34. data/app/helpers/alchemy/admin/elements_helper.rb +2 -2
  35. data/app/helpers/alchemy/admin/essences_helper.rb +8 -8
  36. data/app/helpers/alchemy/admin/pages_helper.rb +13 -7
  37. data/app/helpers/alchemy/base_helper.rb +20 -5
  38. data/app/helpers/alchemy/elements_helper.rb +2 -2
  39. data/app/helpers/alchemy/essences_helper.rb +2 -2
  40. data/app/helpers/alchemy/pages_helper.rb +2 -3
  41. data/app/models/alchemy/cell.rb +11 -3
  42. data/app/models/alchemy/content.rb +17 -17
  43. data/app/models/alchemy/element.rb +49 -26
  44. data/app/models/alchemy/legacy_page_url.rb +6 -0
  45. data/app/models/alchemy/page.rb +24 -45
  46. data/app/models/alchemy/picture.rb +1 -2
  47. data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +3 -3
  48. data/app/views/alchemy/admin/attachments/_attachment.html.erb +6 -6
  49. data/app/views/alchemy/admin/attachments/_files_list.html.erb +2 -2
  50. data/app/views/alchemy/admin/attachments/edit.html.erb +5 -3
  51. data/app/views/alchemy/admin/attachments/index.html.erb +3 -3
  52. data/app/views/alchemy/admin/attachments/new.html.erb +2 -2
  53. data/app/views/alchemy/admin/clipboard/clear.js.erb +1 -1
  54. data/app/views/alchemy/admin/clipboard/index.html.erb +3 -3
  55. data/app/views/alchemy/admin/clipboard/insert.js.erb +2 -2
  56. data/app/views/alchemy/admin/clipboard/remove.js.erb +4 -4
  57. data/app/views/alchemy/admin/contents/_missing.html.erb +2 -2
  58. data/app/views/alchemy/admin/contents/create.js.erb +1 -1
  59. data/app/views/alchemy/admin/contents/new.html.erb +3 -3
  60. data/app/views/alchemy/admin/dashboard/index.html.erb +12 -12
  61. data/app/views/alchemy/admin/elements/_add_picture.html.erb +1 -1
  62. data/app/views/alchemy/admin/elements/_element.html.erb +1 -1
  63. data/app/views/alchemy/admin/elements/_element_foot.html.erb +5 -5
  64. data/app/views/alchemy/admin/elements/_element_head.html.erb +6 -6
  65. data/app/views/alchemy/admin/elements/_elements_select.html.erb +2 -2
  66. data/app/views/alchemy/admin/elements/_new_element_form.html.erb +4 -4
  67. data/app/views/alchemy/admin/elements/_picture_gallery_editor.html.erb +1 -1
  68. data/app/views/alchemy/admin/elements/create.js.erb +2 -2
  69. data/app/views/alchemy/admin/elements/index.html.erb +2 -2
  70. data/app/views/alchemy/admin/elements/list.js.erb +1 -1
  71. data/app/views/alchemy/admin/elements/new.html.erb +4 -4
  72. data/app/views/alchemy/admin/elements/order.js.erb +1 -1
  73. data/app/views/alchemy/admin/elements/trash.js.erb +1 -1
  74. data/app/views/alchemy/admin/elements/update.js.erb +1 -1
  75. data/app/views/alchemy/admin/essence_files/edit.html.erb +5 -5
  76. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +4 -4
  77. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +4 -4
  78. data/app/views/alchemy/admin/languages/_form.html.erb +6 -10
  79. data/app/views/alchemy/admin/languages/_language.html.erb +4 -4
  80. data/app/views/alchemy/admin/languages/_table.html.erb +1 -1
  81. data/app/views/alchemy/admin/languages/index.html.erb +1 -1
  82. data/app/views/alchemy/admin/layoutpages/_layoutpage.html.erb +6 -6
  83. data/app/views/alchemy/admin/layoutpages/index.html.erb +8 -8
  84. data/app/views/alchemy/admin/pages/_contactform_links.html.erb +7 -7
  85. data/app/views/alchemy/admin/pages/_create_language_form.html.erb +10 -9
  86. data/app/views/alchemy/admin/pages/_external_link.html.erb +7 -7
  87. data/app/views/alchemy/admin/pages/_file_link.html.erb +6 -6
  88. data/app/views/alchemy/admin/pages/_internal_link.html.erb +5 -5
  89. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +1 -1
  90. data/app/views/alchemy/admin/pages/_page.html.erb +28 -28
  91. data/app/views/alchemy/admin/pages/_page_for_links.html.erb +5 -5
  92. data/app/views/alchemy/admin/pages/_page_infos.html.erb +3 -3
  93. data/app/views/alchemy/admin/pages/_page_status.html.erb +3 -3
  94. data/app/views/alchemy/admin/pages/_sitemap.html.erb +1 -1
  95. data/app/views/alchemy/admin/pages/configure.html.erb +11 -11
  96. data/app/views/alchemy/admin/pages/configure_external.html.erb +4 -4
  97. data/app/views/alchemy/admin/pages/destroy.js.erb +0 -1
  98. data/app/views/alchemy/admin/pages/edit.html.erb +35 -35
  99. data/app/views/alchemy/admin/pages/flush.js.erb +1 -1
  100. data/app/views/alchemy/admin/pages/fold.js.erb +0 -1
  101. data/app/views/alchemy/admin/pages/index.html.erb +14 -14
  102. data/app/views/alchemy/admin/pages/link.html.erb +4 -4
  103. data/app/views/alchemy/admin/pages/locked.html.erb +1 -1
  104. data/app/views/alchemy/admin/pages/new.html.erb +4 -4
  105. data/app/views/alchemy/admin/pages/update.js.erb +2 -2
  106. data/app/views/alchemy/admin/partials/_autocomplete_tag_list.html.erb +1 -1
  107. data/app/views/alchemy/admin/partials/_flash_notices.html.erb +3 -3
  108. data/app/views/alchemy/admin/partials/_flash_upload.html.erb +8 -8
  109. data/app/views/alchemy/admin/partials/_language_tree_select.html.erb +1 -1
  110. data/app/views/alchemy/admin/partials/_main_navigation_entry.html.erb +1 -1
  111. data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +2 -2
  112. data/app/views/alchemy/admin/partials/_search_form.html.erb +2 -2
  113. data/app/views/alchemy/admin/partials/_sub_navigation_tab.html.erb +1 -1
  114. data/app/views/alchemy/admin/partials/_upload_form.html.erb +11 -11
  115. data/app/views/alchemy/admin/pictures/_archive.html.erb +13 -13
  116. data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +7 -7
  117. data/app/views/alchemy/admin/pictures/_filter_bar.html.erb +4 -4
  118. data/app/views/alchemy/admin/pictures/_overlay_picture_list.html.erb +1 -1
  119. data/app/views/alchemy/admin/pictures/_picture.html.erb +7 -7
  120. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -1
  121. data/app/views/alchemy/admin/pictures/_tag_list.html.erb +2 -2
  122. data/app/views/alchemy/admin/pictures/edit.html.erb +2 -2
  123. data/app/views/alchemy/admin/pictures/edit_multiple.html.erb +6 -6
  124. data/app/views/alchemy/admin/pictures/index.html.erb +10 -10
  125. data/app/views/alchemy/admin/pictures/info.html.erb +2 -2
  126. data/app/views/alchemy/admin/pictures/new.html.erb +2 -2
  127. data/app/views/alchemy/admin/resources/_boolean.html.erb +5 -0
  128. data/app/views/alchemy/admin/resources/_datetime.html.erb +2 -0
  129. data/app/views/alchemy/admin/resources/_form.html.erb +17 -28
  130. data/app/views/alchemy/admin/resources/_resource.html.erb +4 -4
  131. data/app/views/alchemy/admin/resources/_string.html.erb +5 -0
  132. data/app/views/alchemy/admin/resources/_table.html.erb +1 -1
  133. data/app/views/alchemy/admin/resources/_text.html.erb +5 -0
  134. data/app/views/alchemy/admin/resources/index.html.erb +1 -1
  135. data/app/views/alchemy/admin/tags/_tag.html.erb +4 -4
  136. data/app/views/alchemy/admin/tags/edit.html.erb +4 -4
  137. data/app/views/alchemy/admin/tags/index.html.erb +5 -5
  138. data/app/views/alchemy/admin/tags/new.html.erb +2 -2
  139. data/app/views/alchemy/admin/trash/clear.js.coffee +1 -1
  140. data/app/views/alchemy/admin/trash/index.html.erb +3 -3
  141. data/app/views/alchemy/admin/users/_table.html.erb +3 -3
  142. data/app/views/alchemy/admin/users/_user.html.erb +6 -6
  143. data/app/views/alchemy/admin/users/index.html.erb +4 -4
  144. data/app/views/alchemy/base/error_notice.html.erb +1 -4
  145. data/app/views/alchemy/elements/_editor_not_found.html.erb +2 -2
  146. data/app/views/alchemy/essences/_essence_boolean_view.html.erb +1 -1
  147. data/app/views/alchemy/essences/_essence_file_editor.html.erb +7 -7
  148. data/app/views/alchemy/essences/_essence_picture_editor.html.erb +5 -5
  149. data/app/views/alchemy/essences/_essence_picture_tools.html.erb +8 -8
  150. data/app/views/alchemy/essences/_linkable_essence_tools.html.erb +2 -2
  151. data/app/views/alchemy/search/_form.html.erb +2 -2
  152. data/app/views/alchemy/search/_result.html.erb +1 -1
  153. data/app/views/alchemy/search/_results.html.erb +3 -3
  154. data/app/views/alchemy/user_sessions/leave.html.erb +5 -5
  155. data/app/views/alchemy/user_sessions/login.html.erb +1 -1
  156. data/app/views/alchemy/user_sessions/signup.html.erb +2 -2
  157. data/app/views/kaminari/_gap.html.erb +1 -1
  158. data/app/views/kaminari/_next_page.html.erb +2 -2
  159. data/app/views/kaminari/_prev_page.html.erb +2 -2
  160. data/app/views/layouts/alchemy/admin.html.erb +7 -7
  161. data/bin/alchemy +1 -1
  162. data/config/authorization_rules.rb +1 -3
  163. data/config/locales/alchemy.de.yml +33 -23
  164. data/config/locales/alchemy.en.yml +31 -6
  165. data/db/migrate/{20121026100815_alchemy_two_point_three.rb → 20121118000000_alchemy_two_point_four.rb} +51 -28
  166. data/db/migrate/20130110212411_create_alchemy_legacy_page_urls.rb +11 -0
  167. data/lib/alchemy/capistrano.rb +22 -30
  168. data/lib/alchemy/errors.rb +45 -0
  169. data/lib/alchemy/i18n.rb +7 -5
  170. data/lib/alchemy/logger.rb +16 -0
  171. data/lib/alchemy/page_layout.rb +3 -3
  172. data/lib/alchemy/resource.rb +17 -1
  173. data/lib/alchemy/resources_helper.rb +8 -1
  174. data/lib/alchemy/upgrader.rb +9 -0
  175. data/lib/alchemy/version.rb +1 -1
  176. data/lib/alchemy_cms.rb +1 -6
  177. data/lib/rails/generators/alchemy/scaffold/files/elements.yml +41 -19
  178. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +13 -0
  179. data/lib/tasks/alchemy/db.rake +5 -11
  180. data/lib/tasks/alchemy/install.rake +7 -7
  181. data/spec/controllers/admin/pages_controller_spec.rb +14 -2
  182. data/spec/controllers/pages_controller_spec.rb +50 -17
  183. data/spec/dummy/config/application.rb +1 -1
  184. data/spec/dummy/db/migrate/{20121026100815_alchemy_two_point_three.rb → 20121118000000_alchemy_two_point_four.rb} +51 -28
  185. data/spec/dummy/db/migrate/20130110212411_create_alchemy_legacy_page_urls.rb +11 -0
  186. data/spec/dummy/db/schema.rb +10 -1
  187. data/spec/factories.rb +1 -0
  188. data/spec/integration/admin/picture_library_integration_spec.rb +8 -2
  189. data/spec/integration/security_spec.rb +2 -2
  190. data/spec/integration/translation_integration_spec.rb +20 -4
  191. data/spec/libraries/resources_helper_spec.rb +1 -1
  192. data/spec/models/cell_spec.rb +45 -0
  193. data/spec/models/page_spec.rb +19 -2
  194. data/spec/models/picture_spec.rb +12 -0
  195. data/spec/routing_spec.rb +115 -115
  196. data/spec/spec_helper.rb +3 -0
  197. data/spec/support/alchemy/specs_helpers.rb +6 -2
  198. data/spec/support/image.png +0 -0
  199. data/spec/support/image2.PNG +0 -0
  200. data/spec/support/image3.jpeg +0 -0
  201. metadata +27 -23
  202. data/db/migrate/20121113115120_create_alchemy_essence_links.rb +0 -13
  203. data/db/migrate/20121115100736_add_cached_tag_list_to_elements_pages_and_users.rb +0 -7
  204. data/db/migrate/20121116140636_add_cached_tag_list_to_alchemy_attachments.rb +0 -5
  205. data/db/migrate/20121116141016_change_alchemy_pictures_tag_list_column.rb +0 -9
  206. data/spec/dummy/db/migrate/20121113115120_create_alchemy_essence_links.rb +0 -13
  207. data/spec/dummy/db/migrate/20121115100736_add_cached_tag_list_to_elements_pages_and_users.rb +0 -7
  208. data/spec/dummy/db/migrate/20121116140636_add_cached_tag_list_to_alchemy_attachments.rb +0 -5
  209. data/spec/dummy/db/migrate/20121116141016_change_alchemy_pictures_tag_list_column.rb +0 -9
@@ -1,5 +1,6 @@
1
1
  module Alchemy
2
2
  class Element < ActiveRecord::Base
3
+ include Logger
3
4
 
4
5
  FORBIDDEN_DEFINITION_ATTRIBUTES = %w(contents available_contents amount picture_gallery taggable hint)
5
6
  SKIPPED_ATTRIBUTES_ON_COPY = %w(id position folded created_at updated_at creator_id updater_id cached_tag_list)
@@ -58,7 +59,7 @@ module Alchemy
58
59
  if element_scratch
59
60
  new(element_scratch.merge(attributes).except(*FORBIDDEN_DEFINITION_ATTRIBUTES))
60
61
  else
61
- raise "Element description for #{attributes[:name]} not found. Please check your elements.yml"
62
+ raise ElementDefinitionError, "Element description for #{attributes[:name]} not found. Please check your elements.yml"
62
63
  end
63
64
  end
64
65
 
@@ -70,24 +71,18 @@ module Alchemy
70
71
  end
71
72
 
72
73
  # Returns the descriptions from elements.yml file.
73
- # Alchemy comes with its own elements.yml file. As so called standard set.
74
+ #
74
75
  # Place a elements.yml file inside your apps config/alchemy folder to define
75
76
  # your own set of elements
77
+ #
76
78
  def descriptions
77
79
  if ::File.exists? "#{::Rails.root}/config/alchemy/elements.yml"
78
- element_definitions = ::YAML.load_file("#{::Rails.root}/config/alchemy/elements.yml")
79
- end
80
- if !element_definitions
81
- if ::File.exists?(::File.join(::File.dirname(__FILE__), "../../../config/alchemy/elements.yml"))
82
- element_definitions = ::YAML.load_file(::File.join(::File.dirname(__FILE__), "../../../config/alchemy/elements.yml"))
83
- end
84
- end
85
- if !element_definitions
80
+ ::YAML.load_file("#{::Rails.root}/config/alchemy/elements.yml")
81
+ else
86
82
  raise LoadError, "Could not find elements.yml file! Please run: rails generate alchemy:scaffold"
87
83
  end
88
- element_definitions
89
84
  rescue TypeError => e
90
- Rails.logger.warn "\n++++ WARNING: Your elements.yml is empty.\n"
85
+ warn "Your elements.yml is empty."
91
86
  []
92
87
  end
93
88
  alias_method :definitions, :descriptions
@@ -108,7 +103,7 @@ module Alchemy
108
103
  # if page_layout has cells, collect elements from cells and group them by cellname
109
104
  page_layout = PageLayout.get(page.page_layout)
110
105
  if page_layout.blank?
111
- logger.warn "\n++++++\nWARNING! Could not find page_layout description for page: #{page.name}\n++++++++\n"
106
+ warn "Could not find page_layout description for page: #{page.name}"
112
107
  return []
113
108
  end
114
109
  elements_for_layout = []
@@ -296,7 +291,7 @@ module Alchemy
296
291
  # Returns the description for given content_name
297
292
  def content_description_for(content_name)
298
293
  if content_descriptions.blank?
299
- logger.warn("\n+++++++++++ Warning: Element #{self.name} is missing the content description for #{content_name}\n")
294
+ warn "Element #{self.name} is missing the content description for #{content_name}"
300
295
  return nil
301
296
  else
302
297
  content_descriptions.detect { |d| d['name'] == content_name }
@@ -313,7 +308,8 @@ module Alchemy
313
308
  def description
314
309
  description = self.class.descriptions.detect { |d| d['name'] == self.name }
315
310
  if description.blank?
316
- raise "Could not find element definition for #{self.name}. Please check your elements.yml"
311
+ warn "Could not find element definition for #{self.name}. Please check your elements.yml!"
312
+ return {}
317
313
  else
318
314
  return description
319
315
  end
@@ -436,7 +432,7 @@ module Alchemy
436
432
 
437
433
  # Essence validation errors
438
434
  #
439
- # Messages are translated via I18n.
435
+ # == Error messages are translated via I18n
440
436
  #
441
437
  # Inside your translation file add translations like:
442
438
  #
@@ -446,11 +442,11 @@ module Alchemy
446
442
  # name_of_the_content:
447
443
  # validation_error_type: Error Message
448
444
  #
449
- # validation_error_type has to be one of:
445
+ # NOTE: +validation_error_type+ has to be one of:
450
446
  #
451
- # * blank
452
- # * taken
453
- # * wrong_format
447
+ # * blank
448
+ # * taken
449
+ # * invalid
454
450
  #
455
451
  # === Example:
456
452
  #
@@ -459,17 +455,44 @@ module Alchemy
459
455
  # content_validations:
460
456
  # contactform:
461
457
  # email:
462
- # wrong_format: 'Die Email hat nicht das richtige Format'
458
+ # invalid: 'Die Email hat nicht das richtige Format'
459
+ #
460
+ #
461
+ # == Error message translation fallbacks
462
+ #
463
+ # In order to not translate every single content for every element you can provide default error messages per content name:
464
+ #
465
+ # === Example
466
+ #
467
+ # en:
468
+ # alchemy:
469
+ # content_validations:
470
+ # fields:
471
+ # email:
472
+ # invalid: E-Mail has wrong format
473
+ # blank: E-Mail can't be blank
474
+ #
475
+ # And even further you can provide general field agnostic error messages:
476
+ #
477
+ # === Example
478
+ #
479
+ # en:
480
+ # alchemy:
481
+ # content_validations:
482
+ # errors:
483
+ # invalid: %{field} has wrong format
484
+ # blank: %{field} can't be blank
463
485
  #
464
486
  def essence_error_messages
465
487
  messages = []
466
488
  essence_errors.each do |content_name, errors|
467
489
  errors.each do |error|
468
- messages << I18n.t(error,
469
- :scope => [:content_validations, self.name, content_name],
490
+ messages << I18n.t(
491
+ "#{name}.#{content_name}.#{error}",
492
+ :scope => :content_validations,
470
493
  :default => [
471
- "alchemy.content_validations.fields.#{content_name}.#{error}".to_sym,
472
- "alchemy.content_validations.errors.#{error}".to_sym
494
+ "fields.#{content_name}.#{error}".to_sym,
495
+ "errors.#{error}".to_sym
473
496
  ],
474
497
  :field => Content.translated_label_for(content_name)
475
498
  )
@@ -561,7 +584,7 @@ module Alchemy
561
584
  def create_contents
562
585
  contents = []
563
586
  if description["contents"].blank?
564
- logger.warn "\n++++++\nWARNING! Could not find any content descriptions for element: #{self.name}\n++++++++\n"
587
+ warn "Could not find any content descriptions for element: #{self.name}"
565
588
  else
566
589
  description["contents"].each do |content_hash|
567
590
  contents << Content.create_from_scratch(self, content_hash.symbolize_keys)
@@ -0,0 +1,6 @@
1
+ class Alchemy::LegacyPageUrl < ActiveRecord::Base
2
+ attr_accessible :page, :page_id, :urlname
3
+ belongs_to :page, class_name: 'Alchemy::Page'
4
+
5
+ validates_presence_of [:urlname, :page_id]
6
+ end
@@ -48,6 +48,7 @@ module Alchemy
48
48
  has_many :cells, :dependent => :destroy
49
49
  has_many :elements, :dependent => :destroy, :order => :position
50
50
  has_many :contents, :through => :elements
51
+ has_many :legacy_urls, :class_name => 'Alchemy::LegacyPageUrl'
51
52
  has_and_belongs_to_many :to_be_sweeped_elements, :class_name => 'Alchemy::Element', :uniq => true, :join_table => 'alchemy_elements_alchemy_pages'
52
53
  belongs_to :language
53
54
 
@@ -72,6 +73,7 @@ module Alchemy
72
73
  after_create :autogenerate_elements, :unless => proc { |page| page.systempage? || page.do_not_autogenerate }
73
74
  after_update :trash_not_allowed_elements, :if => :page_layout_changed?
74
75
  after_update :autogenerate_elements, :if => :page_layout_changed?
76
+ after_update :create_legacy_url, :if => :urlname_changed?
75
77
 
76
78
  scope :language_roots, where(:language_root => true)
77
79
  scope :layoutpages, where(:layoutpage => true)
@@ -399,52 +401,23 @@ module Alchemy
399
401
  elements.select { |m| type.include? m.name }
400
402
  end
401
403
 
402
- # Returns the translated explanation of seven the page stati.
403
- # TODO: Let I18n do this!
404
- def humanized_status
405
- case self.status
406
- when 0
407
- return I18n.t('page_status_visible_public_locked')
408
- when 1
409
- return I18n.t('page_status_visible_unpublic_locked')
410
- when 2
411
- return I18n.t('page_status_invisible_public_locked')
412
- when 3
413
- return I18n.t('page_status_invisible_unpublic_locked')
414
- when 4
415
- return I18n.t('page_status_visible_public')
416
- when 5
417
- return I18n.t('page_status_visible_unpublic')
418
- when 6
419
- return I18n.t('page_status_invisible_public')
420
- when 7
421
- return I18n.t('page_status_invisible_unpublic')
422
- end
404
+ # Returns a Hash of attributes describing the status of the Page.
405
+ #
406
+ def status
407
+ combined_status = {}
408
+ combined_status[:visible] = self.visible?
409
+ combined_status[:public] = self.public?
410
+ combined_status[:locked] = self.locked?
411
+ combined_status[:restricted] = self.restricted?
412
+ return combined_status
423
413
  end
424
414
 
425
- # Returns the status code. Used by humanized_status and the page status icon inside the sitemap rendered by Pages.index.
426
- def status
427
- if self.locked
428
- if self.public? && self.visible?
429
- return 0
430
- elsif !self.public? && self.visible?
431
- return 1
432
- elsif self.public? && !self.visible?
433
- return 2
434
- elsif !self.public? && !self.visible?
435
- return 3
436
- end
437
- else
438
- if self.public? && self.visible?
439
- return 4
440
- elsif !self.public? && self.visible?
441
- return 5
442
- elsif self.public? && !self.visible?
443
- return 6
444
- elsif !self.public? && !self.visible?
445
- return 7
446
- end
447
- end
415
+ # Returns the translated status for given status type.
416
+ #
417
+ # @param [Symbol] status_type
418
+ #
419
+ def status_title(status_type)
420
+ I18n.t(self.send(status_type), :scope => "page_states.#{status_type}")
448
421
  end
449
422
 
450
423
  def has_controller?
@@ -463,7 +436,7 @@ module Alchemy
463
436
  return {} if self.systempage?
464
437
  description = PageLayout.get(self.page_layout)
465
438
  if description.nil?
466
- raise "Description could not be found for page layout named #{self.page_layout}. Please check page_layouts.yml file."
439
+ raise PageLayoutDefinitionError, "Description could not be found for page layout named #{self.page_layout}. Please check page_layouts.yml file."
467
440
  else
468
441
  description
469
442
  end
@@ -649,5 +622,11 @@ module Alchemy
649
622
  elements.select { |e| !definition['elements'].include?(e.name) }.map(&:trash)
650
623
  end
651
624
 
625
+ # Stores the old urlname in a LegacyPageUrl
626
+ def create_legacy_url
627
+ legacy_url = legacy_urls.new(:urlname => urlname_was)
628
+ legacy_url.save!
629
+ end
630
+
652
631
  end
653
632
  end
@@ -22,7 +22,7 @@ module Alchemy
22
22
  end
23
23
 
24
24
  validates_presence_of :image_file
25
- validates_property :format, :of => :image_file, :in => Config.get('uploader')['allowed_filetypes']['pictures'].map(&:to_sym), :message => I18n.t("not a valid image")
25
+ validates_property :format, :of => :image_file, :in => Config.get('uploader')['allowed_filetypes']['pictures'], :case_sensitive => false, :message => I18n.t("not a valid image")
26
26
 
27
27
  acts_as_taggable
28
28
 
@@ -170,5 +170,4 @@ module Alchemy
170
170
  end
171
171
 
172
172
  end
173
- class PictureInUseError < StandardError; end
174
173
  end
@@ -9,13 +9,13 @@
9
9
  :options => @options
10
10
  ),
11
11
  {
12
- :title => t('upload_file'),
12
+ :title => _t('upload_file'),
13
13
  :size => '540x550'
14
14
  },
15
- :title => t('upload_file'),
15
+ :title => _t('upload_file'),
16
16
  :class => 'icon_button'
17
17
  ) %>
18
- <label><%= t('upload_file') %></label>
18
+ <label><%= _t('upload_file') %></label>
19
19
  </div>
20
20
  <%= js_filter_field(:onkeyup => "Alchemy.ListFilter('.assign_file_file')") %>
21
21
  </div>
@@ -8,7 +8,7 @@
8
8
  attachment.name,
9
9
  alchemy.admin_attachment_path(attachment),
10
10
  :target => '_blank',
11
- :title => t('View File')
11
+ :title => _t('View File')
12
12
  ) %>
13
13
  <% else %>
14
14
  <%= attachment.name %>
@@ -23,14 +23,14 @@
23
23
  <%= link_to(
24
24
  "",
25
25
  alchemy.download_admin_attachment_path(attachment),
26
- :title => t("download_file", :filename => attachment.filename),
26
+ :title => _t("download_file", :filename => attachment.filename),
27
27
  :class => "icon file_download"
28
28
  ) %>
29
29
  <% end %>
30
30
  <% permitted_to?(:destroy, :alchemy_admin_attachments) do %>
31
31
  <%= link_to_confirmation_window(
32
32
  "",
33
- t("confirm_to_delete_file"),
33
+ _t("confirm_to_delete_file"),
34
34
  alchemy.admin_attachment_path(
35
35
  :id => attachment,
36
36
  :query => params[:query],
@@ -39,7 +39,7 @@
39
39
  ),
40
40
  {
41
41
  :class => 'icon file_delete',
42
- :title => t('delete_file')
42
+ :title => _t('delete_file')
43
43
  }
44
44
  ) %>
45
45
  <% end %>
@@ -47,11 +47,11 @@
47
47
  <%= link_to_overlay_window("",
48
48
  alchemy.edit_admin_attachment_path(attachment, :query => params[:query], :page => params[:page]),
49
49
  {
50
- :title => t('rename_file'),
50
+ :title => _t('rename_file'),
51
51
  :size => '380x220'
52
52
  },
53
53
  :class => 'icon file_edit',
54
- :title => t('rename_file')
54
+ :title => _t('rename_file')
55
55
  ) %>
56
56
  <% end %>
57
57
  </td>
@@ -1,12 +1,12 @@
1
1
  <%- if @attachments.blank? && params[:query].nil? -%>
2
2
  <div class="info" id="no_files_notice">
3
3
  <%= render_icon('info') %>
4
- <%= t("no_files_in_archive") %>
4
+ <%= _t("no_files_in_archive") %>
5
5
  </div>
6
6
  <%- elsif @attachments.blank? -%>
7
7
  <div class="info">
8
8
  <%= render_icon('info') %>
9
- <%= t("no_search_results") %>
9
+ <%= _t("no_search_results") %>
10
10
  </div>
11
11
  <%- end -%>
12
12
  <table id="all_files" class="list">
@@ -6,7 +6,10 @@
6
6
  </tr>
7
7
  <tr>
8
8
  <td class="label"><%= f.label 'filename' %>*</td>
9
- <td class="input"><%= f.text_field 'filename', :class => 'thin_border long' %></td>
9
+ <td class="input">
10
+ <%= f.text_field 'filename', :class => 'thin_border long' %>
11
+ <p class="foot_note"><%= _t(:attachment_filename_notice) %></p>
12
+ </td>
10
13
  </tr>
11
14
  <tr>
12
15
  <td class="label"><%= f.label 'tag_list' %></td>
@@ -16,9 +19,8 @@
16
19
  </tr>
17
20
  <tr>
18
21
  <td colspan="2" class="submit">
19
- <%= f.button t('save'), :class => 'button' %>
22
+ <%= f.button _t('save'), :class => 'button' %>
20
23
  </td>
21
24
  </tr>
22
25
  </table>
23
- <p class="foot_note"><%= t(:attachment_filename_notice) %></p>
24
26
  <% end %>
@@ -4,12 +4,12 @@
4
4
  :icon => 'upload',
5
5
  :url => alchemy.new_admin_attachment_path,
6
6
  :overlay_options => {
7
- :title => t('upload_file'),
7
+ :title => _t('upload_file'),
8
8
  :size => '540x550'
9
9
  },
10
- :title => t('upload_file'),
10
+ :title => _t('upload_file'),
11
11
  :class => 'icon_button',
12
- :label => t('upload_file'),
12
+ :label => _t('upload_file'),
13
13
  :if_permitted_to => [:new, :alchemy_admin_attachments]
14
14
  }
15
15
  ]
@@ -3,9 +3,9 @@
3
3
  :partial => "alchemy/admin/partials/upload_form",
4
4
  :locals => {
5
5
  :file_types => configuration(:uploader)['allowed_filetypes']['attachments'],
6
- :file_types_description => t('documents'),
6
+ :file_types_description => _t('documents'),
7
7
  :model_name => 'attachment',
8
- :item_type => t('files')
8
+ :item_type => _t('files')
9
9
  }
10
10
  ) %>
11
11
  <% end %>
@@ -1,6 +1,6 @@
1
1
  (function($) {
2
2
 
3
- $("#clipboard_items").replaceWith("<p><%= t('No items in your clipboard') -%></p>");
3
+ $("#clipboard_items").replaceWith("<p><%= _t('No items in your clipboard') -%></p>");
4
4
  $('#clipboard_button .icon.clipboard').removeClass('full');
5
5
  Alchemy.pleaseWaitOverlay(false);
6
6
 
@@ -2,7 +2,7 @@
2
2
  <%- if @clipboard_items.blank? -%>
3
3
  <div class="info">
4
4
  <%= render_icon('info') %>
5
- <%= t('No items in your clipboard') %>
5
+ <%= _t('No items in your clipboard') %>
6
6
  </div>
7
7
  <%- else -%>
8
8
  <div id="clipboard_items">
@@ -11,12 +11,12 @@
11
11
  <% item_class = item.class.name.demodulize.underscore.pluralize %>
12
12
  <li id="clipboard_item_<%= item.id -%>" class="<%= item_class -%>">
13
13
  <%= item.class.to_s == 'Alchemy::Element' ? item.display_name_with_preview_text(60) : item.name %>
14
- <span class="float_right"><%= link_to(render_icon('delete-small'), alchemy.remove_admin_clipboard_path(:remarkable_type => item_class, :remarkable_id => item.id), :remote => true, :method => :delete, :title => t('Remove item from clipboard')) %></span>
14
+ <span class="float_right"><%= link_to(render_icon('delete-small'), alchemy.remove_admin_clipboard_path(:remarkable_type => item_class, :remarkable_id => item.id), :remote => true, :method => :delete, :title => _t('Remove item from clipboard')) %></span>
15
15
  </li>
16
16
  <%- end -%>
17
17
  </ul>
18
18
  <p>
19
- <%= link_to_confirmation_window(t('clear clipboard'), t('Do you really want to clear the clipboard?'), alchemy.clear_admin_clipboard_path(:remarkable_type => params[:remarkable_type]), :class => 'button') %>
19
+ <%= link_to_confirmation_window(_t('clear clipboard'), _t('Do you really want to clear the clipboard?'), alchemy.clear_admin_clipboard_path(:remarkable_type => params[:remarkable_type]), :class => 'button') %>
20
20
  </p>
21
21
  </div>
22
22
  <%- end -%>