alchemy_cms 2.6.1 → 2.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5cd8a76bd94ec8a9ce8224cc3c4717e2586f19bb
4
+ data.tar.gz: 061556fac26ed8fded1fee1744928741d11e2daa
5
+ SHA512:
6
+ metadata.gz: ede2710502558c4be7ec68064ab6b35cce31e9158c49ecd73440c797ff8d6f76ce3bf6d43d6564c661ff014568d02cdb5b9e16fec451eddf697305e3537bde2a
7
+ data.tar.gz: 6fd48a42acc533c9bb05238cd6dbf8206c95b765602f84ca2dd679ad08c34065269d8113c74a5cef31bb1b80967494a00f38f2ec6a146a263d882848c25e5e55
@@ -150,7 +150,7 @@ module Alchemy
150
150
 
151
151
  def flush
152
152
  # FileUtils.rm_rf only takes arrays of folders...
153
- FileUtils.rm_rf Dir.glob(Rails.root.join('public', Alchemy.mount_point, 'pictures', '*'))
153
+ FileUtils.rm_rf Dir.glob(Rails.root.join('public', Alchemy::MountPoint.get, 'pictures', '*'))
154
154
  @notice = _t('Picture cache flushed')
155
155
  end
156
156
 
@@ -417,7 +417,7 @@ module Alchemy
417
417
  try {
418
418
  Alchemy.loadAlchemyMenuBar({
419
419
  page_id: #{@page.id},
420
- route: '#{Alchemy.mount_point}',
420
+ route: '#{Alchemy::MountPoint.get}',
421
421
  locale: '#{current_user.language || ::I18n.default_locale}'
422
422
  });
423
423
  } catch(e) {
@@ -1,14 +1,14 @@
1
1
  module Alchemy
2
2
  class Notifications < ActionMailer::Base
3
3
 
4
- default :from => Alchemy::Config.get(:mailer)['mail_from']
4
+ default(from: Config.get(:mailer)['mail_from'])
5
5
 
6
6
  def registered_user_created(user)
7
7
  @user = user
8
8
  @url = login_url
9
9
  mail(
10
- :to => user.email,
11
- :subject => Alchemy::I18n.t("alchemy.mailer.new_user_mail.subject")
10
+ to: user.email,
11
+ subject: I18n.t("Your user credentials")
12
12
  )
13
13
  end
14
14
 
@@ -16,14 +16,17 @@ module Alchemy
16
16
  @user = user
17
17
  @url = admin_url
18
18
  mail(
19
- :to => user.email,
20
- :subject => Alchemy::I18n.t("Your Alchemy Login")
19
+ to: user.email,
20
+ subject: I18n.t("Your Alchemy Login")
21
21
  )
22
22
  end
23
23
 
24
24
  def reset_password_instructions(user, opts={})
25
25
  @user = user
26
- mail :to => user.email, :subject => Alchemy::I18n.t("Reset password instructions")
26
+ mail(
27
+ to: user.email,
28
+ subject: I18n.t("Reset password instructions")
29
+ )
27
30
  end
28
31
 
29
32
  end
@@ -14,7 +14,7 @@ module Alchemy
14
14
 
15
15
  def expire_cache_for(picture)
16
16
  # Removing all variants of the picture with FileUtils.
17
- FileUtils.rm_rf(Rails.root.join('public', Alchemy.mount_point, 'pictures', picture.id.to_s))
17
+ FileUtils.rm_rf(Rails.root.join('public', Alchemy::MountPoint.get, 'pictures', picture.id.to_s))
18
18
  end
19
19
 
20
20
  end
@@ -4,8 +4,10 @@
4
4
  <%= link_to(
5
5
  content.ingredient,
6
6
  url_for(content.essence.link),
7
- :title => content.essence.link_title,
8
- :target => (content.essence.link_target == "blank" ? "_blank" : nil),
9
- 'data-link-target' => content.essence.link_target
7
+ {
8
+ title: content.essence.link_title,
9
+ target: (content.essence.link_target == "blank" ? "_blank" : nil),
10
+ 'data-link-target' => content.essence.link_target
11
+ }.merge(html_options)
10
12
  ) %>
11
13
  <%- end -%>
@@ -8,6 +8,6 @@ Es wurde ein Zufallspasswort generiert. Aus Sicherheitsgründen wird dieses hier
8
8
 
9
9
  Klicken Sie bitte daher auf den folgenden Link (*), um sich ein neues Passwort zu vergeben:
10
10
 
11
- <%= alchemy.new_password_url(@user, email: @user.email) %>
11
+ <%= alchemy.new_password_url(email: @user.email) %>
12
12
 
13
13
  *) Sollte dies nicht funktionieren, so kopieren Sie Sich bitte diesen Link und tragen Sie ihn in die Adresszeile Ihres Webbrowsers ein.
@@ -8,6 +8,6 @@ The password was randomly created. For security reasons it is not displayed here
8
8
 
9
9
  Please follow this link (*) to reset your password:
10
10
 
11
- <%= alchemy.new_password_url(@user, email: @user.email) %>
11
+ <%= alchemy.new_password_url(email: @user.email) %>
12
12
 
13
13
  *) If this does not work, please copy the url and paste it into the address bar of your web browser.
@@ -130,12 +130,6 @@ de:
130
130
  messages:
131
131
  success: 'Ihre Nachricht wurde erfolgreich übermittelt.'
132
132
 
133
- # == Translations for the mailer templates
134
- mailer:
135
- # The mail the user gets after registering for alchemy
136
- new_user_mail:
137
- subject: 'Ihre Zugangsdaten'
138
-
139
133
  # == Translated language names for translation select
140
134
  translations:
141
135
  de: 'Deutsch'
@@ -282,6 +276,7 @@ de:
282
276
  "Remove tag filter": "Filter entfernen"
283
277
  "Remove this content": "Diesen Inhalt entfernen"
284
278
  "Reset Imagemask": "Bildmaske zurücksetzen"
279
+ "Reset password instructions": "Anweisungen um Ihr Passwort zurückzusetzen"
285
280
  "Select all": "Alle auswählen"
286
281
  "Select an content": "Wählen Sie einen Inhalt aus"
287
282
  "Select style": "Stilvorlage"
@@ -329,6 +324,7 @@ de:
329
324
  "You may upload files with following extensions": "Sie können %{file_types_description} mit folgenden Endungen hochladen: %{file_types}"
330
325
  "You may upload any file": "Sie können jede Art von Datei hochladen."
331
326
  "Your last login was on %{time}": "Sie waren zuletzt angemeldet am %{time}."
327
+ "Your user credentials": "Ihre Zugangsdaten"
332
328
  "Your Alchemy Login": "Ihre Alchemy Zugangsdaten"
333
329
  "Your last updated pages": "Ihre zuletzt bearbeiteten Seiten"
334
330
  "Your trash is empty": "Der Papierkorb ist leer"
@@ -116,12 +116,6 @@ en:
116
116
  messages:
117
117
  success: 'Your message was delivered succesfully.'
118
118
 
119
- # == Translations for the mailer templates
120
- mailer:
121
- # The mail the user gets after registering for alchemy
122
- new_user_mail:
123
- subject: 'Your user credentials'
124
-
125
119
  # == Translated language names for translation select
126
120
  translations:
127
121
  de: 'German'
@@ -3,7 +3,7 @@ Alchemy::Engine.routes.draw do
3
3
  root :to => 'pages#show'
4
4
 
5
5
  get '/admin' => redirect(
6
- "#{Alchemy.mount_point}/admin/dashboard"
6
+ "#{Alchemy::MountPoint.get}/admin/dashboard"
7
7
  )
8
8
 
9
9
  get '/admin/dashboard' => 'admin/dashboard#index',
@@ -1,16 +1,41 @@
1
1
  module Alchemy
2
+ # Utitlities for Alchemy's mount point in the host rails app.
3
+ #
4
+ class MountPoint
2
5
 
3
- # Returns alchemys mount point in current rails app.
4
- # Pass false to not return a leading slash on empty mount point.
5
- def self.mount_point(remove_leading_slash_if_blank = true)
6
- alchemy_routes = Rails.application.routes.named_routes[:alchemy]
7
- raise "Alchemy not mounted! Please mount Alchemy::Engine in your config/routes.rb file." if alchemy_routes.nil?
8
- mount_point = alchemy_routes.path.spec.to_s
9
- if remove_leading_slash_if_blank && mount_point == "/"
10
- mount_point.gsub(/^\/$/, '')
11
- else
12
- mount_point
6
+ # Returns the path of Alchemy's mount point in current rails app.
7
+ #
8
+ # @param [Boolean] remove_leading_slash_if_blank
9
+ # Pass false to not return a leading slash on empty mount point.
10
+ #
11
+ def self.get(remove_leading_slash_if_blank = true)
12
+ if self.mount_point == "/" && remove_leading_slash_if_blank
13
+ self.mount_point.gsub(/^\/$/, '')
14
+ else
15
+ self.mount_point
16
+ end
17
+ end
18
+
19
+ # Returns the routes object from Alchemy in the host app.
20
+ #
21
+ def self.routes
22
+ ::Rails.application.routes.named_routes[:alchemy]
13
23
  end
14
- end
15
24
 
25
+ # Returns the raw mount point path from the Rails app routes.
26
+ #
27
+ # If Alchemy is not mounted in the main app, it falls back to root path.
28
+ #
29
+ def self.mount_point
30
+ if self.routes.nil?
31
+ ::Rails.logger.warn <<-WARN
32
+ Alchemy is not mounted! Falling back to root path (/).
33
+ If you want to change Alchemy's mount point, please mount Alchemy::Engine in your config/routes.rb file.
34
+ WARN
35
+ return '/'
36
+ end
37
+ routes.path.spec.to_s
38
+ end
39
+
40
+ end
16
41
  end
@@ -1,8 +1,10 @@
1
- require 'thor/shell/color'
1
+ require "#{File.dirname(__FILE__)}/shell"
2
2
 
3
3
  module Alchemy
4
4
  class Seeder
5
5
 
6
+ extend Shell
7
+
6
8
  class << self
7
9
 
8
10
  # This seed builds the necessary page structure for alchemy in your database.
@@ -14,36 +16,6 @@ module Alchemy
14
16
 
15
17
  private
16
18
 
17
- def color(name)
18
- case name
19
- when :green
20
- Thor::Shell::Color::GREEN
21
- when :red
22
- Thor::Shell::Color::RED
23
- when :yellow
24
- Thor::Shell::Color::YELLOW
25
- when :black
26
- Thor::Shell::Color::BLACK
27
- when :clear
28
- Thor::Shell::Color::CLEAR
29
- else
30
- ""
31
- end
32
- end
33
-
34
- def log(message, type=nil)
35
- case type
36
- when :skip
37
- puts "#{color(:yellow)}== Skipping! #{message}#{color(:clear)}"
38
- when :error
39
- puts "#{color(:red)}!! ERROR: #{message}#{color(:clear)}"
40
- when :message
41
- puts "#{color(:clear)}#{message}"
42
- else
43
- puts "#{color(:green)}== #{message}#{color(:clear)}"
44
- end
45
- end
46
-
47
19
  def desc(message)
48
20
  puts "\n#{message}"
49
21
  puts "#{'-' * message.length}\n"
@@ -76,11 +48,11 @@ module Alchemy
76
48
 
77
49
  def create_default_site
78
50
  desc "Creating default site"
79
- site = Alchemy::Site.find_or_initialize_by_host(
80
- :name => 'Default Site',
81
- :host => '*'
82
- )
83
- if site.new_record?
51
+ if Alchemy::Site.count == 0
52
+ site = Alchemy::Site.new(
53
+ name: 'Default Site',
54
+ host: '*'
55
+ )
84
56
  if Alchemy::Language.any?
85
57
  site.languages = Alchemy::Language.all
86
58
  end
@@ -0,0 +1,80 @@
1
+ # encoding: utf-8
2
+ require 'thor/shell/color'
3
+
4
+ module Alchemy
5
+
6
+ # Provides methods for collecting sentences and displaying them
7
+ # in a list on the shell / log
8
+ #
9
+ module Shell
10
+
11
+ def todo(todo)
12
+ add_todo todo
13
+ end
14
+
15
+ # Adds a sentence to the todos Array
16
+ #
17
+ # @param [String] todo
18
+ #
19
+ def add_todo(todo)
20
+ todos << todo
21
+ end
22
+
23
+ # All todos
24
+ #
25
+ # @return [Array]
26
+ #
27
+ def todos
28
+ @@todos ||= []
29
+ end
30
+
31
+ # Prints out all the todos
32
+ #
33
+ def display_todos
34
+ if todos.length > 0
35
+ log "\nTODOS:", :message
36
+ log "------\n", :message
37
+ todos.each_with_index do |todo, i|
38
+ log "\n#{i+1}. ", :message
39
+ log todo, :message
40
+ end
41
+ end
42
+ end
43
+
44
+ # Prints out the given todo message with the color due to its type
45
+ #
46
+ # @param [String] message
47
+ # @param [Symbol] type
48
+ #
49
+ def log(message, type=nil)
50
+ case type
51
+ when :skip
52
+ puts "#{color(:yellow)}== Skipping! #{message}#{color(:clear)}"
53
+ when :error
54
+ puts "#{color(:red)}!! ERROR: #{message}#{color(:clear)}"
55
+ when :message
56
+ puts "#{color(:clear)}#{message}"
57
+ else
58
+ puts "#{color(:green)}== #{message}#{color(:clear)}"
59
+ end
60
+ end
61
+
62
+ private
63
+
64
+ # Gives the color string using Thor
65
+ # Used for colorizing the message on the shell
66
+ #
67
+ # @param [String] name
68
+ # @return [String]
69
+ #
70
+ def color(name)
71
+ color_const = name.to_s.upcase
72
+ if Thor::Shell::Color.const_defined?(color_const)
73
+ "Thor::Shell::Color::#{color_const}".constantize
74
+ else
75
+ ""
76
+ end
77
+ end
78
+
79
+ end
80
+ end
@@ -1,54 +1,54 @@
1
1
  module Alchemy
2
2
  class Upgrader < Alchemy::Seeder
3
+
4
+ Dir["#{File.dirname(__FILE__)}/upgrader/*.rb"].each { |f| require f }
5
+
6
+ extend TwoPointSix
7
+ extend TwoPointFive
8
+ extend TwoPointFour
9
+ extend TwoPointThree
10
+ extend TwoPointTwo
11
+ extend TwoPointOne
12
+ extend TwoPointZero
13
+
3
14
  class << self
4
15
 
5
16
  # Runs ugrades
6
17
  #
7
- # Set UPGRADE env variable to only run a specific task.
8
18
  def run!
9
- if ENV['UPGRADE']
10
- ENV['UPGRADE'].split(',').each do |task|
11
- self.send(task)
12
- end
13
- else
14
- run_all
19
+ upgrade_tasks.each do |task|
20
+ self.send(task)
15
21
  end
16
22
  display_todos
17
23
  end
18
24
 
19
- def run_all
20
- Rake::Task['alchemy:install:migrations'].invoke
21
- Rake::Task['db:migrate'].invoke
22
- Seeder.seed!
23
- convert_attachment_storage
24
- copy_new_config_file
25
+ # Tasks that should run.
26
+ #
27
+ # Set UPGRADE env variable to only run a specific task.
28
+ #
29
+ # Run +rake alchemy:upgrade:list+ for all available tasks
30
+ #
31
+ def upgrade_tasks
32
+ if ENV['UPGRADE'].present?
33
+ ENV['UPGRADE'].split(',')
34
+ else
35
+ all_upgrade_tasks
36
+ end
37
+ end
38
+
39
+ # All available upgrade tasks
40
+ #
41
+ def all_upgrade_tasks
42
+ private_methods - Object.private_methods - superclass.private_methods
25
43
  end
26
44
 
27
45
  private
28
46
 
29
- def convert_attachment_storage
30
- desc "Convert the attachment storage"
31
- converted_files = []
32
- files = Dir.glob Rails.root.join 'uploads/attachments/**/*.*'
33
- if files.blank?
34
- log "No attachments found", :skip
35
- else
36
- files.each do |file|
37
- file_uid = file.gsub(/#{Rails.root.to_s}\/uploads\/attachments\//, '')
38
- file_id = file_uid.split('/')[1].to_i
39
- attachment = Alchemy::Attachment.find_by_id(file_id)
40
- if attachment && attachment.file_uid.blank?
41
- attachment.file_uid = file_uid
42
- attachment.file_size = File.new(file).size
43
- attachment.file_name = attachment.sanitized_filename
44
- if attachment.save!
45
- log "Converted #{file_uid}"
46
- end
47
- else
48
- log "Attachment with id #{file_id} not found or already converted.", :skip
49
- end
50
- end
51
- end
47
+ # Setup task
48
+ def setup
49
+ Rake::Task['alchemy:install:migrations'].invoke
50
+ Rake::Task['db:migrate'].invoke
51
+ Seeder.seed!
52
52
  end
53
53
 
54
54
  def copy_new_config_file