File tree Expand file tree Collapse file tree 4 files changed +41
-5
lines changed Expand file tree Collapse file tree 4 files changed +41
-5
lines changed Original file line number Diff line number Diff line change 33
33
overflow : hidden ;
34
34
}
35
35
36
+ .tag-sidebar-tag-67 { font-size : 0.67em ; }
37
+ .tag-sidebar-tag-75 { font-size : 0.75em ; }
38
+ .tag-sidebar-tag-83 { font-size : 0.83em ; }
39
+ .tag-sidebar-tag-91 { font-size : 0.91em ; }
40
+ .tag-sidebar-tag-100 { font-size : 1em ; }
41
+ .tag-sidebar-tag-112 { font-size : 1.12em ; }
42
+ .tag-sidebar-tag-125 { font-size : 1.25em ; }
43
+ .tag-sidebar-tag-137 { font-size : 1.37em ; }
44
+ .tag-sidebar-tag-150 { font-size : 1.50em ; }
45
+ .tag-sidebar-tag-162 { font-size : 1.62em ; }
46
+ .tag-sidebar-tag-175 { font-size : 1.75em ; }
47
+ .tag-sidebar-tag-187 { font-size : 1.87em ; }
48
+ .tag-sidebar-tag-200 { font-size : 2em ; }
49
+
36
50
.hidden {
37
51
display : none ;
38
52
}
Original file line number Diff line number Diff line change @@ -18,12 +18,34 @@ def sizes
18
18
average = total . to_f / @tags . size
19
19
@sizes = tags . reduce ( { } ) do |h , tag |
20
20
size = tag . content_counter . to_f / average
21
- h . merge tag => size . clamp ( 2.0 / 3.0 , 2 ) * 100
21
+ h . merge tag => bucket ( size )
22
22
end
23
23
end
24
24
25
- def font_multiplier
26
- 80
25
+ BUCKETS = [
26
+ 67 ,
27
+ 75 ,
28
+ 83 ,
29
+ 91 ,
30
+ 100 ,
31
+ 112 ,
32
+ 125 ,
33
+ 137 ,
34
+ 150 ,
35
+ 162 ,
36
+ 175 ,
37
+ 187 ,
38
+ 200
39
+ ] . freeze
40
+
41
+ private
42
+
43
+ def bucket ( size )
44
+ base_size = size . clamp ( 2.0 / 3.0 , 2 ) * 100
45
+ BUCKETS . each do |sz |
46
+ return sz if sz >= base_size
47
+ end
48
+ BUCKETS . last
27
49
end
28
50
end
29
51
Original file line number Diff line number Diff line change 3
3
< div class ="sidebar-body ">
4
4
< p class ="tag-sidebar-tag-cloud ">
5
5
<% sidebar . tags . each do |tag | %>
6
- < span style =" font-size: <%= sidebar . sizes [ tag ] %> % "> <%= link_to tag . display_name , tag_url ( tag . name ) %> </ span >
6
+ < span class =" tag-sidebar-tag- <%= sidebar . sizes [ tag ] %> "> <%= link_to tag . display_name , tag_url ( tag . name ) %> </ span >
7
7
<% end %>
8
8
</ p >
9
9
</ div >
Original file line number Diff line number Diff line change 43
43
create ( :article , keywords : "foo, quuz" )
44
44
45
45
result = sidebar . sizes
46
- expect ( result . values . uniq ) . to contain_exactly ( 2.0 / 3.0 * 100 ) , 200
46
+ expect ( result . values . uniq ) . to contain_exactly 67 , 200
47
47
end
48
48
end
49
49
end
You can’t perform that action at this time.
0 commit comments