Faster tag list

This commit is contained in:
Marcin Kurczewski 2013-11-22 00:15:05 +01:00
parent d636fe1c0a
commit 007e797d3a
2 changed files with 15 additions and 6 deletions

View file

@ -6,9 +6,6 @@
-moz-column-width: 14em; -moz-column-width: 14em;
-webkit-column-width: 14em; -webkit-column-width: 14em;
} }
.tags li a:hover {
opacity: 1 !important;
}
.tags li { .tags li {
margin: 0.2em 0.5em; margin: 0.2em 0.5em;
text-align: top; text-align: top;
@ -38,3 +35,15 @@ form.aligned label.left {
form h1 { form h1 {
display: none; display: none;
} }
.frequency0 { color: #ecc8c8; }
.frequency1 { color: #e6b7b7; }
.frequency2 { color: #e0a7a7; }
.frequency3 { color: #db9696; }
.frequency4 { color: #d58686; }
.frequency5 { color: #cf7575; }
.frequency6 { color: #c96464; }
.frequency7 { color: #c35454; }
.frequency8 { color: #be4343; }
.frequency9 { color: #b83333; }
.frequency10 { color: #b22222; }

View file

@ -1,6 +1,6 @@
<?php $max = max([0]+array_map(function($x) { return $x['post_count']; }, $this->context->transport->tags)); ?> <?php $max = max([0]+array_map(function($x) { return $x['post_count']; }, $this->context->transport->tags)); ?>
<?php $add = 0.25 ?> <?php $add = 0. ?>
<?php $mul = 0.75 / max(1, log(max(1, $max))) ?> <?php $mul = 10. / max(1, log(max(1, $max))) ?>
<?php $url = \Chibi\UrlHelper::route('post', 'list', ['query' => '_query_']) ?> <?php $url = \Chibi\UrlHelper::route('post', 'list', ['query' => '_query_']) ?>
<div class="tags"> <div class="tags">
<ul> <ul>
@ -8,7 +8,7 @@
<?php $name = $tag['name'] ?> <?php $name = $tag['name'] ?>
<?php $count = $tag['post_count'] ?> <?php $count = $tag['post_count'] ?>
<li class="tag" title="<?php echo $name ?> (<?php echo $count ?>)"> <li class="tag" title="<?php echo $name ?> (<?php echo $count ?>)">
<a href="<?php echo str_replace('_query_', $name, $url) ?>" style="opacity: <?php printf('%.02f', $add + $mul * log($count)) ?>"> <a href="<?php echo str_replace('_query_', $name, $url) ?>" class="frequency<?php printf('%1.0f', $add + $mul * log($count)) ?>">
<?php echo $name . ' (' . $count . ')' ?> <?php echo $name . ' (' . $count . ')' ?>
</a> </a>
</li> </li>