diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 56cb214..565f435 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -3,6 +3,7 @@ class PostsController < ApplicationController def index @site = find_site + @category = session[:category] = params.dig(:category) end def show @@ -39,7 +40,7 @@ class PostsController < ApplicationController @post.update_attributes(p) if @post.save - redirect_to site_post_path(@site, @post) + redirect_to site_posts_path(@site, category: session[:category]) else render 'posts/edit' end diff --git a/app/views/layouts/_breadcrumb.haml b/app/views/layouts/_breadcrumb.haml index 2eed3d4..4773631 100644 --- a/app/views/layouts/_breadcrumb.haml +++ b/app/views/layouts/_breadcrumb.haml @@ -1,6 +1,6 @@ %nav{'aria-label': 'breadcrumb', role: 'navigation'} %ol.breadcrumb - - crumbs.each do |crumb| + - crumbs.compact.each do |crumb| - if crumb == crumbs.last %li.breadcrumb-item.active{'aria-current': 'page'}= crumb - else diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index e25bf6f..d802026 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -1,6 +1,6 @@ .row .col - = render 'layouts/breadcrumb', crumbs: [ link_to(t('sites.index'), sites_path), @site.name, t('posts.index') ] + = render 'layouts/breadcrumb', crumbs: [ link_to(t('sites.index'), sites_path), @site.name, link_to(t('posts.index'), site_posts_path(@site)), @category ] .row .col %h1= @site.name @@ -15,10 +15,15 @@ %table.table.table-condensed.table-striped %tbody - @site.posts.each do |post| + - if @category + - next unless post.categories.include?(@category) - direction = post.get_front_matter(:dir) %tr %td{class: direction} = link_to post.title, site_post_path(@site, post) %br - %small= post.categories.join(', ') + %small + - post.categories.each do |c| + = link_to c, site_posts_path(@site, category: c) %td= post.date.strftime('%F') + %td= link_to t('post.edit'), edit_site_post_path(@site, post)