diff --git a/app/controllers/extranet/posts/posts_controller.rb b/app/controllers/extranet/posts/posts_controller.rb index 3705bd3fb3c5a9c7c43c1880d2bf9c888de5b922..fd434c9902d380b947883fd6f1bd1acca7b0d19d 100644 --- a/app/controllers/extranet/posts/posts_controller.rb +++ b/app/controllers/extranet/posts/posts_controller.rb @@ -9,6 +9,7 @@ class Extranet::Posts::PostsController < Extranet::Posts::ApplicationController end def show + # TODO utiliser la date pour permettre des slugs identiques à dates différentes @post = current_extranet.posts.find_by! slug: params[:slug] breadcrumb end diff --git a/app/views/admin/communication/extranets/posts/show.html.erb b/app/views/admin/communication/extranets/posts/show.html.erb index d0c64ed9e89c75ba76b4daa729a5ef3390130778..8515a14c5a5dfe14427494845a6c4700fb3ef1e0 100644 --- a/app/views/admin/communication/extranets/posts/show.html.erb +++ b/app/views/admin/communication/extranets/posts/show.html.erb @@ -31,7 +31,7 @@ <% content_for :action_bar_right do %> <%= link_to t('open'), - posts_post_url(@post.slug, host: @post.extranet.url, extranet_id: nil), + posts_post_url(date: @post.published_at.strftime('%Y-%m-%d'), slug: @post.slug, host: @post.extranet.url, extranet_id: nil), target: :_blank, class: 'btn btn-light btn-xs' if @post.published %> <%= preview_link %> diff --git a/app/views/extranet/posts/posts/_list.html.erb b/app/views/extranet/posts/posts/_list.html.erb index 6d0ba3ad4c0b4cd5be0dfce35e84de33d722192d..616e507b66be2a77486f173d2224b4200cf103fa 100644 --- a/app/views/extranet/posts/posts/_list.html.erb +++ b/app/views/extranet/posts/posts/_list.html.erb @@ -9,7 +9,9 @@ <b><%= post %></b><br> <span class="text-muted"><%= l post.published_at.to_date %><span> </p> - <%= link_to t('extranet.posts.read_post'), posts_post_path(post.slug), class: ' btn btn-outline-primary stretched-link' %> + <%= link_to t('extranet.posts.read_post'), + posts_post_path(date: post.published_at.strftime('%Y-%m-%d'), slug: post.slug), + class: ' btn btn-outline-primary stretched-link' %> </div> </article> <% end %> diff --git a/config/routes/extranet.rb b/config/routes/extranet.rb index f62c4b0e96b0d094f1efd00c227b73f203a6d586..70d9300e1eaa2bfbf29543a0eadf14547444ca57 100644 --- a/config/routes/extranet.rb +++ b/config/routes/extranet.rb @@ -27,7 +27,7 @@ namespace :posts do get 'categories' => 'categories#index', as: :categories get 'categories/:slug' => 'categories#show', as: :category # Categories before slug ! - get ':slug' => 'posts#show', as: :post + get ':date/:slug' => 'posts#show', as: :post root to: 'posts#index' end namespace :library do