diff --git a/public_html/media/css/core.css b/public_html/media/css/core.css index df7b8079..55c59c6d 100644 --- a/public_html/media/css/core.css +++ b/public_html/media/css/core.css @@ -100,7 +100,6 @@ body { #sidebar h1 { margin-top: 0; - text-align: center; font-weight: normal; } @@ -112,3 +111,26 @@ p:first-child, h1:first-child { margin-top: 0; } + +a { + color: firebrick; + text-decoration: none; + outline: 0; +} +a:focus, +a:hover { + color: red; +} + +i[class*='icon-'] { + background-image: url('../img/icons.png'); + background-repeat: no-repeat; + display: inline-block; +} +a i[class*='icon-'] { + background-color: firebrick; +} +a:focus i[class*='icon-'], +a:hover i[class*='icon-'] { + background-color: red; +} diff --git a/public_html/media/css/post-view.css b/public_html/media/css/post-view.css index 1d590f39..fcd05019 100644 --- a/public_html/media/css/post-view.css +++ b/public_html/media/css/post-view.css @@ -1,5 +1,5 @@ .post-wrapper { - text-align: center; + /*text-align: center;*/ } embed { @@ -10,3 +10,67 @@ embed { img { max-width: 100%; } + +.tags ul { + list-style-type: none; + margin: 0 0 0 1em; + padding: 0; +} +.tags li .count { + padding-left: 0.5em; + color: silver; +} + +i.icon-prev { + background-position: -12px -1px; +} +i.icon-next { + background-position: -1px -1px; +} +i.icon-prev, +i.icon-next { + margin: 0 8px; + vertical-align: middle; + width: 8px; + height: 20px; +} +i.icon-dl { + margin: 0; + width: 20px; + height: 20px; + background-position: -22px -1px; +} + +nav .left { + float: left; +} +nav .right { + float: right; +} +nav a.inactive { + color: silver; +} +nav a.inactive i[class*='icon-'] { + background-color: silver; +} +#sidebar h1 { + margin-top: 1em; +} + +.dl-box { + float: left; + margin: 0 2em 0 1em; +} +.dl-box span { + display: block; + text-align: center; + font-size: small; +} + +.details-box { + font-size: small; + line-height: 1.33em; +} +.details-box .key { + margin-right: 0.5em; +} diff --git a/public_html/media/img/icons.png b/public_html/media/img/icons.png new file mode 100644 index 00000000..3490c265 Binary files /dev/null and b/public_html/media/img/icons.png differ diff --git a/src/Controllers/PostController.php b/src/Controllers/PostController.php index 0ac44dbb..b86c183e 100644 --- a/src/Controllers/PostController.php +++ b/src/Controllers/PostController.php @@ -68,7 +68,7 @@ class PostController $searchDbQuery = R::$f->begin(); $searchDbQuery->select('*'); $buildDbQuery($searchDbQuery); - $searchDbQuery->orderBy('upload_date DESC'); + $searchDbQuery->orderBy('id DESC'); $searchDbQuery->limit('?')->put($postsPerPage); $searchDbQuery->offset('?')->put(($page - 1) * $postsPerPage); @@ -205,13 +205,34 @@ class PostController $post = R::findOne('post', 'id = ?', [$id]); if (!$post) throw new SimpleException('Invalid post ID "' . $id . '"'); + R::preload($post, ['user', 'tag']); + + $prevPost = R::findOne('post', 'id < ? ORDER BY id DESC LIMIT 1', [$id]); + $nextPost = R::findOne('post', 'id > ? ORDER BY id ASC LIMIT 1', [$id]); PrivilegesHelper::confirmWithException($this->context->user, Privilege::ViewPost); PrivilegesHelper::confirmWithException($this->context->user, Privilege::ViewPost, PostSafety::toString($post->safety)); + $dbQuery = R::$f->begin(); + $dbQuery->select('tag.name, COUNT(1) AS count'); + $dbQuery->from('tag'); + $dbQuery->innerJoin('post_tag'); + $dbQuery->on('tag.id = post_tag.tag_id'); + $dbQuery->where('tag.id IN (' . R::genSlots($post->sharedTag) . ')'); + foreach ($post->sharedTag as $tag) + $dbQuery->put($tag->id); + $dbQuery->groupBy('tag.id'); + $rows = $dbQuery->get(); + $this->context->transport->tagDistribution = []; + foreach ($rows as $row) + $this->context->transport->tagDistribution[$row['name']] = $row['count']; + $this->context->stylesheets []= 'post-view.css'; $this->context->subTitle = 'showing @' . $post->id; $this->context->transport->post = $post; + $this->context->transport->uploader = R::load('user', $post->user_id); + $this->context->transport->prevPostId = $prevPost ? $prevPost->id : null; + $this->context->transport->nextPostId = $nextPost ? $nextPost->id : null; } diff --git a/src/Controllers/UserController.php b/src/Controllers/UserController.php index 1d65c0aa..98752a2d 100644 --- a/src/Controllers/UserController.php +++ b/src/Controllers/UserController.php @@ -14,7 +14,7 @@ class UserController * @route /user/{name} * @validate name [^\/]+ */ - public function showAction($name) + public function viewAction($name) { $this->context->subTitle = $name; throw new Exception('Not implemented'); diff --git a/src/Helpers/TextHelper.php b/src/Helpers/TextHelper.php index f8915a8b..c3e61120 100644 --- a/src/Helpers/TextHelper.php +++ b/src/Helpers/TextHelper.php @@ -50,4 +50,30 @@ class TextHelper } return constant($constantName); } + + private static function useUnits($number, $base, $suffixes) + { + $suffix = array_shift($suffixes); + if ($number < $base) + { + return sprintf('%d%s', $number, $suffix); + } + do + { + $suffix = array_shift($suffixes); + $number /= (float) $base; + } + while ($number >= $base and !empty($suffixes)); + return sprintf('%.01f%s', $number, $suffix); + } + + public static function useBytesUnits($number) + { + return self::useUnits($number, 1024, ['B', 'K', 'M', 'G']); + } + + public static function useDecimalUnits($number) + { + return self::useUnits($number, 1000, ['', 'K', 'M']); + } } diff --git a/src/Views/layout-normal.phtml b/src/Views/layout-normal.phtml index 4d2c4569..6e99f616 100644 --- a/src/Views/layout-normal.phtml +++ b/src/Views/layout-normal.phtml @@ -48,7 +48,7 @@ } else { - $nav []= ['My account', \Chibi\UrlHelper::route('user', 'show', ['name' => $this->context->user->name])]; + $nav []= ['My account', \Chibi\UrlHelper::route('user', 'view', ['name' => $this->context->user->name])]; $nav []= ['Log out', \Chibi\UrlHelper::route('auth', 'logout')]; } @@ -62,6 +62,11 @@ echo ''; } ?> +
context->transport->errorMessage ?>
-