Public tagcloud and tag cloud styles

This commit is contained in:
sarven 2009-01-21 18:35:45 +00:00
parent 3260106537
commit 0b0f25ce93
2 changed files with 41 additions and 27 deletions

View File

@ -103,7 +103,8 @@ class PublictagcloudAction extends Action
$cnt = $tags->find(); $cnt = $tags->find();
if ($cnt > 0) { if ($cnt > 0) {
$this->elementStart('p', 'tagcloud'); $this->elementStart('div', array('id' => 'tagcloud',
'class' => 'section'));
$tw = array(); $tw = array();
$sum = 0; $sum = 0;
@ -114,36 +115,41 @@ class PublictagcloudAction extends Action
ksort($tw); ksort($tw);
$this->elementStart('dl');
$this->element('dt', null, _('Tag cloud'));
$this->elementStart('dd');
$this->elementStart('ul', 'tags xoxo tag-cloud');
foreach ($tw as $tag => $weight) { foreach ($tw as $tag => $weight) {
$this->showTag($tag, $weight, $weight/$sum); $this->showTag($tag, $weight, $weight/$sum);
} }
$this->elementEnd('ul');
$this->elementEnd('p'); $this->elementEnd('dd');
$this->elementEnd('dl');
$this->elementEnd('div');
} }
} }
function showTag($tag, $weight, $relative) function showTag($tag, $weight, $relative)
{ {
# XXX: these should probably tune to the size of the site
if ($relative > 0.1) { if ($relative > 0.1) {
$cls = 'largest'; $rel = 'tag-cloud-7';
} else if ($relative > 0.05) { } else if ($relative > 0.05) {
$cls = 'verylarge'; $rel = 'tag-cloud-6';
} else if ($relative > 0.02) { } else if ($relative > 0.02) {
$cls = 'large'; $rel = 'tag-cloud-5';
} else if ($relative > 0.01) { } else if ($relative > 0.01) {
$cls = 'medium'; $rel = 'tag-cloud-4';
} else if ($relative > 0.005) { } else if ($relative > 0.005) {
$cls = 'small'; $rel = 'tag-cloud-3';
} else if ($relative > 0.002) { } else if ($relative > 0.002) {
$cls = 'verysmall'; $rel = 'tag-cloud-2';
} else { } else {
$cls = 'smallest'; $rel = 'tag-cloud-1';
} }
$this->element('a', array('class' => "$cls weight-$weight relative-$relative", $this->elementStart('li', $rel);
'href' => common_local_url('tag', array('tag' => $tag))), $this->element('a', array('href' => common_local_url('tag', array('tag' => $tag))),
$tag); $tag);
$this->text(' '); $this->elementEnd('li');
} }
} }

View File

@ -1110,33 +1110,41 @@ width:24px;
/* tagcloud */ /* tagcloud */
#tagcloud ul { .tag-cloud {
list-style-type:none; list-style-type:none;
} }
#tagcloud ul li { .tag-cloud li {
display:inline; display:inline;
margin-right:7px; margin-right:7px;
line-height:1.4; line-height:1;
}
.tag-cloud li a {
text-decoration:none;
} }
#tagcloud.section dt { #tagcloud.section dt {
text-transform:uppercase; text-transform:uppercase;
font-weight:bold; font-weight:bold;
} }
#tagcloud .weight_1 { .tag-cloud-1 {
font-size:1em; font-size:1em;
} }
#tagcloud .weight_2 { .tag-cloud-2 {
font-size:1.3em; font-size:1.5em;
} }
#tagcloud .weight_3 { .tag-cloud-3 {
font-size:1.6em; font-size:2em;
} }
#tagcloud .weight_4 { .tag-cloud-4 {
font-size:1.9em; font-size:2.5em;
} }
#tagcloud .weight_5 { .tag-cloud-5 {
font-size:2.2em; font-size:3em;
}
.tag-cloud-6 {
font-size:3.5em;
}
.tag-cloud-7 {
font-size:4em;
} }