[release-branch.go1.7] godoc/dl: change "All versions" to "Archived versions"
This change makes each release show only once on the whole page. The current stable releases are not shown under the archive. This change also fixes expandos to work correctly on IDs that are not valid CSS selectors (i.e., "#go1.7.4") to ensure that the file listing for a given version is expanded. Updates golang/go#17574. Change-Id: I7ff1041be3e0072286772ffa545a124764f81945 Reviewed-on: https://go-review.googlesource.com/34911 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-on: https://go-review.googlesource.com/35096 Reviewed-by: Chris Broadfoot <cbro@golang.org>
This commit is contained in:
parent
7771da7791
commit
ae17563914
|
@ -255,33 +255,7 @@ func filesToReleases(fs []File) (stable, unstable, archive []Release) {
|
||||||
if r == nil {
|
if r == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if r.Stable {
|
if !r.Stable {
|
||||||
// Show all stable versions in the archive
|
|
||||||
archive = append(archive, *r)
|
|
||||||
|
|
||||||
// Show the most two recent major version under "Stable".
|
|
||||||
if len(stable) < 2 {
|
|
||||||
if len(stable) == 0 {
|
|
||||||
// Most recent stable version.
|
|
||||||
stableMaj, stableMin, _ = parseVersion(r.Version)
|
|
||||||
} else if maj, _, _ := parseVersion(r.Version); maj == stableMaj {
|
|
||||||
// Older minor version of most recent major version.
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// Split the file list into primary/other ports for the stable releases.
|
|
||||||
// NOTE(cbro): This is only done for stable releases because maintaining the historical
|
|
||||||
// nature of primary/other ports for older versions is infeasible.
|
|
||||||
// If freebsd is considered primary some time in the future, we'd not want to
|
|
||||||
// mark all of the older freebsd binaries as "primary".
|
|
||||||
// It might be better if we set that as a flag when uploading.
|
|
||||||
r.SplitPortTable = true
|
|
||||||
r.Visible = true // Toggle open all stable releases.
|
|
||||||
stable = append(stable, *r)
|
|
||||||
} else if len(stable) == 1 {
|
|
||||||
// Show the second most recent major version (i.e., security release)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(unstable) != 0 {
|
if len(unstable) != 0 {
|
||||||
// Only show one (latest) unstable version.
|
// Only show one (latest) unstable version.
|
||||||
return
|
return
|
||||||
|
@ -294,6 +268,41 @@ func filesToReleases(fs []File) (stable, unstable, archive []Release) {
|
||||||
}
|
}
|
||||||
unstable = append(unstable, *r)
|
unstable = append(unstable, *r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reports whether the release is the most recent minor version of the
|
||||||
|
// two most recent major versions.
|
||||||
|
shouldAddStable := func() bool {
|
||||||
|
if len(stable) >= 2 {
|
||||||
|
// Show up to two stable versions.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if len(stable) == 0 {
|
||||||
|
// Most recent stable version.
|
||||||
|
stableMaj, stableMin, _ = parseVersion(r.Version)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if maj, _, _ := parseVersion(r.Version); maj == stableMaj {
|
||||||
|
// Older minor version of most recent major version.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// Second most recent stable version.
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if !shouldAddStable() {
|
||||||
|
archive = append(archive, *r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split the file list into primary/other ports for the stable releases.
|
||||||
|
// NOTE(cbro): This is only done for stable releases because maintaining the historical
|
||||||
|
// nature of primary/other ports for older versions is infeasible.
|
||||||
|
// If freebsd is considered primary some time in the future, we'd not want to
|
||||||
|
// mark all of the older freebsd binaries as "primary".
|
||||||
|
// It might be better if we set that as a flag when uploading.
|
||||||
|
r.SplitPortTable = true
|
||||||
|
r.Visible = true // Toggle open all stable releases.
|
||||||
|
stable = append(stable, *r)
|
||||||
|
}
|
||||||
for _, f := range fs {
|
for _, f := range fs {
|
||||||
if r == nil || f.Version != r.Version {
|
if r == nil || f.Version != r.Version {
|
||||||
add()
|
add()
|
||||||
|
|
|
@ -87,7 +87,7 @@ func TestFilesToReleases(t *testing.T) {
|
||||||
{Version: "go1.5", OS: "windows"},
|
{Version: "go1.5", OS: "windows"},
|
||||||
{Version: "go1.5beta1", OS: "windows"},
|
{Version: "go1.5beta1", OS: "windows"},
|
||||||
}
|
}
|
||||||
stable, unstable, all := filesToReleases(fs)
|
stable, unstable, archive := filesToReleases(fs)
|
||||||
if got, want := len(stable), 2; want != got {
|
if got, want := len(stable), 2; want != got {
|
||||||
t.Errorf("len(stable): got %v, want %v", got, want)
|
t.Errorf("len(stable): got %v, want %v", got, want)
|
||||||
} else {
|
} else {
|
||||||
|
@ -101,8 +101,8 @@ func TestFilesToReleases(t *testing.T) {
|
||||||
if got, want := len(unstable), 0; want != got {
|
if got, want := len(unstable), 0; want != got {
|
||||||
t.Errorf("len(unstable): got %v, want %v", got, want)
|
t.Errorf("len(unstable): got %v, want %v", got, want)
|
||||||
}
|
}
|
||||||
if got, want := len(all), 6; want != got {
|
if got, want := len(archive), 4; want != got {
|
||||||
t.Errorf("len(all): got %v, want %v", got, want)
|
t.Errorf("len(archive): got %v, want %v", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,13 +135,12 @@ information about Go releases.
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{with .Archive}}
|
{{with .Archive}}
|
||||||
<div class="toggle">
|
<div class="toggle" id="archive">
|
||||||
<a name="archive"></a>
|
|
||||||
<div class="collapsed">
|
<div class="collapsed">
|
||||||
<h3 class="toggleButton" title="Click to show versions">All versions▹</h3>
|
<h3 class="toggleButton" title="Click to show versions">Archived versions▹</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="expanded">
|
<div class="expanded">
|
||||||
<h3 class="toggleButton" title="Click to hide versions">All versions▾</h3>
|
<h3 class="toggleButton" title="Click to hide versions">Archived versions▾</h3>
|
||||||
{{template "releases" .}}
|
{{template "releases" .}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -218,8 +217,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
{{define "releases"}}
|
{{define "releases"}}
|
||||||
{{range .}}
|
{{range .}}
|
||||||
<div class="toggle{{if .Visible}}Visible{{end}}">
|
<div class="toggle{{if .Visible}}Visible{{end}}" id="{{.Version}}">
|
||||||
<a name="{{.Version}}"></a> {{/* NOTE(cbro): versions may show multiple times. Don't use "id". */}}
|
|
||||||
<div class="collapsed">
|
<div class="collapsed">
|
||||||
<h2 class="toggleButton" title="Click to show downloads for this version">{{.Version}} ▹</h2>
|
<h2 class="toggleButton" title="Click to show downloads for this version">{{.Version}} ▹</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -246,7 +246,8 @@ function fixFocus() {
|
||||||
|
|
||||||
function toggleHash() {
|
function toggleHash() {
|
||||||
// Open all of the toggles for a particular hash.
|
// Open all of the toggles for a particular hash.
|
||||||
var els = $(window.location.hash + ", a[name='" + window.location.hash.substring(1) + "']");
|
var els = $(document.getElementById(window.location.hash.substring(1)),
|
||||||
|
$("a[name='" + window.location.hash.substring(1) + "']"));
|
||||||
while (els.length) {
|
while (els.length) {
|
||||||
for (var i = 0; i < els.length; i++) {
|
for (var i = 0; i < els.length; i++) {
|
||||||
var el = $(els[i]);
|
var el = $(els[i]);
|
||||||
|
|
|
@ -816,7 +816,8 @@ function fixFocus() {
|
||||||
|
|
||||||
function toggleHash() {
|
function toggleHash() {
|
||||||
// Open all of the toggles for a particular hash.
|
// Open all of the toggles for a particular hash.
|
||||||
var els = $(window.location.hash + ", a[name='" + window.location.hash.substring(1) + "']");
|
var els = $(document.getElementById(window.location.hash.substring(1)),
|
||||||
|
$("a[name='" + window.location.hash.substring(1) + "']"));
|
||||||
while (els.length) {
|
while (els.length) {
|
||||||
for (var i = 0; i < els.length; i++) {
|
for (var i = 0; i < els.length; i++) {
|
||||||
var el = $(els[i]);
|
var el = $(els[i]);
|
||||||
|
|
Loading…
Reference in New Issue