Skip to content

Commit ed12a65

Browse files
committed
Default arch download default to amd64
Remove the popular option as it only included a single item.
1 parent 4f04f9d commit ed12a65

File tree

4 files changed

+30
-26
lines changed

4 files changed

+30
-26
lines changed

content/download.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ <h1>Download</h1>
3636

3737
<div class="panel panel-default download-selection">
3838
<div class="panel-body">
39-
Operating system <%= dropdown(:os, Downloads.operating_systems) %>
40-
Architecture <%= dropdown(:arch, Downloads.architectures) %>
39+
Operating system <%= dropdown(:os, Downloads.operating_systems, :popular, popular: %w(darwin linux windows)) %>
40+
Architecture <%= dropdown(:arch, Downloads.architectures, :amd64) %>
4141
</div>
4242
</div>
4343

lib/default.rb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,3 @@ def get_post_start(post)
2424
end
2525
end
2626
include BlogHelper
27-
28-
module DownloadHelper
29-
def format_bytes(bytes)
30-
'%.2f MiB' % (bytes.to_f / 1024 / 1024)
31-
end
32-
33-
def dropdown(name, items)
34-
caption = %(<span class="caption">all</span> <span class="caret"></span>)
35-
button = %(<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">#{caption}</button>)
36-
default = %(<li><a href="#">all</a></li><li><a href="#">popular</a></li><li role="separator" class="divider"></li>)
37-
list = %(<ul class="dropdown-menu">#{default} #{items.map { |i| %(<li><a href="#">#{i}</a></li>) }.join('') }</ul>)
38-
39-
%(<div class="btn-group #{name}">#{button} #{list}</div>)
40-
end
41-
end
42-
include DownloadHelper
43-
44-

lib/helpers/download.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,25 @@ def size
114114
@data['size']
115115
end
116116
end
117+
118+
module Helper
119+
def format_bytes(bytes)
120+
'%.2f MiB' % (bytes.to_f / 1024 / 1024)
121+
end
122+
123+
def dropdown(name, items, default, groups = {})
124+
additional = groups.map do |name, items|
125+
%(<li data-group="#{items.join(' ')}"><a href="#">#{name}</a></li>)
126+
end.join('')
127+
128+
caption = %(<span class="caption">#{default}</span> <span class="caret"></span>)
129+
button = %(<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">#{caption}</button>)
130+
header = %(<li><a href="#">all</a></li>#{additional}<li role="separator" class="divider"></li>)
131+
list = %(<ul class="dropdown-menu">#{header} #{items.map { |i| %(<li><a href="#">#{i}</a></li>) }.join('') }</ul>)
132+
133+
%(<div class="btn-group #{name}">#{button} #{list}</div>)
134+
end
135+
end
117136
end
137+
138+
include Downloads::Helper

static/docs.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,32 @@ $(document).ready(function() {
2020
$(this).replaceWith(link);
2121
});
2222

23-
var selected = function(value, want, popular) {
23+
var selected = function(value, want, group) {
2424
switch(want) {
2525
case 'all':
2626
return true;
27-
case 'popular':
28-
return popular.indexOf(value) > -1;
2927
default:
28+
if (group.length > 0) {
29+
return group.indexOf(value) > -1;
30+
}
3031
return value === want;
3132
}
3233
}
3334
var selectDownloads = function() {
3435
var os = $('.download-selection .os .caption').text();
36+
var osGroup = $('.download-selection .os li:contains("'+os+'")').data("group");
3537
var arch = $('.download-selection .arch .caption').text();
3638

3739
$('.downloads tbody tr').each(function() {
38-
if (selected($(this).data('os').toString(), os, ['darwin', 'linux', 'windows'])
39-
&& selected($(this).data('arch').toString(), arch, ['amd64'])) {
40+
if (selected($(this).data('os').toString(), os, osGroup !== undefined ? osGroup.split(' ') : [])
41+
&& selected($(this).data('arch').toString(), arch, [])) {
4042
$(this).show();
4143
} else {
4244
$(this).hide();
4345
}
4446
});
4547
};
4648

47-
$('.download-selection button .caption').text('popular');
4849
selectDownloads();
4950

5051
$('.download-selection a').on('click', function() {

0 commit comments

Comments
 (0)