Skip to content
Snippets Groups Projects
Commit 12a5b42a authored by pabois's avatar pabois
Browse files

Merge branch 'master' of github.com:noesya/osuny

parents 54e1f32d d33e89eb
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,7 @@ class Communication::Block < ApplicationRecord ...@@ -50,6 +50,7 @@ class Communication::Block < ApplicationRecord
key_figures: 56, key_figures: 56,
} }
before_validation :sanitize_data
before_save :update_template_images before_save :update_template_images
after_commit :save_and_sync_about, on: [:update, :destroy] after_commit :save_and_sync_about, on: [:update, :destroy]
...@@ -77,11 +78,15 @@ class Communication::Block < ApplicationRecord ...@@ -77,11 +78,15 @@ class Communication::Block < ApplicationRecord
protected protected
def save_and_sync_about def sanitize_data
about&.save_and_sync unless about&.destroyed? self.data = template.sanitized_data
end end
def update_template_images def update_template_images
self.template_images = template.active_storage_blobs self.template_images = template.active_storage_blobs
end end
def save_and_sync_about
about&.save_and_sync unless about&.destroyed?
end
end end
...@@ -5,6 +5,10 @@ class Communication::Block::Template ...@@ -5,6 +5,10 @@ class Communication::Block::Template
@block = block @block = block
end end
def sanitized_data
data
end
def git_dependencies def git_dependencies
unless @git_dependencies unless @git_dependencies
@git_dependencies = [] @git_dependencies = []
......
class Communication::Block::Template::CallToAction < Communication::Block::Template class Communication::Block::Template::CallToAction < Communication::Block::Template
def sanitized_data
{
"text" => Osuny::Sanitizer.sanitize(text),
"url" => url,
"button" => Osuny::Sanitizer.sanitize(button, 'string'),
"url_secondary" => url_secondary,
"button_secondary" => Osuny::Sanitizer.sanitize(button_secondary, 'string'),
"url_tertiary" => url_tertiary,
"button_tertiary" => Osuny::Sanitizer.sanitize(button_tertiary, 'string'),
"image" => data['image'],
"image_alt" => Osuny::Sanitizer.sanitize(data['image_alt'], 'string'),
"image_credit" => Osuny::Sanitizer.sanitize(data['image_credit'], 'string')
}
end
def build_git_dependencies def build_git_dependencies
add_dependency image&.blob add_dependency image&.blob
end end
......
class Communication::Block::Template::Chapter < Communication::Block::Template class Communication::Block::Template::Chapter < Communication::Block::Template
def sanitized_data
{
"text" => Osuny::Sanitizer.sanitize(text),
"notes" => Osuny::Sanitizer.sanitize(notes),
"image" => data['image'],
"image_alt" => Osuny::Sanitizer.sanitize(data['image_alt'], 'string'),
"image_credit" => Osuny::Sanitizer.sanitize(data['image_credit'], 'string')
}
end
def build_git_dependencies def build_git_dependencies
add_dependency image&.blob add_dependency image&.blob
end end
......
class Communication::Block::Template::Image < Communication::Block::Template class Communication::Block::Template::Image < Communication::Block::Template
def sanitized_data
{
"text" => Osuny::Sanitizer.sanitize(text),
"image" => data['image'],
"image_alt" => Osuny::Sanitizer.sanitize(data['image_alt'], 'string'),
"image_credit" => Osuny::Sanitizer.sanitize(data['image_credit'], 'string')
}
end
def build_git_dependencies def build_git_dependencies
add_dependency image&.blob add_dependency image&.blob
end end
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
for="image_credit"> for="image_credit">
<%= t 'admin.communication.blocks.components.image.credit.label' %> <%= t 'admin.communication.blocks.components.image.credit.label' %>
</label> </label>
<input id="image_alt" <input id="image_credit"
type="text" type="text"
class="form-control" class="form-control"
v-model="data.image_credit" v-model="data.image_credit"
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
rows="10" rows="10"
class="form-control" class="form-control"
v-model="data.code" v-model="data.code"
data-summernote-config="mini-list"
placeholder="<%= t '.code_placeholder' %>"></textarea> placeholder="<%= t '.code_placeholder' %>"></textarea>
</div> </div>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment