generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Added notes to constructor #987
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
8d3ead5
Added notes to constructor
alexy78 c7f5226
Added spaces
alexy78 8fde9ed
Fixed some comments
alexy78 5bf308a
updated test
alexy78 8235899
Resolved merge conflicts
alexy78 f53c539
updated partial for showpage and changed validations
alexy78 953013a
Added space to controller
alexy78 bb1bfe5
notes translateble+tests
DanielVajnagi 1f0d03a
cop
DanielVajnagi cf8bd38
Merge branch 'calculators-constructor' into 950-additional-notes
DanielVajnagi 1511258
cop
DanielVajnagi c0fc923
Update spec/models/calculator_spec.rb
DanielVajnagi c63e201
xss
DanielVajnagi 3b01ccb
Merge branch '950-additional-notes' of https://github.com/ita-social-…
DanielVajnagi 0a60823
fix
DanielVajnagi bf3d5f6
moved to helper
DanielVajnagi 371b7d0
fix
DanielVajnagi ac76ba2
Sanitize helper tests
DanielVajnagi dd9271c
rubocop fixes
DanielVajnagi 58f96aa
Merge branch 'calculators-constructor' into 950-additional-notes
DanielVajnagi 477d2b2
remove instance variable in tests
DanielVajnagi 8c7b500
Update calculators_helper_spec.rb
DanielVajnagi 317d9b3
moved tinymce form on top of the page, to the calculators info container
DanielVajnagi 2513033
rails_helper missing fix
DanielVajnagi 1180df7
rubocop fix
DanielVajnagi 6e5ca08
rename helper to more apropriate name
DanielVajnagi d6f9fc3
Merge branch 'calculators-constructor' into 950-additional-notes
DanielVajnagi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,3 +124,4 @@ gem "rails_db", "~> 2.4" | |
gem "meta-tags" | ||
gem "inline_svg" | ||
gem "breadcrumbs_on_rails" | ||
gem "tinymce-rails" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Controller } from '@hotwired/stimulus' | ||
|
||
export default class extends Controller { | ||
static targets = ['input'] | ||
|
||
connect() { | ||
tinymce.init(this.tinymceConfig) | ||
} | ||
|
||
disconnect() { | ||
tinymce.remove() | ||
} | ||
|
||
get tinymceConfig() { | ||
return { | ||
target: this.inputTarget, | ||
...TinyMCERails.configuration.default | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/views/account/calculators/partials/_tinymce_form.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<%= tinymce_assets %> | ||
<div data-controller="tinymce"> | ||
<div class="pt-4"> | ||
<%= f.label :uk_notes, t("account.calculators.new.uk_notes") %> | ||
<%= f.text_area :uk_notes, data: { tinymce_target: "input" }, class: "tinymce", rows: 20, cols: 60 %> | ||
</div> | ||
|
||
<div class="pt-4 pb-4"> | ||
<%= f.label :en_notes, t("account.calculators.new.en_notes") %> | ||
<%= f.text_area :en_notes, data: { tinymce_target: "input" }, class: "tinymce", rows: 20, cols: 60 %> | ||
</div> | ||
</div> | ||
|
||
<%= tinymce %> |
7 changes: 3 additions & 4 deletions
7
app/views/calculators/partials/show/_constructor_calculator_description.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
<%# TODO: Delete this if %> | ||
<% if false %> | ||
<% if calculator.uk_notes.present? || calculator.en_notes.present? %> | ||
<section class="description-section"> | ||
<div class="description-block"> | ||
<%# TODO: ADD text here %> | ||
<div class="description-section"> | ||
<%= sanitize_content(calculator.notes) %> | ||
</div> | ||
</section> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
height: 300 | ||
width: 800 | ||
menubar: false | ||
toolbar: | ||
- undo redo | blocks | bold italic | alignleft aligncenter alignright | bullist numlist outdent indent | removeformat | ||
plugins: | ||
- insertdatetime lists media table code wordcount | ||
license_key: 'gpl' |
8 changes: 8 additions & 0 deletions
8
db/migrate/20241121165300_add_language_notes_to_calculators.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class AddLanguageNotesToCalculators < ActiveRecord::Migration[7.2] | ||
def change | ||
change_table :calculators, bulk: true do |t| | ||
t.text :uk_notes | ||
t.text :en_notes | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe ApplicationHelper, type: :helper do | ||
describe "#sanitize_content" do | ||
let(:valid_html) do | ||
'<p class="text-bold">This is <strong>bold</strong> and <em>italic</em>. <a href="http://example.com" target="_blank">Link</a></p>' | ||
end | ||
|
||
let(:invalid_html) do | ||
'<script>alert("XSS")</script><p>This is safe content</p>' | ||
end | ||
|
||
let(:mixed_html) do | ||
'<p>This is <strong>bold</strong> and <script>alert("XSS")</script> <a href="http://example.com">Link</a></p>' | ||
end | ||
|
||
let(:html_with_attributes) do | ||
'<img src="image.png" alt="example image" style="width:100px;">' | ||
end | ||
|
||
it "allows specific tags and attributes" do | ||
expect(helper.sanitize_content(valid_html)).to include('<p class="text-bold">') | ||
expect(helper.sanitize_content(valid_html)).to include("<strong>bold</strong>") | ||
expect(helper.sanitize_content(valid_html)).to include("<em>italic</em>") | ||
expect(helper.sanitize_content(valid_html)).to include('<a href="http://example.com" target="_blank">Link</a>') | ||
end | ||
|
||
it "removes disallowed tags" do | ||
expect(helper.sanitize_content(invalid_html)).not_to include("<script>") | ||
end | ||
|
||
it "removes disallowed tags but keeps allowed tags and attributes" do | ||
expect(helper.sanitize_content(mixed_html)).to include("<p>This is <strong>bold</strong>") | ||
expect(helper.sanitize_content(mixed_html)).not_to include("<script>") | ||
expect(helper.sanitize_content(mixed_html)).to include('<a href="http://example.com">Link</a>') | ||
end | ||
|
||
it "does not remove allowed attributes from tags" do | ||
expect(helper.sanitize_content(html_with_attributes)).to eq('<img src="image.png" alt="example image" style="width:100px;">') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а тут норм рендериться HTML?