diff --git a/app/models/administration/member.rb b/app/models/administration/member.rb index 7d399e5ef8a33eac04a631b0600146829021fe49..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,22 +101,12 @@ 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/static", 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/static_collection", - formats: [:yml], - layout: false, - assigns: { author: self, github_file: github_file } - ) } } ] end @@ -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/static_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/static_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/github_file.rb b/app/models/communication/website/github_file.rb index e173927eece776d364d3961e9317c380585989e3..95a09b42e14e91ee20a680fc95cc638d2c0b3abc 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) diff --git a/app/models/communication/website/menu/item.rb b/app/models/communication/website/menu/item.rb index 0f4f2b62daa1d13da1b284040fa455564afb8515..538a99285e5e1ba463d59a5338329837766f78a8 100644 --- a/app/models/communication/website/menu/item.rb +++ b/app/models/communication/website/menu/item.rb @@ -58,22 +58,25 @@ class Communication::Website::Menu::Item < ApplicationRecord end 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 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/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/static.html.erb b/app/views/admin/communication/website/authors/static.html.erb index e563627b9364e1b0a5bb7760e2fbf5c5d8947ae8..b52f8eadc00232b290777c8eb59b98abad0c88b1 100644 --- a/app/views/admin/communication/website/authors/static.html.erb +++ b/app/views/admin/communication/website/authors/static.html.erb @@ -1,17 +1,10 @@ --- -title: "<%= @author.to_s %>" +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 %> +<%= prepare_for_github @author.biography, @author.university %> 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/static_collection.yml.erb b/app/views/admin/education/teachers/static.html.erb similarity index 69% rename from app/views/admin/education/teachers/static_collection.yml.erb rename to app/views/admin/education/teachers/static.html.erb index 954df1c552e2466c7d5985e89a5a9116c20e3f39..8da73a8a3f988110b42f6820a754471f85dbe147 100644 --- a/app/views/admin/education/teachers/static_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/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/static_collection.yml.erb b/app/views/admin/research/researchers/static.html.erb similarity index 51% rename from app/views/admin/research/researchers/static_collection.yml.erb rename to app/views/admin/research/researchers/static.html.erb index 3a539eebb52076a5555017fbab40bce82483dc30..ba6513d72803d21aed4d02251467574dd9f2b75d 100644 --- a/app/views/admin/research/researchers/static_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 %>