Skip to content

Commit 4b5f563

Browse files
committed
Updated download widget
Disable versions that dont exist JAVA-1695
1 parent 1d499f2 commit 4b5f563

File tree

4 files changed

+56
-26
lines changed

4 files changed

+56
-26
lines changed

docs/landing/data/releases.toml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,20 @@ current = "3.0.0-rc1"
1919

2020
[[drivers]]
2121
name = "mongodb-driver"
22-
description = "The synchronous driver."
23-
24-
[[drivers]]
25-
name = "mongodb-driver-async"
26-
description = "The new asynchronous driver."
22+
description = "The synchronous driver, new in 3.0, for older versions select the: `mongo-java-driver`"
23+
versions = "3.0.0-rc1"
2724

2825
[[drivers]]
2926
name = "mongo-java-driver"
3027
description = "An uber jar containing the bson library, the core library and the mongodb-driver."
28+
versions = "3.0.0-rc1,2.13.0,2.12.5"
29+
30+
[[drivers]]
31+
name = "mongodb-driver-async"
32+
description = "The new asynchronous driver, new in 3.0"
33+
versions = "3.0.0-rc1"
3134

3235
[[drivers]]
3336
name = "mongodb-driver-core"
34-
description = "The core library."
37+
description = "The core library, new in 3.0"
38+
versions = "3.0.0-rc1"

docs/landing/layouts/partials/quickStart.html

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,32 @@ <h2 id="quickStart">Quick Start</h2>
88
Alternatively, head over to our documentation to learn more about getting started with Java and MongoDB.
99
</p>
1010

11-
{{ range where $.Site.Data.releases.versions "version" $.Site.Data.releases.current }}{{ $.Scratch.Set "currentReleasedVersion" . }}{{end }}
12-
{{$currentReleasedVersion := $.Scratch.Get "currentReleasedVersion"}}
11+
{{ range where $.Site.Data.releases.versions "version" $.Site.Data.releases.current }}{{ $.Scratch.Set "qs.currentReleasedVersion" . }}{{end }}
12+
{{$currentReleasedVersion := $.Scratch.Get "qs.currentReleasedVersion"}}
1313

1414
<div id="downloadWidget">
1515
<form class="form-inline">
1616
<a id="downloadLink" href="https://oss.sonatype.org/content/repositories/releases/org/mongodb/mongodb-driver/{{$currentReleasedVersion.version}}/"
1717
class="btn btn-large btn-dark btn-download" target="_blank">Download</a>
18-
{{ $.Scratch.Set "pos" 0 }}
18+
{{ $.Scratch.Set "qs.pos" 0 }}
19+
{{ $.Scratch.Set "qs.firstDriver" false }}
1920
{{ with $.Site.Data.releases.drivers }}
2021
<select class="driverPicker">
2122
{{ range . }}
22-
<option value="{{$.Scratch.Get "pos"}}">{{.name}}</option>
23-
{{ $.Scratch.Add "pos" 1 }}
23+
{{ if eq ($.Scratch.Get "qs.firstDriver") false }}{{ $.Scratch.Set "qs.firstDriver" . }}{{end}}
24+
<option value="{{$.Scratch.Get "qs.pos"}}" data-versions="{{.versions}}">{{.name}}</option>
25+
{{ $.Scratch.Add "qs.pos" 1 }}
2426
{{ end }}
2527
</select>
2628
{{ end }}
2729

28-
{{ $.Scratch.Set "pos" 0 }}
30+
{{ $.Scratch.Set "qs.pos" 0 }}
31+
{{ $firstDriver := $.Scratch.Get "qs.firstDriver"}}
2932
{{ with $.Site.Data.releases.versions }}
3033
<select class="releasePicker">
3134
{{ range . }}
32-
<option value="{{$.Scratch.Get "pos"}}">{{.version}}</option>
33-
{{ $.Scratch.Add "pos" 1 }}
35+
<option value="{{$.Scratch.Get "qs.pos"}}"{{ if eq (in .version $firstDriver.versions) false }}disabled="disabled"{{end}}>{{.version}}</option>
36+
{{ $.Scratch.Add "qs.pos" 1 }}
3437
{{ end }}
3538
</select>
3639
{{ end }}
@@ -40,17 +43,20 @@ <h2 id="quickStart">Quick Start</h2>
4043
<button class="btn btn-dark"><i class="fa fa-clipboard fa-2"></i></button>
4144
</div>
4245
{{ $currentNode := . }}
46+
{{ $.Scratch.Set "qs.firstDriver" true }}
4347
{{ with $currentNode.Site.Data.releases.drivers }}
44-
{{ $.Scratch.Set "driverPos" 0 }}
48+
{{ $.Scratch.Set "qs.driverPos" 0 }}
4549
{{ range . }}
4650
{{ $currentDriver := . }}
4751
{{ with $.Site.Data.releases.versions }}
48-
{{ $.Scratch.Set "versionPos" 0 }}
52+
{{ $.Scratch.Set "qs.versionPos" 0 }}
4953
{{ range . }}
5054
{{ $currentVersion := . }}
51-
{{ $driverPos := $.Scratch.Get "driverPos" }}
52-
{{ $versionPos := $.Scratch.Get "versionPos" }}
53-
<div id="maven-{{$versionPos}}-{{$driverPos}}" class="download {{if or (ne $currentVersion $currentReleasedVersion) (ne $driverPos 0)}} hidden{{end}}">
55+
{{ $firstDriver := $.Scratch.Get "qs.firstDriver"}}
56+
{{ $driverPos := $.Scratch.Get "qs.driverPos" }}
57+
{{ $versionPos := $.Scratch.Get "qs.versionPos" }}
58+
{{ if in $currentDriver.versions $currentVersion.version }}
59+
<div id="maven-{{$versionPos}}-{{$driverPos}}" class="download {{if ne $firstDriver true}} hidden{{end}}">
5460
<pre><code>
5561
&lt;dependencies&gt;
5662
&lt;dependency&gt;
@@ -70,14 +76,16 @@ <h2 id="quickStart">Quick Start</h2>
7076

7177
</code></pre>
7278
</div>
73-
{{ $.Scratch.Add "versionPos" 1 }}
79+
{{ $.Scratch.Set "qs.firstDriver" false }}
80+
{{ $.Scratch.Add "qs.versionPos" 1 }}
7481
{{ end }}
7582
{{ end }}
76-
{{ $driverPos := $.Scratch.Get "driverPos" }}
83+
{{ end }}
84+
{{ $driverPos := $.Scratch.Get "qs.driverPos" }}
7785
<div id="driver-{{$driverPos}}" class="download description{{if ne $driverPos 0}} hidden{{end}}">
78-
{{$currentDriver.description}}
86+
{{$currentDriver.description | markdownify}}
7987
</div>
80-
{{ $.Scratch.Add "driverPos" 1 }}
88+
{{ $.Scratch.Add "qs.driverPos" 1 }}
8189
{{ end }}
8290
{{ end }}
8391
</div>

docs/landing/static/s/css/frontpage.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,8 @@ input.gsc-search-button[title], input.gsc-search-button:hover[title], input.gsc-
379379
text-align: center;
380380
background: #666;
381381
}
382+
383+
code {
384+
background-color: #ddd;
385+
color: #494747;
386+
}

docs/landing/static/s/js/frontpage.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,24 @@ var toggleDownload = function() {
3333
prefix = $('.distroPicker').prop('checked') ? "#maven" : "#gradle"
3434
driverVersion = $('.driverPicker').selectpicker().val();
3535
releaseVersion = $('.releasePicker').selectpicker().val();
36-
activeSample = prefix + "-" + releaseVersion + "-" + driverVersion;
37-
activeDescription = "#driver-" + driverVersion;
38-
3936
activeDriver = $('.driverPicker option:selected').text();
4037
activeVersion = $('.releasePicker option:selected').text();
38+
39+
driverVersions = $('.driverPicker option:selected').data('versions');
40+
$('.releasePicker option').each(function(){
41+
$(this).prop('disabled', driverVersions.indexOf($(this).text()) < 0);
42+
});
43+
44+
$('.driverPicker option').each(function(){
45+
driverVersions = $(this).data('versions');
46+
$(this).prop('disabled', driverVersions.indexOf(activeVersion) < 0);
47+
});
48+
49+
$('.driverPicker').selectpicker('refresh');
50+
$('.releasePicker').selectpicker('refresh');
51+
52+
activeSample = prefix + "-" + releaseVersion + "-" + driverVersion;
53+
activeDescription = "#driver-" + driverVersion;
4154
activeLink = downloadLink + activeDriver +'/' + activeVersion + '/';
4255

4356
$('.download').addClass('hidden');

0 commit comments

Comments
 (0)