alchemy_cms 5.0.0.beta2 → 5.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89a4ae7079c8ca7f64ae3b28d1acf1b648090d98fc4b9beff5061f81c73e1044
4
- data.tar.gz: bb1169db4e23c9621745888be3963319b3746e156028d711a22870a4f51330e4
3
+ metadata.gz: 6d6a2d7c3149b60f8beaeb06b0cd5b8042f4c8df1f6bf3f9599d3563b98195fb
4
+ data.tar.gz: 18e8ece0618b97099513220ba3368d120bd171c23a3847d7872d1aa4ff19f11e
5
5
  SHA512:
6
- metadata.gz: c60d6b0ddcbe43763ff32fcad72144f572f6f8c91bbd1ac9bd0edbd41fd88723a29ef299f5ae51f5edd366e9f8ad7de5054a19768cfe92f27bb61f36d5c04bc2
7
- data.tar.gz: f2f612afa9ae01c12d56b61c674ff311f89951acbeb0d327e3b15465761380a5344c65160dd121a6b88b6ab2ca6841d26a7eb75b92cfea65cba9bfb956fd81a1
6
+ metadata.gz: 298f71d8ae111b2ce297523f44832bb7ef268dda68e5297df41a1a6bea250ddbe0f90ea9370ac0b0c8095c64ffdfab0463b4a7289a8afa2a48ff4a9df1e84414
7
+ data.tar.gz: c02cd508bbd728d2553716964b24958dd1c25a8cbba1c5c77ba3293df67c0d4c4246e732d20b9d704b4c289a92204626d6722383015c1f7c0e84be0f22ade17b
@@ -43,14 +43,14 @@ jobs:
43
43
  MYSQL_ROOT_PASSWORD: password
44
44
  options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
45
45
  steps:
46
- - uses: actions/checkout@v1
46
+ - uses: actions/checkout@v2.3.4
47
47
  - name: Set up Ruby
48
- uses: actions/setup-ruby@v1
48
+ uses: actions/setup-ruby@v1.1.2
49
49
  with:
50
50
  ruby-version: ${{ matrix.ruby }}
51
51
  - name: Restore apt cache
52
52
  id: apt-cache
53
- uses: actions/cache@preview
53
+ uses: actions/cache@v2.1.3
54
54
  with:
55
55
  path: /home/runner/apt/cache
56
56
  key: ${{ runner.os }}-apt-${{ matrix.database }}
@@ -75,7 +75,7 @@ jobs:
75
75
  gem install bundler
76
76
  - name: Restore Ruby Gems cache
77
77
  id: cache
78
- uses: actions/cache@preview
78
+ uses: actions/cache@v2.1.3
79
79
  with:
80
80
  path: vendor/bundle
81
81
  key: ${{ runner.os }}-bundle-${{ matrix.ruby }}-${{ matrix.rails }}-${{ matrix.database }}-${{ hashFiles('**/Gemfile') }}
@@ -87,7 +87,7 @@ jobs:
87
87
  bundle install --jobs 4 --retry 3 --path vendor/bundle
88
88
  - name: Restore node modules cache
89
89
  id: yarn-cache
90
- uses: actions/cache@preview
90
+ uses: actions/cache@v2.1.3
91
91
  with:
92
92
  path: spec/dummy/node_modules
93
93
  key: ${{ runner.os }}-yarn-dummy-${{ hashFiles('./package.json') }}
@@ -97,12 +97,12 @@ jobs:
97
97
  run: |
98
98
  bundle exec rake alchemy:spec:prepare
99
99
  - name: Run tests & publish code coverage
100
- uses: paambaati/codeclimate-action@v2.5.7
100
+ uses: paambaati/codeclimate-action@v2.7.5
101
101
  env:
102
102
  CC_TEST_REPORTER_ID: bca4349e32f97919210ac8a450b04904b90683fcdd57d65a22c0f5065482bc22
103
103
  with:
104
104
  coverageCommand: bundle exec rspec
105
- - uses: actions/upload-artifact@master
105
+ - uses: actions/upload-artifact@main
106
106
  if: failure()
107
107
  with:
108
108
  name: Screenshots
@@ -112,9 +112,9 @@ jobs:
112
112
  env:
113
113
  NODE_ENV: test
114
114
  steps:
115
- - uses: actions/checkout@v1
115
+ - uses: actions/checkout@v2.3.4
116
116
  - name: Restore node modules cache
117
- uses: actions/cache@preview
117
+ uses: actions/cache@v2.1.3
118
118
  with:
119
119
  path: node_modules
120
120
  key: ${{ runner.os }}-yarn-${{ hashFiles('./package.json') }}
@@ -124,11 +124,3 @@ jobs:
124
124
  run: yarn install
125
125
  - name: Run jest
126
126
  run: yarn jest
127
- - name: Run jest & publish code coverage
128
- uses: paambaati/codeclimate-action@v2.5.7
129
- env:
130
- CC_TEST_REPORTER_ID: bca4349e32f97919210ac8a450b04904b90683fcdd57d65a22c0f5065482bc22
131
- with:
132
- coverageLocations:
133
- ./coverage/lcov.info:lcov
134
- coverageCommand: yarn jest --collectCoverage --coverageDirectory=coverage
@@ -1,5 +1,21 @@
1
- ## 5.0.0 (unreleased)
1
+ ## 5.0.2 (2020-12-18)
2
2
 
3
+ - Fix page sorting [#1984](https://github.com/AlchemyCMS/alchemy_cms/pull/1984) ([tvdeyen](https://github.com/tvdeyen))
4
+
5
+ ## 5.0.1 (2020-09-29)
6
+
7
+ - Better image alt text support [#1940](https://github.com/AlchemyCMS/alchemy_cms/pull/1940) ([tvdeyen](https://github.com/tvdeyen))
8
+
9
+ ## 5.0.0 (2020-07-17)
10
+
11
+ - Do not convert JPEG images into JPG [#1904](https://github.com/AlchemyCMS/alchemy_cms/pull/1904) ([tvdeyen](https://github.com/tvdeyen))
12
+ - Do not enable image cropper if file is missing [#1903](https://github.com/AlchemyCMS/alchemy_cms/pull/1903) ([tvdeyen](https://github.com/tvdeyen))
13
+ - Always show original image as zoomed image [#1902](https://github.com/AlchemyCMS/alchemy_cms/pull/1902) ([tvdeyen](https://github.com/tvdeyen))
14
+ - Rename Attachment#urlname into slug [#1848](https://github.com/AlchemyCMS/alchemy_cms/pull/1848) ([tvdeyen](https://github.com/tvdeyen))
15
+ - Deprecate toolbar helper ([tvdeyen](https://github.com/tvdeyen))
16
+ - Deprecate redirect_to_public_child ([tvdeyen](https://github.com/tvdeyen))
17
+ - Add --auto-accept option to installer ([tvdeyen](https://github.com/tvdeyen))
18
+ - Move all installer code into install generator ([tvdeyen](https://github.com/tvdeyen))
3
19
  - Language Factory: Create default language in host app's locale [#1884](https://github.com/AlchemyCMS/alchemy_cms/pull/1884) ([mamhoff](https://github.com/mamhoff))
4
20
  - Respect filter and tagging params in picture archive size buttons [#1880](https://github.com/AlchemyCMS/alchemy_cms/pull/1880) ([tvdeyen](https://github.com/tvdeyen))
5
21
  - Extract picture thumbnail sizes in a constant [#1879](https://github.com/AlchemyCMS/alchemy_cms/pull/1879) ([tvdeyen](https://github.com/tvdeyen))
data/Gemfile CHANGED
@@ -10,7 +10,7 @@ if ENV["DB"].nil? || ENV["DB"] == "sqlite"
10
10
  gem "sqlite3", "~> 1.4.1"
11
11
  end
12
12
  gem "mysql2", "~> 0.5.1" if ENV["DB"] == "mysql"
13
- gem "pg", "~> 1.0" if ENV["DB"] == "postgresql"
13
+ gem "pg", "~> 1.0" if ENV["DB"] == "postgresql"
14
14
 
15
15
  group :development, :test do
16
16
  if ENV["GITHUB_ACTIONS"]
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # AlchemyCMS
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/alchemy_cms.svg)](http://badge.fury.io/rb/alchemy_cms)
4
- [![Build Status](https://github.com/AlchemyCMS/alchemy_cms/workflows/CI/badge.svg?branch=master)](https://github.com/AlchemyCMS/alchemy_cms/actions)
4
+ [![Build Status](https://github.com/AlchemyCMS/alchemy_cms/workflows/CI/badge.svg?branch=main)](https://github.com/AlchemyCMS/alchemy_cms/actions)
5
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/196c56c56568ed24a697/maintainability)](https://codeclimate.com/github/AlchemyCMS/alchemy_cms/maintainability)
6
6
  [![Test Coverage](https://api.codeclimate.com/v1/badges/196c56c56568ed24a697/test_coverage)](https://codeclimate.com/github/AlchemyCMS/alchemy_cms/test_coverage)
7
7
  [![Depfu](https://badges.depfu.com/badges/ebe56d2dd7b7044a8ae700cc81212a8e/overview.svg)](https://depfu.com/github/AlchemyCMS/alchemy_cms?project_id=4600)
@@ -125,7 +125,7 @@ $ bundle add alchemy-devise
125
125
  Then run the `alchemy-devise` installer:
126
126
 
127
127
  ```bash
128
- $ bin/rails g alchemy_devise:install
128
+ $ bin/rails g alchemy:devise:install
129
129
  ```
130
130
 
131
131
  ##### Use your User model
@@ -167,7 +167,7 @@ Please follow [this guide](http://guides.alchemy-cms.com/stable/custom_authentic
167
167
  **After** you set the user model you need to run the Alchemy install task:
168
168
 
169
169
  ```bash
170
- $ bin/rake alchemy:install
170
+ $ bin/rails alchemy:install
171
171
  ```
172
172
 
173
173
  Now everything should be set up and you should be able to visit the Alchemy Dashboard at:
data/Rakefile CHANGED
@@ -39,16 +39,17 @@ namespace :alchemy do
39
39
  namespace :spec do
40
40
  desc "Prepares database for testing Alchemy"
41
41
  task :prepare do
42
- result = system <<~BASH
43
- cd spec/dummy && \
44
- export RAILS_ENV=test && \
45
- bin/rake db:create && \
46
- bin/rake db:environment:set && \
47
- bin/rake db:migrate:reset && \
48
- bin/rails g alchemy:install --skip --skip-demo-files && \
49
- cd -
50
- BASH
51
- result || fail
42
+ system(
43
+ <<~BASH
44
+ cd spec/dummy && \
45
+ export RAILS_ENV=test && \
46
+ bin/rake db:create && \
47
+ bin/rake db:environment:set && \
48
+ bin/rake db:migrate:reset && \
49
+ bin/rails g alchemy:install --skip --skip-demo-files --auto-accept && \
50
+ cd -
51
+ BASH
52
+ ) || fail
52
53
  end
53
54
  end
54
55
 
@@ -286,5 +286,6 @@
286
286
  color: $muted-text-color;
287
287
  margin-right: $default-margin;
288
288
  font-size: $small-font-size;
289
+ line-height: 31px;
289
290
  }
290
291
  }
@@ -3,14 +3,14 @@
3
3
  padding-bottom: 138px;
4
4
 
5
5
  &.filtered {
6
- padding-bottom: 164px;
6
+ padding-bottom: 178px;
7
7
  }
8
8
 
9
9
  &.with_filter_bar {
10
10
  padding-bottom: 218px;
11
11
 
12
12
  &.filtered {
13
- padding-bottom: 244px;
13
+ padding-bottom: 256px;
14
14
  }
15
15
  }
16
16
 
@@ -138,7 +138,7 @@ module Alchemy
138
138
 
139
139
  def link
140
140
  @attachments = Attachment.all.collect { |f|
141
- [f.name, download_attachment_path(id: f.id, name: f.urlname)]
141
+ [f.name, download_attachment_path(id: f.id, name: f.slug)]
142
142
  }
143
143
  end
144
144
 
@@ -314,6 +314,8 @@ module Alchemy
314
314
  end
315
315
  end
316
316
 
317
+ deprecate toolbar: "Please use `content_for(:toolbar)` instead", deprecator: Alchemy::Deprecation
318
+
317
319
  # (internal) Used by upload form
318
320
  def new_asset_path_with_session_information(asset_type)
319
321
  session_key = Rails.application.config.session_options[:key]
@@ -26,12 +26,12 @@ module Alchemy
26
26
 
27
27
  # Returns the path for downloading an alchemy attachment
28
28
  def download_alchemy_attachment_path(attachment)
29
- alchemy.download_attachment_path(attachment, attachment.urlname)
29
+ alchemy.download_attachment_path(attachment, attachment.slug)
30
30
  end
31
31
 
32
32
  # Returns the url for downloading an alchemy attachment
33
33
  def download_alchemy_attachment_url(attachment)
34
- alchemy.download_attachment_url(attachment, attachment.urlname)
34
+ alchemy.download_attachment_url(attachment, attachment.slug)
35
35
  end
36
36
 
37
37
  # Returns the full url containing host, page and anchor for the given element
@@ -77,10 +77,13 @@ module Alchemy
77
77
  end
78
78
 
79
79
  # An url save filename without format suffix
80
- def urlname
80
+ def slug
81
81
  CGI.escape(file_name.gsub(/\.#{extension}$/, "").tr(".", " "))
82
82
  end
83
83
 
84
+ alias_method :urlname, :slug
85
+ deprecate urlname: :slug, deprecator: Alchemy::Deprecation
86
+
84
87
  # Checks if the attachment is restricted, because it is attached on restricted pages only
85
88
  def restricted?
86
89
  pages.any? && pages.not_restricted.blank?
@@ -23,7 +23,7 @@ module Alchemy
23
23
 
24
24
  routes.download_attachment_path(
25
25
  id: attachment.id,
26
- name: attachment.urlname,
26
+ name: attachment.slug,
27
27
  format: attachment.suffix,
28
28
  )
29
29
  end
@@ -143,7 +143,7 @@ module Alchemy
143
143
  picture.can_be_cropped_to(
144
144
  content.settings[:size],
145
145
  content.settings[:upsample],
146
- )
146
+ ) && !!picture.image_file
147
147
  end
148
148
 
149
149
  def crop_values_present?
@@ -55,7 +55,7 @@ module Alchemy
55
55
  def img_tag
56
56
  @_img_tag ||= image_tag(
57
57
  essence.picture_url(options.except(*DEFAULT_OPTIONS.keys)), {
58
- alt: essence.alt_tag.presence,
58
+ alt: alt_text,
59
59
  title: essence.title.presence,
60
60
  class: caption ? nil : essence.css_class.presence,
61
61
  srcset: srcset.join(", ").presence,
@@ -79,5 +79,9 @@ module Alchemy
79
79
  width.present? ? "#{url} #{width}w" : "#{url} #{height}h"
80
80
  end
81
81
  end
82
+
83
+ def alt_text
84
+ essence.alt_tag.presence || html_options.delete(:alt) || essence.picture.name&.humanize
85
+ end
82
86
  end
83
87
  end
@@ -71,7 +71,9 @@ module Alchemy
71
71
 
72
72
  encoding_options = []
73
73
 
74
- if target_format =~ /jpe?g/
74
+ convert_format = target_format != image_file_format.sub("jpeg", "jpg")
75
+
76
+ if target_format =~ /jpe?g/ && convert_format
75
77
  quality = options[:quality] || Config.get(:output_image_jpg_quality)
76
78
  encoding_options << "-quality #{quality}"
77
79
  end
@@ -80,7 +82,7 @@ module Alchemy
80
82
  encoding_options << "-flatten"
81
83
  end
82
84
 
83
- convertion_needed = target_format != image_file_format || encoding_options.present?
85
+ convertion_needed = convert_format || encoding_options.present?
84
86
 
85
87
  if has_convertible_format? && convertion_needed
86
88
  image = image.encode(target_format, encoding_options.join(" "))
@@ -40,7 +40,7 @@ module Alchemy
40
40
 
41
41
  level = path.count + base_level
42
42
 
43
- path.last[:children] << page_hash(page, has_children, level, folded)
43
+ path.last[:children] << page_hash(page, level, folded)
44
44
  end
45
45
 
46
46
  tree
@@ -48,7 +48,7 @@ module Alchemy
48
48
 
49
49
  protected
50
50
 
51
- def page_hash(page, has_children, level, folded)
51
+ def page_hash(page, level, folded)
52
52
  p_hash = {
53
53
  id: page.id,
54
54
  name: page.name,
@@ -59,8 +59,8 @@ module Alchemy
59
59
  urlname: page.urlname,
60
60
  url_path: page.url_path,
61
61
  level: level,
62
- root: page.depth == 1,
63
- root_or_leaf: page.depth == 1 || !has_children,
62
+ root: page.root?,
63
+ root_or_leaf: page.root? || page.leaf?,
64
64
  children: [],
65
65
  }
66
66
 
@@ -1,5 +1,5 @@
1
1
  <div class="zoomed-picture-background">
2
- <%= image_tag @picture.url(format: @picture.image_file_format) %>
2
+ <%= image_tag @picture.url %>
3
3
  </div>
4
4
 
5
5
  <div class="picture-overlay-navigation">
@@ -1,29 +1,28 @@
1
1
  <% label_title = Alchemy.t("Create #{resource_name}", default: Alchemy.t('Create')) %>
2
2
 
3
- <% toolbar(
4
- buttons: [
5
- {
6
- icon: :plus,
7
- label: label_title,
8
- url: new_resource_path,
3
+ <% content_for(:toolbar) do %>
4
+ <%= toolbar_button(
5
+ icon: :plus,
6
+ label: label_title,
7
+ url: new_resource_path,
8
+ title: label_title,
9
+ hotkey: 'alt+n',
10
+ dialog_options: {
9
11
  title: label_title,
10
- hotkey: 'alt+n',
11
- dialog_options: {
12
- title: label_title,
13
- size: resource_window_size
14
- },
15
- if_permitted_to: [:create, resource_model]
12
+ size: resource_window_size
16
13
  },
17
- {
18
- icon: 'download',
19
- url: resource_url_proxy.url_for(action: 'index', format: 'csv', q: search_filter_params[:q], sort: params[:sort]),
20
- label: Alchemy.t(:download_csv),
21
- title: Alchemy.t(:download_csv),
22
- dialog: false,
23
- if_permitted_to: [:index, resource_model]
24
- }
25
- ]
26
- ) %>
14
+ if_permitted_to: [:create, resource_model]
15
+ ) %>
16
+ <%= toolbar_button(
17
+ icon: :download,
18
+ url: resource_url_proxy.url_for(action: 'index', format: 'csv', q: search_filter_params[:q], sort: params[:sort]),
19
+ label: Alchemy.t(:download_csv),
20
+ title: Alchemy.t(:download_csv),
21
+ dialog: false,
22
+ if_permitted_to: [:index, resource_model]
23
+ ) %>
24
+ <%= render 'alchemy/admin/partials/search_form' %>
25
+ <% end %>
27
26
 
28
27
  <div id="archive_all" class="resources-table-wrapper<%= ' with_tag_filter' if resource_has_tags || resource_has_filters %>">
29
28
  <%= render 'alchemy/admin/resources/table_header' %>
@@ -1,5 +1,5 @@
1
- <%= alchemy_form_for site, url: alchemy.admin_sites_path(site, search_filter_params) do |f| %>
2
- <%= f.input :host, hint: resource_handler.help_text_for(name: :host).html_safe %>
1
+ <%= alchemy_form_for site, url: resource_path(site, search_filter_params) do |f| %>
2
+ <%= f.input :host, hint: resource_handler.help_text_for(name: :host)&.html_safe %>
3
3
  <%= f.input :name %>
4
4
  <%= f.input :public %>
5
5
  <%= f.input :aliases, hint: resource_handler.help_text_for(name: :aliases), input_html: {rows: 4} %>
@@ -7,7 +7,7 @@
7
7
  attachment.name,
8
8
  alchemy.download_attachment_path(
9
9
  attachment,
10
- name: attachment.urlname,
10
+ name: attachment.slug,
11
11
  format: attachment.suffix
12
12
  ),
13
13
  {
@@ -31,7 +31,9 @@ module Alchemy
31
31
  # a value of nil means there is no new default
32
32
  # any not nil value is the new default
33
33
  def deprecated_configs
34
- {}
34
+ {
35
+ redirect_to_public_child: nil,
36
+ }
35
37
  end
36
38
 
37
39
  private
@@ -74,11 +76,11 @@ module Alchemy
74
76
  if deprecated_configs.key?(name.to_sym)
75
77
  config = deprecated_configs[name.to_sym]
76
78
  if config.nil?
77
- Alchemy::Deprecation.warn("#{name} configuration is deprecated and will be removed from Alchemy 5.0")
79
+ Alchemy::Deprecation.warn("#{name} configuration is deprecated and will be removed from Alchemy 5.1")
78
80
  else
79
81
  value = show[name.to_s]
80
82
  if value != config
81
- Alchemy::Deprecation.warn("Setting #{name} configuration to #{value} is deprecated and will be always #{config} in Alchemy 5.0")
83
+ Alchemy::Deprecation.warn("Setting #{name} configuration to #{value} is deprecated and will be always #{config} in Alchemy 5.1")
82
84
  end
83
85
  end
84
86
  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
@@ -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
@@ -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.
@@ -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.0.2"
5
5
 
6
6
  def self.version
7
7
  VERSION
@@ -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
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.beta2
4
+ version: 5.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2020-06-25 00:00:00.000000000 Z
16
+ date: 2020-12-18 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: active_model_serializers
@@ -1087,6 +1087,7 @@ files:
1087
1087
  - lib/alchemy/forms/builder.rb
1088
1088
  - lib/alchemy/hints.rb
1089
1089
  - lib/alchemy/i18n.rb
1090
+ - lib/alchemy/install/tasks.rb
1090
1091
  - lib/alchemy/logger.rb
1091
1092
  - lib/alchemy/modules.rb
1092
1093
  - lib/alchemy/name_conversions.rb
@@ -1262,14 +1263,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
1262
1263
  version: 2.3.0
1263
1264
  required_rubygems_version: !ruby/object:Gem::Requirement
1264
1265
  requirements:
1265
- - - ">"
1266
+ - - ">="
1266
1267
  - !ruby/object:Gem::Version
1267
- version: 1.3.1
1268
+ version: '0'
1268
1269
  requirements:
1269
1270
  - ImageMagick (libmagick), v6.6 or greater.
1270
- rubygems_version: 3.0.3
1271
+ rubygems_version: 3.1.4
1271
1272
  signing_key:
1272
1273
  specification_version: 4
1273
1274
  summary: A powerful, userfriendly and flexible CMS for Rails
1274
1275
  test_files: []
1275
- ...