diff --git a/app/models/administration/member.rb b/app/models/administration/member.rb index 857a248c383762259e883177fbbb7a099648aa78..bf3afeffa4414b2d02ccc287d43eb68ca9766e74 100644 --- a/app/models/administration/member.rb +++ b/app/models/administration/member.rb @@ -77,7 +77,7 @@ class Administration::Member < ApplicationRecord scope :researchers, -> { where(is_researcher: true) } def to_s - "#{last_name} #{first_name}" + "#{first_name} #{last_name}" end def websites @@ -93,6 +93,7 @@ class Administration::Member < ApplicationRecord manifest.concat(author_github_manifest_items) if is_author? manifest.concat(researcher_github_manifest_items) if is_researcher? manifest.concat(teacher_github_manifest_items) if is_teacher? + manifest.concat(administrator_github_manifest_items) if is_administrative? manifest end @@ -100,19 +101,9 @@ class Administration::Member < ApplicationRecord [ { identifier: "author", - generated_path: -> (github_file) { "#{github_file.website.authors_github_directory}/#{slug}.yml" }, + generated_path: -> (github_file) { "content/authors/#{slug}/_index.html" }, data: -> (github_file) { ApplicationController.render( - template: "admin/communication/website/authors/jekyll", - layout: false, - assigns: { author: self, github_file: github_file } - ) } - }, - { - identifier: "author_collection_item", - generated_path: -> (github_file) { "_data/authors/#{slug}.yml" }, - data: -> (github_file) { ApplicationController.render( - template: "admin/communication/website/authors/jekyll_collection", - formats: [:yml], + template: "admin/communication/website/authors/static", layout: false, assigns: { author: self, github_file: github_file } ) } @@ -123,11 +114,10 @@ class Administration::Member < ApplicationRecord def researcher_github_manifest_items [ { - identifier: "researcher_collection_item", - generated_path: -> (github_file) { "_data/researchers/#{slug}.yml" }, + identifier: "researcher", + generated_path: -> (github_file) { "content/researchers/#{slug}/_index.html" }, data: -> (github_file) { ApplicationController.render( - template: "admin/research/researchers/jekyll_collection", - formats: [:yml], + template: "admin/research/researchers/static", layout: false, assigns: { researcher: self, github_file: github_file } ) } @@ -138,11 +128,10 @@ class Administration::Member < ApplicationRecord def teacher_github_manifest_items [ { - identifier: "teacher_collection_item", - generated_path: -> (github_file) { "_data/teachers/#{slug}.yml" }, + identifier: "teacher", + generated_path: -> (github_file) { "content/teachers/#{slug}/_index.html" }, data: -> (github_file) { ApplicationController.render( - template: "admin/education/teachers/jekyll_collection", - formats: [:yml], + template: "admin/education/teachers/static", layout: false, assigns: { teacher: self, github_file: github_file } ) } @@ -150,4 +139,17 @@ class Administration::Member < ApplicationRecord ] end + def administrator_github_manifest_items + [ + { + identifier: "administrator", + generated_path: -> (github_file) { "content/administrators/#{slug}/_index.html" }, + data: -> (github_file) { ApplicationController.render( + template: "admin/administration/members/static", + layout: false, + assigns: { member: self, github_file: github_file } + ) } + } + ] + end end diff --git a/app/models/communication/website/category.rb b/app/models/communication/website/category.rb index b0c4b39a13589fcca6970fe0d9796c6686092897..c9c96a35aa16a3ab2aa155b699c19c413cd24c36 100644 --- a/app/models/communication/website/category.rb +++ b/app/models/communication/website/category.rb @@ -7,6 +7,7 @@ # github_path :text # is_programs_root :boolean default(FALSE) # name :string +# path :string # position :integer # slug :string # created_at :datetime not null @@ -77,27 +78,9 @@ class Communication::Website::Category < ApplicationRecord "#{name}" end - def path - # used in menu_item#jekyll_target - "/#{website.posts_github_directory}/#{slug}" - end - # Override from WithGithubFiles def github_path_generated - "#{website.posts_github_directory}/#{slug}.html" - end - - def github_manifest - super << { - identifier: "collection_item", - generated_path: -> (github_file) { "_data/categories/#{slug}.yml" }, - data: -> (github_file) { ApplicationController.render( - template: "admin/communication/website/categories/jekyll_collection", - formats: [:yml], - layout: false, - assigns: { category: self, github_file: github_file } - ) } - } + "content/categories/#{path}/_index.html".gsub(/\/+/, '/') end protected diff --git a/app/models/communication/website/github_file.rb b/app/models/communication/website/github_file.rb index a909b66eac784711a3777b2aedce03ee8c18dfb1..8a9fc5ea3d02141b9b615aff886ed2be306b194b 100644 --- a/app/models/communication/website/github_file.rb +++ b/app/models/communication/website/github_file.rb @@ -46,15 +46,6 @@ class Communication::Website::GithubFile < ApplicationRecord add_media_to_batch(github) end - def github_frontmatter - @github_frontmatter ||= begin - github_content = github.read_file_at(github_path) - FrontMatterParser::Parser.new(:md).call(github_content) - rescue - FrontMatterParser::Parser.new(:md).call('') - end - end - protected def add_media_to_batch(github) @@ -98,7 +89,7 @@ class Communication::Website::GithubFile < ApplicationRecord { path: github_blob_path(blob), data: ApplicationController.render( - template: 'active_storage/blobs/jekyll', + template: 'active_storage/blobs/static', layout: false, assigns: { blob: blob } ) @@ -106,7 +97,7 @@ class Communication::Website::GithubFile < ApplicationRecord end def github_blob_path(blob) - "_data/media/#{blob.id[0..1]}/#{blob.id}.yml" + "data/media/#{blob.id[0..1]}/#{blob.id}.yml" end def github_commit_message diff --git a/app/models/communication/website/home.rb b/app/models/communication/website/home.rb index e1bca10f9180ffa0b073bf09099c2590986aef41..54d68f7aa5942e548583149f931dc8452cecccab 100644 --- a/app/models/communication/website/home.rb +++ b/app/models/communication/website/home.rb @@ -34,9 +34,9 @@ class Communication::Website::Home < ApplicationRecord '' end - def to_jekyll(github_file) + def to_static(github_file) ApplicationController.render( - template: "admin/communication/website/home/jekyll", + template: "admin/communication/website/home/static", layout: false, assigns: { home: self, github_file: github_file } ) @@ -44,7 +44,7 @@ class Communication::Website::Home < ApplicationRecord # Override from WithGithubFiles def github_path_generated - '_pages/index.html' + 'content/_index.html' end end diff --git a/app/models/communication/website/menu.rb b/app/models/communication/website/menu.rb index 3214611a33915700fa27e8039146283081f40c6a..25eee954061c43c4a7cbfb0f1206b53536054ec7 100644 --- a/app/models/communication/website/menu.rb +++ b/app/models/communication/website/menu.rb @@ -41,10 +41,10 @@ class Communication::Website::Menu < ApplicationRecord # Override from WithGithubFiles def github_path_generated - "_data/menus/#{identifier}.yml" + "data/menus/#{identifier}.yml" end - def to_jekyll(github_file) - items.root.ordered.map(&:to_jekyll_hash).to_yaml + def to_static(github_file) + items.root.ordered.map(&:to_static_hash).to_yaml end end diff --git a/app/models/communication/website/menu/item.rb b/app/models/communication/website/menu/item.rb index d68925da709c7ba493a71095551bbf0c5b40bd1a..cebd923e57d6badfa782af773751af683d597c9c 100644 --- a/app/models/communication/website/menu/item.rb +++ b/app/models/communication/website/menu/item.rb @@ -44,7 +44,17 @@ class Communication::Website::Menu::Item < ApplicationRecord foreign_key: :parent_id, dependent: :destroy - enum kind: { blank: 0, url: 10, page: 20, programs: 30, program: 31, news: 40, news_category: 41, news_article: 42, staff: 50 }, _prefix: :kind + enum kind: { + blank: 0, + url: 10, + page: 20, + programs: 30, + program: 31, + news: 40, + news_category: 41, + news_article: 42, + staff: 50 + }, _prefix: :kind validates :title, presence: true validates :about, presence: true, if: :has_about? @@ -57,23 +67,26 @@ class Communication::Website::Menu::Item < ApplicationRecord "#{title}" end - def jekyll_target + def static_target + target = '' case self.kind when 'url' - url + target = url when 'programs' - "/#{website.programs_github_directory}" + target = "/#{website.programs_github_directory}" when 'program' - "/#{website.programs_github_directory}#{about.path}" + target = "/#{website.programs_github_directory}#{about.path}" when 'news' - "/#{website.posts_github_directory}" + target = "/#{website.posts_github_directory}" when 'staff' - "/#{website.staff_github_directory}" + target = "/#{website.staff_github_directory}" when 'blank' - nil + target = nil else - about&.path + target = about&.path end + target.end_with?('/') ? target + : "#{target}/" end def list_of_other_items @@ -85,13 +98,13 @@ class Communication::Website::Menu::Item < ApplicationRecord items end - def to_jekyll_hash + def to_static_hash return {} if kind_news_article? && !about.published { 'title' => title, - 'target' => jekyll_target, + 'target' => static_target, 'kind' => kind, - 'children' => children.ordered.map(&:to_jekyll_hash) + 'children' => children.ordered.map(&:to_static_hash) } end diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index cd5041fc41a6f16a26179f60ec4afaac9373d138..08e47284b6df7f7eac59d849abd128a2a9270885 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -64,11 +64,9 @@ class Communication::Website::Page < ApplicationRecord foreign_key: :parent_id, dependent: :destroy - validates :title, presence: true validates :slug, uniqueness: { scope: :communication_website_id } - before_validation :make_path after_save :update_children_paths, if: :saved_change_to_path? scope :ordered, -> { order(:position) } @@ -76,7 +74,7 @@ class Communication::Website::Page < ApplicationRecord # Override from WithGithubFiles def github_path_generated - "_pages/#{path}/index.html".gsub(/\/+/, '/') + "content/pages/#{path}/_index.html".gsub(/\/+/, '/') end def list_of_other_pages @@ -97,16 +95,13 @@ class Communication::Website::Page < ApplicationRecord protected def slug_unavailable?(slug) - self.class.unscoped.where(communication_website_id: self.communication_website_id, slug: slug).where.not(id: self.id).exists? - end - - def make_path - self.path = "#{parent&.path}/#{slug}".gsub(/\/+/, '/') + self.class.unscoped + .where(communication_website_id: self.communication_website_id, slug: slug) + .where.not(id: self.id) + .exists? end def update_children_paths children.each(&:save) end - - end diff --git a/app/models/communication/website/post.rb b/app/models/communication/website/post.rb index 0267de840efea305dfdfb93595649ca5154e8674..912f6e30aa3445c0eb6e75d0be75ea3fe5e8071e 100644 --- a/app/models/communication/website/post.rb +++ b/app/models/communication/website/post.rb @@ -64,13 +64,13 @@ class Communication::Website::Post < ApplicationRecord scope :recent, -> { order(published_at: :desc).limit(5) } def path - # used in menu_item#jekyll_target - "/#{website.posts_github_directory}/#{published_at.strftime "%Y/%m/%d"}/#{slug}" + # used in menu_item#static_target + "/#{website.posts_github_directory}/#{published_at.strftime "%Y/%m/%d"}/#{slug}/" end # Override from WithGithubFiles def github_path_generated - "_posts/#{published_at.year}/#{published_at.strftime "%Y-%m-%d"}-#{slug}.html" + "content/posts/#{published_at.year}/#{published_at.strftime "%Y-%m-%d"}-#{slug}.html" end def to_s @@ -80,7 +80,10 @@ class Communication::Website::Post < ApplicationRecord protected def slug_unavailable?(slug) - self.class.unscoped.where(communication_website_id: self.communication_website_id, slug: slug).where.not(id: self.id).exists? + self.class.unscoped + .where(communication_website_id: self.communication_website_id, slug: slug) + .where.not(id: self.id) + .exists? end def set_published_at diff --git a/app/models/concerns/with_github_files.rb b/app/models/concerns/with_github_files.rb index ddc2b863efc2af23c0238ddd6571035fbe86b515..3e73a032a0eec2240d7922699623c444f8230fc4 100644 --- a/app/models/concerns/with_github_files.rb +++ b/app/models/concerns/with_github_files.rb @@ -2,7 +2,10 @@ module WithGithubFiles extend ActiveSupport::Concern included do - has_many :github_files, class_name: "Communication::Website::GithubFile", as: :about, dependent: :destroy + has_many :github_files, + class_name: "Communication::Website::GithubFile", + as: :about, + dependent: :destroy after_save :create_github_files after_save_commit :publish_github_files @@ -14,12 +17,12 @@ module WithGithubFiles end def github_path_generated - "_#{self.class.name.demodulize.pluralize.underscore}/#{self.slug}.html" + "content/#{self.class.name.demodulize.pluralize.underscore}/#{self.slug}/_index.html" end - def to_jekyll(github_file) + def to_static(github_file) ApplicationController.render( - template: "admin/#{self.class.name.underscore.pluralize}/jekyll", + template: "admin/#{self.class.name.underscore.pluralize}/static", layout: false, assigns: { self.class.name.demodulize.underscore => self, github_file: github_file } ) @@ -30,7 +33,7 @@ module WithGithubFiles { identifier: "primary", generated_path: -> (github_file) { github_path_generated }, - data: -> (github_file) { to_jekyll(github_file) }, + data: -> (github_file) { to_static(github_file) }, has_media: true } ] diff --git a/app/models/concerns/with_slug.rb b/app/models/concerns/with_slug.rb index 0f5168cb5098412b2e62613a80d51d35164123cf..f0e773ec712b956dfa26ecf780d05ac731d10339 100644 --- a/app/models/concerns/with_slug.rb +++ b/app/models/concerns/with_slug.rb @@ -7,7 +7,7 @@ module WithSlug validates :slug, format: { with: /\A[a-z0-9\-]+\z/, message: I18n.t('slug_error') } - before_validation :regenerate_slug + before_validation :regenerate_slug, :make_path def regenerate_slug current_slug = self.slug @@ -21,7 +21,15 @@ module WithSlug protected def slug_unavailable?(slug) - self.class.unscoped.where(university_id: self.university_id, slug: slug).where.not(id: self.id).exists? + self.class.unscoped + .where(university_id: self.university_id, slug: slug) + .where.not(id: self.id) + .exists? + end + + def make_path + return unless respond_to?(:path) && respond_to?(:parent) + self.path = "#{parent&.path}/#{slug}".gsub(/\/+/, '/') end end end diff --git a/app/models/education/program.rb b/app/models/education/program.rb index 115b08d0c42d01e36e2587cfe3c5d02f18aea2cf..f6bddcdf33a1dc63ae92d568dd01870df8e173a9 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -32,6 +32,7 @@ class Education::Program < ApplicationRecord include WithGithubFiles include WithMenuItemTarget + include WithSlug include WithTree include WithInheritance include Communication::Website::WithMedia @@ -109,11 +110,7 @@ class Education::Program < ApplicationRecord # Override from WithGithubFiles def github_path_generated - "_programs/#{path}/index.html".gsub(/\/+/, '/') - end - - def make_path - self.path = "#{parent&.path}/#{slug}".gsub(/\/+/, '/') + "content/programs/#{path}/_index.html".gsub(/\/+/, '/') end def update_children_paths diff --git a/app/models/education/school.rb b/app/models/education/school.rb index 383079a78c299760bfd9b5da66a110066d8cf4e8..724b69e2a01b1886acd97764e798e1716e74ec0b 100644 --- a/app/models/education/school.rb +++ b/app/models/education/school.rb @@ -48,7 +48,7 @@ class Education::School < ApplicationRecord "_data/school.yml" end - def to_jekyll(github_file) + def to_static(github_file) { name: name, address: address, diff --git a/app/models/research/journal.rb b/app/models/research/journal.rb index f44d2707a6614b207b89f3a200973d1caf671baa..f05a836dcec4996964e4c7e978c480753e7024b2 100644 --- a/app/models/research/journal.rb +++ b/app/models/research/journal.rb @@ -39,7 +39,7 @@ class Research::Journal < ApplicationRecord "_data/journal.yml" end - def to_jekyll(github_file) + def to_static(github_file) { title: title, description: description, diff --git a/app/models/user.rb b/app/models/user.rb index 43d21694c80e7739cb6672216898b9bee50dffd6..912755e7bad4cc9e40394d83979008f25e794514 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -64,12 +64,8 @@ class User < ApplicationRecord scope :ordered, -> { order(:last_name, :first_name) } - def human_name - "#{first_name} #{last_name}" - end - def to_s - "#{last_name} #{first_name}" + "#{first_name} #{last_name}" end end diff --git a/app/views/active_storage/blobs/jekyll.html.erb b/app/views/active_storage/blobs/static.html.erb similarity index 100% rename from app/views/active_storage/blobs/jekyll.html.erb rename to app/views/active_storage/blobs/static.html.erb diff --git a/app/views/admin/administration/members/_list.html.erb b/app/views/admin/administration/members/_list.html.erb index 7a1dcab14161c160c26ccf1c0de3670e49b65c46..5d04d354d5b2b5f687725f9c5c0b3fa3f00844dc 100644 --- a/app/views/admin/administration/members/_list.html.erb +++ b/app/views/admin/administration/members/_list.html.erb @@ -1,14 +1,16 @@ <table class="<%= table_classes %>"> <thead> <tr> - <th><%= Administration::Member.human_attribute_name('name') %></th> + <th><%= Administration::Member.human_attribute_name('last_name') %></th> + <th><%= Administration::Member.human_attribute_name('first_name') %></th> <th></th> </tr> </thead> <tbody> <% members.each do |member| %> <tr> - <td><%= link_to member, admin_administration_member_path(member) %></td> + <td><%= link_to member.last_name, admin_administration_member_path(member) %></td> + <td><%= link_to member.first_name, admin_administration_member_path(member) %></td> <td class="text-end"> <div class="btn-group" role="group"> <%= link_to t('edit'), diff --git a/app/views/admin/administration/members/static.html.erb b/app/views/admin/administration/members/static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..3c16ebf872dc90c2583fb3f410c7a2ae830a7cfb --- /dev/null +++ b/app/views/admin/administration/members/static.html.erb @@ -0,0 +1,10 @@ +--- +title: > + <%= @member.to_s %> +slug: "<%= @member.slug %>" +first_name: "<%= @member.first_name %>" +last_name: "<%= @member.last_name %>" +phone: "<%= @member.phone %>" +email: "<%= @member.email %>" +--- +<%= prepare_for_github @member.biography, @member.university %> diff --git a/app/views/admin/application/_top.html.erb b/app/views/admin/application/_top.html.erb index 15a97ce2634425b69c349b064a6700682f9ff162..3de9fcc23337941e0d9e4d637a8c0ec74fb3510d 100644 --- a/app/views/admin/application/_top.html.erb +++ b/app/views/admin/application/_top.html.erb @@ -7,7 +7,7 @@ <ul class="navbar-nav navbar-align"> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle d-none d-sm-inline-block js-user-dropdown-toggle" href="#" data-bs-toggle="dropdown"> - <span class="text-dark"><%= current_user.human_name %></span> + <span class="text-dark"><%= current_user.to_s %></span> </a> <div class="dropdown-menu dropdown-menu-end"> <%= link_to t('menu.profile'), edit_user_registration_path, class: 'dropdown-item' %> diff --git a/app/views/admin/communication/website/authors/_list.html.erb b/app/views/admin/communication/website/authors/_list.html.erb index fede64fd38960172f9edc9d16ee31650c398136e..9eb1c1bdd7c2c73137d5c44fb41e5a501c52b078 100644 --- a/app/views/admin/communication/website/authors/_list.html.erb +++ b/app/views/admin/communication/website/authors/_list.html.erb @@ -1,14 +1,16 @@ <table class="<%= table_classes %>"> <thead> <tr> - <th><%= Administration::Member.human_attribute_name('name') %></th> + <th><%= Administration::Member.human_attribute_name('last_name') %></th> + <th><%= Administration::Member.human_attribute_name('first_name') %></th> <th><%= t('communication.number_of_posts') %></th> </tr> </thead> <tbody> <% authors.each do |author| %> <tr> - <td><%= link_to author, admin_communication_website_author_path(website_id: @website.id, id: author.id) %></td> + <td><%= link_to author.last_name, admin_communication_website_author_path(website_id: @website.id, id: author.id) %></td> + <td><%= link_to author.first_name, admin_communication_website_author_path(website_id: @website.id, id: author.id) %></td> <td><%= author.communication_website_posts.count %></td> </tr> <% end %> diff --git a/app/views/admin/communication/website/authors/jekyll.html.erb b/app/views/admin/communication/website/authors/jekyll.html.erb deleted file mode 100644 index e563627b9364e1b0a5bb7760e2fbf5c5d8947ae8..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/website/authors/jekyll.html.erb +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: "<%= @author.to_s %>" -slug: "<%= @author.slug %>" -identifier: "<%= @author.id %>" -permalink: "/<%= @github_file.website.authors_github_directory %>/<%= @author.slug %>" -first_name: "<%= @author.first_name %>" -last_name: "<%= @author.last_name %>" -phone: "<%= @author.phone %>" -email: "<%= @author.email %>" -biography: > - <%= prepare_for_github @author.biography, @author.university %> -pagination: - enabled: true - tag: <%= @author.id %> - permalink: /:num/ ---- -<%= @github_file.github_frontmatter.content.html_safe %> diff --git a/app/views/admin/communication/website/authors/jekyll_collection.yml.erb b/app/views/admin/communication/website/authors/jekyll_collection.yml.erb deleted file mode 100644 index 76518b7276c8e5c016e4f442276a22b178433c10..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/website/authors/jekyll_collection.yml.erb +++ /dev/null @@ -1,3 +0,0 @@ -name: "<%= @author.to_s %>" -identifier: "<%= @author.id %>" -link: "/<%= @github_file.website.authors_github_directory %>/<%= @author.slug %>" diff --git a/app/views/admin/communication/website/authors/static.html.erb b/app/views/admin/communication/website/authors/static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..b52f8eadc00232b290777c8eb59b98abad0c88b1 --- /dev/null +++ b/app/views/admin/communication/website/authors/static.html.erb @@ -0,0 +1,10 @@ +--- +title: > + <%= @author.to_s %> +slug: "<%= @author.slug %>" +first_name: "<%= @author.first_name %>" +last_name: "<%= @author.last_name %>" +phone: "<%= @author.phone %>" +email: "<%= @author.email %>" +--- +<%= prepare_for_github @author.biography, @author.university %> diff --git a/app/views/admin/communication/website/categories/jekyll.html.erb b/app/views/admin/communication/website/categories/jekyll.html.erb deleted file mode 100644 index 39e21da3ce6b438882cc4d186f8c21c108ce6c80..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/website/categories/jekyll.html.erb +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: "<%= @category.name %>" -slug: "<%= @category.slug %>" -identifier: "<%= @category.id %>" -permalink: "/<%= @category.website.posts_github_directory %>/<%= @category.slug %>" -parent: "<%= @category.parent_id %>" -description: > - <%= prepare_for_github @category.description, @category.university %> -pagination: - enabled: true - category: <%= @category.id %> - permalink: /:num/ ---- -<%= @github_file.github_frontmatter.content.html_safe %> diff --git a/app/views/admin/communication/website/categories/jekyll_collection.yml.erb b/app/views/admin/communication/website/categories/jekyll_collection.yml.erb deleted file mode 100644 index 93e6b74fedb399e012f74fc8c189e85b172ae642..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/website/categories/jekyll_collection.yml.erb +++ /dev/null @@ -1,5 +0,0 @@ -name: "<%= @category.name %>" -identifier: "<%= @category.id %>" -link: "/<%= @category.website.posts_github_directory %>/<%= @category.slug %>" -parent: "<%= @category.parent_id %>" -position: <%= @category.position %> diff --git a/app/views/admin/communication/website/categories/static.html.erb b/app/views/admin/communication/website/categories/static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..cc16d53779680fb506b915e61d046e3a1f46ee70 --- /dev/null +++ b/app/views/admin/communication/website/categories/static.html.erb @@ -0,0 +1,5 @@ +--- +title: "<%= @category.name %>" +slug: "<%= @category.slug %>" +--- +<%= prepare_for_github @category.description, @category.university %> diff --git a/app/views/admin/communication/website/home/jekyll.html.erb b/app/views/admin/communication/website/home/static.html.erb similarity index 50% rename from app/views/admin/communication/website/home/jekyll.html.erb rename to app/views/admin/communication/website/home/static.html.erb index 7910e69ed4b9ae6d9e6ff7a9f6b71059bb138525..61c67859ea9be2c07f951298a0e956f06e574009 100644 --- a/app/views/admin/communication/website/home/jekyll.html.erb +++ b/app/views/admin/communication/website/home/static.html.erb @@ -1,12 +1,12 @@ --- -layout: home -permalink: "/" -title: "" +title: > + <%= @home.website.name %> +breadcrumb_title: "Accueil" <% if @home.featured_image.attached? %> image: "<%= @home.featured_image.blob.id %>" image_alt: "<%= @home.featured_image_alt %>" <% end %> description: > - <%= prepare_for_github @home.text, @home.university %> + <%= strip_tags(@home.text.to_s).chomp %> --- -<%= @github_file.github_frontmatter.content.html_safe %> +<%= prepare_for_github @home.text, @home.university %> diff --git a/app/views/admin/communication/website/menu/items/_form.html.erb b/app/views/admin/communication/website/menu/items/_form.html.erb index 97329593860078584a8ecea4830150806ce0a05d..e69a398400fd64f60bc6d7ea1654e2d46042a344 100644 --- a/app/views/admin/communication/website/menu/items/_form.html.erb +++ b/app/views/admin/communication/website/menu/items/_form.html.erb @@ -10,7 +10,6 @@ <%= f.input :title %> <%= f.input :kind, include_blank: false, - label_method: -> (p) { I18n.t(p[1], scope: 'enums.communication/website/menu/item.kind') }, input_html: { class: 'js-kind-input', data: { url: kind_switch_admin_communication_website_menu_items_path } diff --git a/app/views/admin/communication/website/menu/items/show.html.erb b/app/views/admin/communication/website/menu/items/show.html.erb index 312dd7bb5f58e865d54b5e10c7aa8377583ab9e8..c532a3e1fe9d305442af4809bb4f3daddd642f60 100644 --- a/app/views/admin/communication/website/menu/items/show.html.erb +++ b/app/views/admin/communication/website/menu/items/show.html.erb @@ -22,7 +22,7 @@ </div> <div class="card-body"> <h3 class="h5"><%= Communication::Website::Menu::Item.human_attribute_name('kind') %></h3> - <p><%= I18n.t(@item.kind, scope: 'enums.communication/website/menu/item.kind') %></p> + <p><%= @item.kind_i18n %></p> <% if @item.kind_url? %> <h3 class="h5"><%= Communication::Website::Menu::Item.human_attribute_name('url') %></h3> <p><%= link_to @item.url, @item.url, target: '_blank' unless @item.url.blank? %></p> diff --git a/app/views/admin/communication/website/pages/jekyll.html.erb b/app/views/admin/communication/website/pages/jekyll.html.erb deleted file mode 100644 index 55377413e7d4736c72f3d2e4449813ee20e96332..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/website/pages/jekyll.html.erb +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: "<%= @page.title %>" -permalink: "<%= @page.path %>" -identifier: "<%= @page.id %>" -parent: "<%= @page.parent_id %>" -related_category: "<%= @page.related_category_id %>" -position: <%= @page.position %> -<% if @page.best_featured_image.attached? %> -image: "<%= @page.best_featured_image.blob.id %>" -image_alt: "<%= @page.featured_image_alt %>" -<% end %> -description: > - <%= prepare_for_github @page.description, @page.university %> -text: > - <%= prepare_for_github @page.text, @page.university %> ---- -<%= @github_file.github_frontmatter.content.html_safe %> diff --git a/app/views/admin/communication/website/pages/static.html.erb b/app/views/admin/communication/website/pages/static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e18d1756ccdbfd121b036017846de8dccb73cb41 --- /dev/null +++ b/app/views/admin/communication/website/pages/static.html.erb @@ -0,0 +1,13 @@ +--- +title: > + <%= @page.title %> +url: "<%= @page.path %>" +position: <%= @page.position %> +<% if @page.best_featured_image.attached? %> +image: "<%= @page.best_featured_image.blob.id %>" +image_alt: "<%= @page.featured_image_alt %>" +<% end %> +description: > + <%= prepare_for_github @page.description, @page.university %> +--- +<%= prepare_for_github @page.text, @page.university %> diff --git a/app/views/admin/communication/website/posts/jekyll.html.erb b/app/views/admin/communication/website/posts/static.html.erb similarity index 52% rename from app/views/admin/communication/website/posts/jekyll.html.erb rename to app/views/admin/communication/website/posts/static.html.erb index 94a08c8776e4ad88d1084da0a585f85b0ac31a43..6fca22570eb3c991c236badeb8dde7d287ae7f5b 100644 --- a/app/views/admin/communication/website/posts/jekyll.html.erb +++ b/app/views/admin/communication/website/posts/static.html.erb @@ -2,25 +2,22 @@ title: "<%= @post.title %>" date: <%= @post.published_at %> UTC slug: "<%= @post.slug %>" -pinned: <%= @post.pinned %> -author: "<%= @post.author_id %>" +<% if @post.pinned %> +weight: 1 +<% end %> +authors: + - "<%= @post.author.slug %>" <% if @post.categories.any? %> categories: <% @post.categories.each do |category| %> - - "<%= category.id %>" + - "<%= category.path %>" <% end %> <% end %> -<% if @post.author_id.present? %> -tags: - - "<%= @post.author_id %>" -<% end %> <% if @post.featured_image.attached? %> image: "<%= @post.featured_image.blob.id %>" image_alt: "<%= @post.featured_image_alt %>" <% end %> description: > - <%= prepare_for_github @post.description, @post.university %> -text: > - <%= prepare_for_github @post.text, @post.university %> + <%= @post.description.chomp %> --- -<%= @github_file.github_frontmatter.content.html_safe %> +<%= prepare_for_github @post.text, @post.university %> diff --git a/app/views/admin/education/programs/jekyll.html.erb b/app/views/admin/education/programs/jekyll.html.erb index d9a369f865f205c3d6b84c977b43c2855f780c10..d69a6983cf9697e13035645cc92a5c261b2c90e2 100644 --- a/app/views/admin/education/programs/jekyll.html.erb +++ b/app/views/admin/education/programs/jekyll.html.erb @@ -30,7 +30,7 @@ accessibility: > contacts: > <%= prepare_for_github @program.best_contacts, @program.university %> description: > - <%= prepare_for_github @program.best_description, @program.university %> + <%= prepare_for_github @program.description, @program.university %> duration: > <%= prepare_for_github @program.best_duration, @program.university %> evaluation: > diff --git a/app/views/admin/education/programs/show.html.erb b/app/views/admin/education/programs/show.html.erb index fe12adf4d7c89d27a6758b1d52e11ef1bd462a43..c52a813cb4ced4ddbd17a5e558020d10f49d1956 100644 --- a/app/views/admin/education/programs/show.html.erb +++ b/app/views/admin/education/programs/show.html.erb @@ -45,7 +45,11 @@ <h5 class="card-title mb-0"><%= t('education.program.useful_informations') %></h5> </div> <div class="card-body"> - <% ['description', 'registration', 'pricing', 'duration', 'contacts', 'accessibility', 'other'].each_with_index do |prop, index| %> + <h3 class="h5 mt-4"> + <%= Education::Program.human_attribute_name('description') %> + </h3> + <p><% @program.description %></p> + <% ['registration', 'pricing', 'duration', 'contacts', 'accessibility', 'other'].each_with_index do |prop, index| %> <% best_prop_value = @program.public_send("best_#{prop}") best_prop_source = @program.public_send("best_#{prop}_source") diff --git a/app/views/admin/education/teachers/_list.html.erb b/app/views/admin/education/teachers/_list.html.erb index ec41239ac10899b7f6e144c42ee2e38f62448cd7..5ef8fafad0c8c94009036f45f5153b5c10dfada0 100644 --- a/app/views/admin/education/teachers/_list.html.erb +++ b/app/views/admin/education/teachers/_list.html.erb @@ -1,7 +1,8 @@ <table class="<%= table_classes %>"> <thead> <tr> - <th><%= Administration::Member.human_attribute_name('name') %></th> + <th><%= Administration::Member.human_attribute_name('last_name') %></th> + <th><%= Administration::Member.human_attribute_name('first_name') %></th> <th></th> </tr> </thead> diff --git a/app/views/admin/education/teachers/jekyll_collection.yml.erb b/app/views/admin/education/teachers/static.html.erb similarity index 69% rename from app/views/admin/education/teachers/jekyll_collection.yml.erb rename to app/views/admin/education/teachers/static.html.erb index 954df1c552e2466c7d5985e89a5a9116c20e3f39..8da73a8a3f988110b42f6820a754471f85dbe147 100644 --- a/app/views/admin/education/teachers/jekyll_collection.yml.erb +++ b/app/views/admin/education/teachers/static.html.erb @@ -1,15 +1,16 @@ -title: "<%= @teacher.to_s %>" -identifier: "<%= @teacher.id %>" +--- +title: > + <%= @teacher.to_s %> +slug: "<%= @teacher.slug %>" first_name: "<%= @teacher.first_name %>" last_name: "<%= @teacher.last_name %>" phone: "<%= @teacher.phone %>" email: "<%= @teacher.email %>" -slug: "<%= @teacher.slug %>" <% if @teacher.education_programs.any? %> programs: <% @teacher.education_programs.each do |program| %> - "<%= program.id %>" <% end %> <% end %> -biography: > - <%= prepare_for_github @teacher.biography, @teacher.university %> +--- +<%= prepare_for_github @teacher.biography, @teacher.university %> diff --git a/app/views/admin/research/journal/articles/jekyll.html.erb b/app/views/admin/research/journal/articles/static.html.erb similarity index 100% rename from app/views/admin/research/journal/articles/jekyll.html.erb rename to app/views/admin/research/journal/articles/static.html.erb diff --git a/app/views/admin/research/journal/volumes/jekyll.html.erb b/app/views/admin/research/journal/volumes/static.html.erb similarity index 100% rename from app/views/admin/research/journal/volumes/jekyll.html.erb rename to app/views/admin/research/journal/volumes/static.html.erb diff --git a/app/views/admin/research/researchers/index.html.erb b/app/views/admin/research/researchers/index.html.erb index eb0e7bb1d8298cb326262210814682bd7241c04e..9f11f2a304ce8ecd440d7237419f3e1307c4ef67 100644 --- a/app/views/admin/research/researchers/index.html.erb +++ b/app/views/admin/research/researchers/index.html.erb @@ -4,6 +4,7 @@ <thead> <tr> <th><%= Administration::Member.human_attribute_name('name') %></th> + <th><%= Administration::Member.human_attribute_name('first_name') %></th> <th><%= t('research.number_of_articles') %></th> </tr> </thead> @@ -11,7 +12,8 @@ <tbody> <% @researchers.each do |researcher| %> <tr> - <td><%= link_to researcher, admin_research_researcher_path(researcher) %></td> + <td><%= link_to researcher.last_name, admin_research_researcher_path(researcher) %></td> + <td><%= link_to researcher.first_name, admin_research_researcher_path(researcher) %></td> <td><%= researcher.research_journal_articles.count %></td> </tr> <% end %> diff --git a/app/views/admin/research/researchers/jekyll_collection.yml.erb b/app/views/admin/research/researchers/static.html.erb similarity index 51% rename from app/views/admin/research/researchers/jekyll_collection.yml.erb rename to app/views/admin/research/researchers/static.html.erb index 3a539eebb52076a5555017fbab40bce82483dc30..ba6513d72803d21aed4d02251467574dd9f2b75d 100644 --- a/app/views/admin/research/researchers/jekyll_collection.yml.erb +++ b/app/views/admin/research/researchers/static.html.erb @@ -1,7 +1,10 @@ -title: "<%= @researcher.to_s %>" +--- +title: > + <%= @researcher.to_s %> +slug: "<%= @researcher.slug %>" first_name: "<%= @researcher.first_name %>" last_name: "<%= @researcher.last_name %>" phone: "<%= @researcher.phone %>" email: "<%= @researcher.email %>" -biography: > - <%= prepare_for_github @researcher.biography, @researcher.university %> +--- +<%= prepare_for_github @researcher.biography, @researcher.university %> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 8928fa86f7138b08940d67df090c6944715e19c6..7c289b1bd6d6fb0c0b189f7e533e0374dccd8365 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -129,14 +129,17 @@ en: new_curation: New curation see_all: See the full list (%{number} elements) enums: - communication/website/menu/item: - kind: - blank: Title - news: News index - news_article: Specific news - news_category: News category - page: Specific Page - program: Specific program - programs: Programs index - staff: Staff - url: URL + communication: + website: + menu: + item: + kind: + blank: Title + news: News index + news_article: Specific news + news_category: News category + page: Specific Page + program: Specific program + programs: Programs index + staff: Staff + url: URL diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 57be17030f4598641d9f3d7e086104f893e18fb8..ce57688d06a53a053550a84bc4b4cefa85c085f9 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -119,14 +119,17 @@ fr: new_curation: Nouvelle curation see_all: Voir la liste complète (%{number} éléments) enums: - communication/website/menu/item: - kind: - blank: Titre intermédiaire - news: Index des actualités - news_article: Actualité spécifique - news_category: Catégorie d'actualités - page: Page spécifique - program: Formation spécifique - programs: Index des formations - staff: Équipe - url: URL + communication: + website: + menu: + item: + kind: + blank: Titre intermédiaire + news: Index des actualités + news_article: Actualité spécifique + news_category: Catégorie d'actualités + page: Page spécifique + program: Formation spécifique + programs: Index des formations + staff: Équipe + url: URL diff --git a/db/migrate/20211224090935_add_path_to_communication_website_category.rb b/db/migrate/20211224090935_add_path_to_communication_website_category.rb new file mode 100644 index 0000000000000000000000000000000000000000..113395ef7e18ca025dc084c07b0c71d07904e24b --- /dev/null +++ b/db/migrate/20211224090935_add_path_to_communication_website_category.rb @@ -0,0 +1,5 @@ +class AddPathToCommunicationWebsiteCategory < ActiveRecord::Migration[6.1] + def change + add_column :communication_website_categories, :path, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index ba4496448e3cc3ecc2b94c11c520297af4ddd4ef..c72e6d804eae9f92715907b1e4d5d7a8204ab0bf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_12_23_085935) do +ActiveRecord::Schema.define(version: 2021_12_24_090935) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -109,6 +109,7 @@ ActiveRecord::Schema.define(version: 2021_12_23_085935) do t.text "github_path" t.uuid "program_id" t.boolean "is_programs_root", default: false + t.string "path" t.index ["communication_website_id"], name: "idx_communication_website_post_cats_on_communication_website_id" t.index ["parent_id"], name: "index_communication_website_categories_on_parent_id" t.index ["program_id"], name: "index_communication_website_categories_on_program_id"