From 6b9e25fda2e976088eddd65222890f1ad94a5c28 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Mon, 10 Oct 2022 18:10:38 +0200 Subject: [PATCH] list sites --- app/controllers/server/websites_controller.rb | 8 +++++++ app/views/server/universities/index.html.erb | 2 +- app/views/server/websites/index.html.erb | 22 +++++++++++++++++++ config/routes/server.rb | 2 +- config/server_navigation.rb | 3 +++ 5 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 app/controllers/server/websites_controller.rb create mode 100644 app/views/server/websites/index.html.erb diff --git a/app/controllers/server/websites_controller.rb b/app/controllers/server/websites_controller.rb new file mode 100644 index 000000000..764ba04ca --- /dev/null +++ b/app/controllers/server/websites_controller.rb @@ -0,0 +1,8 @@ +class Server::WebsitesController < Server::ApplicationController + + def index + @websites = Communication::Website.all.ordered + breadcrumb + end + +end \ No newline at end of file diff --git a/app/views/server/universities/index.html.erb b/app/views/server/universities/index.html.erb index 4859d8cda..17c0ece01 100644 --- a/app/views/server/universities/index.html.erb +++ b/app/views/server/universities/index.html.erb @@ -1,4 +1,4 @@ -<% content_for :title, University.model_name.human(count: 2) %> +<% content_for :title, "#{ @universities.count} #{University.model_name.human(count: @universities.count).downcase}" %> <div class="table-responsive"> <table class="<%= table_classes %>"> diff --git a/app/views/server/websites/index.html.erb b/app/views/server/websites/index.html.erb new file mode 100644 index 000000000..747e9f8bf --- /dev/null +++ b/app/views/server/websites/index.html.erb @@ -0,0 +1,22 @@ +<% content_for :title, "#{@websites.count} #{Communication::Website.model_name.human(count: @websites.count).downcase}" %> + +<div class="table-responsive"> + <table class="<%= table_classes %>"> + <thead> + <tr> + <th><%= Communication::Website.human_attribute_name('name') %></th> + <th><%= Communication::Website.human_attribute_name('url') %></th> + <th><%= University.model_name.human %></th> + </tr> + </thead> + <tbody> + <% @websites.each do |website| %> + <tr> + <td><%= website.name %></td> + <td><%= link_to website.url, website.url, target: :_blank if website.url.present? %></td> + <td><%= link_to website.university, [:server, website.university] %></td> + </tr> + <% end %> + </tbody> + </table> +</div> \ No newline at end of file diff --git a/config/routes/server.rb b/config/routes/server.rb index c76985a75..394797b29 100644 --- a/config/routes/server.rb +++ b/config/routes/server.rb @@ -1,5 +1,5 @@ namespace :server do - resources :universities, :languages + resources :universities, :languages, :websites get 'blocks' => 'blocks#index', as: :blocks get 'blocks/:id' => 'blocks#show', as: :block post 'blocks/:id' => 'blocks#resave', as: :resave_block diff --git a/config/server_navigation.rb b/config/server_navigation.rb index 5aca9b137..c2b389ca7 100644 --- a/config/server_navigation.rb +++ b/config/server_navigation.rb @@ -11,6 +11,9 @@ SimpleNavigation::Configuration.run do |navigation| primary.item :universities, University.model_name.human(count: 2), server_universities_path, { icon: 'university' } if can?(:read, University) + primary.item :websites, + Communication::Website.model_name.human(count: 2), + server_websites_path, { icon: 'globe' } primary.item :languages, Language.model_name.human(count: 2), server_languages_path, -- GitLab