pages_core 3.9.0 → 3.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -3
  3. data/VERSION +1 -0
  4. data/app/assets/builds/pages_core/admin-dist.js +13 -13
  5. data/app/assets/stylesheets/pages/admin/controllers/pages.scss +6 -0
  6. data/app/controllers/admin/categories_controller.rb +3 -3
  7. data/app/controllers/admin/invites_controller.rb +1 -1
  8. data/app/controllers/admin/pages_controller.rb +1 -1
  9. data/app/controllers/admin/password_resets_controller.rb +7 -7
  10. data/app/controllers/admin/users_controller.rb +1 -1
  11. data/app/controllers/concerns/pages_core/error_reporting.rb +2 -0
  12. data/app/controllers/concerns/pages_core/ranged_response.rb +40 -0
  13. data/app/controllers/pages_core/attachments_controller.rb +6 -4
  14. data/app/controllers/pages_core/frontend/pages_controller.rb +1 -1
  15. data/app/controllers/sessions_controller.rb +5 -6
  16. data/app/javascript/components/ImageEditor/Form.jsx +1 -1
  17. data/app/javascript/components/ImageGrid.jsx +1 -1
  18. data/app/mailers/admin_mailer.rb +1 -1
  19. data/app/models/attachment.rb +1 -1
  20. data/app/models/concerns/pages_core/page_model/pathable.rb +1 -1
  21. data/app/models/invite.rb +0 -2
  22. data/app/models/page_category.rb +0 -1
  23. data/app/models/page_exporter.rb +2 -2
  24. data/app/models/password_reset_token.rb +0 -2
  25. data/app/models/tagging.rb +0 -2
  26. data/app/models/user.rb +1 -13
  27. data/app/views/admin/users/login.html.erb +2 -2
  28. data/app/views/admin/users/new_password.html.erb +1 -1
  29. data/app/views/admin_mailer/invite.text.erb +0 -2
  30. data/app/views/admin_mailer/password_reset.text.erb +0 -2
  31. data/app/views/feeds/pages.rss.builder +1 -1
  32. data/config/locales/en.yml +40 -14
  33. data/db/migrate/20220615160300_remove_username.rb +7 -0
  34. data/lib/pages_core/static_cache/page_cache_handler.rb +1 -1
  35. data/lib/pages_core/static_cache.rb +7 -3
  36. data/lib/rails/generators/pages_core/frontend/frontend_generator.rb +34 -34
  37. data/lib/rails/generators/pages_core/frontend/templates/{layout.html.erb → application.html.erb} +3 -0
  38. data/lib/rails/generators/pages_core/frontend/templates/javascript/lib/GridOverlay.js +66 -0
  39. data/lib/rails/generators/pages_core/frontend/templates/javascript/lib/ResponsiveEmbeds.js +72 -0
  40. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/application.sass.scss +15 -0
  41. data/lib/rails/generators/pages_core/frontend/templates/{base.scss.erb → stylesheets/components/base.scss} +9 -0
  42. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/config.scss +26 -0
  43. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/framework/breakpoints.scss +42 -0
  44. data/lib/rails/generators/pages_core/frontend/templates/{clearfix.scss.erb → stylesheets/framework/clearfix.scss} +0 -0
  45. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/framework/fonts.scss +32 -0
  46. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/framework/grid.scss +168 -0
  47. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/framework/grid_overlay.scss +44 -0
  48. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/global/colors.scss +8 -0
  49. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/global/typography.scss +90 -0
  50. data/lib/rails/generators/pages_core/frontend/templates/stylesheets/vendor/normalize.css +349 -0
  51. metadata +26 -14
  52. data/lib/rails/generators/pages_core/frontend/templates/application.scss.erb +0 -3
  53. data/lib/rails/generators/pages_core/frontend/templates/breakpoints.scss.erb +0 -24
  54. data/lib/rails/generators/pages_core/frontend/templates/normalize.css.erb +0 -425
@@ -9,6 +9,12 @@
9
9
  background-image: image-url("pages/admin/drag-icon.png");
10
10
  }
11
11
 
12
+ td.drag-handle {
13
+ float: none;
14
+ background-repeat: no-repeat;
15
+ background-position: right 0px top 50%;
16
+ }
17
+
12
18
  .page-list {
13
19
  float: left;
14
20
  list-style-type: none;
@@ -19,7 +19,7 @@ module Admin
19
19
  def create
20
20
  @category = Category.create(category_params)
21
21
  if @category.valid?
22
- flash[:notice] = "New category created"
22
+ flash[:notice] = t("pages_core.categories_controller.created")
23
23
  redirect_to admin_pages_url(@locale)
24
24
  else
25
25
  render action: :new
@@ -30,7 +30,7 @@ module Admin
30
30
 
31
31
  def update
32
32
  if @category.update(category_params)
33
- flash[:notice] = "Category was updated"
33
+ flash[:notice] = t("pages_core.categories_controller.updated")
34
34
  redirect_to admin_pages_url(@locale)
35
35
  else
36
36
  render action: :edit
@@ -39,7 +39,7 @@ module Admin
39
39
 
40
40
  def destroy
41
41
  @category.destroy
42
- flash[:notice] = "Category was deleted"
42
+ flash[:notice] = t("pages_core.categories_controller.deleted")
43
43
  redirect_to admin_pages_url(@locale)
44
44
  end
45
45
 
@@ -61,7 +61,7 @@ module Admin
61
61
  @invite = Invite.find_by(id: params[:id])
62
62
  return if @invite && secure_compare(@invite.token, params[:token])
63
63
 
64
- flash[:notice] = "This invite is no longer valid."
64
+ flash[:notice] = t("pages_core.invite_expired")
65
65
  redirect_to(login_admin_users_url) && return
66
66
  end
67
67
 
@@ -52,7 +52,7 @@ module Admin
52
52
  if @page.update(page_params)
53
53
  @page.categories = param_categories
54
54
  respond_with_page(@page) do
55
- flash[:notice] = "Your changes were saved"
55
+ flash[:notice] = t("pages_core.changes_saved")
56
56
  redirect_to edit_admin_page_url(@locale, @page)
57
57
  end
58
58
  else
@@ -9,13 +9,13 @@ module Admin
9
9
  layout "admin"
10
10
 
11
11
  def create
12
- @user = find_user_by_email(params[:username])
12
+ @user = find_user_by_email(params[:email])
13
13
  if @user
14
14
  @password_reset_token = @user.password_reset_tokens.create
15
15
  deliver_password_reset(@user, @password_reset_token)
16
- flash[:notice] = "An email with further instructions has been sent"
16
+ flash[:notice] = t("pages_core.password_reset.sent")
17
17
  else
18
- flash[:notice] = "Couldn't find a user with that email address"
18
+ flash[:notice] = t("pages_core.password_reset.not_found")
19
19
  end
20
20
  redirect_to login_admin_users_url
21
21
  end
@@ -29,7 +29,7 @@ module Admin
29
29
  if user_params[:password].present? && @user.update(user_params)
30
30
  @password_reset_token.destroy
31
31
  authenticate!(@user)
32
- flash[:notice] = "Your password has been changed"
32
+ flash[:notice] = t("pages_core.password_reset.changed")
33
33
  redirect_to login_admin_users_url
34
34
  else
35
35
  render action: :show
@@ -50,7 +50,7 @@ module Admin
50
50
  def find_user_by_email(email)
51
51
  return unless email
52
52
 
53
- User.login_name(params[:username])
53
+ User.find_by_email(params[:email])
54
54
  end
55
55
 
56
56
  def user_params
@@ -70,7 +70,7 @@ module Admin
70
70
 
71
71
  return if valid_token?(@password_reset_token)
72
72
 
73
- flash[:notice] = "Invalid password reset request"
73
+ flash[:notice] = t("pages_core.password_reset.invalid_request")
74
74
  redirect_to(login_admin_users_url) && return
75
75
  end
76
76
 
@@ -78,7 +78,7 @@ module Admin
78
78
  return unless @password_reset_token.expired?
79
79
 
80
80
  @password_reset_token.destroy
81
- flash[:notice] = "Your password reset link has expired"
81
+ flash[:notice] = t("pages_core.password_reset.expired")
82
82
  redirect_to(login_admin_users_url)
83
83
  end
84
84
  end
@@ -95,7 +95,7 @@ module Admin
95
95
  def require_no_users
96
96
  return unless User.any?
97
97
 
98
- flash[:error] = "Account holder already exists"
98
+ flash[:error] = t("pages_core.account_holder_exists")
99
99
  redirect_to(admin_users_url)
100
100
  end
101
101
  end
@@ -11,6 +11,8 @@ module PagesCore
11
11
  protected
12
12
 
13
13
  def configure_sentry_context
14
+ return if Rails.env.test?
15
+
14
16
  if Object.const_defined?("Sentry")
15
17
  Sentry.set_user(current_user_context)
16
18
  Sentry.set_tags(locale: params[:locale] || I18n.default_locale.to_s)
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PagesCore
4
+ module RangedResponse
5
+ extend ActiveSupport::Concern
6
+
7
+ def send_ranged_data(data, options = {})
8
+ response.header["Content-Length"] = data.length
9
+ response.header["Accept-Ranges"] = "bytes"
10
+
11
+ content_range_headers(data.length) if ranged_request?
12
+
13
+ send_data(ranged_data(data),
14
+ options.merge(status: ranged_request? ? 206 : 200))
15
+ end
16
+
17
+ private
18
+
19
+ def content_range(length)
20
+ Rack::Utils.byte_ranges(request.headers, length)[0]
21
+ end
22
+
23
+ def content_range_headers(size)
24
+ bytes = content_range(size)
25
+ response.header["Content-Length"] = bytes.end - bytes.begin + 1
26
+ response.header["Content-Range"] =
27
+ "bytes #{bytes.begin}-#{bytes.end}/#{size}"
28
+ end
29
+
30
+ def ranged_data(data)
31
+ return data unless ranged_request?
32
+
33
+ data[content_range(data.length)]
34
+ end
35
+
36
+ def ranged_request?
37
+ request.headers["HTTP_RANGE"]
38
+ end
39
+ end
40
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  module PagesCore
4
4
  class AttachmentsController < ::ApplicationController
5
+ include PagesCore::RangedResponse
6
+
5
7
  before_action :verify_signed_params
6
8
  before_action :find_attachment, only: %i[show download]
7
9
 
@@ -26,10 +28,10 @@ module PagesCore
26
28
  return
27
29
  end
28
30
 
29
- send_data(@attachment.data,
30
- filename: @attachment.filename,
31
- type: @attachment.content_type,
32
- disposition: disposition)
31
+ send_ranged_data(@attachment.data,
32
+ filename: @attachment.filename,
33
+ type: @attachment.content_type,
34
+ disposition: disposition)
33
35
  end
34
36
 
35
37
  def verify_signed_params
@@ -109,7 +109,7 @@ module PagesCore
109
109
  def redirect_page(page)
110
110
  return false unless page.redirects?
111
111
 
112
- redirect_to(page.redirect_path(locale: locale))
112
+ redirect_to(page.redirect_path(locale: locale), allow_other_host: true)
113
113
  end
114
114
 
115
115
  def require_page
@@ -2,27 +2,26 @@
2
2
 
3
3
  class SessionsController < ::ApplicationController
4
4
  def create
5
- user = find_user(params[:username], params[:password])
5
+ user = find_user(params[:email], params[:password])
6
6
  authenticate!(user) if user
7
7
 
8
8
  if logged_in?
9
9
  redirect_to admin_default_url
10
10
  else
11
- flash[:notice] = "The provided email address and password combination " \
12
- "was not valid"
11
+ flash[:notice] = t("pages_core.invalid_login")
13
12
  redirect_to login_admin_users_url
14
13
  end
15
14
  end
16
15
 
17
16
  def destroy
18
- flash[:notice] = "You have been logged out"
17
+ flash[:notice] = t("pages_core.logged_out")
19
18
  deauthenticate!
20
19
  redirect_to login_admin_users_url
21
20
  end
22
21
 
23
22
  protected
24
23
 
25
- def find_user(username, password)
26
- User.authenticate(username, password: password) if username && password
24
+ def find_user(email, password)
25
+ User.authenticate(email, password: password) if email && password
27
26
  end
28
27
  end
@@ -90,7 +90,7 @@ Form.propTypes = {
90
90
  caption: PropTypes.object,
91
91
  image: PropTypes.object,
92
92
  locale: PropTypes.string,
93
- locales: PropTypes.array,
93
+ locales: PropTypes.object,
94
94
  setLocale: PropTypes.func,
95
95
  save: PropTypes.func,
96
96
  showCaption: PropTypes.bool,
@@ -249,7 +249,7 @@ export default function ImageGrid(props) {
249
249
  ImageGrid.propTypes = {
250
250
  attribute: PropTypes.string,
251
251
  locale: PropTypes.string,
252
- locales: PropTypes.array,
252
+ locales: PropTypes.object,
253
253
  records: PropTypes.array,
254
254
  enablePrimary: PropTypes.bool,
255
255
  primaryAttribute: PropTypes.string,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class AdminMailer < ApplicationMailer
4
- default from: proc { "\"Pages\" <support@anyone.no>" }
4
+ default from: proc { "\"Pages\" <no-reply@anyone.no>" }
5
5
 
6
6
  def password_reset(user, url)
7
7
  @user = user
@@ -67,7 +67,7 @@ class Attachment < ApplicationRecord
67
67
  # Includes a timestamp fingerprint in the URL param, so
68
68
  # that rendered images can be cached indefinitely.
69
69
  def to_param
70
- [id, updated_at.utc.to_s(cache_timestamp_format)].join("-")
70
+ [id, updated_at.utc.to_fs(cache_timestamp_format)].join("-")
71
71
  end
72
72
 
73
73
  private
@@ -107,7 +107,7 @@ module PagesCore
107
107
  siblings.reject { |p| p == self }
108
108
  .map { |p| p.localize(locale) }
109
109
  .map(&:path_segment)
110
- .reject(&:blank?)
110
+ .compact_blank
111
111
  end
112
112
  end
113
113
  end
data/app/models/invite.rb CHANGED
@@ -8,8 +8,6 @@ class Invite < ApplicationRecord
8
8
 
9
9
  before_validation :ensure_token
10
10
 
11
- validates :user_id, presence: true
12
-
13
11
  validates :email,
14
12
  presence: true,
15
13
  format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i },
@@ -3,5 +3,4 @@
3
3
  class PageCategory < ApplicationRecord
4
4
  belongs_to :page
5
5
  belongs_to :category
6
- validates :page_id, :category_id, presence: true
7
6
  end
@@ -74,7 +74,7 @@ class PageExporter
74
74
 
75
75
  def page_file_name(page)
76
76
  [page.path_segment,
77
- page.to_param[0..250]].reject(&:blank?).first
77
+ page.to_param[0..250]].compact_blank.first
78
78
  end
79
79
 
80
80
  def page_path_segment(page)
@@ -95,6 +95,6 @@ class PageExporter
95
95
 
96
96
  def write_file(path, data)
97
97
  FileUtils.mkdir_p(File.dirname(path))
98
- File.open(path, "wb") { |fh| fh.write(data) }
98
+ File.binwrite(path, data)
99
99
  end
100
100
  end
@@ -5,8 +5,6 @@ class PasswordResetToken < ApplicationRecord
5
5
  before_create :ensure_token
6
6
  before_create :ensure_expiration
7
7
 
8
- validates :user_id, presence: true
9
-
10
8
  scope :active, -> { where("expires_at >= ?", Time.now.utc) }
11
9
  scope :expired, -> { where("expires_at < ?", Time.now.utc) }
12
10
 
@@ -4,10 +4,8 @@ class Tagging < ApplicationRecord
4
4
  belongs_to :tag
5
5
  belongs_to :taggable, polymorphic: true, touch: true
6
6
 
7
- validates :taggable_id, presence: true
8
7
  validates :taggable_type, presence: true
9
8
  validates :tag_id,
10
- presence: true,
11
9
  uniqueness: { scope: %i[taggable_type taggable_id] }
12
10
 
13
11
  def self.tagged_class(taggable)
data/app/models/user.rb CHANGED
@@ -23,8 +23,6 @@ class User < ApplicationRecord
23
23
 
24
24
  serialize :persistent_data
25
25
 
26
- validates :username, presence: true, uniqueness: { case_sensitive: false }
27
-
28
26
  validates :name, presence: true
29
27
 
30
28
  validates :email,
@@ -37,7 +35,6 @@ class User < ApplicationRecord
37
35
 
38
36
  validate :confirm_password_must_match
39
37
 
40
- before_validation :ensure_username
41
38
  before_validation :hash_password
42
39
  before_create :ensure_first_user_has_all_roles
43
40
 
@@ -47,18 +44,13 @@ class User < ApplicationRecord
47
44
 
48
45
  class << self
49
46
  def authenticate(email, password:)
50
- user = User.login_name(email)
47
+ user = User.find_by_email(email)
51
48
  user if user.try { |u| u.authenticate!(password) }
52
49
  end
53
50
 
54
51
  def find_by_email(str)
55
52
  find_by("LOWER(email) = ?", str.to_s.downcase)
56
53
  end
57
-
58
- # Finds a user by either username or email address.
59
- def login_name(string)
60
- find_by(username: string.to_s) || find_by_email(string)
61
- end
62
54
  end
63
55
 
64
56
  def authenticate!(password)
@@ -102,10 +94,6 @@ class User < ApplicationRecord
102
94
  BCrypt::Password.create(password)
103
95
  end
104
96
 
105
- def ensure_username
106
- self.username ||= email
107
- end
108
-
109
97
  def ensure_first_user_has_all_roles
110
98
  return if User.any?
111
99
 
@@ -19,7 +19,7 @@
19
19
  <%= form_tag session_path do %>
20
20
  <p>
21
21
  <label>Email address</label>
22
- <%= text_field_tag :username, '' %>
22
+ <%= text_field_tag :email, '' %>
23
23
  </p>
24
24
  <p>
25
25
  <label>Password</label>
@@ -54,7 +54,7 @@
54
54
  and we'll send you a link where you can reset your password.
55
55
  </p>
56
56
  <p>
57
- <%= text_field_tag :username, '' %>
57
+ <%= text_field_tag :email, '' %>
58
58
  </p>
59
59
  <p>
60
60
  <button type="submit">
@@ -13,7 +13,7 @@
13
13
  </div>
14
14
  <%= form_tag(reset_password_admin_users_path, method: :post) do %>
15
15
  <p>
16
- <%= text_field_tag :username, '', size: 32 %>
16
+ <%= text_field_tag :email, '', size: 32 %>
17
17
  <%= submit_tag "Find" %>
18
18
  </p>
19
19
  </form>
@@ -5,5 +5,3 @@ Welcome!
5
5
  Click the link below to create your account and get started.
6
6
 
7
7
  <%= @url %>
8
-
9
- If you have any further trouble, please don't hesitate in contacting us by sending us an email at support@anyone.no (or simply by replying to this message).
@@ -9,5 +9,3 @@ If you want to reset your password, please click the following link:
9
9
  This will take you to a web page where you can set a new password of your choosing. The link will expire in 24 hours.
10
10
 
11
11
  If you do not want to change your password, please ignore this email.
12
-
13
- If you have any further trouble, please don't hesitate in contacting us by sending us an email at support@anyone.no (or simply by replying to this message).
@@ -23,7 +23,7 @@ xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do
23
23
  end
24
24
  end
25
25
  xml.guid page_url(@locale, item, only_path: false)
26
- xml.pubDate item.published_at.to_formatted_s(:rfc822)
26
+ xml.pubDate item.published_at.to_fs(:rfc822)
27
27
  xml.tag!("dc:creator", item.author.name)
28
28
  if item.image
29
29
  xml.enclosure(
@@ -1,3 +1,4 @@
1
+ ---
1
2
  en:
2
3
  date:
3
4
  formats:
@@ -16,40 +17,65 @@ en:
16
17
  user:
17
18
  email: Email address
18
19
  image: Profile picture
20
+ pages_core:
21
+ account_holder_exists: Account holder already exists
22
+ categories_controller:
23
+ created: New category created
24
+ deleted: Category was deleted
25
+ updated: Category was updated
26
+ changes_saved: Your changes were saved
27
+ invalid_login: >
28
+ The provided email address and password combination was not valid
29
+ invite_expired: This invite is no longer valid.
30
+ logged_out: You have been logged out
31
+ password_reset:
32
+ changed: Your password has been changed
33
+ expired: Your password reset link has expired
34
+ invalid_request: Invalid password reset request
35
+ not_found: Couldn't find a user with that email address
36
+ sent: An email with further instructions has been sent
19
37
  templates:
20
38
  default:
21
39
  blocks:
22
40
  name:
23
41
  name: Name
24
- description: "This is the name of the page, and it will also be the
25
- name of the link to this page."
42
+ description: >
43
+ This is the name of the page, and it will also be the name
44
+ of the link to this page.
26
45
  body:
27
46
  name: Body
28
47
  description: ""
29
48
  headline:
30
49
  name: Headline
31
- description: "Optional, use if the headline should differ from the
32
- page name."
50
+ description: >
51
+ Optional, use if the headline should differ from the page
52
+ name.
33
53
  excerpt:
34
54
  name: Standfirst
35
55
  description: An introductory paragraph before the start of the body.
36
56
  boxout:
37
57
  name: Boxout
38
- description: "Part of the page, usually background info or facts
39
- related to the article."
58
+ description: >
59
+ Part of the page, usually background info or facts related
60
+ to the article.
40
61
  meta_title:
41
62
  name: Title
42
- description: "Document title. Will fall back to the page name if
43
- empty. Recommended length: Up to 56 characters."
63
+ description: >
64
+ Document title. Will fall back to the page name if empty.
65
+ Recommended length: Up to 56 characters.
44
66
  meta_description:
45
67
  name: Description
46
- description: "Description for search engines. Will fall back to
47
- Standfirst if empty. Recommended length: Up to 156 characters."
68
+ description: >
69
+ Description for search engines. Will fall back to
70
+ Standfirst if empty. Recommended length: Up to 156
71
+ characters.
48
72
  open_graph_title:
49
73
  name: Open Graph Title
50
- description: "Page title for Facebook sharing. Will fall back to the
51
- document title."
74
+ description: >
75
+ Page title for Facebook sharing. Will fall back to the
76
+ document title.
52
77
  open_graph_description:
53
78
  name: Open Graph Description
54
- description: "Description for Facebook sharing. Will fall back to
55
- Description or Standfirst if empty."
79
+ description: >
80
+ Description for Facebook sharing. Will fall back to
81
+ Description or Standfirst if empty.
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RemoveUsername < ActiveRecord::Migration[7.0]
4
+ def change
5
+ remove_column :users, :username, :string
6
+ end
7
+ end
@@ -35,7 +35,7 @@ module PagesCore
35
35
  private
36
36
 
37
37
  def cache_root
38
- Rails.root.join("public")
38
+ Rails.public_path
39
39
  end
40
40
 
41
41
  def clear_directory(path)
@@ -14,13 +14,17 @@ module PagesCore
14
14
  private
15
15
 
16
16
  def default_handler
17
- if ENV["VARNISH_URL"]
18
- return PagesCore::StaticCache::VarnishHandler.new(ENV["VARNISH_URL"])
19
- end
17
+ return varnish_handler if ENV["VARNISH_URL"]
20
18
 
21
19
  # PagesCore::StaticCache::NullHandler.new
22
20
  PagesCore::StaticCache::PageCacheHandler.new
23
21
  end
22
+
23
+ def varnish_handler
24
+ PagesCore::StaticCache::VarnishHandler.new(
25
+ ENV.fetch("VARNISH_URL", nil)
26
+ )
27
+ end
24
28
  end
25
29
  end
26
30
  end
@@ -8,48 +8,48 @@ module PagesCore
8
8
 
9
9
  def create_layout
10
10
  copy_file(
11
- "layout.html.erb",
11
+ "application.html.erb",
12
12
  File.join("app/views/layouts/application.html.erb")
13
13
  )
14
14
  end
15
15
 
16
- def create_application_scss
17
- template(
18
- "application.scss.erb",
19
- File.join("app/assets/stylesheets/application.scss")
20
- )
21
- end
22
-
23
- def remove_application_css
24
- remove_file("app/assets/stylesheets/application.css")
16
+ def create_css_framework
17
+ ["application.sass.scss",
18
+ "config.scss",
19
+ "components/base.scss",
20
+ "framework/breakpoints.scss",
21
+ "framework/clearfix.scss",
22
+ "framework/grid.scss",
23
+ "framework/grid_overlay.scss",
24
+ "framework/fonts.scss",
25
+ "global/colors.scss",
26
+ "global/typography.scss",
27
+ "vendor/normalize.css"].each do |f|
28
+ template("stylesheets/#{f}", File.join("app/assets/stylesheets/#{f}"))
29
+ end
25
30
  end
26
31
 
27
- def create_normalize_css
28
- template(
29
- "normalize.css.erb",
30
- File.join("vendor/assets/stylesheets/normalize.css")
31
- )
32
+ def create_js_framework
33
+ ["lib/ResponsiveEmbeds.js",
34
+ "lib/GridOverlay.js"].each do |f|
35
+ template("javascript/#{f}", File.join("app/javascript/#{f}"))
36
+ end
37
+
38
+ append_to_file "app/javascript/application.js" do
39
+ <<~JS
40
+ // Responsive embeds
41
+ import ResponsiveEmbeds from "./lib/ResponsiveEmbeds";
42
+ ResponsiveEmbeds.start();
43
+
44
+ // Grid overlay
45
+ import GridOverlay from "./lib/GridOverlay";
46
+ GridOverlay.start();
47
+ JS
48
+ end
32
49
  end
33
50
 
34
- def create_breakpoints_css
35
- template(
36
- "breakpoints.scss.erb",
37
- File.join("app/assets/stylesheets/mixins/breakpoints.scss")
38
- )
39
- end
40
-
41
- def create_clearfix_css
42
- template(
43
- "clearfix.scss.erb",
44
- File.join("app/assets/stylesheets/mixins/clearfix.scss")
45
- )
46
- end
47
-
48
- def create_base_css
49
- template(
50
- "base.scss.erb",
51
- File.join("app/assets/stylesheets/components/base.scss")
52
- )
51
+ def remove_application_css
52
+ remove_file("app/assets/stylesheets/application.css")
53
53
  end
54
54
  end
55
55
  end