diff --git a/app/assets/images/communication/blocks/templates/agenda.jpg b/app/assets/images/communication/blocks/templates/agenda.jpg index ccbb036a4dca8424c1d9a09aa02cd35d05075d17..b9eac45e46f2208ef434dcdc727f1f8200eb0a42 100644 Binary files a/app/assets/images/communication/blocks/templates/agenda.jpg and b/app/assets/images/communication/blocks/templates/agenda.jpg differ diff --git a/app/assets/images/communication/blocks/templates/agenda/grid.png b/app/assets/images/communication/blocks/templates/agenda/grid.png new file mode 100644 index 0000000000000000000000000000000000000000..312afc839c211c20b23e7e5dd90249d8117e9b16 Binary files /dev/null and b/app/assets/images/communication/blocks/templates/agenda/grid.png differ diff --git a/app/assets/images/communication/blocks/templates/agenda/list.png b/app/assets/images/communication/blocks/templates/agenda/list.png new file mode 100644 index 0000000000000000000000000000000000000000..3dcd1c332187840733835fba32668942151a8750 Binary files /dev/null and b/app/assets/images/communication/blocks/templates/agenda/list.png differ diff --git a/app/assets/images/communication/blocks/templates/people.jpg b/app/assets/images/communication/blocks/templates/persons.jpg similarity index 100% rename from app/assets/images/communication/blocks/templates/people.jpg rename to app/assets/images/communication/blocks/templates/persons.jpg diff --git a/app/controllers/admin/communication/websites_controller.rb b/app/controllers/admin/communication/websites_controller.rb index 611dfa7357a34e148725bb60c42b82b0cd620691..36d1774ab7007ba9548064944635871f2871064c 100644 --- a/app/controllers/admin/communication/websites_controller.rb +++ b/app/controllers/admin/communication/websites_controller.rb @@ -17,22 +17,6 @@ class Admin::Communication::WebsitesController < Admin::Communication::Websites: add_breadcrumb t('communication.website.security') end - def import - if request.post? - @website.import! - flash[:notice] = t('communication.website.imported.launched') - end - @imported_website = @website.imported_website - @imported_pages = @imported_website.pages.page params[:pages_page] - @imported_posts = @imported_website.posts.page params[:posts_page] - @imported_authors = @imported_website.authors.page params[:authors_page] - @imported_categories = @imported_website.categories - @imported_media = @imported_website.media.includes(file_attachment: :blob ).page params[:media_page] - @imported_media_total_size = @imported_website.media.joins(file_attachment: :blob).sum(:byte_size) - breadcrumb - add_breadcrumb Communication::Website::Imported::Website.model_name.human - end - def show @all_pages = @website.pages.accessible_by(current_ability).for_language(current_website_language) @pages = @all_pages.recent diff --git a/app/models/ability/admin.rb b/app/models/ability/admin.rb index f6692c611cb18f7a4c4723f9316bc7bd865e1afa..8cf3f3d3664ec304942b6d598c71de6d811febb1 100644 --- a/app/models/ability/admin.rb +++ b/app/models/ability/admin.rb @@ -56,9 +56,6 @@ class Ability::Admin < Ability # Le risque de faussse manip est grand. cannot :destroy, Communication::Website, university_id: @user.university_id can :manage, Communication::Website::Category, university_id: @user.university_id - can :manage, Communication::Website::Imported::Website, university_id: @user.university_id - can :manage, Communication::Website::Imported::Page, university_id: @user.university_id - can :manage, Communication::Website::Imported::Post, university_id: @user.university_id can :manage, Communication::Website::Menu, university_id: @user.university_id can :manage, Communication::Website::Menu::Item, university_id: @user.university_id can :manage, Communication::Website::Page, university_id: @user.university_id diff --git a/app/models/communication/block.rb b/app/models/communication/block.rb index 2c68be3b53ecb969d2af8f1fb1e269a17577937c..8ed12e14ab5761a1260062436416b2d40c2c381e 100644 --- a/app/models/communication/block.rb +++ b/app/models/communication/block.rb @@ -77,7 +77,7 @@ class Communication::Block < ApplicationRecord license: 4040, organizations: 200, pages: 600, - people: 100, + persons: 100, posts: 500, programs: 58, sound: 1005, @@ -89,7 +89,7 @@ class Communication::Block < ApplicationRecord CATEGORIES = { basic: [:chapter, :image, :video, :sound, :datatable], storytelling: [:key_figures, :features, :gallery, :call_to_action, :testimonials, :timeline], - references: [:pages, :posts, :people, :organizations, :agenda, :programs], + references: [:pages, :posts, :persons, :organizations, :agenda, :programs], utilities: [:files, :definitions, :contact, :license, :embed] } diff --git a/app/models/communication/block/template/agenda.rb b/app/models/communication/block/template/agenda.rb index b9f50f7070965b3cf8a3841e43b79273c47ef349..5a59c7bbf78e99ca0cf148aed9ade2c63524b1c0 100644 --- a/app/models/communication/block/template/agenda.rb +++ b/app/models/communication/block/template/agenda.rb @@ -1,19 +1,41 @@ class Communication::Block::Template::Agenda < Communication::Block::Template::Base + has_layouts [:grid, :list] + has_component :description, :rich_text - has_component :events_quantity, :number, options: 3 + has_component :quantity, :number, options: 3 + has_component :time, :option, options: [:future_or_present, :future, :present, :archive] def selected_events - @selected_events ||= block.about&.website - .events - .for_language(block.language) - .published - .ordered - .limit(events_quantity) + @selected_events ||= events_with_time_scope end def allowed_for_about? website.present? end + protected + + def events_with_time_scope + events = block.about&.website + .events + .for_language(block.language) + .published + .limit(quantity) + # Whitelist for security + # (not very elegant though) + case time + when 'future_or_present' + events.future_or_present + when 'future' + events.future + when 'present' + events.present + when 'archive' + events.archive + else + events + end + end + end diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index 8319135f8b3b02d3cd3e48435ba44a8fed1279f8..1e0fa32ed0fd5ad319317581a1ec378d46bd03bb 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -61,7 +61,6 @@ class Communication::Website < ApplicationRecord include WithDeuxfleurs include WithGit include WithGitRepository - include WithImport include WithLanguages include WithManagers include WithProgramCategories diff --git a/app/models/communication/website/agenda/event.rb b/app/models/communication/website/agenda/event.rb index 029165bb63dcbe609177442336a594ca9ec3d33d..db88db5e0f63db34cc9175c4100277f58ccb2421 100644 --- a/app/models/communication/website/agenda/event.rb +++ b/app/models/communication/website/agenda/event.rb @@ -57,10 +57,17 @@ class Communication::Website::Agenda::Event < ApplicationRecord class_name: 'Communication::Website::Agenda::Event', optional: true - scope :ordered, -> { order(from_day: :desc, from_hour: :desc) } - scope :recent, -> { ordered.limit(5) } + scope :ordered_desc, -> { order(from_day: :desc, from_hour: :desc) } + scope :ordered_asc, -> { order(:from_day, :from_hour) } + scope :ordered, -> { ordered_asc } + scope :recent, -> { order(:updated_at).limit(5) } scope :published, -> { where(published: true) } scope :draft, -> { where(published: false) } + scope :future, -> { where('from_day > :today', today: Date.today).ordered_asc } + scope :future_or_present, -> { where('from_day >= :today', today: Date.today).ordered_asc } + scope :present, -> { where('(from_day >= :today AND to_day IS NULL) OR (from_day >= :today AND to_day <= :today)', today: Date.today).ordered_asc } + scope :archive, -> { where('to_day < :today', today: Date.today).ordered_desc } + scope :past, -> { archive } validates_presence_of :from_day, :title validate :to_day_after_from_day, :to_hour_after_from_hour_on_same_day diff --git a/app/models/communication/website/category.rb b/app/models/communication/website/category.rb index 842ec319a0dd014ab0decf0400c948f72704e778..571f5bacf300cd292c804161cf5a68b71074f0d2 100644 --- a/app/models/communication/website/category.rb +++ b/app/models/communication/website/category.rb @@ -53,9 +53,6 @@ class Communication::Website::Category < ApplicationRecord include WithTree include WithUniversity - has_one :imported_category, - class_name: 'Communication::Website::Imported::Category', - dependent: :destroy belongs_to :university belongs_to :parent, class_name: 'Communication::Website::Category', @@ -63,9 +60,6 @@ class Communication::Website::Category < ApplicationRecord belongs_to :program, class_name: 'Education::Program', optional: true - has_one :imported_category, - class_name: 'Communication::Website::Imported::Category', - dependent: :destroy has_many :children, class_name: 'Communication::Website::Category', foreign_key: :parent_id, diff --git a/app/models/communication/website/imported.rb b/app/models/communication/website/imported.rb deleted file mode 100644 index 1f0a38d5cba2ba932dea24a6facc59dcddd68a81..0000000000000000000000000000000000000000 --- a/app/models/communication/website/imported.rb +++ /dev/null @@ -1,5 +0,0 @@ -module Communication::Website::Imported - def self.table_name_prefix - 'communication_website_imported_' - end -end diff --git a/app/models/communication/website/imported/author.rb b/app/models/communication/website/imported/author.rb deleted file mode 100644 index 46d127f66b10ded1e9d18b46bb903bd3b3f237c4..0000000000000000000000000000000000000000 --- a/app/models/communication/website/imported/author.rb +++ /dev/null @@ -1,73 +0,0 @@ -# == Schema Information -# -# Table name: communication_website_imported_authors -# -# id :uuid not null, primary key -# data :jsonb -# description :text -# identifier :string -# name :string -# slug :string -# created_at :datetime not null -# updated_at :datetime not null -# author_id :uuid indexed -# university_id :uuid not null, indexed -# website_id :uuid not null, indexed -# -# Indexes -# -# idx_communication_website_imported_auth_on_author (author_id) -# idx_communication_website_imported_auth_on_university (university_id) -# idx_communication_website_imported_auth_on_website (website_id) -# -# Foreign Keys -# -# fk_rails_71485b09cb (website_id => communication_website_imported_websites.id) -# fk_rails_902ba99cba (university_id => universities.id) -# fk_rails_e37b63f880 (author_id => university_people.id) -# -class Communication::Website::Imported::Author < ApplicationRecord - include WithUniversity - - belongs_to :website, - class_name: 'Communication::Website::Imported::Website' - belongs_to :author, - class_name: 'University::Person', - optional: true - - before_validation :sync - - default_scope { order(:name) } - - def data=(value) - super value - self.slug = value['slug'] - self.name = value['name'] - self.description = value['description'] - end - - def to_s - "#{name}" - end - - protected - - def sync - if author.nil? - self.author = University::Person.new university: university, language: university.default_language - self.author.last_name = "Doe" # No title yet - self.author.first_name = "John" # No title yet - self.author.save - end - puts "Update author #{author.id}" - sanitized_name = Wordpress.clean_string(self.name.to_s).split(' ') - sanitized_biography = Wordpress.clean_string description.to_s - unless sanitized_name.blank? - author.first_name = sanitized_name.first - author.last_name = sanitized_name[1..10].join(' ') - end - author.slug = slug - author.biography = sanitized_biography unless sanitized_biography.blank? - author.save - end -end diff --git a/app/models/communication/website/imported/category.rb b/app/models/communication/website/imported/category.rb deleted file mode 100644 index 022282e4dca9a2dc363088659e5ad6d42b649e4a..0000000000000000000000000000000000000000 --- a/app/models/communication/website/imported/category.rb +++ /dev/null @@ -1,75 +0,0 @@ -# == Schema Information -# -# Table name: communication_website_imported_categories -# -# id :uuid not null, primary key -# data :jsonb -# description :text -# identifier :string -# name :string -# parent :string -# slug :string -# url :string -# created_at :datetime not null -# updated_at :datetime not null -# category_id :uuid indexed -# university_id :uuid not null, indexed -# website_id :uuid not null, indexed -# -# Indexes -# -# idx_communication_website_imported_cat_on_category (category_id) -# idx_communication_website_imported_cat_on_university (university_id) -# idx_communication_website_imported_cat_on_website (website_id) -# -# Foreign Keys -# -# fk_rails_409ee93de2 (website_id => communication_website_imported_websites.id) -# fk_rails_43df612943 (category_id => communication_website_categories.id) -# fk_rails_f6070ca53d (university_id => universities.id) -# -class Communication::Website::Imported::Category < ApplicationRecord - include WithUniversity - - belongs_to :website, - class_name: 'Communication::Website::Imported::Website' - belongs_to :category, - class_name: 'Communication::Website::Category', - optional: true - alias_attribute :generated_object, :category - - before_validation :sync - - default_scope { order(:name) } - - def data=(value) - super value - self.url = value['link'] - self.slug = value['slug'] - self.name = value['name'] - self.description = value['description'] - self.parent = value['parent'] - end - - def to_s - "#{name}" - end - - protected - - def sync - if category.nil? - self.category = Communication::Website::Category.new university: university, - website: website.website, # Real website, not imported website - language: website.website.default_language - self.category.name = "Untitled" # No title yet - self.category.save - end - puts "Update category #{category.id}" - sanitized_name = Wordpress.clean_string self.name.to_s - category.name = sanitized_name unless sanitized_name.blank? # If there is no title, leave it with "Untitled" - category.slug = slug - category.meta_description = Wordpress.clean_string description.to_s - category.save - end -end diff --git a/app/models/communication/website/imported/medium.rb b/app/models/communication/website/imported/medium.rb deleted file mode 100644 index 0f3ab3b074d0a0644af758e0dd88e05bea0ca5ea..0000000000000000000000000000000000000000 --- a/app/models/communication/website/imported/medium.rb +++ /dev/null @@ -1,62 +0,0 @@ -# == Schema Information -# -# Table name: communication_website_imported_media -# -# id :uuid not null, primary key -# data :jsonb -# file_url :text -# filename :string -# identifier :string -# mime_type :string -# variant_urls :text default([]), is an Array -# created_at :datetime -# updated_at :datetime -# university_id :uuid not null, indexed -# website_id :uuid not null, indexed -# -# Indexes -# -# index_communication_website_imported_media_on_university_id (university_id) -# index_communication_website_imported_media_on_website_id (website_id) -# -# Foreign Keys -# -# fk_rails_acbe85119e (university_id => universities.id) -# fk_rails_c54ac5a28b (website_id => communication_website_imported_websites.id) -# -class Communication::Website::Imported::Medium < ApplicationRecord - include WithUniversity - - belongs_to :website, - class_name: 'Communication::Website::Imported::Website' - has_many :pages, - class_name: 'Communication::Website::Imported::Page', - foreign_key: :featured_medium_id, - dependent: :destroy - has_many :posts, - class_name: 'Communication::Website::Imported::Post', - foreign_key: :featured_medium_id, - dependent: :destroy - - has_one_attached_deletable :file - - scope :for_variant_url, -> (variant_url) { where('? = ANY(variant_urls)', variant_url) } - - def data=(value) - super value - sanitized_file_url = Addressable::URI.parse(value['source_url']).display_uri.to_s # ASCII-only for URI - self.file_url = sanitized_file_url - self.filename = File.basename(URI(file_url).path) - self.mime_type = value['mime_type'] - self.created_at = value['date_gmt'] - self.updated_at = value['modified_gmt'] - self.variant_urls = (value['media_details']['sizes'] || {}).values.map { |variant| - Addressable::URI.parse(variant['source_url']).display_uri.to_s - } - end - - def load_remote_file! - download_service = DownloadService.download(file_url) - file.attach(download_service.attachable_data) - end -end diff --git a/app/models/communication/website/imported/page.rb b/app/models/communication/website/imported/page.rb deleted file mode 100644 index e03e729fa81d54cc7bc308a7926646e58fcfb1f4..0000000000000000000000000000000000000000 --- a/app/models/communication/website/imported/page.rb +++ /dev/null @@ -1,103 +0,0 @@ -# == Schema Information -# -# Table name: communication_website_imported_pages -# -# id :uuid not null, primary key -# content :text -# data :jsonb -# excerpt :text -# identifier :string indexed -# parent :string -# path :text -# slug :text -# status :integer default(0) -# title :string -# url :text -# created_at :datetime not null -# updated_at :datetime not null -# featured_medium_id :uuid indexed -# page_id :uuid indexed -# university_id :uuid not null, indexed -# website_id :uuid not null, indexed -# -# Indexes -# -# idx_communication_website_imported_pages_on_featured_medium_id (featured_medium_id) -# index_communication_website_imported_pages_on_identifier (identifier) -# index_communication_website_imported_pages_on_page_id (page_id) -# index_communication_website_imported_pages_on_university_id (university_id) -# index_communication_website_imported_pages_on_website_id (website_id) -# -# Foreign Keys -# -# fk_rails_aa3ad9c6c8 (website_id => communication_website_imported_websites.id) -# fk_rails_df500f96c3 (page_id => communication_website_pages.id) -# fk_rails_e47b76ff30 (university_id => universities.id) -# fk_rails_e582fbdc5c (featured_medium_id => communication_website_imported_media.id) -# -class Communication::Website::Imported::Page < ApplicationRecord - include WithUniversity - - belongs_to :website, - class_name: 'Communication::Website::Imported::Website' - belongs_to :page, - class_name: 'Communication::Website::Page', - optional: true - alias_attribute :generated_object, :page - belongs_to :featured_medium, - class_name: 'Communication::Website::Imported::Medium', - optional: true - - before_validation :sync - - default_scope { order(:path) } - - def data=(value) - super value - self.url = value['link'] - self.slug = value['slug'] - self.title = value['title']['rendered'] - self.excerpt = value['excerpt']['rendered'] - self.content = value['content']['rendered'] - self.parent = value['parent'] - self.featured_medium = website.media.find_by(identifier: value['featured_media']) unless value['featured_media'] == 0 - self.created_at = value['date_gmt'] - self.updated_at = value['modified_gmt'] - end - - def to_s - "#{title}" - end - - protected - - def sync - if page.nil? - self.page = Communication::Website::Page.new university: university, - website: website.website, # Real website, not imported website - language: website.website.default_language, - parent: website.website.special_page(Communication::Website::Page::Home), - slug: path - self.page.title = "Untitled" - self.page.save - else - # Continue only if there are remote changes - # Don't touch if there are local changes (page.updated_at > updated_at) - # Don't touch if there are no remote changes (page.updated_at == updated_at) - return unless ENV['APPLICATION_ENV'] == 'development' || updated_at > page.updated_at - end - puts "Update page #{page.id}" - sanitized_title = Wordpress.clean_string self.title.to_s - page.title = sanitized_title unless sanitized_title.blank? # If there is no title, leave it with "Untitled" - page.slug = slug - page.meta_description = Wordpress.clean_string excerpt.to_s - page.published = true - page.save - - chapter = page.blocks.where(university: website.university, template_kind: :chapter).first_or_create - chapter_data = chapter.data.deep_dup - chapter_data['text'] = Wordpress.clean_html(content.to_s) - chapter.data = chapter_data - chapter.save - end -end diff --git a/app/models/communication/website/imported/post.rb b/app/models/communication/website/imported/post.rb deleted file mode 100644 index 6cd5ecf00a6cbbf727ea6ae874bccd5e9e535eec..0000000000000000000000000000000000000000 --- a/app/models/communication/website/imported/post.rb +++ /dev/null @@ -1,126 +0,0 @@ -# == Schema Information -# -# Table name: communication_website_imported_posts -# -# id :uuid not null, primary key -# author :string -# categories :jsonb -# content :text -# data :jsonb -# excerpt :text -# identifier :string -# path :text -# published_at :datetime -# slug :text -# status :integer default(0) -# title :string -# url :text -# created_at :datetime not null -# updated_at :datetime not null -# featured_medium_id :uuid indexed -# post_id :uuid indexed -# university_id :uuid not null, indexed -# website_id :uuid not null, indexed -# -# Indexes -# -# idx_communication_website_imported_posts_on_featured_medium_id (featured_medium_id) -# index_communication_website_imported_posts_on_post_id (post_id) -# index_communication_website_imported_posts_on_university_id (university_id) -# index_communication_website_imported_posts_on_website_id (website_id) -# -# Foreign Keys -# -# fk_rails_78380969b3 (featured_medium_id => communication_website_imported_media.id) -# fk_rails_a5bc137386 (university_id => universities.id) -# fk_rails_de8b4a9cfe (website_id => communication_website_imported_websites.id) -# fk_rails_f9a08c7c77 (post_id => communication_website_posts.id) -# -class Communication::Website::Imported::Post < ApplicationRecord - include WithUniversity - include Communication::Website::Imported::WithFeaturedImage - - belongs_to :website, - class_name: 'Communication::Website::Imported::Website' - belongs_to :post, - class_name: 'Communication::Website::Post', - optional: true - alias_attribute :generated_object, :post - belongs_to :featured_medium, - class_name: 'Communication::Website::Imported::Medium', - optional: true - - before_validation :sync - - default_scope { order(path: :desc) } - - def data=(value) - super value - self.url = value['link'] - self.slug = value['slug'] - self.path = URI(self.url).path - self.title = value['title']['rendered'] - self.excerpt = value['excerpt']['rendered'] - self.content = value['content']['rendered'] - self.author = value['author'] - self.categories = value['categories'] - self.created_at = value['date_gmt'] - self.updated_at = value['modified_gmt'] - self.published_at = value['date_gmt'] - self.featured_medium = website.media.find_by(identifier: value['featured_media']) unless value['featured_media'] == 0 - end - - def to_s - "#{title}" - end - - protected - - def sync - if post.nil? - self.post = Communication::Website::Post.new university: university, - website: website.website, # Real website, not imported website - language: website.website.default_language - self.post.title = "Untitled" # No title yet - self.post.save - else - # Continue only if there are remote changes, and no recent local changes - # updated_at reflects last update on wordpress, based on the last import - # Don't touch if there are local changes (post.updated_at > updated_at) - # Don't touch if there are no remote changes (post.updated_at == updated_at) - return unless ENV['APPLICATION_ENV'] == 'development' || updated_at > post.updated_at - end - puts "Update post #{post.id}" - sanitized_title = Wordpress.clean_string self.title.to_s - post.title = sanitized_title unless sanitized_title.blank? # If there is no title, leave it with "Untitled" - post.slug = slug - post.meta_description = Wordpress.clean_string excerpt.to_s - post.created_at = created_at - post.updated_at = updated_at - post.published_at = published_at if published_at - post.published = true - - sync_author - sync_categories - post.save - - chapter = post.blocks.where(university: website.university, template_kind: :chapter).first_or_create - chapter_data = chapter.data.deep_dup - chapter_data['text'] = Wordpress.clean_html(content.to_s) - chapter.data = chapter_data - chapter.save - end - - def sync_author - imported_author = website.authors.where(identifier: author).first - post.author = imported_author.author if imported_author&.author.present? - end - - def sync_categories - imported_categories = website.categories.where(identifier: categories) - imported_categories.each do |imported_category| - post.categories << imported_category.category unless post.categories.pluck(:id).include?(imported_category.category_id) - end - end - -end diff --git a/app/models/communication/website/imported/website.rb b/app/models/communication/website/imported/website.rb deleted file mode 100644 index 0e6426109becb482228823a05df9be03e10fe64b..0000000000000000000000000000000000000000 --- a/app/models/communication/website/imported/website.rb +++ /dev/null @@ -1,116 +0,0 @@ -# == Schema Information -# -# Table name: communication_website_imported_websites -# -# id :uuid not null, primary key -# status :integer default(0) -# created_at :datetime not null -# updated_at :datetime not null -# university_id :uuid not null, indexed -# website_id :uuid not null, indexed -# -# Indexes -# -# index_communication_website_imported_websites_on_university_id (university_id) -# index_communication_website_imported_websites_on_website_id (website_id) -# -# Foreign Keys -# -# fk_rails_32d782a604 (university_id => universities.id) -# fk_rails_3dbdb9cb2d (website_id => communication_websites.id) -# -class Communication::Website::Imported::Website < ApplicationRecord - include WithUniversity - - belongs_to :website, - class_name: 'Communication::Website' - has_many :authors, - class_name: 'Communication::Website::Imported::Author', - dependent: :destroy - has_many :categories, - class_name: 'Communication::Website::Imported::Category', - dependent: :destroy - has_many :media, - class_name: 'Communication::Website::Imported::Medium', - dependent: :destroy - has_many :pages, - class_name: 'Communication::Website::Imported::Page', - dependent: :destroy - has_many :posts, - class_name: 'Communication::Website::Imported::Post', - dependent: :destroy - - def run! - sync_authors - sync_categories - sync_media - sync_pages - sync_posts - website.save_and_sync - end - handle_asynchronously :run!, queue: 'default' - - def uploads_url - @uploads_url ||= "#{website.url}/wp-content/uploads" - end - - protected - - def wordpress - @wordpress ||= Wordpress.new website.url - end - - def sync_authors - wordpress.authors.each do |data| - author = authors.where(university: university, identifier: data['id']).first_or_initialize - author.data = data - author.save - end - end - - def sync_categories - wordpress.categories.each do |data| - category = categories.where(university: university, identifier: data['id']).first_or_initialize - category.data = data - category.save - end - sync_tree(categories) - end - - def sync_media - wordpress.media.each do |data| - medium = media.where(university: university, identifier: data['id']).first_or_initialize - medium.data = data - medium.save - end - end - - def sync_pages - wordpress.pages.each do |data| - page = pages.where(university: university, identifier: data['id']).first_or_initialize - page.data = data - page.save - end - sync_tree(pages) - end - - def sync_posts - wordpress.posts.each do |data| - post = posts.where(university: university, identifier: data['id']).first_or_initialize - post.data = data - post.save - end - end - - def sync_tree(elements) - # The order will treat parents before children - elements.order(:url).find_each do |element| - next if element.parent.blank? - parent = elements.where(identifier: element.parent).first - next if parent.nil? - generated_element = element.generated_object - generated_element.parent = parent.generated_object - generated_element.save - end - end -end diff --git a/app/models/communication/website/imported/with_featured_image.rb b/app/models/communication/website/imported/with_featured_image.rb deleted file mode 100644 index 000d0be664295352cbb1bb7354660e25dfdc0867..0000000000000000000000000000000000000000 --- a/app/models/communication/website/imported/with_featured_image.rb +++ /dev/null @@ -1,48 +0,0 @@ -module Communication::Website::Imported::WithFeaturedImage - extend ActiveSupport::Concern - - included do - after_commit :sync_featured_image, on: [:create, :update] - end - - def sync_featured_image - return unless ENV['APPLICATION_ENV'] == 'development' || updated_at > generated_object.updated_at - - if featured_medium.present? - sync_featured_image_from_featured_medium - else - sync_featured_image_from_content - end - end - - def sync_featured_image_from_featured_medium - unless featured_medium.file.attached? - featured_medium.load_remote_file! - featured_medium.save - end - generated_object.featured_image.attach( - io: URI.open(featured_medium.file.blob.url), - filename: featured_medium.file.blob.filename, - content_type: featured_medium.file.blob.content_type - ) - end - - def sync_featured_image_from_content - chapter = generated_object.blocks.where(university: website.university, template_kind: :chapter).first_or_create - chapter_data = chapter.data.deep_dup - fragment = Nokogiri::HTML.fragment(chapter_data['text'].to_s) - image = fragment.css('img').first - if image.present? - begin - url = image.attr('src') - download_service = DownloadService.download(url) - generated_object.featured_image.attach(download_service.attachable_data) - image.remove - chapter_data['text'] = fragment.to_html - chapter.data = chapter_data - chapter.save - rescue - end - end - end -end \ No newline at end of file diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index 04ae61204187e7e9e90e71fcd6903d5b48d37013..9c7f9d5c17bec1bc40f634314cd647d31450213e 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -72,9 +72,6 @@ class Communication::Website::Page < ApplicationRecord class_name: 'Communication::Website::Page', optional: true belongs_to :language - has_one :imported_page, - class_name: 'Communication::Website::Imported::Page', - dependent: :nullify has_many :children, class_name: 'Communication::Website::Page', foreign_key: :parent_id, @@ -117,6 +114,10 @@ class Communication::Website::Page < ApplicationRecord abouts_with_page_block end + def best_title + breadcrumb_title.blank? ? title : breadcrumb_title + end + def to_s "#{title}" end diff --git a/app/models/communication/website/post.rb b/app/models/communication/website/post.rb index 1d6d33d22ae24189b54e022a755ae2fc52143b9b..4ed2039ef5b66625cd4f69909bd9c4f20b109907 100644 --- a/app/models/communication/website/post.rb +++ b/app/models/communication/website/post.rb @@ -53,9 +53,6 @@ class Communication::Website::Post < ApplicationRecord has_summernote :text # TODO: Remove text attribute - has_one :imported_post, - class_name: 'Communication::Website::Imported::Post', - dependent: :destroy belongs_to :author, class_name: 'University::Person', optional: true diff --git a/app/models/communication/website/with_import.rb b/app/models/communication/website/with_import.rb deleted file mode 100644 index bb7576c4d7dfc38d3dc2ebc19f3fc6333eae84a1..0000000000000000000000000000000000000000 --- a/app/models/communication/website/with_import.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Communication::Website::WithImport - extend ActiveSupport::Concern - - included do - has_one :imported_website, - class_name: 'Communication::Website::Imported::Website', - dependent: :destroy - end - - def import! - create_imported_website(university: university) unless imported? - imported_website.run! - reload - end - - def imported? - !imported_website.nil? - end -end diff --git a/app/models/concerns/with_tree.rb b/app/models/concerns/with_tree.rb index 94e88ff0ecf1b0ca3251d1dbf6aff92bf2b7f4c4..85f09725d2b3574807c4869a351af1d7a6707e02 100644 --- a/app/models/concerns/with_tree.rb +++ b/app/models/concerns/with_tree.rb @@ -18,6 +18,10 @@ module WithTree : [] end + def ancestors_and_self + ancestors + [self] + end + def descendants has_children? ? children.ordered.map { |child| [child, child.descendants].flatten }.flatten : [] diff --git a/app/models/university/person.rb b/app/models/university/person.rb index 8ff4a620267be62f95c37c61c1ce46048ac2b74e..4e0f9f82c1825b45551fb6a03b96eba1f8204c18 100644 --- a/app/models/university/person.rb +++ b/app/models/university/person.rb @@ -99,11 +99,6 @@ class University::Person < ApplicationRecord foreign_key: :author_id, dependent: :nullify - has_many :communication_website_imported_authors, - class_name: "Communication::Website::Imported::Author", - foreign_key: :author_id, - dependent: :destroy - has_many :involvements, class_name: 'University::Person::Involvement', dependent: :destroy diff --git a/app/views/admin/application/static/_breadcrumbs.html.erb b/app/views/admin/application/static/_breadcrumbs.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..819e44a2dfaea4fb581fba483f38a5ae29e16fba --- /dev/null +++ b/app/views/admin/application/static/_breadcrumbs.html.erb @@ -0,0 +1,6 @@ +breadcrumbs: +<% pages.each do |page| %> + - title: "<%= page.best_title %>" + path: "<%= page.path %>" +<% end %> + - title: "<%= current.to_s %>" \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/agenda/_edit.html.erb b/app/views/admin/communication/blocks/templates/agenda/_edit.html.erb index d7e74067071ff9de21f63aae626efe918df7a7ab..4a7e9278d614e6f44c51b08c6d58e6676b0c6508 100644 --- a/app/views/admin/communication/blocks/templates/agenda/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/agenda/_edit.html.erb @@ -1,8 +1,12 @@ +<%= block_component_edit block, :layout %> + <div class="row pure__row--small"> <div class="col-xl-6"> <%= block_component_edit block, :description %> </div> <div class="col-xl-6"> - <%= block_component_edit block, :events_quantity %> + <%= block_component_edit block, :quantity %> </div> </div> + +<%= block_component_edit block, :time %> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/agenda/_static.html.erb b/app/views/admin/communication/blocks/templates/agenda/_static.html.erb index c5bc832a210a8fda5245866334cd6761dcf07ffc..ab663bee370e0c454303cb16fcbf2edf1cd79ce6 100644 --- a/app/views/admin/communication/blocks/templates/agenda/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/agenda/_static.html.erb @@ -1,19 +1,7 @@ + layout: <%= block.template.layout %> <%= block_component_static block, :description %> - elements: + events: <% block.template.selected_events.each do |element| %> - - title: >- - <%= prepare_text_for_static element.to_s %> - summary: >- - <%= prepare_text_for_static element.summary, 6 %> - slug: "<%= element.slug %>" - url: "<%= element.current_permalink_in_website(@website)&.path %>" -<%= render 'admin/communication/websites/agenda/events/dates_static', event: element, depth: 5 %> -<% if element.best_featured_image.attached? %> - image: - id: "<%= element.best_featured_image.blob.id %>" - alt: >- - <%= prepare_text_for_static element.best_featured_image_alt, 7 %> - credit: >- - <%= prepare_html_for_static element.best_featured_image_credit, @website.university %> -<% end %> + - path: "<%= element.current_permalink_in_website(@website)&.path %>" + file: "<%= element.git_path(@website) %>" <% end %> diff --git a/app/views/admin/communication/blocks/templates/organizations/_static.html.erb b/app/views/admin/communication/blocks/templates/organizations/_static.html.erb index 5713921b799cbd659457202b1e87c7bc7dc9f6c6..4164446aa684b27ce516254c71ef3c47848cb005 100644 --- a/app/views/admin/communication/blocks/templates/organizations/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/organizations/_static.html.erb @@ -6,35 +6,11 @@ <% next if element.best_name.blank? %> <% if element.organization %> - slug: "<%= element.organization.slug %>" + external: false <% else %> <%= block_component_static block, :name, template: element, depth: 4, list: true %> <%= block_component_static block, :url, template: element, depth: 5 %> + external: true logo: "<%= element.logo_component.blob&.id %>" <% end %> -<% end %> - elements: -<% block.template.elements.each do |element| %> - - title: >- - <%= prepare_text_for_static element.name %> -<% if element.organization %> - kind: "osuny" - slug: "<%= element.organization.slug %>" - url: "<%= element.organization.current_permalink_in_website(@website)&.path %>" - logo: -<% if element.organization.logo.attached? %> - light_background: - id: "<%= element.organization.logo.blob.id %>" -<% end %> -<% if element.organization.logo_on_dark_background.attached? %> - dark_background: - id: "<%= element.organization.logo_on_dark_background.blob.id %>" -<% end %> -<% else %> - kind: "external" - url: "<%= element.url %>" -<% if element.logo_component.blob %> - logo: - id: "<%= element.logo_component.blob&.id %>" -<% end %> -<% end %> <% end %> diff --git a/app/views/admin/communication/blocks/templates/pages/_static.html.erb b/app/views/admin/communication/blocks/templates/pages/_static.html.erb index 7f3504a31f8fa0c0f5bd00089cf6c364d4dd8dae..f73d63e99e3f91104d5ebe341b4eab050866b318 100644 --- a/app/views/admin/communication/blocks/templates/pages/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/pages/_static.html.erb @@ -1,5 +1,11 @@ -<% if block.template.page %> - page: <%= block.template.page.path %> +<% +if block.template.page + page = block.template.page +%> + page: + path: "<%= page.path %>" + slug: "<%= page.slug %>" + file: "<%= page.git_path(@website) %>" <% end %> show_main_description: <%= block.template.show_main_description %> show_descriptions: <%= block.template.show_description %> @@ -7,26 +13,8 @@ layout: <%= block.template.layout %> pages: <% block.template.selected_pages.each do |element| %> - - page: "<%= element.path %>" - slug: "<%= element.path %>" -<% end %> - elements: -<% block.template.selected_pages.each do |element| %> - - title: >- - <%= prepare_text_for_static element.title %> - summary: >- - <%= prepare_text_for_static element.summary, 6 %> + - path: "<%= element.path %>" slug: "<%= element.slug %>" - path: "<%= element.path %>" - url: "<%= element.current_permalink_in_website(@website)&.path %>" - bodyclass: >- - <%= prepare_text_for_static element.bodyclass, 6 %> -<% if element.best_featured_image.attached? %> - image: - id: "<%= element.best_featured_image.blob.id %>" - alt: >- - <%= prepare_text_for_static element.best_featured_image_alt, 7 %> - credit: >- - <%= prepare_html_for_static element.best_featured_image_credit, @website.university %> -<% end %> + file: "<%= element.git_path(@website) %>" + external: false <% end %> diff --git a/app/views/admin/communication/blocks/templates/people/_static.html.erb b/app/views/admin/communication/blocks/templates/people/_static.html.erb deleted file mode 100644 index f81df66ce2ffc051ef54a5590fc612424c5f581c..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/blocks/templates/people/_static.html.erb +++ /dev/null @@ -1,29 +0,0 @@ -<%= block_component_static block, :description %> -<%= block_component_static block, :with_link %> -<%= block_component_static block, :with_photo %> - persons: -<% block.template.elements.each do |element| %> -<% next unless element.person %> - - slug: "<%= element.person.slug %>" -<%= block_component_static block, :role, template: element, depth: 5 %> -<% end %> - elements: -<% block.template.elements.each do |element| - person = element.person - next unless person -%> - - title: >- - <%= prepare_text_for_static person.to_s %> - summary: >- -<% if element.role.present? %> - <%= prepare_text_for_static element.role, 6 %> -<% else %> - <%= prepare_text_for_static person.summary, 6 %> -<% end %> - kind: "osuny" - slug: "<%= person.slug %>" - url: "<%= person.current_permalink_in_website(@website)&.path %>" -<% if person.best_picture.attached? %> - picture: "<%= person.best_picture.blob.id %>" -<% end %> -<% end %> diff --git a/app/views/admin/communication/blocks/templates/people/_edit.html.erb b/app/views/admin/communication/blocks/templates/persons/_edit.html.erb similarity index 100% rename from app/views/admin/communication/blocks/templates/people/_edit.html.erb rename to app/views/admin/communication/blocks/templates/persons/_edit.html.erb diff --git a/app/views/admin/communication/blocks/templates/people/_show.html.erb b/app/views/admin/communication/blocks/templates/persons/_show.html.erb similarity index 97% rename from app/views/admin/communication/blocks/templates/people/_show.html.erb rename to app/views/admin/communication/blocks/templates/persons/_show.html.erb index 2f936778f1b1d2be90f1026561ff2309c5375be0..33a7dcbb8b0a50aa3b5d84090a8b28a607d28c03 100644 --- a/app/views/admin/communication/blocks/templates/people/_show.html.erb +++ b/app/views/admin/communication/blocks/templates/persons/_show.html.erb @@ -1,5 +1,5 @@ <% -class_name = "block block-people" +class_name = "block block-persons" unless block.title.blank? class_name += " block-with-title" end diff --git a/app/views/admin/communication/blocks/templates/people/_snippet.html.erb b/app/views/admin/communication/blocks/templates/persons/_snippet.html.erb similarity index 100% rename from app/views/admin/communication/blocks/templates/people/_snippet.html.erb rename to app/views/admin/communication/blocks/templates/persons/_snippet.html.erb diff --git a/app/views/admin/communication/blocks/templates/persons/_static.html.erb b/app/views/admin/communication/blocks/templates/persons/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..c23bd8489bb2464bc260e65cc89628f615d7ad54 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/persons/_static.html.erb @@ -0,0 +1,10 @@ +<%= block_component_static block, :description %> +<%= block_component_static block, :with_link %> +<%= block_component_static block, :with_photo %> + persons: +<% block.template.elements.each do |element| %> +<% next unless element.person %> + - slug: "<%= element.person.slug %>" + external: false +<%= block_component_static block, :role, template: element, depth: 5 %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/posts/_static.html.erb b/app/views/admin/communication/blocks/templates/posts/_static.html.erb index f9d7f76f1a3a5dbefe56eb285858402e34a58b1b..167e7e361c87955622b10570652ec5db3a6da0fa 100644 --- a/app/views/admin/communication/blocks/templates/posts/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/posts/_static.html.erb @@ -7,38 +7,4 @@ posts: <% block.template.selected_posts.each do |post| %> - "<%= post.static_path %>" -<% end %> - elements: -<% block.template.selected_posts.each do |element| %> - - title: >- - <%= prepare_text_for_static element.title %> - summary: >- - <%= prepare_text_for_static element.summary, 6 %> - slug: "<%= element.slug %>" - path: "<%= element.path %>" - url: "<%= element.current_permalink_in_website(@website)&.path %>" - date: "<%= element.published_at&.iso8601 %>" -<% if element.best_featured_image.attached? %> - image: - id: "<%= element.best_featured_image.blob.id %>" - alt: >- - <%= prepare_text_for_static element.best_featured_image_alt, 7 %> - credit: >- - <%= prepare_html_for_static element.best_featured_image_credit, @website.university %> -<% end %> - categories: -<% element.categories.each do |category| %> - - title: >- - <%= prepare_text_for_static category.name, 8 %> - slug: "<%= category.slug %>" - path: "<%= category.path %>" - url: "<%= category.current_permalink_in_website(@website)&.path %>" -<% end %> -<% if element.author %> - author: - name: >- - <%= prepare_text_for_static element.author.name, 7 %> - slug: "<%= element.author.slug %>" - url: "<%= element.author.current_permalink_in_website(@website)&.path %>" -<% end %> <% end %> diff --git a/app/views/admin/communication/blocks/templates/programs/_static.html.erb b/app/views/admin/communication/blocks/templates/programs/_static.html.erb index cfbdd424f7dc176a8461b66901d78664ec28e584..787e6871c92537ec41a975e6ce34a90ff5b8bf2e 100644 --- a/app/views/admin/communication/blocks/templates/programs/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/programs/_static.html.erb @@ -2,31 +2,4 @@ <% block.template.elements.each do |element| %> <% next unless element.program %> - path: "<%= element.program.path %>" -<% end %> - elements: -<% block.template.elements.each do |element| %> -<% program = element.program %> -<% next unless program %> - - title: >- - <%= prepare_text_for_static element.program.name %> - summary: >- - <%= prepare_text_for_static element.program.summary, 6 %> - slug: "<%= program.slug %>" - path: "<%= program.path %>" - url: "<%= program.current_permalink_in_website(@website)&.path %>" -<% if program.best_featured_image.attached? %> - image: - id: "<%= program.best_featured_image.blob.id %>" - alt: >- - <%= prepare_text_for_static program.best_featured_image_alt, 7 %> - credit: >- - <%= prepare_html_for_static program.best_featured_image_credit, @website.university %> -<% end %> -<% diploma = program.diploma %> -<% if diploma.present? %> - diploma: - - title: >- - <%= prepare_text_for_static diploma.name %> - slug: "<%= diploma.slug %>" - url: "<%= diploma.current_permalink_in_website(@website)&.path %>"<% end %> -<% end %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/communication/extranets/documents/show.html.erb b/app/views/admin/communication/extranets/documents/show.html.erb index 5a1494f7532a8eba7be06c1dd4f41ef7bb5e7c9f..0dc09c3054efd8bd7a6d0a2d949fceeac9923be1 100644 --- a/app/views/admin/communication/extranets/documents/show.html.erb +++ b/app/views/admin/communication/extranets/documents/show.html.erb @@ -12,7 +12,7 @@ <%= osuny_label Communication::Extranet::Document.human_attribute_name('published') %> <p> <%= t @document.published %><% if @document.published %>, - <%= l @document.published_at.to_date, format: :long %> + <%= l @document.published_at, format: :date_with_explicit_month %> <% end %> </p> <% if @document.category %> diff --git a/app/views/admin/communication/extranets/posts/show/_metadata.html.erb b/app/views/admin/communication/extranets/posts/show/_metadata.html.erb index 9c581f3d28c21178ccf69b928ec9ec5226dd4d7c..456baa834bc32280cfb8a58329b646b1f0b8139c 100644 --- a/app/views/admin/communication/extranets/posts/show/_metadata.html.erb +++ b/app/views/admin/communication/extranets/posts/show/_metadata.html.erb @@ -2,7 +2,7 @@ <%= osuny_label t('metadata') %><br> <% if @post.published %> - <%= t('communication.extranet.post.metadata.published_on', date: l(@post.published_at.to_date, format: :long)) %> + <%= t('communication.extranet.post.metadata.published_on', date: l(@post.published_at, format: :date_with_explicit_month)) %> <% if @post.pinned %> <%= t('communication.extranet.post.metadata.and_pinned') %> <% end %> diff --git a/app/views/admin/communication/websites/agenda/events/static.html.erb b/app/views/admin/communication/websites/agenda/events/static.html.erb index fa989ad67e10d32d998c6e037af8dd0eb1853a55..9e83a432b2ee92ada11d4c303e668f8f92799aa1 100644 --- a/app/views/admin/communication/websites/agenda/events/static.html.erb +++ b/app/views/admin/communication/websites/agenda/events/static.html.erb @@ -1,6 +1,9 @@ --- title: "<%= @about.title %>" <%= render 'admin/communication/websites/agenda/events/dates_static', event: @about %> +<%= render 'admin/application/static/breadcrumbs', + pages: @website.special_page(Communication::Website::Page::CommunicationAgenda).ancestors_and_self, + current: @about %> weight: <%= @about.distance_in_days %> <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: false, toc_offcanvas: false %> diff --git a/app/views/admin/communication/websites/import.html.erb b/app/views/admin/communication/websites/import.html.erb deleted file mode 100644 index e40e2665d503ab01a38c6c80c396eb177df00019..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/websites/import.html.erb +++ /dev/null @@ -1,172 +0,0 @@ -<% content_for :title, @website %> -<% content_for :action_bar_right do %> - <%= link_to t('communication.website.imported.refresh'), - import_admin_communication_website_path, - method: :post, - class: button_classes %> -<% end %> - -<div class="card"> - <div class="card-header"> - <h2><%= @imported_posts.total_count %> posts</h2> - </div> - <div class="table-responsive"> - <table class="<%= table_classes %>"> - <thead> - <tr> - <th><%= Communication::Website::Imported::Post.human_attribute_name('title') %></th> - <th><%= Communication::Website::Imported::Post.human_attribute_name('original') %></th> - <th class="text-end" width="150">Generated post</th> - </tr> - </thead> - <tbody> - <% @imported_posts.each do |post| %> - <tr> - <td><%= post %></td> - <td class="small"><%= link_to post.path, post.url, target: :_blank %></td> - <td class="text-end"> - <%= link_to t('show'), - admin_communication_website_post_path(website_id: @website.id, id: post.post.id), - class: button_classes if post.post.present? %> - </td> - </tr> - <% end %> - </tbody> - </table> - </div> - <div class="card-footer"> - <%= paginate @imported_posts, param_name: :posts_page, theme: 'bootstrap-5' %> - </div> -</div> - -<div class="card mt-5"> - <div class="card-header"> - <h2><%= @imported_pages.total_count %> pages</h2> - </div> - <div class="table-responsive"> - <table class="<%= table_classes %>"> - <thead> - <tr> - <th><%= Communication::Website::Imported::Page.human_attribute_name('title') %></th> - <th><%= Communication::Website::Imported::Page.human_attribute_name('original') %></th> - <th class="text-end" width="150">Generated page</th> - </tr> - </thead> - <tbody> - <% @imported_pages.each do |page| %> - <tr> - <td><%= page %></td> - <td class="small"><%= link_to page.path, page.url, target: :_blank %></td> - <td class="text-end"> - <%= link_to t('show'), - admin_communication_website_page_path(website_id: @website.id, id: page.page.id), - class: button_classes if page.page.present? %> - </td> - </tr> - <% end %> - </tbody> - </table> - </div> - <div class="card-footer"> - <%= paginate @imported_pages, param_name: :pages_page, theme: 'bootstrap-5' %> - </div> -</div> - -<div class="card mt-5"> - <div class="card-header"> - <h2><%= @imported_media.total_count %> media (<%= number_to_human_size(@imported_media_total_size) %>)</h2> - </div> - <div class="table-responsive"> - <table class="<%= table_classes %>"> - <thead> - <tr> - <th><%= Communication::Website::Imported::Medium.human_attribute_name('filename') %></th> - <th><%= t('communication.website.imported.media.file_size') %></th> - <th class="text-end" width="150"> </th> - </tr> - </thead> - <tbody> - <% @imported_media.each do |medium| %> - <tr> - <td><%= medium.filename %></td> - <td><%= number_to_human_size(medium.file.blob.byte_size) if medium&.file&.attached? %></td> - <td class="text-end"> - <% if medium&.file&.attached? %> - <%= link_to t('show'), - url_for(medium.file), - class: button_classes, - target: :blank %> - <% else %> - <%= t('communication.website.imported.media.not_imported_yet') %> - <% end %> - </td> - </tr> - <% end %> - </tbody> - </table> - </div> - <div class="card-footer"> - <%= paginate @imported_media, param_name: :media_page, theme: 'bootstrap-5' %> - </div> -</div> - -<div class="card mt-5"> - <div class="card-header"> - <h2><%= @imported_authors.total_count %> authors</h2> - </div> - <div class="table-responsive"> - <table class="<%= table_classes %>"> - <thead> - <tr> - <th><%= University::Person.human_attribute_name('name') %></th> - <th class="text-end" width="150"> </th> - </tr> - </thead> - <tbody> - <% @imported_authors.each do |author| %> - <tr> - <td><%= author.name %></td> - <td class="text-end"> - <%= link_to t('show'), - admin_communication_website_author_path(website_id: @website.id, id: author.author.id), - class: button_classes %> - </td> - </tr> - <% end %> - </tbody> - </table> - </div> - <div class="card-footer"> - <%= paginate @imported_authors, param_name: :authors_page, theme: 'bootstrap-5' %> - </div> -</div> - -<div class="card mt-5"> - <div class="card-header"> - <h2><%= @imported_categories.count %> categories</h2> - </div> - <div class="table-responsive"> - <table class="<%= table_classes %>"> - <thead> - <tr> - <th><%= Communication::Website::Category.human_attribute_name('name') %></th> - <th><%= Communication::Website::Imported::Category.human_attribute_name('original') %></th> - <th class="text-end" width="150"> </th> - </tr> - </thead> - <tbody> - <% @imported_categories.each do |category| %> - <tr> - <td><%= category.name %></td> - <td class="small"><%= link_to category.url, category.url, target: :_blank %></td> - <td class="text-end"> - <%= link_to t('show'), - admin_communication_website_category_path(website_id: @website.id, id: category.category.id), - class: button_classes %> - </td> - </tr> - <% end %> - </tbody> - </table> - </div> -</div> diff --git a/app/views/admin/communication/websites/pages/static.html.erb b/app/views/admin/communication/websites/pages/static.html.erb index 19abb0ecda59f3a8072873047ad86fb180dac9e2..21804c972a9f5d8e079c3f3aa3af899b5f8ffc3f 100644 --- a/app/views/admin/communication/websites/pages/static.html.erb +++ b/app/views/admin/communication/websites/pages/static.html.erb @@ -1,7 +1,9 @@ --- -title: > - <%= @about.title %> -breadcrumb_title: "<%= @about.breadcrumb_title.blank? ? @about.title : @about.breadcrumb_title %>" +title: "<%= @about.title %>" +breadcrumb_title: "<%= @about.best_title %>" +<%= render 'admin/application/static/breadcrumbs', + pages: @about.ancestors, + current: @about %> <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design' %> <% if @about.static_layout %> @@ -25,7 +27,7 @@ children: @about.children.published.ordered.each do |child| next unless child.is_listed_among_children? %> - - <%= child.path %> + - "<%= child.git_path(@website) %>" <% end %> <% end %> <%= render 'admin/application/meta_description/static' %> diff --git a/app/views/admin/communication/websites/posts/static.html.erb b/app/views/admin/communication/websites/posts/static.html.erb index 8f4dc2b7e390a5c2b98e07484ca4e60a2da92ad0..0c17c1a6a04ea6d446c9363a908100bc67cc4bac 100644 --- a/app/views/admin/communication/websites/posts/static.html.erb +++ b/app/views/admin/communication/websites/posts/static.html.erb @@ -1,6 +1,9 @@ --- title: "<%= @about.title %>" date: "<%= @about.published_at&.iso8601 %>" +<%= render 'admin/application/static/breadcrumbs', + pages: @website.special_page(Communication::Website::Page::CommunicationPost).ancestors_and_self, + current: @about %> <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: false, toc_offcanvas: false %> <% if @about.pinned %> diff --git a/app/views/admin/communication/websites/show.html.erb b/app/views/admin/communication/websites/show.html.erb index a6687f6833d72ce77134a9c54e65f5fb3bc4760c..6b673312c89f6fd32bfbbc2bb578cb37a3303a50 100644 --- a/app/views/admin/communication/websites/show.html.erb +++ b/app/views/admin/communication/websites/show.html.erb @@ -22,18 +22,6 @@ <% content_for :action_bar_left do %> <%= destroy_link @website %> - <% if can? :read, Communication::Website::Imported::Website %> - <% if @website.imported? %> - <%= link_to t('communication.website.imported.show'), - import_admin_communication_website_path, - class: button_classes %> - <% else %> - <%= link_to t('communication.website.imported.launch'), - import_admin_communication_website_path, - method: :post, - class: button_classes %> - <% end %> - <% end %> <%= static_link static_admin_communication_website_path(@website) %> <% end %> diff --git a/app/views/admin/university/organizations/static.html.erb b/app/views/admin/university/organizations/static.html.erb index 9a7848d6108b35155a0e585f79ca05ccd7905c45..9a05c35d08381e85697cb48d835ecd1b5bfd7f4e 100644 --- a/app/views/admin/university/organizations/static.html.erb +++ b/app/views/admin/university/organizations/static.html.erb @@ -1,6 +1,9 @@ --- title: > <%= @about.to_s %> +<%= render 'admin/application/static/breadcrumbs', + pages: @website.special_page(Communication::Website::Page::Organization).ancestors_and_self, + current: @about %> <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: true, toc_offcanvas: true %> kind: diff --git a/app/views/admin/university/people/administrators/static.html.erb b/app/views/admin/university/people/administrators/static.html.erb index 286718254a26cc80a23b5781399c066f0eed9c4d..43ab4f75ec114df29a6568ef581b7c350d477662 100644 --- a/app/views/admin/university/people/administrators/static.html.erb +++ b/app/views/admin/university/people/administrators/static.html.erb @@ -1,6 +1,14 @@ --- title: > Responsabilités de <%= @about.to_s %> +breadcrumbs: +<% @website.special_page(Communication::Website::Page::Person).ancestors_and_self.each do |page| %> + - title: "<%= page.best_title %>" + path: "<%= page.path %>" +<% end %> + - title: "<%= @about.to_s %>" + path: "<%= @about.person.current_permalink_in_website(@website)&.path %>" + - title: "Responsabilités" <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: true, toc_offcanvas: true %> person: > diff --git a/app/views/admin/university/people/authors/static.html.erb b/app/views/admin/university/people/authors/static.html.erb index e44ee10cea02e1831dbb6bd7ae35b32ea5d56068..810120269f60e3be81bcaadb55a4a79f61576209 100644 --- a/app/views/admin/university/people/authors/static.html.erb +++ b/app/views/admin/university/people/authors/static.html.erb @@ -1,6 +1,14 @@ --- title: > Actualités de <%= @about.to_s %> +breadcrumbs: +<% @website.special_page(Communication::Website::Page::Person).ancestors_and_self.each do |page| %> + - title: "<%= page.best_title %>" + path: "<%= page.path %>" +<% end %> + - title: "<%= @about.to_s %>" + path: "<%= @about.person.current_permalink_in_website(@website)&.path %>" + - title: "Actualités" <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: true, toc_offcanvas: true %> person: > diff --git a/app/views/admin/university/people/researchers/static.html.erb b/app/views/admin/university/people/researchers/static.html.erb index 17d3bdd271425c0c335fb816b77831079caba48f..6c2deb3b3e8e69a143c46d4e9ce0051b40993bd7 100644 --- a/app/views/admin/university/people/researchers/static.html.erb +++ b/app/views/admin/university/people/researchers/static.html.erb @@ -1,6 +1,14 @@ --- title: > Publications de <%= @about.to_s %> +breadcrumbs: +<% @website.special_page(Communication::Website::Page::Person).ancestors_and_self.each do |page| %> + - title: "<%= page.best_title %>" + path: "<%= page.path %>" +<% end %> + - title: "<%= @about.to_s %>" + path: "<%= @about.person.current_permalink_in_website(@website)&.path %>" + - title: "Publications" <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: true, toc_offcanvas: true %> person: > diff --git a/app/views/admin/university/people/static.html.erb b/app/views/admin/university/people/static.html.erb index a176d7302d9533876beb893083eab309fc4ed282..c0d0ff946ff576ee6f680795e422b488bdb63631 100644 --- a/app/views/admin/university/people/static.html.erb +++ b/app/views/admin/university/people/static.html.erb @@ -3,6 +3,9 @@ title: >- <%= @about.to_s %> linkTitle: >- <%= @about.to_s_alphabetical %> +<%= render 'admin/application/static/breadcrumbs', + pages: @website.special_page(Communication::Website::Page::Person).ancestors_and_self, + current: @about %> <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/meta_description/static' %> <%= render 'admin/application/summary/static' %> diff --git a/app/views/admin/university/people/teachers/static.html.erb b/app/views/admin/university/people/teachers/static.html.erb index 1c684711d25b7cf619ba56fcc491ae61f4c07d57..024b5c7db723789916369140e1544899b3c35621 100644 --- a/app/views/admin/university/people/teachers/static.html.erb +++ b/app/views/admin/university/people/teachers/static.html.erb @@ -1,6 +1,14 @@ --- title: > Enseignements de <%= @about.to_s %> +breadcrumbs: +<% @website.special_page(Communication::Website::Page::Person).ancestors_and_self.each do |page| %> + - title: "<%= page.best_title %>" + path: "<%= page.path %>" +<% end %> + - title: "<%= @about.to_s %>" + path: "<%= @about.person.current_permalink_in_website(@website)&.path %>" + - title: "Enseignements" <%= render 'admin/application/static/permalink' %> <%= render 'admin/application/static/design', full_width: true, toc_offcanvas: true %> person: > diff --git a/app/views/extranet/home/features/_alumni.html.erb b/app/views/extranet/home/features/_alumni.html.erb index 6197ca669cb010510ff6791beeb6009c77317ef3..e8d763b22b8a83cf93f0b820ddd5967d2e4bbedf 100644 --- a/app/views/extranet/home/features/_alumni.html.erb +++ b/app/views/extranet/home/features/_alumni.html.erb @@ -27,7 +27,7 @@ <%= '—' if experience.description.present? && experience.organization.present? %> <%= experience.organization %> </p> - <small><%= l experience.created_at.to_date, format: :long %></small> + <small><%= l experience.created_at, format: :date_with_explicit_month %></small> </div> <% if experience.organization.present? %> <% if experience.organization.logo.attached? %> diff --git a/app/views/extranet/posts/posts/show.html.erb b/app/views/extranet/posts/posts/show.html.erb index e79ed648be346bae5130cee8c160d19ec03bad2b..8f4abc748c08039223d8409b47045a711cec1857 100644 --- a/app/views/extranet/posts/posts/show.html.erb +++ b/app/views/extranet/posts/posts/show.html.erb @@ -16,7 +16,7 @@ <h1><%= @post %></h1> <p class="small"> <% if @post.published_at %> - Publié le <%= l @post.published_at.to_date, format: :long %> + Publié le <%= l @post.published_at, format: :date_with_explicit_month %> <% end %> <% if @post.category %> <br> diff --git a/app/views/server/websites/index.txt.erb b/app/views/server/websites/index.txt.erb new file mode 100644 index 0000000000000000000000000000000000000000..906f096d4a58e670a4bfeccc53c80e02a84494e8 --- /dev/null +++ b/app/views/server/websites/index.txt.erb @@ -0,0 +1,5 @@ +[ +<% @websites.each do |website| %> + "<%= website.repository_url %>", +<% end %> +] \ No newline at end of file diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 07ca293a6920106c19334d1b478c93f9f6ea124a..3b8c7437ae4a624827461072bb7760ee6efcc40d 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,3 +1,4 @@ # Be sure to restart your server when you modify this file. Mime::Type.register "application/xls", :xlsx +Mime::Type.register "text/plain", :txt Mime::Type.register "application/xml", :xml, %w( text/xml application/x-xml ) diff --git a/config/locales/communication/contents/en.yml b/config/locales/communication/contents/en.yml index 0eafd2fd051aec198dd7f1fd62a4c1147e05d8f3..bad502f6fd158edf97cb5abbabc7ca966a120358 100644 --- a/config/locales/communication/contents/en.yml +++ b/config/locales/communication/contents/en.yml @@ -53,10 +53,26 @@ en: templates: agenda: description: A list of upcoming events. + layouts: + grid: + label: Grid + description: Events are presented as a grid, from left to right and top to bottom, with constant size cropped images. + list: + label: List + description: A list of posts with small images the same width. edit: - events_quantity: + description: + label: Description + quantity: label: Quantity of events to show placeholder: Enter quantity + time: + label: Which events? + options: + future_or_present: Now and in the future + future: In the future, not started yet + present: Running now + archive: Past, archives call_to_action: description: A title, a text, an optional image and up to 3 call to action buttons. edit: @@ -361,7 +377,7 @@ en: title: Selected pages display: title: Layout options - people: + persons: description: People and their jobs. edit: add_person: Add person @@ -513,7 +529,7 @@ en: license: License organizations: Organizations pages: Pages - people: People + persons: People posts: Posts programs: Programs sound: Sound diff --git a/config/locales/communication/contents/fr.yml b/config/locales/communication/contents/fr.yml index 1d4966d86980311c5a08a5fee786e71aff477878..aa35715c28a165c9aaa9a915ae978071b4ed958c 100644 --- a/config/locales/communication/contents/fr.yml +++ b/config/locales/communication/contents/fr.yml @@ -53,10 +53,26 @@ fr: templates: agenda: description: Une liste d'événements à venir. + layouts: + grid: + label: Grille + description: Les événements sont présentées en grille, avec les images toutes de la même taille. + list: + label: Liste + description: Une liste d'événements avec de petites images à la même largeur. edit: - events_quantity: + description: + label: Description + quantity: label: Quantité d'événements à afficher placeholder: Entrer la quantité + time: + label: Quels événements afficher ? + options: + future_or_present: En cours et à venir + future: À venir, pas encore en cours + present: En cours en ce moment + archive: Terminés, archivés call_to_action: description: Un titre, un texte, un visuel et 3 boutons pour inviter les personnes à agir. edit: @@ -361,7 +377,7 @@ fr: title: Pages sélectionnées display: title: Options d'affichage - people: + persons: description: Une liste de personnes, avec photo, fonction et lien vers la page de la personne. edit: add_person: Ajouter une personne @@ -513,7 +529,7 @@ fr: license: Licence organizations: Organisations pages: Pages - people: Personnes + persons: Personnes posts: Actualités programs: Formations sound: Son diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 224327d6c8dabb3bba1d1b173d8414151bd724e2..6cd50c56b90fb6f85137131d9504925fd33d90db 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -41,9 +41,6 @@ en: communication/website/connection: one: Connection other: Connections - communication/website/imported/website: - one: Imported website - other: Imported websites communication/website/menu: one: Menu other: Menus @@ -189,10 +186,6 @@ en: indirect_object_type: Indirect object type indirect_object_id: Indirect object identifier updated_at: Updated at - communication/website/imported/category: - original: Original - communication/website/imported/medium: - filename: Filename communication/website/menu: automatic: Automatic identifier: Identifier @@ -301,17 +294,6 @@ en: analytics: Analytics git: Git hosting: Hosting - imported: - from: Imported from - launch: Launch import - launched: Import in progress - original_url: Original URL - media: - file_size: File size - not_imported_yet: Not imported yet - refresh: Refresh import - show: Show import - pending: Import in progress last_events: Last events last_pages: Last pages last_posts: Last posts diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 92a96dcc25dba8ce4a039b9e1dd357181d44f813..a61369e14711f2ba2e070c4b620217ffbce5dcb1 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -41,9 +41,6 @@ fr: communication/website/connection: one: Connexion other: Connexions - communication/website/imported/website: - one: Site importé - other: Sites importés communication/website/menu: one: Menu other: Menus @@ -189,10 +186,6 @@ fr: indirect_object_type: Type de l'objet indirect_object_id: Identifiant de l'objet updated_at: Date de mise à jour - communication/website/imported/category: - original: Original - communication/website/imported/medium: - filename: Nom du fichier communication/website/menu: automatic: Automatique identifier: Identifiant @@ -301,17 +294,6 @@ fr: analytics: Analytics git: Git hosting: Hébergement - imported: - from: Importé depuis - launch: Importer le site - launched: Importation en cours - original_url: URL originale - media: - file_size: Taille du fichier - not_imported_yet: Non importé pour le moment - refresh: Relancer l'import - show: Voir l'import - pending: Import en cours last_events: Derniers événements last_pages: Dernières pages last_posts: Dernières actualités diff --git a/config/routes/admin/communication.rb b/config/routes/admin/communication.rb index 63b172ca1f1d6673e2918c2e706c8eaa56c37497..8c851edbc704856e35599db897b260be412d0bee 100644 --- a/config/routes/admin/communication.rb +++ b/config/routes/admin/communication.rb @@ -5,8 +5,6 @@ namespace :communication do end resources :websites do member do - post :import - get :import get :analytics get :security get :static diff --git a/db/migrate/20231005070935_remove_wordpress_tables.rb b/db/migrate/20231005070935_remove_wordpress_tables.rb new file mode 100644 index 0000000000000000000000000000000000000000..dcc4ab4b32d8a3adb6d133a6161a34df7831cf31 --- /dev/null +++ b/db/migrate/20231005070935_remove_wordpress_tables.rb @@ -0,0 +1,10 @@ +class RemoveWordpressTables < ActiveRecord::Migration[7.0] + def change + drop_table :communication_website_imported_categories + drop_table :communication_website_imported_authors + drop_table :communication_website_imported_pages + drop_table :communication_website_imported_posts + drop_table :communication_website_imported_media + drop_table :communication_website_imported_websites + end +end diff --git a/test/fixtures/communication/blocks.yml b/test/fixtures/communication/blocks.yml index b8eefcfaab9d8c5bc678328238269551a3c8e0f7..6b060977a5be9e7443ddd967251314c46d1625c8 100644 --- a/test/fixtures/communication/blocks.yml +++ b/test/fixtures/communication/blocks.yml @@ -36,5 +36,5 @@ olivia_in_noesya: about: noesya (University::Organization) data: { "elements": [ { "id": "53cbac40-e430-585a-965c-a7412a92f35a" } ] } position: 1 - template_kind: :people + template_kind: :persons published: true diff --git a/test/models/communication/website/connection_test.rb b/test/models/communication/website/connection_test.rb index 43ee9cba48fe28147101f2abe7f7cd392d14af9d..2bf68e198c02a409ca61b1ff3727488d9f41cce7 100644 --- a/test/models/communication/website/connection_test.rb +++ b/test/models/communication/website/connection_test.rb @@ -154,7 +154,7 @@ class Communication::Website::ConnectionTest < ActiveSupport::TestCase # On connecte PA via un block "Personnes" : +2 assert_difference -> { Communication::Website::Connection.count } => 2 do - block = page.blocks.create(position: 2, published: true, template_kind: :people) + block = page.blocks.create(position: 2, published: true, template_kind: :persons) block.data = "{ \"elements\": [ { \"id\": \"#{pa.id}\" } ] }" block.save end @@ -168,7 +168,7 @@ class Communication::Website::ConnectionTest < ActiveSupport::TestCase # On ajoute Arnaud à noesya via un block "Personnes" : +2 assert_difference -> { Communication::Website::Connection.count } => 2 do - block = noesya.blocks.create(position: 2, published: true, template_kind: :people) + block = noesya.blocks.create(position: 2, published: true, template_kind: :persons) block.data = "{ \"elements\": [ { \"id\": \"#{arnaud.id}\" } ] }" block.save end diff --git a/test/models/communication/website/dependency_test.rb b/test/models/communication/website/dependency_test.rb index dbff0184262c7729ec528a082c5a7c55586fe489..95ccd829946ef064d5428c3c13e4cb08631d0097 100644 --- a/test/models/communication/website/dependency_test.rb +++ b/test/models/communication/website/dependency_test.rb @@ -20,7 +20,7 @@ class Communication::Website::DependencyTest < ActiveSupport::TestCase # - 4 composants du template du block + 1 élément (5) # - 2 composants de l'élément du template (2) # - la personne en dépendance du composant Person (1) - block = page.blocks.create(position: 1, published: true, template_kind: :people) + block = page.blocks.create(position: 1, published: true, template_kind: :persons) block.data = "{ \"elements\": [ { \"id\": \"#{arnaud.id}\" } ] }" block.save