Skip to content

Commit

Permalink
Revert "Revert "Merge restarone:comfortable-mexican-sofa:master""
Browse files Browse the repository at this point in the history
  • Loading branch information
rdsun0301 authored Jul 17, 2023
1 parent 421a5b1 commit 8d84a1a
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 6 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ group :development, :test do
gem "autoprefixer-rails", "~> 8.1.0"
gem "byebug", "~> 10.0.0", platforms: %i[mri mingw x64_mingw]
gem "capybara", "~> 2.17.0"
gem "image_processing", ">= 1.2"
gem "kaminari", "~> 1.1.1"
gem "puma", "~> 3.12.2"
gem "rubocop", "~> 0.55.0", require: false
Expand Down
9 changes: 8 additions & 1 deletion app/assets/javascripts/comfy/admin/cms/wysiwyg.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@
imageManagerJson,
fileUpload,
fileManagerJson,
definedLinks
definedLinks,
// allow unsafe tags and the like (prevent redactor stripping divs and other elements)
cleanOnEnter: false,
replaceTags: false,
removeComments: false,
removeNewLines: false,
deniedTags: [],
replaceDivs: false
};
};

Expand Down
10 changes: 9 additions & 1 deletion app/models/comfy/cms/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class Comfy::Cms::File < ActiveRecord::Base
after_save :process_attachment
end

after_save :clear_page_content_cache

# -- Validations -------------------------------------------------------------
validates :label, presence: true
validates :file, presence: true, on: :create
Expand All @@ -41,6 +43,12 @@ class Comfy::Cms::File < ActiveRecord::Base
where("active_storage_blobs.content_type LIKE 'image/%'").references(:blob)
}

private

def clear_page_content_cache
Comfy::Cms::Page.where(id: site.pages.pluck(:id)).update_all(content_cache: nil)
end

protected

def assign_position
Expand All @@ -56,7 +64,7 @@ def assign_label

def process_attachment
return if @file.blank?
attachment.attach(@file)
self.attachment = @file
end

end
2 changes: 1 addition & 1 deletion app/views/comfy/admin/cms/categories/_edit.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- url = comfy_admin_cms_site_category_path(@site, category)
= form_with model: @category, scope: :category, url: url, html: {class: "edit-category", id: dom_id(category)} do |form|
= form_with model: @category, scope: :category, url: url, html: {class: "edit-category", id: dom_id(category)}, local: false do |form|
.input-group
= form.text_field :label, class: "form-control form-control-sm", id: nil
.input-group-btn
Expand Down
2 changes: 1 addition & 1 deletion app/views/comfy/admin/cms/categories/_index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
= render "comfy/admin/cms/categories/show", category: category

- url = comfy_admin_cms_site_categories_path(@site)
= form_with scope: :category, url: url, html: {id: "new-category"} do |form|
= form_with scope: :category, url: url, html: {id: "new-category"}, local: false do |form|
= form.hidden_field :categorized_type, value: type
.input-group
= form.text_field :label, placeholder: t('.add_placeholder'), class: 'form-control form-control-sm', id: nil
Expand Down
4 changes: 2 additions & 2 deletions app/views/comfy/admin/cms/pages/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
= comfy_admin_partial "comfy/admin/cms/partials/page_form_after", form: form

= form.form_actions do
= submit_tag t(".preview"), name: "preview", formtarget: "comfy-cms-preview", id: nil, class: "btn btn-secondary", data: {disable_with: false}
= submit_tag t(@page.new_record?? ".create" : ".update"), class: "btn btn-primary ml-sm-1", data: {disable_with: false}
= submit_tag t(".preview"), name: "preview", formtarget: "comfy-cms-preview", id: nil, class: "btn btn-secondary"
= submit_tag t(@page.new_record?? ".create" : ".update"), class: "btn btn-primary ml-sm-1"
= link_to t(".cancel"), comfy_admin_cms_site_pages_path, class: "btn btn-link"
1 change: 1 addition & 0 deletions comfortable_mexican_sofa.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Gem::Specification.new do |s|
s.add_dependency "active_link_to", ">= 1.0.0"
s.add_dependency "comfy_bootstrap_form", ">= 4.0.0"
s.add_dependency "haml-rails", ">= 1.0.0"
s.add_dependency "image_processing", ">= 1.2"
s.add_dependency "jquery-rails", ">= 4.3.1"
s.add_dependency "kramdown", ">= 1.0.0"
s.add_dependency "mimemagic", ">= 0.3.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This migration comes from active_storage (originally 20190112182829)
class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]
def up
unless column_exists?(:active_storage_blobs, :service_name)
add_column :active_storage_blobs, :service_name, :string

if configured_service = ActiveStorage::Blob.service.name
ActiveStorage::Blob.unscoped.update_all(service_name: configured_service)
end

change_column :active_storage_blobs, :service_name, :string, null: false
end
end

def down
remove_column :active_storage_blobs, :service_name
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This migration comes from active_storage (originally 20191206030411)
class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
def change
create_table :active_storage_variant_records do |t|
t.belongs_to :blob, null: false, index: false
t.string :variation_digest, null: false

t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
end
end
2 changes: 2 additions & 0 deletions lib/comfortable_mexican_sofa/content/params_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Error < StandardError; end
HASH_CLOSE = %r{\}}
ARRAY_OPEN = %r{\[}
ARRAY_CLOSE = %r{\]}
INTEGER = %r{\b[0-9]+\b}i

# @param <String> string
def initialize(string = "")
Expand Down Expand Up @@ -133,6 +134,7 @@ def tokenize(args_string)
tokens <<
if (t = ss.scan(STRING_LITERAL)) then [:string, t[1...-1]]
elsif (t = ss.scan(HASH_KEY)) then [:hash_key, t[0...-1]]
elsif (t = ss.scan(INTEGER)) then [:string, t.to_i]
elsif (t = ss.scan(IDENTIFIER)) then [:string, t]
elsif (t = ss.scan(HASH_OPEN)) then [:hash_open, t]
elsif (t = ss.scan(HASH_CLOSE)) then [:hash_close, t]
Expand Down
12 changes: 12 additions & 0 deletions test/lib/content/params_parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ def test_tokenizer_with_arrays
], tokens
end

def test_tokenizer_with_arrays_containing_numbers
tokens = PARSER.new.send(:tokenize, "arr: [1, 2, 3]")
assert_equal [
[:hash_key, "arr"],
[:array_open, "["],
[:string, "1".to_i],
[:string, "2".to_i],
[:string, "3".to_i],
[:array_close, "]"]
], tokens
end

def test_tokenizer_with_quoted_value
tokens = PARSER.new.send(:tokenize, "key: ''")
assert_equal [[:hash_key, "key"], [:string, ""]], tokens
Expand Down

0 comments on commit 8d84a1a

Please sign in to comment.