This commit is contained in:
Marcin Kurczewski 2013-10-12 22:37:18 +02:00
parent 6e7791e94b
commit 21f4669a98
12 changed files with 176 additions and 186 deletions

View file

@ -136,6 +136,8 @@ a:hover i[class*='icon-'] {
padding: 10px; padding: 10px;
border-style: solid; border-style: solid;
border-width: 1px; border-width: 1px;
max-width: 500px;
margin: 0 auto;
} }
.alert-error { .alert-error {

View file

@ -26,6 +26,7 @@ class Bootstrap
$this->config->chibi->baseUrl = 'http://' . rtrim($_SERVER['HTTP_HOST'], '/') . '/'; $this->config->chibi->baseUrl = 'http://' . rtrim($_SERVER['HTTP_HOST'], '/') . '/';
session_start(); session_start();
$this->context->handleExceptions = false;
$this->context->title = $this->config->main->title; $this->context->title = $this->config->main->title;
$this->context->stylesheets = $this->context->stylesheets =
[ [
@ -63,6 +64,8 @@ class Bootstrap
$this->context->transport->errorMessage = rtrim($e->getMessage(), '.') . '.'; $this->context->transport->errorMessage = rtrim($e->getMessage(), '.') . '.';
$this->context->transport->exception = $e; $this->context->transport->exception = $e;
$this->context->transport->success = false; $this->context->transport->success = false;
if (!$this->context->handleExceptions)
$this->context->viewName = 'error-simple';
(new \Chibi\View())->renderFile($this->context->layoutName); (new \Chibi\View())->renderFile($this->context->layoutName);
} }
catch (Exception $e) catch (Exception $e)

View file

@ -12,6 +12,7 @@ class AuthController
*/ */
public function loginAction() public function loginAction()
{ {
$this->context->handleExceptions = true;
$this->context->stylesheets []= 'auth.css'; $this->context->stylesheets []= 'auth.css';
$this->context->subTitle = 'authentication form'; $this->context->subTitle = 'authentication form';
@ -62,6 +63,7 @@ class AuthController
*/ */
public function registerAction() public function registerAction()
{ {
$this->context->handleExceptions = true;
$this->context->stylesheets []= 'auth.css'; $this->context->stylesheets []= 'auth.css';
$this->context->subTitle = 'registration form'; $this->context->subTitle = 'registration form';

View file

@ -8,6 +8,6 @@ class CommentController
{ {
$this->context->activeSection = 'comments'; $this->context->activeSection = 'comments';
$this->context->subTitle = 'comments'; $this->context->subTitle = 'comments';
throw new Exception('Not implemented'); throw new SimpleException('Not implemented');
} }
} }

View file

@ -7,7 +7,7 @@ class UserController
public function listAction() public function listAction()
{ {
$this->context->subTitle = 'users'; $this->context->subTitle = 'users';
throw new Exception('Not implemented'); throw new SimpleException('Not implemented');
} }
/** /**
@ -17,6 +17,6 @@ class UserController
public function viewAction($name) public function viewAction($name)
{ {
$this->context->subTitle = $name; $this->context->subTitle = $name;
throw new Exception('Not implemented'); throw new SimpleException('Not implemented');
} }
} }

View file

@ -4,7 +4,3 @@
<p>However, you still need to be approved by admin.</p> <p>However, you still need to be approved by admin.</p>
<?php endif ?> <?php endif ?>
<?php endif ?> <?php endif ?>
<?php if (isset($this->context->transport->errorMessage)): ?>
<p class="alert alert-error"><?php echo $this->context->transport->errorMessage ?></p>
<?php endif ?>

View file

@ -37,9 +37,9 @@
</div> </div>
<?php if (isset($this->context->transport->errorMessage)): ?> <?php if (isset($this->context->transport->errorMessage)): ?>
<div> <div>
<p class="alert alert-error">Error: <?php echo $this->context->transport->errorMessage ?></p> <p class="alert alert-error">Error: <?php echo $this->context->transport->errorMessage ?></p>
</div> </div>
<?php endif ?> <?php endif ?>
<div> <div>

View file

@ -0,0 +1 @@
<p class="alert alert-error">Error: <?php echo $this->context->transport->errorMessage ?><br><a href="javascript:history.go(-1)">Go back</a></p>

View file

@ -1,6 +1,4 @@
<?php if (!empty($this->context->transport->errorMessage)): ?> <?php if (empty($this->context->transport->posts)): ?>
<p class="alert alert-error"><?php echo $this->context->transport->errorMessage ?></p>
<?php elseif (empty($this->context->transport->posts)): ?>
<p class="alert alert-warning">No posts to show.</p> <p class="alert alert-warning">No posts to show.</p>
<?php else: ?> <?php else: ?>
<div class="posts paginator-content"> <div class="posts paginator-content">

View file

@ -1,7 +1,5 @@
<?php if ($this->context->transport->success === true): ?> <?php if ($this->context->transport->success === true): ?>
<p>Post created!</p> <p>Post created!</p>
<?php elseif (isset($this->context->transport->errorMessage)): ?>
<p class="alert alert-error"><?php echo $this->context->transport->errorMessage ?></p>
<?php else: ?> <?php else: ?>
<div id="sidebar"> <div id="sidebar">

View file

@ -1,183 +1,177 @@
<?php if (!empty($this->context->transport->errorMessage)): ?> <div id="sidebar">
<p class="alert alert-error"><?php echo $this->context->transport->errorMessage ?></p> <nav>
<?php else: ?> <div class="left">
<?php if ($this->context->transport->nextPostId): ?>
<a href="<?php echo \Chibi\UrlHelper::route('post', 'view', ['id' => $this->context->transport->nextPostId]) ?>">
<?php else: ?>
<a class="inactive">
<?php endif ?>
<i class="icon-next"></i>
<span>next post</span>
</a>
</div>
<div id="sidebar"> <div class="right">
<nav> <?php if ($this->context->transport->prevPostId): ?>
<div class="left"> <a href="<?php echo \Chibi\UrlHelper::route('post', 'view', ['id' => $this->context->transport->prevPostId]) ?>">
<?php if ($this->context->transport->nextPostId): ?> <?php else: ?>
<a href="<?php echo \Chibi\UrlHelper::route('post', 'view', ['id' => $this->context->transport->nextPostId]) ?>"> <a class="inactive">
<?php else: ?> <?php endif ?>
<a class="inactive"> <span>prev post</span>
<?php endif ?> <i class="icon-prev"></i>
<i class="icon-next"></i> </a>
<span>next post</span> </div>
<div class="clear"></div>
</nav>
<div class="sidebar-unit tags">
<h1>tags (<?php echo count($this->context->transport->post->sharedTag) ?>)</h1>
<!-- todo: edit tags -->
<ul>
<?php foreach ($this->context->transport->post->sharedTag as $tag): ?>
<li>
<a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => $tag->name]) ?>">
<?php echo $tag->name ?>
</a>
<span class="count">
<?php echo TextHelper::useDecimalUnits($this->context->transport->tagDistribution[$tag->name]) ?>
</span>
</li>
<?php endforeach ?>
</ul>
</div>
<div class="sidebar-unit details">
<h1>details</h1>
<div class="safety">
<span class="key">Safety:</span>
<span class="value"><?php echo PostSafety::toString($this->context->transport->post->safety) ?></span>
</div>
<div class="uploader">
<span class="key">Uploader:</span>
<span class="value">
<a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $this->context->transport->post->uploader->id]) ?>">
<?php echo $this->context->transport->post->uploader->name ?>
</a> </a>
</span>
</div>
<div class="date">
<span class="key">Date:</span>
<span class="value"><?php echo date('Y-m-d H:i', $this->context->transport->post->upload_date) ?></span>
</div>
<?php if ($this->context->transport->post->image_width > 0): ?>
<div class="dim">
<span class="key">Dimensions:</span>
<span class="value"><?php printf('%dx%d',
$this->context->transport->post->image_width,
$this->context->transport->post->image_height) ?></span>
</div> </div>
<?php endif ?>
<div class="right"> <div class="permalink">
<?php if ($this->context->transport->prevPostId): ?> <a href="<?php echo \Chibi\UrlHelper::route('post', 'retrieve', ['name' => $this->context->transport->post->name]) ?>" alt="<?php echo $this->context->transport->post->name ?>">
<a href="<?php echo \Chibi\UrlHelper::route('post', 'view', ['id' => $this->context->transport->prevPostId]) ?>"> <i class="icon-dl"></i>
<?php else: ?> <span class="ext">
<a class="inactive"> <?php echo strtoupper(substr($this->context->transport->post->orig_name, strrpos($this->context->transport->post->orig_name, '.') + 1)) ?>
<?php endif ?> </span>
<span>prev post</span> <span class="size">
<i class="icon-prev"></i> <?php echo TextHelper::useBytesUnits($this->context->transport->post->file_size) ?>
</a> </span>
</div> </a>
</div>
</div>
<div class="clear"></div> <div class="sidebar-unit favorites">
</nav> <?php if (count($this->context->transport->post->ownFavoritee) == 0): ?>
<h1>favorites</h1>
<div class="sidebar-unit tags"> <p>None yet.</p>
<h1>tags (<?php echo count($this->context->transport->post->sharedTag) ?>)</h1> <?php else: ?>
<!-- todo: edit tags --> <h1>favorites (<?php echo count($this->context->transport->post->ownFavoritee) ?>)</h1>
<ul> <ul>
<?php foreach ($this->context->transport->post->sharedTag as $tag): ?> <?php foreach ($this->context->transport->post->via('favoritee')->sharedUser as $user): ?>
<li> <li>
<a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => $tag->name]) ?>"> <a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $user->name]) ?>">
<?php echo $tag->name ?> <img src="<?php echo $user->avatarUrl() ?>" alt="<?php echo $user->name ?>">
</a> </a>
<span class="count">
<?php echo TextHelper::useDecimalUnits($this->context->transport->tagDistribution[$tag->name]) ?>
</span>
</li> </li>
<?php endforeach ?> <?php endforeach ?>
</ul> </ul>
</div> <?php endif ?>
</div>
<div class="sidebar-unit details"> <div class="sidebar-unit options">
<h1>details</h1> <h1>options</h1>
<div class="safety"> <nav>
<span class="key">Safety:</span> <ul>
<span class="value"><?php echo PostSafety::toString($this->context->transport->post->safety) ?></span> <?php if (PrivilegesHelper::confirm($this->context->user, Privilege::FavoritePost)): ?>
</div> <?php if (!$this->context->favorite): ?>
<li class="add-fav">
<div class="uploader"> <a href="<?php echo \Chibi\UrlHelper::route('post', 'add-favorite', ['id' => $this->context->transport->post->id]) ?>">
<span class="key">Uploader:</span> Add to favorites
<span class="value"> </a>
<a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $this->context->transport->post->uploader->id]) ?>"> </li>
<?php echo $this->context->transport->post->uploader->name ?> <?php else: ?>
</a> <li class="rem-fav">
</span> <a href="<?php echo \Chibi\UrlHelper::route('post', 'rem-favorite', ['id' => $this->context->transport->post->id]) ?>">
</div> Remove from favorites
<div class="date">
<span class="key">Date:</span>
<span class="value"><?php echo date('Y-m-d H:i', $this->context->transport->post->upload_date) ?></span>
</div>
<?php if ($this->context->transport->post->image_width > 0): ?>
<div class="dim">
<span class="key">Dimensions:</span>
<span class="value"><?php printf('%dx%d',
$this->context->transport->post->image_width,
$this->context->transport->post->image_height) ?></span>
</div>
<?php endif ?>
<div class="permalink">
<a href="<?php echo \Chibi\UrlHelper::route('post', 'retrieve', ['name' => $this->context->transport->post->name]) ?>" alt="<?php echo $this->context->transport->post->name ?>">
<i class="icon-dl"></i>
<span class="ext">
<?php echo strtoupper(substr($this->context->transport->post->orig_name, strrpos($this->context->transport->post->orig_name, '.') + 1)) ?>
</span>
<span class="size">
<?php echo TextHelper::useBytesUnits($this->context->transport->post->file_size) ?>
</span>
</a>
</div>
</div>
<div class="sidebar-unit favorites">
<?php if (count($this->context->transport->post->ownFavoritee) == 0): ?>
<h1>favorites</h1>
<p>None yet.</p>
<?php else: ?>
<h1>favorites (<?php echo count($this->context->transport->post->ownFavoritee) ?>)</h1>
<ul>
<?php foreach ($this->context->transport->post->via('favoritee')->sharedUser as $user): ?>
<li>
<a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $user->name]) ?>">
<img src="<?php echo $user->avatarUrl() ?>" alt="<?php echo $user->name ?>">
</a> </a>
</li> </li>
<?php endforeach ?>
</ul>
<?php endif ?>
</div>
<div class="sidebar-unit options">
<h1>options</h1>
<nav>
<ul>
<?php if (PrivilegesHelper::confirm($this->context->user, Privilege::FavoritePost)): ?>
<?php if (!$this->context->favorite): ?>
<li class="add-fav">
<a href="<?php echo \Chibi\UrlHelper::route('post', 'add-favorite', ['id' => $this->context->transport->post->id]) ?>">
Add to favorites
</a>
</li>
<?php else: ?>
<li class="rem-fav">
<a href="<?php echo \Chibi\UrlHelper::route('post', 'rem-favorite', ['id' => $this->context->transport->post->id]) ?>">
Remove from favorites
</a>
</li>
<?php endif ?>
<?php endif ?> <?php endif ?>
<?php endif ?>
<!-- <!--
<li> <li>
<a href="#"> <a href="#">
Edit tags Edit tags
</a> </a>
</li> </li>
<li> <li>
<a href="#"> <a href="#">
Change safety Change safety
</a> </a>
</li> </li>
<li> <li>
<a href="#"> <a href="#">
Show on main page Show on main page
</a> </a>
</li> </li>
<li> <li>
<a href="#"> <a href="#">
Hide from main page Hide from main page
</a> </a>
</li> </li>
<li> <li>
<a href="#"> <a href="#">
Remove Remove
</a> </a>
</li> </li>
--> -->
</ul> </ul>
</nav> </nav>
<script type="text/javascript"> <script type="text/javascript">
if (!$('.options ul li').length) if (!$('.options ul li').length)
$('.options').hide(); $('.options').hide();
</script> </script>
</div>
</div> </div>
</div>
<div id="inner-content"> <div id="inner-content">
<div class="post-wrapper"> <div class="post-wrapper">
<?php if ($this->context->transport->post->type == PostType::Image): ?> <?php if ($this->context->transport->post->type == PostType::Image): ?>
<img src="<?php echo \Chibi\UrlHelper::route('post', 'retrieve', ['name' => $this->context->transport->post->name]) ?>" alt="<?php echo $this->context->transport->post->name ?>"/> <img src="<?php echo \Chibi\UrlHelper::route('post', 'retrieve', ['name' => $this->context->transport->post->name]) ?>" alt="<?php echo $this->context->transport->post->name ?>"/>
<?php elseif ($this->context->transport->post->type == PostType::Flash): ?> <?php elseif ($this->context->transport->post->type == PostType::Flash): ?>
<embed width="<?php echo $this->context->transport->post->image_width ?>" height="<?php echo $this->context->transport->post->image_height ?>" type="application/x-shockwave-flash" src="<?php echo \Chibi\UrlHelper::route('post', 'retrieve', ['name' => $this->context->transport->post->name]) ?>"/> <embed width="<?php echo $this->context->transport->post->image_width ?>" height="<?php echo $this->context->transport->post->image_height ?>" type="application/x-shockwave-flash" src="<?php echo \Chibi\UrlHelper::route('post', 'retrieve', ['name' => $this->context->transport->post->name]) ?>"/>
<?php endif ?> <?php endif ?>
</div>
</div> </div>
</div>
<?php endif ?>

View file

@ -1,13 +1,9 @@
<?php if (isset($this->context->transport->errorMessage)): ?> <ul>
<p class="alert alert-error"><?php echo $this->context->transport->errorMessage ?></p> <?php foreach ($this->context->transport->tagDistribution as $tagName => $count): ?>
<?php else: ?> <li>
<ul> <a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => $tagName]) ?>">
<?php foreach ($this->context->transport->tagDistribution as $tagName => $count): ?> <?php echo $tagName . ' (' . $count . ')' ?>
<li> </a>
<a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => $tagName]) ?>"> </li>
<?php echo $tagName . ' (' . $count . ')' ?> <?php endforeach ?>
</a> </ul>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>