diff --git a/app/controllers/admin/communication/websites_controller.rb b/app/controllers/admin/communication/websites_controller.rb index ae9e404eaf9c349002eddf98da1afcc9abee85e9..86f2e8ca80dcdebf0fba1fbc8444f42ba8ff3756 100644 --- a/app/controllers/admin/communication/websites_controller.rb +++ b/app/controllers/admin/communication/websites_controller.rb @@ -71,6 +71,9 @@ class Admin::Communication::WebsitesController < Admin::Communication::Applicati protected def website_params - params.require(:communication_website).permit(:name, :url, :repository, :access_token, :about_type, :about_id) + params.require(:communication_website).permit( + :name, :url, :repository, :access_token, :about_type, :about_id, + :authors_github_directory, :posts_github_directory + ) end end diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index 15048d7d5e32eeaa48510b9a30b56809409c0fe6..eddce3c46d84d9db90397544b256592a7b67863b 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -2,16 +2,18 @@ # # Table name: communication_websites # -# id :uuid not null, primary key -# about_type :string -# access_token :string -# name :string -# repository :string -# url :string -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid -# university_id :uuid not null +# id :uuid not null, primary key +# about_type :string +# access_token :string +# authors_github_directory :string +# name :string +# posts_github_directory :string +# repository :string +# url :string +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid +# university_id :uuid not null # # Indexes # diff --git a/app/models/communication/website/author.rb b/app/models/communication/website/author.rb index 65b8783fb19201cfe51698040769b66f6f948f8d..fe7a41c2c5efffa36a59c899f530f0efb003f204 100644 --- a/app/models/communication/website/author.rb +++ b/app/models/communication/website/author.rb @@ -52,7 +52,7 @@ class Communication::Website::Author < ApplicationRecord # Override from WithGithubFiles def github_path_generated - "auteurs/#{slug}.html" + "#{website.authors_github_directory}/#{slug}.html" end def github_manifest diff --git a/app/models/communication/website/category.rb b/app/models/communication/website/category.rb index 11a09fe23f8acaf215e09168c3ad24d861ef2b9c..014bd9ddaf4d74409bd73d779380d2c655221b44 100644 --- a/app/models/communication/website/category.rb +++ b/app/models/communication/website/category.rb @@ -78,7 +78,7 @@ class Communication::Website::Category < ApplicationRecord # Override from WithGithubFiles def github_path_generated - "actualites/#{slug}.html" + "#{website.posts_github_directory}/#{slug}.html" end def github_manifest diff --git a/app/views/admin/communication/website/authors/jekyll.html.erb b/app/views/admin/communication/website/authors/jekyll.html.erb index 2f36fcfbdfd0f56782760acdd94449e612cd12d2..c0f06a33a4db3c6419776e19eb56559635832d02 100644 --- a/app/views/admin/communication/website/authors/jekyll.html.erb +++ b/app/views/admin/communication/website/authors/jekyll.html.erb @@ -2,7 +2,7 @@ title: "<%= @author.to_s %>" slug: "<%= @author.slug %>" identifier: "<%= @author.id %>" -permalink: "/auteurs/<%= @author.slug %>" +permalink: "/<%= @author.website.authors_github_directory %>/<%= @author.slug %>" first_name: "<%= @author.first_name %>" last_name: "<%= @author.last_name %>" biography: > diff --git a/app/views/admin/communication/website/authors/jekyll_collection.yml.erb b/app/views/admin/communication/website/authors/jekyll_collection.yml.erb index 301ee362ddd7cb4b4fa860c81b2e4625457e6209..f4582d8a12aeb7372274b17e1b11f849ab0190e2 100644 --- a/app/views/admin/communication/website/authors/jekyll_collection.yml.erb +++ b/app/views/admin/communication/website/authors/jekyll_collection.yml.erb @@ -1,3 +1,3 @@ name: "<%= @author.to_s %>" identifier: "<%= @author.id %>" -link: "/auteurs/<%= @author.slug %>" +link: "/<%= @author.website.authors_github_directory %>/<%= @author.slug %>" diff --git a/app/views/admin/communication/website/categories/jekyll.html.erb b/app/views/admin/communication/website/categories/jekyll.html.erb index 5cbc3475a1c27b019780f50d9474629ca38b8504..39e21da3ce6b438882cc4d186f8c21c108ce6c80 100644 --- a/app/views/admin/communication/website/categories/jekyll.html.erb +++ b/app/views/admin/communication/website/categories/jekyll.html.erb @@ -2,7 +2,7 @@ title: "<%= @category.name %>" slug: "<%= @category.slug %>" identifier: "<%= @category.id %>" -permalink: "/actualites/<%= @category.slug %>" +permalink: "/<%= @category.website.posts_github_directory %>/<%= @category.slug %>" parent: "<%= @category.parent_id %>" description: > <%= prepare_for_github @category.description, @category.university %> diff --git a/app/views/admin/communication/website/categories/jekyll_collection.yml.erb b/app/views/admin/communication/website/categories/jekyll_collection.yml.erb index 1d9d99738cbfce7800423ba555a349e368f6a23a..93e6b74fedb399e012f74fc8c189e85b172ae642 100644 --- a/app/views/admin/communication/website/categories/jekyll_collection.yml.erb +++ b/app/views/admin/communication/website/categories/jekyll_collection.yml.erb @@ -1,5 +1,5 @@ name: "<%= @category.name %>" identifier: "<%= @category.id %>" -link: "/actualites/<%= @category.slug %>" +link: "/<%= @category.website.posts_github_directory %>/<%= @category.slug %>" parent: "<%= @category.parent_id %>" position: <%= @category.position %> diff --git a/app/views/admin/communication/websites/_form.html.erb b/app/views/admin/communication/websites/_form.html.erb index 840edae94fa63fbbd369850f15f00bba3ef38d12..b45fcf6960dfc3319dec4c0dc2ddc3ae4ee71da1 100644 --- a/app/views/admin/communication/websites/_form.html.erb +++ b/app/views/admin/communication/websites/_form.html.erb @@ -37,6 +37,8 @@ <%= f.input :url %> <%= f.input :repository %> <%= f.input :access_token %> + <%= f.input :authors_github_directory %> + <%= f.input :posts_github_directory %> </div> </div> </div> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 431f195b2199caa5a1c136dbc2abb9027056d4bd..948fa94b43672e4606d08c22fd6ce1c5ed2e3620 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -60,7 +60,9 @@ en: about_Education::School: School website about_Research::Journal: Journal website about_type: About + authors_github_directory: Authors' GitHub directory name: Name + posts_github_directory: Posts' GitHub directory url: URL communication/website/author: biography: Biography diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index e28bdc95707514c683cc9a0200821b2890fa717a..1ebadc3aa10266b0c9c0c4f1760c9900eba7a58b 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -60,7 +60,9 @@ fr: about_Education::School: Site d'école about_Research::Journal: Site de revue scientifique about_type: Sujet du site + authors_github_directory: Dossier GitHub des auteurs name: Nom + posts_github_directory: Dossier GitHub des actualités url: URL communication/website/author: biography: Biographie diff --git a/db/migrate/20211210145958_add_categories_and_authors_github_directories_to_communication_websites.rb b/db/migrate/20211210145958_add_categories_and_authors_github_directories_to_communication_websites.rb new file mode 100644 index 0000000000000000000000000000000000000000..378d79e0c16538078e60db043e47d444a8458b9b --- /dev/null +++ b/db/migrate/20211210145958_add_categories_and_authors_github_directories_to_communication_websites.rb @@ -0,0 +1,6 @@ +class AddCategoriesAndAuthorsGithubDirectoriesToCommunicationWebsites < ActiveRecord::Migration[6.1] + def change + add_column :communication_websites, :authors_github_directory, :string + add_column :communication_websites, :posts_github_directory, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 98bd292dd3d7f73f20dcb93dc2dcc21e28984fa0..51550f05c1e89f48065bd9d81d23556ef307f320 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_10_112555) do +ActiveRecord::Schema.define(version: 2021_12_10_145958) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -334,6 +334,8 @@ ActiveRecord::Schema.define(version: 2021_12_10_112555) do t.string "repository" t.string "about_type" t.uuid "about_id" + t.string "authors_github_directory" + t.string "posts_github_directory" t.index ["about_type", "about_id"], name: "index_communication_websites_on_about" t.index ["university_id"], name: "index_communication_websites_on_university_id" end diff --git a/lib/tasks/app.rake b/lib/tasks/app.rake index d5d196178625107ab6b480803aba6efcd9f03540..ce967d66533e11eab285f2c800d1795a7a3325c0 100644 --- a/lib/tasks/app.rake +++ b/lib/tasks/app.rake @@ -56,6 +56,11 @@ namespace :app do 10.times do Education::Program.find_each { |p| p.update_column :path, "#{p.parent&.path}/#{p.slug}".gsub(/\/+/, '/') } end + + Communication::Website.all.find_each { |website| + website.update_column(:authors_github_directory, "auteurs") if website.authors_github_directory.blank? + website.update_column(:posts_github_directory, "actualites") if website.posts_github_directory.blank? + } end namespace :db do