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

Refactor du code des contenus (blocs et titres) #1492

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion app/models/communication/extranet/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
# fk_rails_86cc935add (author_id => university_people.id)
#
class Communication::Extranet::Post < ApplicationRecord
include Contentful
include Sanitizable
include WithAccessibility
include WithBlocks
include WithFeaturedImage
include WithPublication
include WithPermalink
Expand Down
2 changes: 1 addition & 1 deletion app/models/communication/website/agenda/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
#
class Communication::Website::Agenda::Category < ApplicationRecord
include AsDirectObject
include Contentful
include Sanitizable
include WithBlobs
include WithBlocks
include WithFeaturedImage
include WithMenuItemTarget
include WithPermalink
Expand Down
4 changes: 2 additions & 2 deletions app/models/communication/website/agenda/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
#
class Communication::Website::Agenda::Event < ApplicationRecord
include AsDirectObject
include Contentful
include Sanitizable
include WithAccessibility
include WithBlobs
include WithBlocks
include WithDuplication
include WithFeaturedImage
include WithMenuItemTarget
Expand Down Expand Up @@ -131,7 +131,7 @@ def template_static

def dependencies
active_storage_blobs +
blocks +
contents_dependencies +
[website.config_default_content_security_policy]
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/communication/website/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ class Communication::Website::Page < ApplicationRecord
self.ignored_columns = %w(path)

include AsDirectObject
include Contentful
include Sanitizable
include WithAccessibility
include WithAutomaticMenus
include WithBlobs
include WithBlocks
include WithDuplication
include WithFeaturedImage
include WithMenuItemTarget
Expand Down Expand Up @@ -103,7 +103,7 @@ def template_static
end

def dependencies
calculated_dependencies = active_storage_blobs + blocks
calculated_dependencies = active_storage_blobs + contents_dependencies
calculated_dependencies += [website.config_default_content_security_policy]
# children are used only if there is no block to display
calculated_dependencies += children unless blocks.published.any?
Expand Down
4 changes: 2 additions & 2 deletions app/models/communication/website/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
#
class Communication::Website::Post < ApplicationRecord
include AsDirectObject
include Contentful
include Sanitizable
include WithAccessibility
include WithBlobs
include WithBlocks
include WithDuplication
include WithFeaturedImage
include WithMenuItemTarget
Expand Down Expand Up @@ -118,7 +118,7 @@ def template_static

def dependencies
active_storage_blobs +
blocks +
contents_dependencies +
categories +
[author&.author] +
[website.config_default_content_security_policy]
Expand Down
4 changes: 2 additions & 2 deletions app/models/communication/website/post/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
#
class Communication::Website::Post::Category < ApplicationRecord
include AsDirectObject
include Contentful
include Sanitizable
include WithBlobs
include WithBlocks
include WithFeaturedImage
include WithMenuItemTarget
include WithPermalink
Expand Down Expand Up @@ -89,7 +89,7 @@ def template_static

def dependencies
active_storage_blobs +
blocks +
contents_dependencies +
children +
[website.config_default_content_security_policy]
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module WithBlocks
module Contentful
extend ActiveSupport::Concern

included do
Expand All @@ -24,6 +24,10 @@ def contents_full_text
@contents_full_text ||= contents.collect(&:full_text).join("\r")
end

def contents_dependencies
blocks + headings
end

# Basic rule is: TOC if 2 titles or more
def show_toc?
headings.many?
Expand Down
2 changes: 1 addition & 1 deletion app/models/education/diploma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#
class Education::Diploma < ApplicationRecord
include AsIndirectObject
include Contentful
include Sanitizable
include WithBlocks
include WithGitFiles
include WithPermalink
include WithSlug
Expand Down
4 changes: 2 additions & 2 deletions app/models/education/program.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
class Education::Program < ApplicationRecord
include Aboutable
include AsIndirectObject
include Contentful
include Sanitizable
include WithAccessibility
include WithAlumni
include WithBlobs
include WithBlocks
include WithDiploma
include WithFeaturedImage
include WithGitFiles
Expand Down Expand Up @@ -146,7 +146,7 @@ def git_path(website)

def dependencies
active_storage_blobs +
blocks +
contents_dependencies +
university_people_through_involvements.map(&:teacher) +
university_people_through_role_involvements.map(&:administrator) +
[diploma]
Expand Down
4 changes: 2 additions & 2 deletions app/models/research/journal/paper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Research::Journal::Paper < ApplicationRecord
include AsIndirectObject
include Sanitizable
include WithBlobs
include WithBlocks
include Contentful
include WithCitations
include WithGitFiles
include WithPermalink
Expand Down Expand Up @@ -93,7 +93,7 @@ def template_static

def dependencies
active_storage_blobs +
blocks +
contents_dependencies +
people.map(&:researcher)
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/university/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
#
class University::Organization < ApplicationRecord
include AsIndirectObject
include Contentful
include Backlinkable
include Sanitizable
include WithBlobs
include WithBlocks
include WithCountry
include WithGeolocation
include WithGitFiles
Expand Down
4 changes: 2 additions & 2 deletions app/models/university/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
class University::Person < ApplicationRecord
include AsIndirectObject
include Backlinkable
include Contentful
include Sanitizable
include WithBlobs
include WithBlocks
include WithCountry
# WithRoles included before WithEducation because needed for the latter
include WithRoles
Expand Down Expand Up @@ -197,7 +197,7 @@ def git_path(website)
end

def dependencies
blocks +
contents_dependencies +
active_storage_blobs
end

Expand Down
Loading