Added author and upload date to post view

This commit is contained in:
Marcin Kurczewski 2014-09-21 23:01:01 +02:00
parent 881d2a6b38
commit 51a80c22c5
4 changed files with 53 additions and 6 deletions

3
TODO
View file

@ -4,13 +4,10 @@ first major release.
everything related to posts: everything related to posts:
- single post view - single post view
- basic information - basic information
- uploader's picture
- remember about support for anonymous uploads
- safety - safety
- source - source
- image dimensions - image dimensions
- time of last edit - time of last edit
- time of upload
- time of last feature - time of last feature
- how many times the post was featured - how many times the post was featured
- download - download

View file

@ -14,6 +14,12 @@
font-size: 90%; font-size: 90%;
} }
#post-view-wrapper #sidebar h1 {
margin-top: 1.5em;
font-weight: normal;
font-size: 30px;
}
#post-view-wrapper #sidebar h1:first-of-type { #post-view-wrapper #sidebar h1:first-of-type {
margin-top: 0; margin-top: 0;
} }
@ -70,3 +76,11 @@
color: silver; color: silver;
padding-left: 0.5em; padding-left: 0.5em;
} }
#sidebar .author-box img {
float: left;
margin-right: 0.5em;
}
#sidebar .author-box .author-name {
font-weight: bold;
}

View file

@ -11,6 +11,30 @@
</li> </li>
<% }) %> <% }) %>
</ul> </ul>
<h1>Details</h1>
<div class="author-box">
<% if (post.user.name) { %>
<a href="#/user/<%= post.user.name %>">
<% } %>
<img class="author-avatar"
src="/data/thumbnails/40x40/avatars/<%= post.user.name || '!' %>"
alt="<%= post.user.name || 'Anonymous user' %>"/>
<span class="author-name">
<%= post.user.name || 'Anonymous user' %>
</span>
<% if (post.user.name) { %>
</a>
<% } %>
<br/>
<span class="date"><%= formatRelativeTime(post.uploadTime) %></span>
</div>
</div> </div>
<div id="post-view"> <div id="post-view">

View file

@ -27,7 +27,14 @@ final class UserAvatarController extends AbstractController
public function getAvatarByName($userName, $size) public function getAvatarByName($userName, $size)
{ {
$user = $this->userService->getByName($userName); try
{
$user = $this->userService->getByName($userName);
}
catch (\Exception $e)
{
$this->serveBlankFile($size);
}
switch ($user->getAvatarStyle()) switch ($user->getAvatarStyle())
{ {
@ -38,7 +45,7 @@ final class UserAvatarController extends AbstractController
break; break;
case \Szurubooru\Entities\User::AVATAR_STYLE_BLANK: case \Szurubooru\Entities\User::AVATAR_STYLE_BLANK:
$this->serveFromFile($this->getBlankAvatarSourceContentPath(), $size); $this->serveBlankFile($size);
break; break;
case \Szurubooru\Entities\User::AVATAR_STYLE_MANUAL: case \Szurubooru\Entities\User::AVATAR_STYLE_MANUAL:
@ -46,7 +53,7 @@ final class UserAvatarController extends AbstractController
break; break;
default: default:
$this->serveFromFile($this->getBlankAvatarSourceContentPath(), $size); $this->serveBlankFile($size);
break; break;
} }
} }
@ -63,6 +70,11 @@ final class UserAvatarController extends AbstractController
$this->fileService->serve($thumbnailName); $this->fileService->serve($thumbnailName);
} }
private function serveBlankFile($size)
{
$this->serveFromFile($this->getBlankAvatarSourceContentPath(), $size);
}
private function getBlankAvatarSourceContentPath() private function getBlankAvatarSourceContentPath()
{ {
return 'avatars/blank.png'; return 'avatars/blank.png';