-
Notifications
You must be signed in to change notification settings - Fork 1
/
tagcloud.php
65 lines (57 loc) · 1.48 KB
/
tagcloud.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
include('common.php');
?>
<html>
<head>
<style>
.thing {
display:grid;
grid-template-columns: 1fr 1fr;
}
img {
max-width:50vw;
}
.tags {
display: flex;
flex-wrap: wrap;
justify-content: center;
max-width: 960px;
margin: auto;
padding: 2rem 0 1rem;
list-style: none;
border: 2px solid white;
border-radius: 5px;
}
.tag {
display: flex;
align-items: center;
margin: 0.25rem 1rem;
}
.tag__link {
padding: 5px 5px 0;
transition: 0.3s;
text-decoration: none;
}
</style>
</head>
<?php
$results = getResults();
foreach ($results as $image => $wordCounts) {
echo '<div class="thing">';
echo '<img src="' . $image . '">';
echo '<ul class="tags">';
// Discover the max count for this thing
$maxCount = 0;
foreach($wordCounts as $word => $count) {
if ($count > $maxCount) {
$maxCount = $count;
}
}
foreach($wordCounts as $word => $count) {
echo '<li class="tag" style="font-size: ' . ($count/$maxCount) * 4 . 'em">' . $word . ' (' . $count . ')</li>';
}
echo '</ul>';
echo '</div>';
echo '<hr>';
}
?>