ver un articulo

This commit is contained in:
f 2018-01-30 12:20:19 -03:00
parent 6fb899a15b
commit 24b0d74221
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
5 changed files with 46 additions and 1 deletions

View file

@ -19,4 +19,12 @@ class ApplicationController < ActionController::Base
s.id == id
end
end
def find_post(site)
id = params[:post_id] || params[:id]
site.posts.find do |p|
p.id == id
end
end
end

View file

@ -4,4 +4,9 @@ class PostsController < ApplicationController
def index
@site = find_site
end
def show
@site = find_site
@post = find_post(@site)
end
end

View file

@ -72,6 +72,14 @@ class Post
@post.basename != basename_from_front_matter
end
def data
@post.data
end
def content
@post.content
end
private
def new_post

View file

@ -5,4 +5,4 @@
- @site.posts.each do |post|
%tr
%td= link_to post.title, site_post_path(@site, post)
%td= post.date
%td= post.date.strftime('%F')

24
app/views/posts/show.haml Normal file
View file

@ -0,0 +1,24 @@
.row
%h1= @post.title
.content
:markdown
#{@post.content}
%table.table.table-condensed.table-striped
%tbody
- @post.data.each do |key, data|
%tr
%th= key
%td
- if data.respond_to? :each
- data.each do |d|
%span.badge.badge-success= d
- elsif data.respond_to? :content
:markdown
#{data.content}
- elsif data.respond_to? :strftime
= data.strftime('%F')
- else
= data