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.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/README.md +108 -25
- data/alchemy_cms.gemspec +0 -1
- data/app/assets/stylesheets/alchemy/archive.scss +2 -2
- data/app/assets/stylesheets/alchemy/base.scss +0 -37
- data/app/assets/stylesheets/alchemy/elements.scss +1 -1
- data/app/assets/stylesheets/alchemy/flash.scss +1 -1
- data/app/assets/stylesheets/alchemy/form_elements.scss +1 -1
- data/app/assets/stylesheets/alchemy/icon-font.css.scss +40 -40
- data/app/assets/stylesheets/alchemy/icons.scss +4 -32
- data/app/assets/stylesheets/alchemy/jquery-ui.scss +4 -4
- data/app/assets/stylesheets/alchemy/menubar.css.scss +20 -12
- data/app/assets/stylesheets/alchemy/modules.scss +0 -4
- data/app/assets/stylesheets/alchemy/search.scss +1 -1
- data/app/assets/stylesheets/alchemy/sitemap.scss +1 -1
- data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy-tinymce-dialog/window.css.scss +3 -3
- data/app/controllers/alchemy/admin/base_controller.rb +12 -8
- data/app/controllers/alchemy/admin/dashboard_controller.rb +10 -5
- data/app/controllers/alchemy/admin/elements_controller.rb +1 -1
- data/app/controllers/alchemy/admin/essence_pictures_controller.rb +8 -1
- data/app/controllers/alchemy/admin/layoutpages_controller.rb +1 -1
- data/app/controllers/alchemy/admin/pages_controller.rb +11 -6
- data/app/controllers/alchemy/admin/resources_controller.rb +2 -2
- data/app/controllers/alchemy/admin/users_controller.rb +1 -1
- data/app/controllers/alchemy/base_controller.rb +71 -37
- data/app/controllers/alchemy/elements_controller.rb +1 -1
- data/app/controllers/alchemy/pages_controller.rb +9 -3
- data/app/controllers/alchemy/pictures_controller.rb +1 -0
- data/app/helpers/alchemy/admin/base_helper.rb +2 -10
- data/app/helpers/alchemy/admin/pages_helper.rb +1 -1
- data/app/helpers/alchemy/base_helper.rb +1 -1
- data/app/helpers/alchemy/pages_helper.rb +1 -1
- data/app/models/alchemy/attachment.rb +3 -4
- data/app/models/alchemy/cell.rb +1 -1
- data/app/models/alchemy/content.rb +3 -4
- data/app/models/alchemy/element.rb +5 -6
- data/app/models/alchemy/folded_page.rb +1 -1
- data/app/models/alchemy/language.rb +1 -1
- data/app/models/alchemy/message.rb +1 -7
- data/app/models/alchemy/page.rb +12 -10
- data/app/models/alchemy/page/{cells.rb → page_cells.rb} +2 -2
- data/app/models/alchemy/page/{elements.rb → page_elements.rb} +2 -2
- data/app/models/alchemy/page/{naming.rb → page_naming.rb} +1 -1
- data/app/models/alchemy/page/{natures.rb → page_natures.rb} +3 -3
- data/app/models/alchemy/page/{scopes.rb → page_scopes.rb} +3 -3
- data/app/models/alchemy/page/page_users.rb +33 -0
- data/app/models/alchemy/picture.rb +3 -3
- data/app/models/alchemy/site.rb +2 -2
- data/app/views/alchemy/admin/dashboard/_locked_pages.html.erb +1 -1
- data/app/views/alchemy/admin/dashboard/_recent_pages.html.erb +1 -1
- data/app/views/alchemy/admin/dashboard/_sites.html.erb +1 -1
- data/app/views/alchemy/admin/dashboard/index.html.erb +10 -4
- data/app/views/alchemy/admin/pages/_page.html.erb +1 -1
- data/app/views/alchemy/admin/pages/update.js.erb +1 -1
- data/app/views/alchemy/{user_sessions → base}/leave.html.erb +2 -2
- data/app/views/alchemy/base/permission_denied.js.erb +3 -2
- data/app/views/layouts/alchemy/admin.html.erb +6 -3
- data/config/alchemy/config.yml +1 -11
- data/config/alchemy/modules.yml +0 -12
- data/config/locales/alchemy.de.yml +3 -40
- data/config/locales/alchemy.en.yml +2 -22
- data/config/routes.rb +2 -27
- data/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -31
- data/lib/alchemy/auth_accessors.rb +54 -0
- data/lib/alchemy/capistrano.rb +5 -17
- data/lib/alchemy/engine.rb +7 -7
- data/lib/alchemy/errors.rb +6 -0
- data/lib/alchemy/essence.rb +2 -2
- data/lib/alchemy/seeder.rb +1 -1
- data/lib/alchemy/tasks/helpers.rb +83 -0
- data/lib/alchemy/test_support/auth_helpers.rb +35 -0
- data/lib/alchemy/test_support/controller_requests.rb +37 -0
- data/{spec/support → lib/alchemy/test_support}/factories.rb +7 -28
- data/{spec/support/alchemy → lib/alchemy/test_support}/integration_helpers.rb +9 -36
- data/lib/alchemy/upgrader.rb +8 -7
- data/lib/alchemy/upgrader/two_point_nine.rb +33 -0
- data/lib/alchemy/userstamp.rb +10 -0
- data/lib/alchemy/version.rb +1 -3
- data/lib/rails/templates/alchemy.rb +1 -0
- data/lib/tasks/alchemy/db.rake +5 -5
- data/spec/controllers/admin/attachments_controller_spec.rb +3 -3
- data/spec/controllers/admin/dashboard_controller_spec.rb +55 -34
- data/spec/controllers/admin/elements_controller_spec.rb +1 -1
- data/spec/controllers/admin/essence_pictures_controller_spec.rb +22 -6
- data/spec/controllers/admin/pages_controller_spec.rb +41 -58
- data/spec/controllers/admin/resources_controller_spec.rb +30 -5
- data/spec/controllers/admin/trash_controller_spec.rb +1 -1
- data/spec/controllers/attachments_controller_spec.rb +26 -44
- data/spec/controllers/base_controller_spec.rb +8 -33
- data/spec/controllers/elements_controller_spec.rb +1 -1
- data/spec/controllers/pages_controller_spec.rb +7 -15
- data/spec/controllers/pictures_controller_spec.rb +44 -5
- data/spec/dummy/app/controllers/application_controller.rb +9 -1
- data/spec/dummy/app/models/user.rb +14 -0
- data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -31
- data/spec/dummy/db/schema.rb +0 -31
- data/spec/features/admin/language_tree_feature_spec.rb +34 -0
- data/spec/features/admin/pages_controller_spec.rb +1 -1
- data/spec/features/pages_controller_spec.rb +5 -12
- data/spec/features/picture_security_spec.rb +2 -2
- data/spec/features/security_spec.rb +6 -45
- data/spec/features/translation_integration_spec.rb +11 -20
- data/spec/{support → fixtures}/80x60.png +0 -0
- data/spec/support/image with spaces.png b/data/spec/fixtures/image with → spaces.png +0 -0
- data/spec/{support → fixtures}/image.png +0 -0
- data/spec/{support → fixtures}/image2.PNG +0 -0
- data/spec/{support → fixtures}/image3.jpeg +0 -0
- data/spec/helpers/admin/base_helper_spec.rb +31 -43
- data/spec/helpers/admin/pages_helper_spec.rb +4 -2
- data/spec/helpers/base_helper_spec.rb +10 -3
- data/spec/helpers/pages_helper_spec.rb +32 -22
- data/spec/models/attachment_spec.rb +1 -1
- data/spec/models/element_spec.rb +33 -57
- data/spec/models/message_spec.rb +0 -16
- data/spec/models/page_spec.rb +62 -26
- data/spec/models/picture_spec.rb +5 -5
- data/spec/spec_helper.rb +13 -4
- data/spec/tasks/helpers_spec.rb +213 -0
- metadata +33 -75
- data/app/controllers/alchemy/passwords_controller.rb +0 -35
- data/app/controllers/alchemy/user_sessions_controller.rb +0 -67
- data/app/controllers/alchemy/users_controller.rb +0 -46
- data/app/mailers/alchemy/notifications.rb +0 -33
- data/app/models/alchemy/page/users.rb +0 -25
- data/app/models/alchemy/user.rb +0 -183
- data/app/views/alchemy/admin/users/_table.html.erb +0 -69
- data/app/views/alchemy/admin/users/_user.html.erb +0 -39
- data/app/views/alchemy/admin/users/edit.html.erb +0 -6
- data/app/views/alchemy/admin/users/index.html.erb +0 -58
- data/app/views/alchemy/admin/users/new.html.erb +0 -6
- data/app/views/alchemy/notifications/admin_user_created.de.text.erb +0 -15
- data/app/views/alchemy/notifications/admin_user_created.en.text.erb +0 -15
- data/app/views/alchemy/notifications/registered_user_created.de.text.erb +0 -13
- data/app/views/alchemy/notifications/registered_user_created.en.text.erb +0 -13
- data/app/views/alchemy/notifications/reset_password_instructions.de.text.erb +0 -8
- data/app/views/alchemy/notifications/reset_password_instructions.en.text.erb +0 -8
- data/app/views/alchemy/passwords/edit.html.erb +0 -35
- data/app/views/alchemy/passwords/new.html.erb +0 -30
- data/app/views/alchemy/user_sessions/new.html.erb +0 -48
- data/app/views/alchemy/users/new.html.erb +0 -14
- data/config/initializers/devise.rb +0 -242
- data/config/locales/devise.de.yml +0 -58
- data/config/locales/devise.en.yml +0 -60
- data/lib/rails/generators/alchemy/devise/devise_generator.rb +0 -29
- data/spec/controllers/admin/users_controller_spec.rb +0 -132
- data/spec/controllers/passwords_controller_spec.rb +0 -16
- data/spec/controllers/user_sessions_controller_spec.rb +0 -22
- data/spec/controllers/users_controller_spec.rb +0 -66
- data/spec/mailers/notifications_spec.rb +0 -67
- data/spec/models/user_spec.rb +0 -252
- data/spec/support/alchemy/controller_helpers.rb +0 -35
@@ -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
|
-
|
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
|
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
|
-
|
201
|
-
|
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?(
|
9
|
+
if page.folded?(current_alchemy_user.id)
|
10
10
|
css_class = 'folded'
|
11
11
|
title = _t('Show childpages')
|
12
12
|
else
|
@@ -423,7 +423,7 @@ module Alchemy
|
|
423
423
|
Alchemy.loadAlchemyMenuBar({
|
424
424
|
page_id: #{@page.id},
|
425
425
|
route: '#{Alchemy::MountPoint.get}',
|
426
|
-
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 :
|
10
|
+
stampable stamper_class_name: Alchemy.user_class_name
|
12
11
|
|
13
12
|
attr_accessible :file, :name, :file_name, :tag_list
|
14
13
|
|
data/app/models/alchemy/cell.rb
CHANGED
@@ -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:
|
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
|
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
|
@@ -46,7 +46,7 @@ module Alchemy
|
|
46
46
|
|
47
47
|
case field.to_sym
|
48
48
|
when :email
|
49
|
-
validates_format_of field, :
|
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
|
data/app/models/alchemy/page.rb
CHANGED
@@ -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
|
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:
|
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
|
68
|
-
include
|
69
|
-
include
|
70
|
-
include
|
71
|
-
include
|
72
|
-
include
|
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
|
-
|
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::
|
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::
|
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
|
-
|
21
|
-
|
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::
|
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
|
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
|
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
|
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
|
data/app/models/alchemy/site.rb
CHANGED
@@ -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?
|