alchemy_cms 5.0.0.beta2 → 5.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +1 -1
  3. data/.github/workflows/stale.yml +1 -1
  4. data/.gitignore +1 -0
  5. data/.travis.yml +48 -0
  6. data/CHANGELOG.md +63 -2
  7. data/CONTRIBUTING.md +2 -2
  8. data/Gemfile +3 -3
  9. data/README.md +4 -4
  10. data/Rakefile +11 -10
  11. data/alchemy_cms.gemspec +2 -2
  12. data/app/assets/images/alchemy/missing-image.svg +1 -0
  13. data/app/assets/stylesheets/alchemy/_variables.scss +1 -0
  14. data/app/assets/stylesheets/alchemy/archive.scss +23 -17
  15. data/app/assets/stylesheets/alchemy/errors.scss +1 -1
  16. data/app/assets/stylesheets/alchemy/navigation.scss +7 -9
  17. data/app/assets/stylesheets/alchemy/pagination.scss +1 -1
  18. data/app/assets/stylesheets/alchemy/search.scss +12 -2
  19. data/app/assets/stylesheets/alchemy/tags.scss +19 -31
  20. data/app/controllers/alchemy/admin/pages_controller.rb +1 -1
  21. data/app/controllers/alchemy/admin/pictures_controller.rb +13 -6
  22. data/app/controllers/alchemy/admin/resources_controller.rb +3 -3
  23. data/app/controllers/alchemy/pages_controller.rb +49 -14
  24. data/app/helpers/alchemy/admin/base_helper.rb +0 -42
  25. data/app/helpers/alchemy/admin/navigation_helper.rb +2 -1
  26. data/app/helpers/alchemy/url_helper.rb +2 -2
  27. data/app/models/alchemy/attachment.rb +21 -1
  28. data/app/models/alchemy/attachment/url.rb +40 -0
  29. data/app/models/alchemy/essence_file.rb +1 -1
  30. data/app/models/alchemy/essence_picture.rb +4 -4
  31. data/app/models/alchemy/essence_picture_view.rb +10 -4
  32. data/app/models/alchemy/page.rb +16 -1
  33. data/app/models/alchemy/page/page_natures.rb +2 -0
  34. data/app/models/alchemy/page/url_path.rb +8 -6
  35. data/app/models/alchemy/picture.rb +58 -2
  36. data/app/models/alchemy/picture/calculations.rb +55 -0
  37. data/app/models/alchemy/picture/transformations.rb +5 -49
  38. data/app/models/alchemy/picture/url.rb +28 -75
  39. data/app/models/alchemy/picture_thumb.rb +57 -0
  40. data/app/models/alchemy/picture_thumb/create.rb +39 -0
  41. data/app/models/alchemy/picture_thumb/signature.rb +23 -0
  42. data/app/models/alchemy/picture_thumb/uid.rb +22 -0
  43. data/app/models/alchemy/picture_variant.rb +114 -0
  44. data/app/views/alchemy/admin/attachments/show.html.erb +8 -8
  45. data/app/views/alchemy/admin/dashboard/index.html.erb +13 -16
  46. data/app/views/alchemy/admin/essence_pictures/crop.html.erb +1 -1
  47. data/app/views/alchemy/admin/essence_pictures/edit.html.erb +2 -2
  48. data/app/views/alchemy/admin/layoutpages/edit.html.erb +4 -6
  49. data/app/views/alchemy/admin/pages/_form.html.erb +4 -6
  50. data/app/views/alchemy/admin/pages/_new_page_form.html.erb +2 -1
  51. data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +14 -13
  52. data/app/views/alchemy/admin/partials/_search_form.html.erb +8 -8
  53. data/app/views/alchemy/admin/pictures/_archive.html.erb +1 -1
  54. data/app/views/alchemy/admin/pictures/_form.html.erb +1 -1
  55. data/app/views/alchemy/admin/pictures/_picture.html.erb +3 -3
  56. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -1
  57. data/app/views/alchemy/admin/pictures/edit_multiple.html.erb +1 -1
  58. data/app/views/alchemy/admin/pictures/index.html.erb +1 -1
  59. data/app/views/alchemy/admin/pictures/show.html.erb +3 -3
  60. data/app/views/alchemy/admin/resources/_per_page_select.html.erb +3 -3
  61. data/app/views/alchemy/admin/resources/index.html.erb +24 -22
  62. data/app/views/alchemy/admin/sites/_form.html.erb +2 -2
  63. data/app/views/alchemy/admin/tags/index.html.erb +14 -15
  64. data/app/views/alchemy/base/500.html.erb +11 -13
  65. data/app/views/alchemy/essences/_essence_file_view.html.erb +4 -4
  66. data/config/alchemy/config.yml +15 -11
  67. data/config/alchemy/modules.yml +12 -12
  68. data/config/routes.rb +1 -1
  69. data/db/migrate/20200617110713_create_alchemy_picture_thumbs.rb +22 -0
  70. data/db/migrate/20200907111332_remove_tri_state_booleans.rb +33 -0
  71. data/lib/alchemy/auth_accessors.rb +12 -5
  72. data/lib/alchemy/config.rb +2 -2
  73. data/lib/alchemy/deprecation.rb +1 -1
  74. data/lib/alchemy/engine.rb +7 -2
  75. data/lib/alchemy/install/tasks.rb +41 -0
  76. data/lib/alchemy/modules.rb +11 -1
  77. data/lib/alchemy/resource.rb +2 -2
  78. data/lib/alchemy/test_support/factories/picture_factory.rb +0 -1
  79. data/lib/alchemy/test_support/factories/picture_thumb_factory.rb +12 -0
  80. data/lib/alchemy/version.rb +1 -1
  81. data/lib/generators/alchemy/install/files/alchemy.en.yml +2 -2
  82. data/lib/generators/alchemy/install/install_generator.rb +60 -1
  83. data/lib/generators/alchemy/install/templates/dragonfly.rb.tt +5 -5
  84. data/lib/tasks/alchemy/install.rake +5 -49
  85. data/lib/tasks/alchemy/thumbnails.rake +37 -0
  86. metadata +24 -15
  87. data/.github/workflows/ci.yml +0 -134
  88. data/.github/workflows/greetings.yml +0 -13
  89. data/app/controllers/concerns/alchemy/locale_redirects.rb +0 -40
  90. data/app/controllers/concerns/alchemy/page_redirects.rb +0 -68
  91. data/lib/alchemy/userstamp.rb +0 -12
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RemoveTriStateBooleans < ActiveRecord::Migration[5.2]
4
+ def change
5
+ change_column_null :alchemy_elements, :public, false, false
6
+ change_column_default :alchemy_elements, :public, true
7
+
8
+ change_column_null :alchemy_elements, :folded, false
9
+ change_column_null :alchemy_elements, :unique, false
10
+
11
+ change_column_null :alchemy_essence_richtexts, :public, false, false
12
+ change_column_default :alchemy_essence_richtexts, :public, false
13
+
14
+ change_column_null :alchemy_essence_texts, :public, false
15
+
16
+ change_column_null :alchemy_folded_pages, :folded, false
17
+
18
+ change_column_null :alchemy_languages, :public, false
19
+ change_column_null :alchemy_languages, :default, false
20
+
21
+ change_column_null :alchemy_pages, :language_root, false, false
22
+ change_column_default :alchemy_pages, :language_root, false
23
+
24
+ change_column_null :alchemy_pages, :restricted, false
25
+ change_column_null :alchemy_pages, :robot_index, false
26
+ change_column_null :alchemy_pages, :robot_follow, false
27
+ change_column_null :alchemy_pages, :sitemap, false
28
+
29
+ change_column_null :alchemy_sites, :public, false
30
+ change_column_null :alchemy_sites, :redirect_to_primary_host, false, false
31
+ change_column_default :alchemy_sites, :redirect_to_primary_host, false
32
+ end
33
+ end
@@ -91,16 +91,23 @@ module Alchemy
91
91
  @@user_class_name.constantize
92
92
  rescue NameError => e
93
93
  if e.message =~ /#{Regexp.escape(@@user_class_name)}/
94
- abort <<-MSG.strip_heredoc
94
+ Rails.logger.warn <<~MSG
95
+ #{e.message}
96
+ #{e.backtrace.join("\n")}
95
97
 
96
- AlchemyCMS cannot find any user class!
98
+ AlchemyCMS cannot find any user class!
97
99
 
98
- Please add a user class and tell Alchemy about it or, if you don't want
99
- to create your own class, add the `alchemy-devise` gem to your Gemfile.
100
+ Please add a user class and tell Alchemy about it:
100
101
 
101
- bundle add alchemy-devise
102
+ # config/initializers/alchemy.rb
103
+ Alchemy.user_class_name = 'MyUser'
104
+
105
+ Or add the `alchemy-devise` gem to your Gemfile:
106
+
107
+ bundle add alchemy-devise
102
108
 
103
109
  MSG
110
+ nil
104
111
  else
105
112
  raise e
106
113
  end
@@ -74,11 +74,11 @@ module Alchemy
74
74
  if deprecated_configs.key?(name.to_sym)
75
75
  config = deprecated_configs[name.to_sym]
76
76
  if config.nil?
77
- Alchemy::Deprecation.warn("#{name} configuration is deprecated and will be removed from Alchemy 5.0")
77
+ Alchemy::Deprecation.warn("#{name} configuration is deprecated and will be removed from Alchemy 5.1")
78
78
  else
79
79
  value = show[name.to_s]
80
80
  if value != config
81
- Alchemy::Deprecation.warn("Setting #{name} configuration to #{value} is deprecated and will be always #{config} in Alchemy 5.0")
81
+ Alchemy::Deprecation.warn("Setting #{name} configuration to #{value} is deprecated and will be always #{config} in Alchemy 5.1")
82
82
  end
83
83
  end
84
84
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Alchemy
3
- Deprecation = ActiveSupport::Deprecation.new("5.0", "Alchemy")
3
+ Deprecation = ActiveSupport::Deprecation.new("5.1", "Alchemy")
4
4
  end
@@ -40,8 +40,13 @@ module Alchemy
40
40
  end
41
41
  end
42
42
 
43
- config.after_initialize do
44
- require_relative "./userstamp"
43
+ initializer "alchemy.userstamp" do
44
+ if Alchemy.user_class
45
+ ActiveSupport.on_load(:active_record) do
46
+ Alchemy.user_class.model_stamper
47
+ Alchemy.user_class.stampable(stamper_class_name: Alchemy.user_class_name)
48
+ end
49
+ end
45
50
  end
46
51
  end
47
52
  end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+ require "thor"
3
+
4
+ module Alchemy
5
+ module Install
6
+ class Tasks < Thor
7
+ include Thor::Actions
8
+
9
+ no_tasks do
10
+ def inject_routes(auto_accept = false)
11
+ return if File.read("./config/routes.rb").match?("mount Alchemy::Engine")
12
+
13
+ mountpoint = "/"
14
+ unless auto_accept
15
+ mountpoint = ask("- At which path do you want to mount Alchemy CMS at?", default: mountpoint)
16
+ end
17
+ sentinel = /\.routes\.draw do(?:\s*\|map\|)?\s*$/
18
+ inject_into_file "./config/routes.rb", "\n mount Alchemy::Engine => '#{mountpoint}'\n", { after: sentinel, verbose: true }
19
+ end
20
+
21
+ def set_primary_language(auto_accept = false)
22
+ code = "en"
23
+ unless auto_accept
24
+ code = ask("- What is the language code of your site's primary language?", default: code)
25
+ end
26
+ name = "English"
27
+ unless auto_accept
28
+ name = ask("- What is the name of your site's primary language?", default: name)
29
+ end
30
+ gsub_file "./config/alchemy/config.yml", /default_language:\n\s\scode:\sen\n\s\sname:\sEnglish/m do
31
+ "default_language:\n code: #{code}\n name: #{name}"
32
+ end
33
+ end
34
+
35
+ def inject_seeder
36
+ append_file "./db/seeds.rb", "Alchemy::Seeder.seed!\n"
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -72,7 +72,8 @@ module Alchemy
72
72
  alchemy_modules.detect do |alchemy_module|
73
73
  module_navi = alchemy_module.fetch("navigation", {})
74
74
  definition_from_mainnavi(module_navi, name_or_params) ||
75
- definition_from_subnavi(module_navi, name_or_params)
75
+ definition_from_subnavi(module_navi, name_or_params) ||
76
+ definition_from_nested(module_navi, name_or_params)
76
77
  end
77
78
  else
78
79
  raise ArgumentError, "Could not find module definition for #{name_or_params}"
@@ -94,6 +95,15 @@ module Alchemy
94
95
  end
95
96
  end
96
97
 
98
+ def definition_from_nested(module_navi, params)
99
+ nested = module_navi["nested"]
100
+ return if nested.nil?
101
+
102
+ nested.any? do |navi|
103
+ controller_matches?(navi, params) && action_matches?(navi, params)
104
+ end
105
+ end
106
+
97
107
  def controller_matches?(navi, params)
98
108
  remove_slash(navi["controller"]) == remove_slash(params["controller"])
99
109
  end
@@ -210,7 +210,7 @@ module Alchemy
210
210
  @module_definition && @module_definition["engine_name"]
211
211
  end
212
212
 
213
- # Returns a help text for resource's form
213
+ # Returns a help text for resource's form or nil if no help text is available
214
214
  #
215
215
  # === Example:
216
216
  #
@@ -223,7 +223,7 @@ module Alchemy
223
223
  def help_text_for(attribute)
224
224
  ::I18n.translate!(attribute[:name], scope: [:alchemy, :resource_help_texts, resource_name])
225
225
  rescue ::I18n::MissingTranslationData
226
- false
226
+ nil
227
227
  end
228
228
 
229
229
  # Return attributes that should be viewable but not editable.
@@ -8,7 +8,6 @@ FactoryBot.define do
8
8
  File.new(Alchemy::Engine.root.join("lib", "alchemy", "test_support", "fixtures", "image.png"))
9
9
  end
10
10
  name { "image" }
11
- image_file_name { "image.png" }
12
11
  upload_hash { Time.current.hash }
13
12
  end
14
13
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "factory_bot"
4
+ require "securerandom"
5
+
6
+ FactoryBot.define do
7
+ factory :alchemy_picture_thumb, class: "Alchemy::PictureThumb" do
8
+ picture { create(:alchemy_picture) }
9
+ signature { SecureRandom.hex(16) }
10
+ sequence(:uid) { |n| "#{Time.now.strftime("%Y/%m/%d")}/#{n}.jpg" }
11
+ end
12
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
- VERSION = "5.0.0.beta2"
4
+ VERSION = "5.1.0.beta1"
5
5
 
6
6
  def self.version
7
7
  VERSION
@@ -18,7 +18,7 @@ en:
18
18
  # Default texts for new contents created
19
19
  default_content_texts:
20
20
  article_headline: "Welcome to your first Alchemy CMS page"
21
- article_text: '<p><strong>How to get started.</strong></p><p>First of all you should read about Alchemy and its architecture in the <a class="external" href="http://guides.alchemy-cms.com/stable/alchemy_approach.html" target="_blank" data-link-target="blank">guidelines</a>.</p><p>The most important things to know about Alchemy are elements and page layouts.</p><p><span style="text-decoration: underline;"><strong>Elements:</strong></span></p><p>With Alchemy you can split pages into content parts, elements. These elements can be defined out of several base content types: essences. The basic essences are:</p><ul><li>EssenceText - <em>A single line of text</em></li><li>EssenceRichtext - <em>A TinyMCE powered formatted text block</em></li><li>EssencePicture - <em>A reference to an image</em></li><li>EssenceHtml - <em>HTML embed code</em></li><li>EssenceSelect - <em>A selection of values</em></li><li>EssenceBoolean - <em>A checkbox</em></li></ul><p>Elements get defined in a YAML file <strong>config/alchemy/elements.yml</strong></p><p><a class="external" href="http://guides.alchemy-cms.com/stable/elements.html" target="_blank" data-link-target="blank">Read more about elements and how to define them in the guidelines.</a></p><p><span style="text-decoration: underline;"><strong>Page types:</strong></span></p><p>You can define several types of pages, called page layouts. You can assign elements to page layouts and control how elements and the page of a certain layout behave.</p><p>Page layouts get defined in a YAML file <strong>config/alchemy/page_layouts.yml</strong></p><p><a class="external" href="http://guides.alchemy-cms.com/stable/page_layouts.html" target="_blank" data-link-target="blank">Read more about defining page layouts in the guidelines.</a></p>'
21
+ article_text: '<p><strong>How to get started.</strong></p><p>First of all you should read about Alchemy and its architecture in the <a class="external" href="http://guides.alchemy-cms.com/alchemy_approach.html" target="_blank" data-link-target="blank">guidelines</a>.</p><p>The most important things to know about Alchemy are elements and page layouts.</p><p><span style="text-decoration: underline;"><strong>Elements:</strong></span></p><p>With Alchemy you can split pages into content parts, elements. These elements can be defined out of several base content types: essences. The basic essences are:</p><ul><li>EssenceText - <em>A single line of text</em></li><li>EssenceRichtext - <em>A TinyMCE powered formatted text block</em></li><li>EssencePicture - <em>A reference to an image</em></li><li>EssenceHtml - <em>HTML embed code</em></li><li>EssenceSelect - <em>A selection of values</em></li><li>EssenceBoolean - <em>A checkbox</em></li></ul><p>Elements get defined in a YAML file <strong>config/alchemy/elements.yml</strong></p><p><a class="external" href="http://guides.alchemy-cms.com/elements.html" target="_blank" data-link-target="blank">Read more about elements and how to define them in the guidelines.</a></p><p><span style="text-decoration: underline;"><strong>Page types:</strong></span></p><p>You can define several types of pages, called page layouts. You can assign elements to page layouts and control how elements and the page of a certain layout behave.</p><p>Page layouts get defined in a YAML file <strong>config/alchemy/page_layouts.yml</strong></p><p><a class="external" href="http://guides.alchemy-cms.com/page_layouts.html" target="_blank" data-link-target="blank">Read more about defining page layouts in the guidelines.</a></p>'
22
22
 
23
23
  # Hint texts for elements
24
24
  element_hints:
@@ -28,4 +28,4 @@ en:
28
28
  content_hints:
29
29
  headline: "This is a single line of unformatable Text"
30
30
  picture: "Pictures are stored in the library. You can assign a picture multiple times throughout your site. Alchemy has an image cropper build right in."
31
- text: "This is a rich text block powered by TinyMCE editor. You can change the configuration of the editor. See http://guides.alchemy-cms.com/stable/customize_tinymce.html"
31
+ text: "This is a rich text block powered by TinyMCE editor. You can change the configuration of the editor. See http://guides.alchemy-cms.com/customize_tinymce.html"
@@ -1,11 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
  require "rails/generators"
3
+ require "alchemy/install/tasks"
3
4
 
4
5
  module Alchemy
5
6
  module Generators
6
7
  class InstallGenerator < ::Rails::Generators::Base
7
8
  desc "Installs Alchemy into your App."
8
9
 
10
+ class_option :auto_accept,
11
+ type: :boolean,
12
+ default: false,
13
+ desc: "Automatically accept defaults."
14
+
9
15
  class_option :skip_demo_files,
10
16
  type: :boolean,
11
17
  default: false,
@@ -18,6 +24,13 @@ module Alchemy
18
24
 
19
25
  source_root File.expand_path("files", __dir__)
20
26
 
27
+ def setup
28
+ header
29
+ say "Welcome to AlchemyCMS!"
30
+ say "Let's begin with some questions.\n\n"
31
+ install_tasks.inject_routes(options[:auto_accept])
32
+ end
33
+
21
34
  def copy_config
22
35
  copy_file "#{gem_config_path}/config.yml", app_config_path.join("alchemy", "config.yml")
23
36
  end
@@ -53,7 +66,11 @@ module Alchemy
53
66
  end
54
67
 
55
68
  def copy_dragonfly_config
56
- template "#{__dir__}/templates/dragonfly.rb.tt", app_config_path.join("initializers", "dragonfly.rb")
69
+ template(
70
+ "#{__dir__}/templates/dragonfly.rb.tt",
71
+ app_config_path.join("initializers", "dragonfly.rb"),
72
+ skip: options[:auto_accept]
73
+ )
57
74
  end
58
75
 
59
76
  def install_gutentag_migrations
@@ -80,8 +97,46 @@ module Alchemy
80
97
  app_root.join(webpack_config["source_path"], webpack_config["source_entry_path"], "alchemy/admin.js")
81
98
  end
82
99
 
100
+ def set_primary_language
101
+ header
102
+ install_tasks.set_primary_language(options[:auto_accept])
103
+ end
104
+
105
+ def setup_database
106
+ rake("db:create", abort_on_failure: true)
107
+ # We can't invoke this rake task, because Rails will use wrong engine names otherwise
108
+ rake("railties:install:migrations", abort_on_failure: true)
109
+ rake("db:migrate", abort_on_failure: true)
110
+ install_tasks.inject_seeder
111
+ rake("db:seed", abort_on_failure: true)
112
+ end
113
+
114
+ def finalize
115
+ header
116
+ say "Alchemy successfully installed!"
117
+ say "Now start the server with:\n\n"
118
+ say " bin/rails server\n\n"
119
+ say "and point your browser to\n\n"
120
+ say " http://localhost:3000/admin\n\n"
121
+ say "and follow the onscreen instructions to finalize the installation.\n\n"
122
+ end
123
+
83
124
  private
84
125
 
126
+ def header
127
+ return if options[:auto_accept]
128
+
129
+ puts "─────────────────────"
130
+ puts "* Alchemy Installer *"
131
+ puts "─────────────────────"
132
+ end
133
+
134
+ def say(something)
135
+ return if options[:auto_accept]
136
+
137
+ puts " #{something}"
138
+ end
139
+
85
140
  def gem_config_path
86
141
  @_config_path ||= File.expand_path("../../../../config/alchemy", __dir__)
87
142
  end
@@ -105,6 +160,10 @@ module Alchemy
105
160
  def app_root
106
161
  @_app_root ||= Rails.root
107
162
  end
163
+
164
+ def install_tasks
165
+ @_install_tasks ||= Alchemy::Install::Tasks.new
166
+ end
108
167
  end
109
168
  end
110
169
  end
@@ -15,12 +15,12 @@ Dragonfly.app(:alchemy_pictures).configure do
15
15
  dragonfly_url nil
16
16
  plugin :imagemagick
17
17
  plugin :svg
18
- secret '<%= SecureRandom.hex(32) %>'
19
- url_format '/pictures/:job/:name.:ext'
18
+ secret "<%= SecureRandom.hex(32) %>"
19
+ url_format "/pictures/:job/:basename.:ext"
20
20
 
21
21
  datastore :file,
22
- root_path: Rails.root.join('uploads/pictures').to_s,
23
- server_root: Rails.root.join('public'),
22
+ root_path: Rails.root.join("uploads/pictures").to_s,
23
+ server_root: Rails.root.join("public"),
24
24
  store_meta: false
25
25
  end
26
26
 
@@ -30,6 +30,6 @@ Rails.application.middleware.use Dragonfly::Middleware, :alchemy_pictures
30
30
  # Attachments
31
31
  Dragonfly.app(:alchemy_attachments).configure do
32
32
  datastore :file,
33
- root_path: Rails.root.join('uploads/attachments').to_s,
33
+ root_path: Rails.root.join("uploads/attachments").to_s,
34
34
  store_meta: false
35
35
  end
@@ -1,59 +1,15 @@
1
1
  # frozen_string_literal: true
2
- require "thor"
3
-
4
- class Alchemy::InstallTask < Thor
5
- include Thor::Actions
6
-
7
- no_tasks do
8
- def inject_routes
9
- mountpoint = ask "\nAt which path do you want to mount Alchemy CMS at? (DEFAULT: At root path '/')"
10
- mountpoint = "/" if mountpoint.empty?
11
- sentinel = /\.routes\.draw do(?:\s*\|map\|)?\s*$/
12
- inject_into_file "./config/routes.rb", "\n mount Alchemy::Engine => '#{mountpoint}'\n", { after: sentinel, verbose: true }
13
- end
14
-
15
- def set_primary_language
16
- code = ask "\nWhat's the language code of your site's primary language? (DEFAULT: en)"
17
- code = "en" if code.empty?
18
- name = ask "What's the name of your site's primary language? (DEFAULT: English)"
19
- name = "English" if name.empty?
20
- gsub_file "./config/alchemy/config.yml", /default_language:\n\s\scode:\sen\n\s\sname:\sEnglish/m do
21
- "default_language:\n code: #{code}\n name: #{name}"
22
- end
23
- end
24
-
25
- def inject_seeder
26
- append_file "./db/seeds.rb", "Alchemy::Seeder.seed!\n"
27
- end
28
- end
29
- end
30
2
 
31
3
  namespace :alchemy do
32
4
  desc "Installs Alchemy CMS into your app."
33
- task install: "alchemy:yarn:install" do
34
- install_helper = Alchemy::InstallTask.new
35
-
36
- puts "\nAlchemy Installer"
37
- puts "-----------------"
38
-
39
- Rake::Task["alchemy:mount"].invoke
40
- system("rails g alchemy:install") || exit!(1)
41
- install_helper.set_primary_language
42
- Rake::Task["db:create"].invoke
43
- # We can't invoke this rake task, because Rails will use wrong engine names otherwise
44
- `bundle exec rake railties:install:migrations`
45
- Rake::Task["db:migrate"].invoke
46
- install_helper.inject_seeder
47
- Rake::Task["db:seed"].invoke
48
-
49
- puts "\nAlchemy successfully installed."
50
- puts "\nNow start the server with:"
51
- puts "\n$ bin/rails server"
52
- puts "\nand point your browser to http://localhost:3000/admin and follow the onscreen instructions to finalize the installation."
5
+ task :install do
6
+ require "generators/alchemy/install/install_generator"
7
+ Alchemy::Generators::InstallGenerator.start
53
8
  end
54
9
 
55
10
  desc "Mounts Alchemy into your routes."
56
11
  task :mount do
57
- Alchemy::InstallTask.new.inject_routes
12
+ require "alchemy/install/tasks"
13
+ Alchemy::InstallTasks.new.inject_routes
58
14
  end
59
15
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :alchemy do
4
+ namespace :generate do
5
+ desc "Generates all thumbnails for Alchemy Pictures and EssencePictures."
6
+ task thumbnails: [
7
+ "alchemy_dragonfly_s3:generate:picture_thumbnails",
8
+ "alchemy_dragonfly_s3:generate:essence_picture_thumbnails",
9
+ ]
10
+
11
+ desc "Generates thumbnails for Alchemy Pictures."
12
+ task picture_thumbnails: :environment do
13
+ puts "Regenerate #{Alchemy::Picture.count} picture thumbnails."
14
+ puts "Please wait..."
15
+
16
+ Alchemy::Picture.find_each do |picture|
17
+ puts Alchemy::PictureThumb.generate_thumbs!(picture)
18
+ end
19
+
20
+ puts "Done!"
21
+ end
22
+
23
+ desc "Generates thumbnails for Alchemy EssencePictures."
24
+ task essence_picture_thumbnails: :environment do
25
+ essence_pictures = Alchemy::EssencePicture.joins(:content, :ingredient_association)
26
+ puts "Regenerate #{essence_pictures.count} essence picture thumbnails."
27
+ puts "Please wait..."
28
+
29
+ essence_pictures.find_each do |essence_picture|
30
+ puts essence_picture.picture_url
31
+ puts essence_picture.thumbnail_url
32
+ end
33
+
34
+ puts "Done!"
35
+ end
36
+ end
37
+ end