Skip to content

Commit

Permalink
Merge pull request spf13#7 from lornajane/authors
Browse files Browse the repository at this point in the history
Adding author display name to posts
  • Loading branch information
spf13 committed Jan 10, 2012
2 parents 9ff7674 + d2cdf50 commit d51557c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
12 changes: 12 additions & 0 deletions app/routes/post.php
Expand Up @@ -12,17 +12,29 @@ function __construct() {
$prefix = $this->prefix;

$s->get($this->base . "(:slug)", $this->page_init(), function ($slug) use ($s) {
$author_list = $s->db->users->find();
$authors = array();
foreach ($author_list as $a) {
$authors[$a['_id']] = $a['display_name'];
}
return $s->render('posts/view.tpl', array(
'action_name' => 'List',
'label' => 'Post',
'authors' => $authors,
'post' => $s->db->articles->findone(array('slug' => $slug))
));
})->name($prefix);

$s->get("/", $this->page_init(), function () use ($s) {
$author_list = $s->db->users->find();
$authors = array();
foreach ($author_list as $a) {
$authors[$a['_id']] = $a['display_name'];
}
return $s->render('posts/home.tpl', array(
'action_name' => 'List',
'label' => 'Posts',
'authors' => $authors,
'posts' => $s->db->articles->find()
));
})->name('home');
Expand Down
7 changes: 7 additions & 0 deletions app/routes/tag.php
Expand Up @@ -12,10 +12,17 @@ function __construct() {
$prefix = $this->prefix;

$s->get($this->base . "(:tag)", $this->page_init(), function ($tag) use ($s) {
$author_list = $s->db->users->find();
$authors = array();
foreach ($author_list as $a) {
$authors[$a['_id']] = $a['display_name'];
}

return $s->render('posts/tag.tpl', array(
'tag' => $tag,
'label' => 'Posts by Tag',
'action_name' => 'List',
'authors' => $authors,
'posts' => $s->db->articles->find(array('tags' => $tag))));
})->name($prefix);
}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/posts/single.tpl
@@ -1,6 +1,6 @@
<li class="post">
<h3 class="post_title">{$post.title}</h3>
<a class="date" href="{slimurl name=post key=slug val=$post.slug}" title="Permanent link">{$post.created_at|date_format}</a>
<span class="date"><a href="{slimurl name=post key=slug val=$post.slug}" title="Permanent link">{$post.created_at->sec|date_format}</a> by {$authors.{$post.author}}</span>
<div class="post_body">
{$post.content}
</div>
Expand Down
2 changes: 1 addition & 1 deletion public/style/css/public.css
Expand Up @@ -104,7 +104,7 @@ li.tag {
padding:1em;
}

a.date {
.date {
top: -1.3em;
margin-left: 2px;
position: relative;
Expand Down

0 comments on commit d51557c

Please sign in to comment.