Freshened up sidebar

This commit is contained in:
Marcin Kurczewski 2014-02-17 19:50:02 +01:00
parent e7a0fdae26
commit 65c6caa13c
6 changed files with 160 additions and 133 deletions

View file

@ -156,6 +156,7 @@ footer a {
} }
#sidebar h1 { #sidebar h1 {
margin-top: 0; margin-top: 0;
margin-bottom: 10px;
} }

View file

@ -55,13 +55,24 @@ embed {
background-color: silver; background-color: silver;
} }
#sidebar .uploader img { #sidebar .uploader .date {
vertical-align: middle; font-size: 9pt !important;
margin: 0 0.5em 0 0; color: gray;
width: 16px; display: inline-block;
height: 16px; position: relative;
background-image: url('http://www.gravatar.com/avatar/0?f=y&d=mm&s=16'); top: -5px;
} }
#sidebar .uploader img {
vertical-align: text-top;
float: left;
margin: 3px 8px 0 0;
width: 25px;
height: 25px;
background-image: url('http://www.gravatar.com/avatar/0?f=y&d=mm&s=25');
}
#sidebar .unit.details { margin-bottom: 1.5em; }
#sidebar .unit.hl-options { margin-top: 1.5em; }
#sidebar .safety-safe { #sidebar .safety-safe {
color: #43aa43; color: #43aa43;
@ -80,17 +91,19 @@ embed {
i.icon-prev { i.icon-prev {
background-position: -12px -1px; background-position: -12px -1px;
margin-left: 8px;
} }
i.icon-next { i.icon-next {
background-position: -1px -1px; background-position: -1px -1px;
margin-right: 8px;
} }
i.icon-prev, i.icon-prev,
i.icon-next { i.icon-next {
margin: 0 8px;
vertical-align: middle; vertical-align: middle;
width: 8px; width: 8px;
height: 20px; height: 20px;
} }
i.icon-dl { i.icon-dl {
margin: 0; margin: 0;
width: 20px; width: 20px;
@ -98,14 +111,33 @@ i.icon-dl {
background-position: -22px -1px; background-position: -22px -1px;
} }
.permalink { i.icon-edit {
margin: 1em 0; margin: 0;
width: 20px;
height: 20px;
background-position: -43px -22px;
} }
.permalink .icon-dl {
i.icon-fav {
margin: 0;
width: 20px;
height: 20px;
}
.add-fav i.icon-fav {
background-position: -1px -22px;
}
.rem-fav i.icon-fav {
background-position: -22px -22px;
}
.hl-option {
margin: 0.4em 0;
}
.hl-option i[class^='icon'] {
vertical-align: middle; vertical-align: middle;
margin-right: 1em;
} }
.permalink span { .hl-option span {
padding-left: 0.6em;
vertical-align: middle; vertical-align: middle;
} }
.permalink .ext:after { .permalink .ext:after {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -2,7 +2,7 @@ $(function()
{ {
function onDomUpdate() function onDomUpdate()
{ {
$('#sidebar .edit a').click(function(e) $('#sidebar a.edit-post').click(function(e)
{ {
e.preventDefault(); e.preventDefault();
@ -126,5 +126,5 @@ $(function()
Mousetrap.bind('a', function() { var a = $('#sidebar .left a'); var url = a.attr('href'); if (typeof url !== 'undefined') { a.click(); window.location.href = url; } }, 'keyup'); Mousetrap.bind('a', function() { var a = $('#sidebar .left a'); var url = a.attr('href'); if (typeof url !== 'undefined') { a.click(); window.location.href = url; } }, 'keyup');
Mousetrap.bind('d', function() { var a = $('#sidebar .right a'); var url = a.attr('href'); if (typeof url !== 'undefined') { a.click(); window.location.href = url; } }, 'keyup'); Mousetrap.bind('d', function() { var a = $('#sidebar .right a'); var url = a.attr('href'); if (typeof url !== 'undefined') { a.click(); window.location.href = url; } }, 'keyup');
Mousetrap.bind('e', function() { $('li.edit a').trigger('click'); return false; }, 'keyup'); Mousetrap.bind('e', function() { $('a.edit-post').trigger('click'); return false; }, 'keyup');
}); });

View file

@ -4,6 +4,20 @@ LayoutHelper::addStylesheet('post-view.css');
LayoutHelper::addScript('post-view.js'); LayoutHelper::addScript('post-view.js');
LayoutHelper::addStylesheet('../lib/tagit/jquery.tagit.css'); LayoutHelper::addStylesheet('../lib/tagit/jquery.tagit.css');
LayoutHelper::addScript('../lib/tagit/jquery.tagit.js'); LayoutHelper::addScript('../lib/tagit/jquery.tagit.js');
$editPostPrivileges = [
Privilege::EditPostSafety,
Privilege::EditPostTags,
Privilege::EditPostThumb,
Privilege::EditPostSource,
];
$editPostPrivileges = array_fill_keys($editPostPrivileges, false);
foreach (array_keys($editPostPrivileges) as $privilege)
{
if (PrivilegesHelper::confirm($privilege, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->post->getUploader())))
$editPostPrivileges[$privilege] = true;
}
$canEditAnything = count(array_filter($editPostPrivileges)) > 0;
?> ?>
<div id="sidebar"> <div id="sidebar">
@ -41,9 +55,9 @@ LayoutHelper::addScript('../lib/tagit/jquery.tagit.js');
</nav> </nav>
<div class="unit tags"> <div class="unit tags">
<h1>tags (<?php echo count($this->context->transport->post->getTags()) ?>)</h1> <?php $tags = $this->context->transport->post->getTags() ?>
<h1>tags (<?php echo count($tags) ?>)</h1>
<ul> <ul>
<?php $tags = $this->context->transport->post->getTags() ?>
<?php uasort($tags, function($a, $b) { return strnatcasecmp($a->name, $b->name); }) ?> <?php uasort($tags, function($a, $b) { return strnatcasecmp($a->name, $b->name); }) ?>
<?php foreach ($tags as $tag): ?> <?php foreach ($tags as $tag): ?>
<li title="<?php echo $tag->name ?>"> <li title="<?php echo $tag->name ?>">
@ -61,13 +75,12 @@ LayoutHelper::addScript('../lib/tagit/jquery.tagit.js');
<div class="unit details"> <div class="unit details">
<h1>details</h1> <h1>details</h1>
<div class="key-value uploader"> <div class="uploader">
<span class="key">Uploader:</span>
<?php $uploader = $this->context->transport->post->getUploader() ?> <?php $uploader = $this->context->transport->post->getUploader() ?>
<?php if ($uploader): ?> <?php if ($uploader): ?>
<span class="value" title="<?php echo $val = $uploader->name ?>"> <span class="value" title="<?php echo $val = $uploader->name ?>">
<a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $uploader->name]) ?>"> <a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $uploader->name]) ?>">
<img src="<?php echo htmlentities($uploader->getAvatarUrl(16)) ?>" alt="<?php echo $uploader->name ?>"/> <img src="<?php echo htmlentities($uploader->getAvatarUrl(24)) ?>" alt="<?php echo $uploader->name ?>"/>
<?php echo $val ?> <?php echo $val ?>
</a> </a>
</span> </span>
@ -77,6 +90,10 @@ LayoutHelper::addScript('../lib/tagit/jquery.tagit.js');
<?php echo UserModel::getAnonymousName() ?> <?php echo UserModel::getAnonymousName() ?>
</span> </span>
<?php endif ?> <?php endif ?>
<br>
<span class="date" title="<?php echo TextHelper::formatDate($this->context->transport->post->uploadDate, true) ?>">
<?php echo TextHelper::formatDate($this->context->transport->post->uploadDate, false) ?>
</span>
</div> </div>
<div class="key-value safety"> <div class="key-value safety">
@ -86,6 +103,28 @@ LayoutHelper::addScript('../lib/tagit/jquery.tagit.js');
</span> </span>
</div> </div>
<div class="key-value source">
<span class="key">Source:</span>
<span class="value" title="<?php echo $val = htmlspecialchars($this->context->transport->post->source ?: 'unknown') ?>">
<?php if (preg_match('/^((https?|ftp):|)\/\//', $val)): ?>
<a href="<?php echo $val ?>"><?php echo $val ?></a>
<?php else: ?>
<?php echo $val ?>
<?php endif ?>
</span>
</div>
<?php if ($this->context->transport->post->imageWidth > 0): ?>
<div class="key-value dim">
<span class="key">Dimensions:</span>
<span class="value" title="<?php echo $val = sprintf('%dx%d',
$this->context->transport->post->imageWidth,
$this->context->transport->post->imageHeight) ?>">
<?php echo $val ?>
</span>
</div>
<?php endif ?>
<div class="key-value score"> <div class="key-value score">
<span class="key">Score:</span> <span class="key">Score:</span>
<span class="value"> <span class="value">
@ -115,48 +154,48 @@ LayoutHelper::addScript('../lib/tagit/jquery.tagit.js');
<?php endif ?> <?php endif ?>
</span> </span>
</div> </div>
</div>
<div class="key-value date"> <div class="unit hl-options">
<span class="key">Uploaded:</span> <?php if ($this->context->transport->post->type != PostType::Youtube): ?>
<span class="value" title="<?php echo TextHelper::formatDate($this->context->transport->post->uploadDate, true) ?>"> <div class="hl-option">
<?php echo TextHelper::formatDate($this->context->transport->post->uploadDate, false) ?> <a href="<?php echo \Chibi\UrlHelper::route('post', 'retrieve', ['name' => $this->context->transport->post->name]) ?>" title="Download">
</span> <i class="icon-dl"></i>
</div> <span>
<?php
<?php if ($this->context->transport->post->imageWidth > 0): ?> $mimes = ['image/jpeg' => 'jpg', 'image/gif' => 'gif', 'image/png' => 'png', 'application/x-shockwave-flash' => 'swf'];
<div class="key-value dim"> $mime = $this->context->transport->post->mimeType;
<span class="key">Dimensions:</span> printf(
<span class="value" title="<?php echo $val = sprintf('%dx%d', 'Download %s (%s)',
$this->context->transport->post->imageWidth, isset($mimes[$mime]) ? strtoupper($mimes[$mime]) : 'Unknown',
$this->context->transport->post->imageHeight) ?>"> TextHelper::useBytesUnits($this->context->transport->post->fileSize));
<?php echo $val ?> ?>
</span> </span>
</a>
</div> </div>
<?php endif ?> <?php endif ?>
<div class="key-value source"> <?php if (PrivilegesHelper::confirm(Privilege::FavoritePost)): ?>
<span class="key">Source:</span> <div class="hl-option">
<span class="value" title="<?php echo $val = htmlspecialchars($this->context->transport->post->source ?: 'unknown') ?>"> <?php if (!$this->context->favorite): ?>
<?php if (preg_match('/^((https?|ftp):|)\/\//', $val)): ?> <a class="add-fav icon simple-action" href="<?php echo \Chibi\UrlHelper::route('post', 'add-favorite', ['id' => $this->context->transport->post->id]) ?>">
<a href="<?php echo $val ?>"><?php echo $val ?></a> <i class="icon-fav"></i>
<span>Add to favorites</span>
</a>
<?php else: ?> <?php else: ?>
<?php echo $val ?> <a class="rem-fav icon simple-action" href="<?php echo \Chibi\UrlHelper::route('post', 'rem-favorite', ['id' => $this->context->transport->post->id]) ?>">
<i class="icon-fav"></i>
<span>Remove from favorites</span>
</a>
<?php endif ?> <?php endif ?>
</span> </div>
</div> <?php endif ?>
<?php if ($this->context->transport->post->type != PostType::Youtube): ?> <?php if ($canEditAnything): ?>
<div class="permalink"> <div class="hl-option">
<a href="<?php echo \Chibi\UrlHelper::route('post', 'retrieve', ['name' => $this->context->transport->post->name]) ?>" title="Download"> <a class="edit-post icon" href="#">
<i class="icon-dl"></i> <i class="icon-edit"></i>
<span class="ext"> <span>Edit</span>
<?php $mimes = ['image/jpeg' => 'JPG', 'image/gif' => 'GIF', 'image/png' => 'PNG', 'application/x-shockwave-flash' => 'SWF'] ?>
<?php $mime = $this->context->transport->post->mimeType ?>
<?php echo isset($mimes[$mime]) ? $mimes[$mime] : 'unknown' ?>
</span>
<span class="size">
<?php echo TextHelper::useBytesUnits($this->context->transport->post->fileSize) ?>
</span>
</a> </a>
</div> </div>
<?php endif ?> <?php endif ?>
@ -178,7 +217,7 @@ LayoutHelper::addScript('../lib/tagit/jquery.tagit.js');
<?php endif ?> <?php endif ?>
<?php if (count($this->context->transport->post->getRelations())): ?> <?php if (count($this->context->transport->post->getRelations())): ?>
<div class="relations unit"> <div class="unit relations">
<h1>related</h1> <h1>related</h1>
<ul> <ul>
<?php foreach ($this->context->transport->post->getRelations() as $relatedPost): ?> <?php foreach ($this->context->transport->post->getRelations() as $relatedPost): ?>
@ -193,75 +232,8 @@ LayoutHelper::addScript('../lib/tagit/jquery.tagit.js');
<?php endif ?> <?php endif ?>
<?php <?php
$editPostPrivileges = [
Privilege::EditPostSafety,
Privilege::EditPostTags,
Privilege::EditPostThumb,
Privilege::EditPostSource,
];
$editPostPrivileges = array_fill_keys($editPostPrivileges, false);
foreach (array_keys($editPostPrivileges) as $privilege)
{
if (PrivilegesHelper::confirm($privilege, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->post->getUploader())))
$editPostPrivileges[$privilege] = true;
}
$canEditAnything = count(array_filter($editPostPrivileges)) > 0;
$options = []; $options = [];
if (PrivilegesHelper::confirm(Privilege::FavoritePost))
{
if (!$this->context->favorite)
{
$options []=
[
'class' => 'add-fav',
'text' => 'Add to favorites',
'simple-action' => \Chibi\UrlHelper::route('post', 'add-favorite', ['id' => $this->context->transport->post->id]),
];
}
else
{
$options []=
[
'class' => 'rem-fav',
'text' => 'Remove from favorites',
'simple-action' => \Chibi\UrlHelper::route('post', 'rem-favorite', ['id' => $this->context->transport->post->id]),
];
}
}
if ($canEditAnything)
{
$options []=
[
'class' => 'edit',
'text' => 'Edit',
];
}
if (PrivilegesHelper::confirm(Privilege::HidePost, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->post->getUploader())))
{
if ($this->context->transport->post->hidden)
{
$options []=
[
'class' => 'unhide',
'text' => 'Unhide',
'simple-action' => \Chibi\UrlHelper::route('post', 'unhide', ['id' => $this->context->transport->post->id]),
];
}
else
{
$options []=
[
'class' => 'hide',
'text' => 'Hide',
'simple-action' => \Chibi\UrlHelper::route('post', 'hide', ['id' => $this->context->transport->post->id]),
];
}
}
if (PrivilegesHelper::confirm(Privilege::FeaturePost)) if (PrivilegesHelper::confirm(Privilege::FeaturePost))
{ {
$options []= $options []=
@ -297,6 +269,28 @@ LayoutHelper::addScript('../lib/tagit/jquery.tagit.js');
} }
} }
if (PrivilegesHelper::confirm(Privilege::HidePost, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->post->getUploader())))
{
if ($this->context->transport->post->hidden)
{
$options []=
[
'class' => 'unhide',
'text' => 'Unhide',
'simple-action' => \Chibi\UrlHelper::route('post', 'unhide', ['id' => $this->context->transport->post->id]),
];
}
else
{
$options []=
[
'class' => 'hide',
'text' => 'Hide',
'simple-action' => \Chibi\UrlHelper::route('post', 'hide', ['id' => $this->context->transport->post->id]),
];
}
}
if (PrivilegesHelper::confirm(Privilege::DeletePost, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->post->getUploader()))) if (PrivilegesHelper::confirm(Privilege::DeletePost, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->post->getUploader())))
{ {
$options []= $options []=
@ -320,7 +314,7 @@ LayoutHelper::addScript('../lib/tagit/jquery.tagit.js');
</div> </div>
<?php if ($canEditAnything): ?> <?php if ($canEditAnything): ?>
<div class="edit-post unit"> <div class="unit edit-post">
<?php $this->renderFile('post-edit') ?> <?php $this->renderFile('post-edit') ?>
</div> </div>
<?php endif ?> <?php endif ?>
@ -331,7 +325,7 @@ LayoutHelper::addScript('../lib/tagit/jquery.tagit.js');
?> ?>
<div class="comments-wrapper"> <div class="comments-wrapper">
<?php if (!empty($this->context->transport->post->getComments())): ?> <?php if (!empty($this->context->transport->post->getComments())): ?>
<div class="comments unit"> <div class="unit comments">
<h1>comments (<?php echo count($this->context->transport->post->getComments()) ?>)</h1> <h1>comments (<?php echo count($this->context->transport->post->getComments()) ?>)</h1>
<div class="comments"> <div class="comments">
<?php foreach ($this->context->transport->post->getComments() as $comment): ?> <?php foreach ($this->context->transport->post->getComments() as $comment): ?>
@ -344,7 +338,7 @@ LayoutHelper::addScript('../lib/tagit/jquery.tagit.js');
</div> </div>
<?php if (PrivilegesHelper::confirm(Privilege::AddComment)): ?> <?php if (PrivilegesHelper::confirm(Privilege::AddComment)): ?>
<div class="unit"> <div class="unit comment-add">
<?php $this->renderFile('comment-add') ?> <?php $this->renderFile('comment-add') ?>
</div> </div>
<?php endif ?> <?php endif ?>

View file

@ -76,13 +76,13 @@ LayoutHelper::addStylesheet('user-view.css');
]; ];
} }
if (PrivilegesHelper::confirm(Privilege::DeleteUser, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->user))) if (PrivilegesHelper::confirm(Privilege::AcceptUserRegistration) and !$this->context->transport->user->staffConfirmed and $this->config->registration->staffActivation)
{ {
$options []= $options []=
[ [
'class' => 'delete', 'class' => 'accept-registration',
'text' => 'Delete account', 'text' => 'Accept registration',
'link' => \Chibi\UrlHelper::route('user', 'delete', ['name' => $this->context->transport->user->name, 'tab' => 'delete']), 'simple-action' => \Chibi\UrlHelper::route('user', 'accept-registration', ['name' => $this->context->transport->user->name]),
]; ];
} }
@ -133,13 +133,13 @@ LayoutHelper::addStylesheet('user-view.css');
} }
} }
if (PrivilegesHelper::confirm(Privilege::AcceptUserRegistration) and !$this->context->transport->user->staffConfirmed and $this->config->registration->staffActivation) if (PrivilegesHelper::confirm(Privilege::DeleteUser, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->user)))
{ {
$options []= $options []=
[ [
'class' => 'accept-registration', 'class' => 'delete',
'text' => 'Accept registration', 'text' => 'Delete account',
'simple-action' => \Chibi\UrlHelper::route('user', 'accept-registration', ['name' => $this->context->transport->user->name]), 'link' => \Chibi\UrlHelper::route('user', 'delete', ['name' => $this->context->transport->user->name, 'tab' => 'delete']),
]; ];
} }