ver las categorias de un post y poder filtrar

This commit is contained in:
f 2018-02-19 18:16:48 -03:00
parent e90e20a901
commit 3a8c004ec7
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
3 changed files with 10 additions and 4 deletions

View file

@ -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

View file

@ -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

View file

@ -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)