Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajaystha42feat/parser modifications #957

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a251929
fix image_processing variant breakage in activestorage, include new d…
donrestarone Apr 4, 2021
b999f48
activestorage install was outdated, updated it (includes database cha…
donrestarone Apr 4, 2021
c7b5360
rubocop
donrestarone Apr 4, 2021
fd230ae
Merge pull request #1 from restarone/shashike_issues#925
donrestarone Apr 4, 2021
1b88108
override default config
donrestarone Apr 15, 2021
b3fadd4
Merge pull request #2 from restarone/RedactorDontStripHtmlTags
donrestarone Apr 15, 2021
c556027
fix file update
donrestarone Jun 16, 2021
53ad319
Merge pull request #4 from restarone/fixFileUpdate
donrestarone Jun 16, 2021
854bc2d
when a file is updated, the content cache is flushed so that the upda…
donrestarone Jul 10, 2021
31a9844
Merge pull request #5 from restarone/flushPageCacheAferFileUpdate
donrestarone Jul 10, 2021
af5b6da
Remove data-disable-with attributes on the page update form
johnnaegle Nov 30, 2018
9caf301
update this route which was failing in ruby 3.0
Aug 4, 2021
050c09c
Merge pull request #6 from GoodMeasuresLLC/fix-for-ruby-3.0
donrestarone Jan 3, 2022
2b80ce7
Merge pull request #7 from restarone/fixforRuby3
donrestarone Jan 3, 2022
361150d
chore(): add remote form explicitly
Pralish May 16, 2022
6aee712
local false for categories form
Pralish May 16, 2022
3cd03b7
Merge pull request #8 from restarone/fix-categories-creation
donrestarone May 19, 2022
456fb85
Merge pull request #9 from restarone/patch-for-broken-categorizations
donrestarone May 19, 2022
1d4912e
feat(): integers conditions added
sthajay Jan 26, 2023
54b4fd7
test cases update
sthajay Jan 26, 2023
fc1113b
Add integer tokenizer
donrestarone Jan 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion app/views/comfy/admin/cms/files/_file.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%li{data: {id: file.id}}
:ruby
file_tag = cms_file_link_tag(file)
thumb_url = url_for(file.attachment.variant(combine_options: Comfy::Cms::File::VARIANT_SIZE[:thumb])) if file.attachment.variable?
thumb_url = url_for(file.attachment.variant(Comfy::Cms::File::VARIANT_SIZE[:thumb])) if file.attachment.variable?
.row
.col-md-5.item
.item-controls.d-none.d-lg-block
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 @@ -134,6 +135,7 @@ def tokenize(args_string)
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(IDENTIFIER)) then [:string, t]
elsif (t = ss.scan(INTEGER)) then [:string, t.to_i]
elsif (t = ss.scan(HASH_OPEN)) then [:hash_open, t]
elsif (t = ss.scan(HASH_CLOSE)) then [:hash_close, t]
elsif (t = ss.scan(ARRAY_OPEN)) then [:array_open, t]
Expand Down
2 changes: 1 addition & 1 deletion lib/comfortable_mexican_sofa/routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class ActionDispatch::Routing::Mapper

def comfy_route(identifier, options = {})
send("comfy_route_#{identifier}", options)
send("comfy_route_#{identifier}", **options)
end

end
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