0
0
Fork 0

add post controller

This adds the post controller to get the posts from the database and
make apply all filters needed to make it a workable result.
This commit is contained in:
Gibheer 2013-10-26 14:56:55 +02:00
parent 8d7938d108
commit 0e547febf1
3 changed files with 28 additions and 6 deletions

15
controller/post.rb Normal file
View File

@ -0,0 +1,15 @@
module Routes
class Post < Controller
def self.get(session)
posts = DB[:posts].
filter(:released => true).
select(:posts__id___post_id, :written, :title, :content).
join(:accounts, :id___account_id => :account_id).
reverse_order(:written)
posts = posts.where(:posts__id => session.options[:id]) if session.options[:id]
puts posts.literal(:account__id___account_id)
session.options[:posts] = posts
session.options[:render] = 'posts/index'
end
end
end

View File

@ -1,7 +1,7 @@
module Routes
class Welcome < Controller
def self.get(session)
session.options[:render] = 'posts/index'
class Welcome
def self.call(session)
Post
end
end
end

View File

@ -1,4 +1,4 @@
doctype html
doctype 5
html
head
title zero-knowledge
@ -7,6 +7,13 @@ html
h1 zero-knowledge
h2 noch ohne blub
#content
- for post in DB[:posts] do
- for post in fetch(:posts)
article
= post[:title]
header
h1
a href="/post/#{post[:post_id]}"= post[:title]
footer
.author=post[:username]
.date= post[:written].strftime('%Y-%m-%d')
.time= post[:written].strftime('%H-%M')
section= post[:content]