ver un articulo
This commit is contained in:
parent
6fb899a15b
commit
24b0d74221
5 changed files with 46 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -4,4 +4,9 @@ class PostsController < ApplicationController
|
|||
def index
|
||||
@site = find_site
|
||||
end
|
||||
|
||||
def show
|
||||
@site = find_site
|
||||
@post = find_post(@site)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
24
app/views/posts/show.haml
Normal 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
|
Loading…
Reference in a new issue