alchemy_cms 2.8.3 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -2
  3. data/README.md +108 -25
  4. data/alchemy_cms.gemspec +0 -1
  5. data/app/assets/stylesheets/alchemy/archive.scss +2 -2
  6. data/app/assets/stylesheets/alchemy/base.scss +0 -37
  7. data/app/assets/stylesheets/alchemy/elements.scss +1 -1
  8. data/app/assets/stylesheets/alchemy/flash.scss +1 -1
  9. data/app/assets/stylesheets/alchemy/form_elements.scss +1 -1
  10. data/app/assets/stylesheets/alchemy/icon-font.css.scss +40 -40
  11. data/app/assets/stylesheets/alchemy/icons.scss +4 -32
  12. data/app/assets/stylesheets/alchemy/jquery-ui.scss +4 -4
  13. data/app/assets/stylesheets/alchemy/menubar.css.scss +20 -12
  14. data/app/assets/stylesheets/alchemy/modules.scss +0 -4
  15. data/app/assets/stylesheets/alchemy/search.scss +1 -1
  16. data/app/assets/stylesheets/alchemy/sitemap.scss +1 -1
  17. data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy-tinymce-dialog/window.css.scss +3 -3
  18. data/app/controllers/alchemy/admin/base_controller.rb +12 -8
  19. data/app/controllers/alchemy/admin/dashboard_controller.rb +10 -5
  20. data/app/controllers/alchemy/admin/elements_controller.rb +1 -1
  21. data/app/controllers/alchemy/admin/essence_pictures_controller.rb +8 -1
  22. data/app/controllers/alchemy/admin/layoutpages_controller.rb +1 -1
  23. data/app/controllers/alchemy/admin/pages_controller.rb +11 -6
  24. data/app/controllers/alchemy/admin/resources_controller.rb +2 -2
  25. data/app/controllers/alchemy/admin/users_controller.rb +1 -1
  26. data/app/controllers/alchemy/base_controller.rb +71 -37
  27. data/app/controllers/alchemy/elements_controller.rb +1 -1
  28. data/app/controllers/alchemy/pages_controller.rb +9 -3
  29. data/app/controllers/alchemy/pictures_controller.rb +1 -0
  30. data/app/helpers/alchemy/admin/base_helper.rb +2 -10
  31. data/app/helpers/alchemy/admin/pages_helper.rb +1 -1
  32. data/app/helpers/alchemy/base_helper.rb +1 -1
  33. data/app/helpers/alchemy/pages_helper.rb +1 -1
  34. data/app/models/alchemy/attachment.rb +3 -4
  35. data/app/models/alchemy/cell.rb +1 -1
  36. data/app/models/alchemy/content.rb +3 -4
  37. data/app/models/alchemy/element.rb +5 -6
  38. data/app/models/alchemy/folded_page.rb +1 -1
  39. data/app/models/alchemy/language.rb +1 -1
  40. data/app/models/alchemy/message.rb +1 -7
  41. data/app/models/alchemy/page.rb +12 -10
  42. data/app/models/alchemy/page/{cells.rb → page_cells.rb} +2 -2
  43. data/app/models/alchemy/page/{elements.rb → page_elements.rb} +2 -2
  44. data/app/models/alchemy/page/{naming.rb → page_naming.rb} +1 -1
  45. data/app/models/alchemy/page/{natures.rb → page_natures.rb} +3 -3
  46. data/app/models/alchemy/page/{scopes.rb → page_scopes.rb} +3 -3
  47. data/app/models/alchemy/page/page_users.rb +33 -0
  48. data/app/models/alchemy/picture.rb +3 -3
  49. data/app/models/alchemy/site.rb +2 -2
  50. data/app/views/alchemy/admin/dashboard/_locked_pages.html.erb +1 -1
  51. data/app/views/alchemy/admin/dashboard/_recent_pages.html.erb +1 -1
  52. data/app/views/alchemy/admin/dashboard/_sites.html.erb +1 -1
  53. data/app/views/alchemy/admin/dashboard/index.html.erb +10 -4
  54. data/app/views/alchemy/admin/pages/_page.html.erb +1 -1
  55. data/app/views/alchemy/admin/pages/update.js.erb +1 -1
  56. data/app/views/alchemy/{user_sessions → base}/leave.html.erb +2 -2
  57. data/app/views/alchemy/base/permission_denied.js.erb +3 -2
  58. data/app/views/layouts/alchemy/admin.html.erb +6 -3
  59. data/config/alchemy/config.yml +1 -11
  60. data/config/alchemy/modules.yml +0 -12
  61. data/config/locales/alchemy.de.yml +3 -40
  62. data/config/locales/alchemy.en.yml +2 -22
  63. data/config/routes.rb +2 -27
  64. data/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -31
  65. data/lib/alchemy/auth_accessors.rb +54 -0
  66. data/lib/alchemy/capistrano.rb +5 -17
  67. data/lib/alchemy/engine.rb +7 -7
  68. data/lib/alchemy/errors.rb +6 -0
  69. data/lib/alchemy/essence.rb +2 -2
  70. data/lib/alchemy/seeder.rb +1 -1
  71. data/lib/alchemy/tasks/helpers.rb +83 -0
  72. data/lib/alchemy/test_support/auth_helpers.rb +35 -0
  73. data/lib/alchemy/test_support/controller_requests.rb +37 -0
  74. data/{spec/support → lib/alchemy/test_support}/factories.rb +7 -28
  75. data/{spec/support/alchemy → lib/alchemy/test_support}/integration_helpers.rb +9 -36
  76. data/lib/alchemy/upgrader.rb +8 -7
  77. data/lib/alchemy/upgrader/two_point_nine.rb +33 -0
  78. data/lib/alchemy/userstamp.rb +10 -0
  79. data/lib/alchemy/version.rb +1 -3
  80. data/lib/rails/templates/alchemy.rb +1 -0
  81. data/lib/tasks/alchemy/db.rake +5 -5
  82. data/spec/controllers/admin/attachments_controller_spec.rb +3 -3
  83. data/spec/controllers/admin/dashboard_controller_spec.rb +55 -34
  84. data/spec/controllers/admin/elements_controller_spec.rb +1 -1
  85. data/spec/controllers/admin/essence_pictures_controller_spec.rb +22 -6
  86. data/spec/controllers/admin/pages_controller_spec.rb +41 -58
  87. data/spec/controllers/admin/resources_controller_spec.rb +30 -5
  88. data/spec/controllers/admin/trash_controller_spec.rb +1 -1
  89. data/spec/controllers/attachments_controller_spec.rb +26 -44
  90. data/spec/controllers/base_controller_spec.rb +8 -33
  91. data/spec/controllers/elements_controller_spec.rb +1 -1
  92. data/spec/controllers/pages_controller_spec.rb +7 -15
  93. data/spec/controllers/pictures_controller_spec.rb +44 -5
  94. data/spec/dummy/app/controllers/application_controller.rb +9 -1
  95. data/spec/dummy/app/models/user.rb +14 -0
  96. data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -31
  97. data/spec/dummy/db/schema.rb +0 -31
  98. data/spec/features/admin/language_tree_feature_spec.rb +34 -0
  99. data/spec/features/admin/pages_controller_spec.rb +1 -1
  100. data/spec/features/pages_controller_spec.rb +5 -12
  101. data/spec/features/picture_security_spec.rb +2 -2
  102. data/spec/features/security_spec.rb +6 -45
  103. data/spec/features/translation_integration_spec.rb +11 -20
  104. data/spec/{support → fixtures}/80x60.png +0 -0
  105. data/spec/support/image with spaces.png b/data/spec/fixtures/image with → spaces.png +0 -0
  106. data/spec/{support → fixtures}/image.png +0 -0
  107. data/spec/{support → fixtures}/image2.PNG +0 -0
  108. data/spec/{support → fixtures}/image3.jpeg +0 -0
  109. data/spec/helpers/admin/base_helper_spec.rb +31 -43
  110. data/spec/helpers/admin/pages_helper_spec.rb +4 -2
  111. data/spec/helpers/base_helper_spec.rb +10 -3
  112. data/spec/helpers/pages_helper_spec.rb +32 -22
  113. data/spec/models/attachment_spec.rb +1 -1
  114. data/spec/models/element_spec.rb +33 -57
  115. data/spec/models/message_spec.rb +0 -16
  116. data/spec/models/page_spec.rb +62 -26
  117. data/spec/models/picture_spec.rb +5 -5
  118. data/spec/spec_helper.rb +13 -4
  119. data/spec/tasks/helpers_spec.rb +213 -0
  120. metadata +33 -75
  121. data/app/controllers/alchemy/passwords_controller.rb +0 -35
  122. data/app/controllers/alchemy/user_sessions_controller.rb +0 -67
  123. data/app/controllers/alchemy/users_controller.rb +0 -46
  124. data/app/mailers/alchemy/notifications.rb +0 -33
  125. data/app/models/alchemy/page/users.rb +0 -25
  126. data/app/models/alchemy/user.rb +0 -183
  127. data/app/views/alchemy/admin/users/_table.html.erb +0 -69
  128. data/app/views/alchemy/admin/users/_user.html.erb +0 -39
  129. data/app/views/alchemy/admin/users/edit.html.erb +0 -6
  130. data/app/views/alchemy/admin/users/index.html.erb +0 -58
  131. data/app/views/alchemy/admin/users/new.html.erb +0 -6
  132. data/app/views/alchemy/notifications/admin_user_created.de.text.erb +0 -15
  133. data/app/views/alchemy/notifications/admin_user_created.en.text.erb +0 -15
  134. data/app/views/alchemy/notifications/registered_user_created.de.text.erb +0 -13
  135. data/app/views/alchemy/notifications/registered_user_created.en.text.erb +0 -13
  136. data/app/views/alchemy/notifications/reset_password_instructions.de.text.erb +0 -8
  137. data/app/views/alchemy/notifications/reset_password_instructions.en.text.erb +0 -8
  138. data/app/views/alchemy/passwords/edit.html.erb +0 -35
  139. data/app/views/alchemy/passwords/new.html.erb +0 -30
  140. data/app/views/alchemy/user_sessions/new.html.erb +0 -48
  141. data/app/views/alchemy/users/new.html.erb +0 -14
  142. data/config/initializers/devise.rb +0 -242
  143. data/config/locales/devise.de.yml +0 -58
  144. data/config/locales/devise.en.yml +0 -60
  145. data/lib/rails/generators/alchemy/devise/devise_generator.rb +0 -29
  146. data/spec/controllers/admin/users_controller_spec.rb +0 -132
  147. data/spec/controllers/passwords_controller_spec.rb +0 -16
  148. data/spec/controllers/user_sessions_controller_spec.rb +0 -22
  149. data/spec/controllers/users_controller_spec.rb +0 -66
  150. data/spec/mailers/notifications_spec.rb +0 -67
  151. data/spec/models/user_spec.rb +0 -252
  152. data/spec/support/alchemy/controller_helpers.rb +0 -35
@@ -43,7 +43,7 @@ module Alchemy
43
43
 
44
44
  def load_element
45
45
  element = Element.available
46
- if !current_user
46
+ if !current_alchemy_user
47
47
  element = element.not_restricted
48
48
  end
49
49
  @element = element.find(params[:id])
@@ -6,7 +6,7 @@ module Alchemy
6
6
  # And we cannot define the breadcrump method as helper_method, because rspec does not see helper_methods.
7
7
  # Not the best solution, but's working.
8
8
  # Anyone with a better idea please provide a patch.
9
- include BaseHelper
9
+ include Alchemy::BaseHelper
10
10
 
11
11
  rescue_from ActionController::RoutingError, :with => :render_404
12
12
 
@@ -57,7 +57,7 @@ module Alchemy
57
57
  end
58
58
  end
59
59
 
60
- private
60
+ private
61
61
 
62
62
  # Load the current page and store it in @page.
63
63
  #
@@ -96,7 +96,7 @@ module Alchemy
96
96
 
97
97
  def render_page_or_redirect
98
98
  @page ||= load_page
99
- if User.admins.count == 0 && @page.nil?
99
+ if signup_required?
100
100
  redirect_to signup_path
101
101
  elsif @page.nil? && last_legacy_url
102
102
  @page = last_legacy_url.page
@@ -126,6 +126,12 @@ module Alchemy
126
126
  end
127
127
  end
128
128
 
129
+ def signup_required?
130
+ if Alchemy.user_class.respond_to?(:admins)
131
+ Alchemy.user_class.admins.size == 0 && @page.nil?
132
+ end
133
+ end
134
+
129
135
  def redirect_to_public_child
130
136
  @page = @page.self_and_descendants.published.not_restricted.first
131
137
  if @page
@@ -90,6 +90,7 @@ module Alchemy
90
90
  image_file.process(:resize, resize_string)
91
91
  elsif params[:crop] == 'crop' && @size.present?
92
92
  width, height = @size.split('x').collect(&:to_i)
93
+ raise ArgumentError, "You have to state both width and height in the form 'widthxheight' when cropping" if width.nil? || height.nil?
93
94
  # prevent upscaling unless :upsample param is true
94
95
  # unfurtunally dragonfly does not handle this correctly while cropping
95
96
  unless params[:upsample] == 'true'
@@ -197,16 +197,8 @@ module Alchemy
197
197
  # (internal) Returns max image count as integer or nil. Used for the picture editor in element editor views.
198
198
  def max_image_count
199
199
  return nil if !@options
200
- if @options[:maximum_amount_of_images].blank?
201
- image_count = @options[:max_images]
202
- else
203
- image_count = @options[:maximum_amount_of_images]
204
- end
205
- if image_count.blank?
206
- nil
207
- else
208
- image_count.to_i
209
- end
200
+ image_count = @options[:maximum_amount_of_images] || @options[:max_images]
201
+ image_count.blank? ? nil : image_count.to_i
210
202
  end
211
203
 
212
204
  # (internal) Renders a select tag for all items in the clipboard
@@ -6,7 +6,7 @@ module Alchemy
6
6
  # Used for rendering the folder link in +Admin::Pages#index+ sitemap.
7
7
  #
8
8
  def sitemap_folder_link(page)
9
- if page.folded?(current_user.id)
9
+ if page.folded?(current_alchemy_user.id)
10
10
  css_class = 'folded'
11
11
  title = _t('Show childpages')
12
12
  else
@@ -33,7 +33,7 @@ module Alchemy
33
33
 
34
34
  # Returns an icon
35
35
  def render_icon(icon_class)
36
- content_tag('span', '', :class => "icon #{icon_class}")
36
+ content_tag('span', '', class: "icon #{icon_class}")
37
37
  end
38
38
 
39
39
  # Returns a div with an icon and the passed content
@@ -423,7 +423,7 @@ module Alchemy
423
423
  Alchemy.loadAlchemyMenuBar({
424
424
  page_id: #{@page.id},
425
425
  route: '#{Alchemy::MountPoint.get}',
426
- locale: '#{current_user.language || ::I18n.default_locale}'
426
+ locale: '#{current_alchemy_user.language || ::I18n.default_locale}'
427
427
  });
428
428
  } catch(e) {
429
429
  if(console){console.log(e)}
@@ -1,14 +1,13 @@
1
- require 'userstamp'
2
1
  require 'acts-as-taggable-on'
3
2
 
4
3
  module Alchemy
5
4
  class Attachment < ActiveRecord::Base
6
- include Filetypes
7
- include NameConversions
5
+ include Alchemy::Filetypes
6
+ include Alchemy::NameConversions
8
7
 
9
8
  acts_as_taggable
10
9
  file_accessor :file
11
- stampable :stamper_class_name => 'Alchemy::User'
10
+ stampable stamper_class_name: Alchemy.user_class_name
12
11
 
13
12
  attr_accessible :file, :name, :file_name, :tag_list
14
13
 
@@ -12,7 +12,7 @@
12
12
  #
13
13
  module Alchemy
14
14
  class Cell < ActiveRecord::Base
15
- include Logger
15
+ include Alchemy::Logger
16
16
 
17
17
  attr_accessible :page_id, :name
18
18
 
@@ -1,12 +1,11 @@
1
- require 'userstamp'
2
1
  require 'acts_as_list'
3
2
 
4
3
  module Alchemy
5
4
  class Content < ActiveRecord::Base
6
- include Logger
5
+ include Alchemy::Logger
7
6
 
8
7
  # Concerns
9
- include Factory
8
+ include Alchemy::Content::Factory
10
9
 
11
10
  attr_accessible(
12
11
  :do_not_index,
@@ -20,7 +19,7 @@ module Alchemy
20
19
  belongs_to :essence, :polymorphic => true, :dependent => :destroy
21
20
  belongs_to :element
22
21
 
23
- stampable stamper_class_name: 'Alchemy::User'
22
+ stampable stamper_class_name: Alchemy.user_class_name
24
23
 
25
24
  acts_as_list
26
25
 
@@ -1,10 +1,9 @@
1
1
  require 'acts-as-taggable-on'
2
- require 'userstamp'
3
2
  require 'acts_as_list'
4
3
 
5
4
  module Alchemy
6
5
  class Element < ActiveRecord::Base
7
- include Logger
6
+ include Alchemy::Logger
8
7
 
9
8
  FORBIDDEN_DEFINITION_ATTRIBUTES = %w(contents available_contents amount picture_gallery taggable hint)
10
9
  SKIPPED_ATTRIBUTES_ON_COPY = %w(id position folded created_at updated_at creator_id updater_id cached_tag_list)
@@ -24,7 +23,7 @@ module Alchemy
24
23
 
25
24
  # All Elements inside a cell are a list. All Elements not in cell are in the cell_id.nil list.
26
25
  acts_as_list :scope => [:page_id, :cell_id]
27
- stampable(:stamper_class_name => 'Alchemy::User')
26
+ stampable stamper_class_name: Alchemy.user_class_name
28
27
 
29
28
  has_many :contents, :order => :position, :dependent => :destroy
30
29
  belongs_to :cell
@@ -54,8 +53,8 @@ module Alchemy
54
53
  #default_scope { from_current_site }
55
54
 
56
55
  # Concerns
57
- include Definitions
58
- include Presenters
56
+ include Alchemy::Element::Definitions
57
+ include Alchemy::Element::Presenters
59
58
 
60
59
  # class methods
61
60
  class << self
@@ -147,7 +146,7 @@ module Alchemy
147
146
  end
148
147
 
149
148
  # Trashing an element means nullifying its position, folding and unpublishing it.
150
- def trash
149
+ def trash!
151
150
  self.update_column(:public, false)
152
151
  self.update_column(:folded, true)
153
152
  self.remove_from_list
@@ -1,6 +1,6 @@
1
1
  module Alchemy
2
2
  class FoldedPage < ActiveRecord::Base
3
3
  belongs_to :page
4
- belongs_to :user
4
+ belongs_to :user, class_name: Alchemy.user_class_name
5
5
  end
6
6
  end
@@ -66,7 +66,7 @@ module Alchemy
66
66
  end
67
67
  end
68
68
 
69
- include Code
69
+ include Alchemy::Language::Code
70
70
 
71
71
  private
72
72
 
@@ -46,7 +46,7 @@ module Alchemy
46
46
 
47
47
  case field.to_sym
48
48
  when :email
49
- validates_format_of field, :with => ::Devise.email_regexp, :if => :email_is_filled
49
+ validates_format_of field, with: Alchemy::Config.get(:email_regexp), if: -> { email.present? }
50
50
  when :email_confirmation
51
51
  validates_confirmation_of :email
52
52
  end
@@ -68,11 +68,5 @@ module Alchemy
68
68
  false
69
69
  end
70
70
 
71
- private
72
-
73
- def email_is_filled #:nodoc:
74
- !email.blank?
75
- end
76
-
77
71
  end
78
72
  end
@@ -1,6 +1,5 @@
1
1
  require 'acts-as-taggable-on'
2
2
  require 'awesome_nested_set'
3
- require 'userstamp'
4
3
 
5
4
  module Alchemy
6
5
  class Page < ActiveRecord::Base
@@ -44,12 +43,13 @@ module Alchemy
44
43
  acts_as_taggable
45
44
  acts_as_nested_set(:dependent => :destroy)
46
45
 
47
- stampable(:stamper_class_name => 'Alchemy::User')
46
+ stampable stamper_class_name: Alchemy.user_class_name
48
47
 
49
48
  has_many :folded_pages
49
+
50
50
  has_many :legacy_urls, :class_name => 'Alchemy::LegacyPageUrl'
51
51
  belongs_to :language
52
- belongs_to :locker, class_name: 'Alchemy::User', foreign_key: 'locked_by'
52
+ belongs_to :locker, class_name: Alchemy.user_class_name, foreign_key: 'locked_by'
53
53
 
54
54
  validates_presence_of :language, :on => :create, :unless => :root
55
55
  validates_presence_of :page_layout, :unless => :systempage?
@@ -64,12 +64,12 @@ module Alchemy
64
64
  after_update :create_legacy_url, :if => :urlname_changed?, :unless => :redirects_to_external?
65
65
 
66
66
  # Concerns
67
- include Scopes
68
- include Natures
69
- include Naming
70
- include Users
71
- include Cells
72
- include Elements
67
+ include Alchemy::Page::PageScopes
68
+ include Alchemy::Page::PageNatures
69
+ include Alchemy::Page::PageNaming
70
+ include Alchemy::Page::PageUsers
71
+ include Alchemy::Page::PageCells
72
+ include Alchemy::Page::PageElements
73
73
 
74
74
  # Class methods
75
75
  #
@@ -206,7 +206,9 @@ module Alchemy
206
206
 
207
207
  # Touches the timestamps and userstamps
208
208
  def touch
209
- Page.where(id: self.id).update_all(updated_at: Time.now, updater_id: User.stamper)
209
+ update_hash = {updated_at: Time.now}
210
+ update_hash[:updater_id] = Alchemy.user_class.stamper if Alchemy.user_class.respond_to?(:stamper)
211
+ Page.where(id: self.id).update_all(update_hash)
210
212
  end
211
213
 
212
214
  # Returns the previous page on the same level or nil.
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
- module Page::Cells
2
+ module Page::PageCells
3
3
 
4
4
  extend ActiveSupport::Concern
5
5
 
@@ -68,4 +68,4 @@ module Alchemy
68
68
  end
69
69
 
70
70
  end
71
- end
71
+ end
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
- module Page::Elements
2
+ module Page::PageElements
3
3
 
4
4
  extend ActiveSupport::Concern
5
5
 
@@ -207,7 +207,7 @@ module Alchemy
207
207
 
208
208
  # Trashes all elements that are not allowed for this page_layout.
209
209
  def trash_not_allowed_elements
210
- elements.select { |e| !definition['elements'].include?(e.name) }.map(&:trash)
210
+ elements.select { |e| !definition['elements'].include?(e.name) }.map(&:trash!)
211
211
  end
212
212
 
213
213
  # Deletes unique and already present definitions from @elements_for_layout.
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
- module Page::Naming
2
+ module Page::PageNaming
3
3
 
4
4
  extend ActiveSupport::Concern
5
5
  include NameConversions
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
- module Page::Natures
2
+ module Page::PageNatures
3
3
 
4
4
  extend ActiveSupport::Concern
5
5
 
@@ -17,8 +17,8 @@ module Alchemy
17
17
  end
18
18
 
19
19
  def folded?(user_id)
20
- folded_page = folded_pages.find_by_user_id(user_id)
21
- folded_page.try(:folded) || false
20
+ return unless Alchemy.user_class < ActiveRecord::Base
21
+ folded_pages.where(user_id: user_id, folded: true).any?
22
22
  end
23
23
 
24
24
  def contains_feed?
@@ -2,7 +2,7 @@ module Alchemy
2
2
 
3
3
  # ActiveRecord scopes for Alchemy::Page
4
4
  #
5
- module Page::Scopes
5
+ module Page::PageScopes
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
@@ -18,7 +18,7 @@ module Alchemy
18
18
  #
19
19
  scope :all_locked, where(locked: true)
20
20
 
21
- # All pages locked by given +Alchemy::User+
21
+ # All pages locked by given user
22
22
  #
23
23
  scope :all_locked_by, ->(user) {
24
24
  all_locked.where(locked_by: user.id)
@@ -52,7 +52,7 @@ module Alchemy
52
52
  )
53
53
  }
54
54
 
55
- # Last 5 pages that where recently edited by given +Alchemy::User+
55
+ # Last 5 pages that where recently edited by given user
56
56
  #
57
57
  scope :all_last_edited_from, ->(user) {
58
58
  where(updater_id: user.id).order('updated_at DESC').limit(5)
@@ -0,0 +1,33 @@
1
+ module Alchemy
2
+ module Page::PageUsers
3
+ extend ActiveSupport::Concern
4
+
5
+ # Returns the name of the creator of this page.
6
+ #
7
+ # If no creator could be found or associated user model
8
+ # does not respond to +#name+ it returns +'unknown'+
9
+ #
10
+ def creator_name
11
+ (creator && creator.respond_to?(:name) ? creator.name : nil) || I18n.t('unknown')
12
+ end
13
+
14
+ # Returns the name of the last updater of this page.
15
+ #
16
+ # If no updater could be found or associated user model
17
+ # does not respond to +#name+ it returns +'unknown'+
18
+ #
19
+ def updater_name
20
+ (updater && updater.respond_to?(:name) ? updater.name : nil) || I18n.t('unknown')
21
+ end
22
+
23
+ # Returns the name of the user currently editing this page.
24
+ #
25
+ # If no locker could be found or associated user model
26
+ # does not respond to +#name+ it returns +'unknown'+
27
+ #
28
+ def locker_name
29
+ (locker && locker.respond_to?(:name) ? locker.name : nil) || I18n.t('unknown')
30
+ end
31
+
32
+ end
33
+ end
@@ -1,10 +1,9 @@
1
1
  require 'acts-as-taggable-on'
2
2
  require 'dragonfly'
3
- require 'userstamp'
4
3
 
5
4
  module Alchemy
6
5
  class Picture < ActiveRecord::Base
7
- include NameConversions
6
+ include Alchemy::NameConversions
8
7
 
9
8
  has_many :essence_pictures, :class_name => 'Alchemy::EssencePicture', :foreign_key => 'picture_id'
10
9
  has_many :contents, :through => :essence_pictures
@@ -39,7 +38,7 @@ module Alchemy
39
38
  :upload_hash
40
39
  )
41
40
 
42
- stampable(:stamper_class_name => 'Alchemy::User')
41
+ stampable stamper_class_name: Alchemy.user_class_name
43
42
 
44
43
  scope :recent, where("#{self.table_name}.created_at > ?", Time.now-24.hours).order(:created_at)
45
44
  scope :deletable, where("alchemy_pictures.id NOT IN (SELECT picture_id FROM alchemy_essence_pictures)")
@@ -145,6 +144,7 @@ module Alchemy
145
144
  return "111x93" if size == "111x93" || size.blank?
146
145
  x = size.split('x')[0].to_i
147
146
  y = size.split('x')[1].to_i
147
+ return "111x93" if x.zero? || y.zero?
148
148
  if (x > y)
149
149
  zoom_factor = 111.0 / x
150
150
  new_x = 111
@@ -9,10 +9,10 @@ module Alchemy
9
9
  # associations
10
10
  has_many :languages
11
11
 
12
- scope :published, where(public: true)
12
+ scope :published, -> { where(public: true) }
13
13
 
14
14
  # concerns
15
- include Layout
15
+ include Alchemy::Site::Layout
16
16
 
17
17
  # Returns true if this site is the current site
18
18
  def current?