Compare commits
8 Commits
master
...
release-br
Author | SHA1 | Date |
---|---|---|
|
6220cba641 | |
|
ae17563914 | |
|
7771da7791 | |
|
9d32829149 | |
|
05ca1f09ae | |
|
46af848339 | |
|
26c35b4dcf | |
|
a84e830bb0 |
|
@ -35,6 +35,7 @@ var xMap = map[string]xRepo{
|
|||
"mobile": {"https://go.googlesource.com/mobile", "git"},
|
||||
"net": {"https://go.googlesource.com/net", "git"},
|
||||
"oauth2": {"https://go.googlesource.com/oauth2", "git"},
|
||||
"perf": {"https://go.googlesource.com/perf", "git"},
|
||||
"playground": {"https://go.googlesource.com/playground", "git"},
|
||||
"review": {"https://go.googlesource.com/review", "git"},
|
||||
"sync": {"https://go.googlesource.com/sync", "git"},
|
||||
|
|
|
@ -98,6 +98,22 @@ func (f File) PrettySize() string {
|
|||
return fmt.Sprintf("%.0fMB", float64(f.Size)/mb)
|
||||
}
|
||||
|
||||
var primaryPorts = map[string]bool{
|
||||
"darwin/amd64": true,
|
||||
"linux/386": true,
|
||||
"linux/amd64": true,
|
||||
"linux/armv6l": true,
|
||||
"windows/386": true,
|
||||
"windows/amd64": true,
|
||||
}
|
||||
|
||||
func (f File) PrimaryPort() bool {
|
||||
if f.Kind == "source" {
|
||||
return true
|
||||
}
|
||||
return primaryPorts[f.OS+"/"+f.Arch]
|
||||
}
|
||||
|
||||
func (f File) Highlight() bool {
|
||||
switch {
|
||||
case f.Kind == "source":
|
||||
|
@ -122,10 +138,11 @@ func (f File) URL() string {
|
|||
}
|
||||
|
||||
type Release struct {
|
||||
Version string
|
||||
Stable bool
|
||||
Files []File
|
||||
Visible bool // show files on page load
|
||||
Version string
|
||||
Stable bool
|
||||
Files []File
|
||||
Visible bool // show files on page load
|
||||
SplitPortTable bool // whether files should be split by primary/other ports.
|
||||
}
|
||||
|
||||
type Feature struct {
|
||||
|
@ -164,9 +181,9 @@ var featuredFiles = []Feature{
|
|||
|
||||
// data to send to the template; increment cacheKey if you change this.
|
||||
type listTemplateData struct {
|
||||
Featured []Feature
|
||||
Stable, Unstable []Release
|
||||
LoginURL string
|
||||
Featured []Feature
|
||||
Stable, Unstable, Archive []Release
|
||||
LoginURL string
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -196,7 +213,7 @@ func listHandler(w http.ResponseWriter, r *http.Request) {
|
|||
log.Errorf(c, "error listing: %v", err)
|
||||
return
|
||||
}
|
||||
d.Stable, d.Unstable = filesToReleases(fs)
|
||||
d.Stable, d.Unstable, d.Archive = filesToReleases(fs)
|
||||
if len(d.Stable) > 0 {
|
||||
d.Featured = filesToFeatured(d.Stable[0].Files)
|
||||
}
|
||||
|
@ -229,7 +246,7 @@ func filesToFeatured(fs []File) (featured []Feature) {
|
|||
return
|
||||
}
|
||||
|
||||
func filesToReleases(fs []File) (stable, unstable []Release) {
|
||||
func filesToReleases(fs []File) (stable, unstable, archive []Release) {
|
||||
sort.Sort(fileOrder(fs))
|
||||
|
||||
var r *Release
|
||||
|
@ -238,27 +255,53 @@ func filesToReleases(fs []File) (stable, unstable []Release) {
|
|||
if r == nil {
|
||||
return
|
||||
}
|
||||
if r.Stable {
|
||||
if len(stable) == 0 {
|
||||
// Display files for latest stable release.
|
||||
stableMaj, stableMin, _ = parseVersion(r.Version)
|
||||
r.Visible = len(stable) == 0
|
||||
if !r.Stable {
|
||||
if len(unstable) != 0 {
|
||||
// Only show one (latest) unstable version.
|
||||
return
|
||||
}
|
||||
stable = append(stable, *r)
|
||||
maj, min, _ := parseVersion(r.Version)
|
||||
if maj < stableMaj || maj == stableMaj && min <= stableMin {
|
||||
// Display unstable version only if newer than the
|
||||
// latest stable release.
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
if len(unstable) != 0 {
|
||||
// Only show one (latest) unstable version.
|
||||
return
|
||||
}
|
||||
maj, min, _ := parseVersion(r.Version)
|
||||
if maj < stableMaj || maj == stableMaj && min <= stableMin {
|
||||
// Display unstable version only if newer than the
|
||||
// latest stable release.
|
||||
return
|
||||
}
|
||||
r.Visible = true
|
||||
unstable = append(unstable, *r)
|
||||
|
||||
// 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 {
|
||||
if r == nil || f.Version != r.Version {
|
||||
|
|
|
@ -70,3 +70,68 @@ func TestFileOrder(t *testing.T) {
|
|||
t.Errorf("sort order is\n%s\nwant:\n%s", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilesToReleases(t *testing.T) {
|
||||
fs := []File{
|
||||
{Version: "go1.7.4", OS: "darwin"},
|
||||
{Version: "go1.7.4", OS: "windows"},
|
||||
{Version: "go1.7", OS: "darwin"},
|
||||
{Version: "go1.7", OS: "windows"},
|
||||
{Version: "go1.6.2", OS: "darwin"},
|
||||
{Version: "go1.6.2", OS: "windows"},
|
||||
{Version: "go1.6", OS: "darwin"},
|
||||
{Version: "go1.6", OS: "windows"},
|
||||
{Version: "go1.5.2", OS: "darwin"},
|
||||
{Version: "go1.5.2", OS: "windows"},
|
||||
{Version: "go1.5", OS: "darwin"},
|
||||
{Version: "go1.5", OS: "windows"},
|
||||
{Version: "go1.5beta1", OS: "windows"},
|
||||
}
|
||||
stable, unstable, archive := filesToReleases(fs)
|
||||
if got, want := len(stable), 2; want != got {
|
||||
t.Errorf("len(stable): got %v, want %v", got, want)
|
||||
} else {
|
||||
if got, want := stable[0].Version, "go1.7.4"; want != got {
|
||||
t.Errorf("stable[0].Version: got %v, want %v", got, want)
|
||||
}
|
||||
if got, want := stable[1].Version, "go1.6.2"; want != got {
|
||||
t.Errorf("stable[1].Version: got %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
if got, want := len(unstable), 0; want != got {
|
||||
t.Errorf("len(unstable): got %v, want %v", got, want)
|
||||
}
|
||||
if got, want := len(archive), 4; want != got {
|
||||
t.Errorf("len(archive): got %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOldUnstableNotShown(t *testing.T) {
|
||||
fs := []File{
|
||||
{Version: "go1.7.4"},
|
||||
{Version: "go1.7"},
|
||||
{Version: "go1.7beta1"},
|
||||
}
|
||||
_, unstable, _ := filesToReleases(fs)
|
||||
if len(unstable) != 0 {
|
||||
t.Errorf("got unstable, want none")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnstableShown(t *testing.T) {
|
||||
fs := []File{
|
||||
{Version: "go1.8beta2"},
|
||||
{Version: "go1.8rc1"},
|
||||
{Version: "go1.7.4"},
|
||||
{Version: "go1.7"},
|
||||
{Version: "go1.7beta1"},
|
||||
}
|
||||
_, unstable, _ := filesToReleases(fs)
|
||||
if got, want := len(unstable), 1; got != want {
|
||||
t.Fatalf("len(unstable): got %v, want %v", got, want)
|
||||
}
|
||||
// show rcs ahead of betas.
|
||||
if got, want := unstable[0].Version, "go1.8rc1"; got != want {
|
||||
t.Fatalf("unstable[0].Version: got %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,6 +134,18 @@ information about Go releases.
|
|||
{{template "releases" .}}
|
||||
{{end}}
|
||||
|
||||
{{with .Archive}}
|
||||
<div class="toggle" id="archive">
|
||||
<div class="collapsed">
|
||||
<h3 class="toggleButton" title="Click to show versions">Archived versions▹</h3>
|
||||
</div>
|
||||
<div class="expanded">
|
||||
<h3 class="toggleButton" title="Click to hide versions">Archived versions▾</h3>
|
||||
{{template "releases" .}}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
|
||||
<!-- Disabled for now; there's no admin functionality yet.
|
||||
<p>
|
||||
|
@ -213,8 +225,13 @@ $(document).ready(function() {
|
|||
<h2 class="toggleButton" title="Click to hide downloads for this version">{{.Version}} ▾</h2>
|
||||
{{if .Stable}}{{else}}
|
||||
<p>This is an <b>unstable</b> version of Go. Use with caution.</p>
|
||||
<p>If you already have Go installed, you can install this version by running:</p>
|
||||
<pre>
|
||||
go get golang.org/x/build/version/{{.Version}}
|
||||
</pre>
|
||||
<p>Then, use the <code>{{.Version}}</code> command instead of the <code>go</code> command to use {{.Version}}.</p>
|
||||
{{end}}
|
||||
{{template "files" .Files}}
|
||||
{{template "files" .}}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
@ -230,10 +247,22 @@ $(document).ready(function() {
|
|||
<th>Arch</th>
|
||||
<th>Size</th>
|
||||
{{/* Use the checksum type of the first file for the column heading. */}}
|
||||
<th>{{(index . 0).ChecksumType}} Checksum</th>
|
||||
<th>{{(index .Files 0).ChecksumType}} Checksum</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{{range .}}
|
||||
{{if .SplitPortTable}}
|
||||
{{range .Files}}{{if .PrimaryPort}}{{template "file" .}}{{end}}{{end}}
|
||||
|
||||
{{/* TODO(cbro): add a link to an explanatory doc page */}}
|
||||
<tr class="first"><th colspan="6" class="first">Other Ports</th></tr>
|
||||
{{range .Files}}{{if not .PrimaryPort}}{{template "file" .}}{{end}}{{end}}
|
||||
{{else}}
|
||||
{{range .Files}}{{template "file" .}}{{end}}
|
||||
{{end}}
|
||||
</table>
|
||||
{{end}}
|
||||
|
||||
{{define "file"}}
|
||||
<tr{{if .Highlight}} class="highlight"{{end}}>
|
||||
<td class="filename"><a class="download" href="{{.URL}}">{{.Filename}}</a></td>
|
||||
<td>{{pretty .Kind}}</td>
|
||||
|
@ -242,12 +271,6 @@ $(document).ready(function() {
|
|||
<td>{{.PrettySize}}</td>
|
||||
<td><tt>{{.PrettyChecksum}}</tt></td>
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr>
|
||||
<td colspan="5">No downloads available.</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
{{end}}
|
||||
|
||||
{{define "download"}}
|
||||
|
|
|
@ -113,6 +113,11 @@ function generateTOC() {
|
|||
|
||||
function bindToggle(el) {
|
||||
$('.toggleButton', el).click(function() {
|
||||
if ($(this).closest(".toggle, .toggleVisible")[0] != el) {
|
||||
// Only trigger the closest toggle header.
|
||||
return;
|
||||
}
|
||||
|
||||
if ($(el).is('.toggle')) {
|
||||
$(el).addClass('toggleVisible').removeClass('toggle');
|
||||
} else {
|
||||
|
@ -120,6 +125,7 @@ function bindToggle(el) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
function bindToggles(selector) {
|
||||
$(selector).each(function(i, el) {
|
||||
bindToggle(el);
|
||||
|
@ -239,10 +245,18 @@ function fixFocus() {
|
|||
}
|
||||
|
||||
function toggleHash() {
|
||||
var hash = $(window.location.hash);
|
||||
if (hash.is('.toggle')) {
|
||||
hash.find('.toggleButton').first().click();
|
||||
// Open all of the toggles for a particular hash.
|
||||
var els = $(document.getElementById(window.location.hash.substring(1)),
|
||||
$.find("a[name='" + window.location.hash.substring(1) + "']"));
|
||||
while (els.length) {
|
||||
for (var i = 0; i < els.length; i++) {
|
||||
var el = $(els[i]);
|
||||
if (el.is('.toggle')) {
|
||||
el.find('.toggleButton').first().click();
|
||||
}
|
||||
}
|
||||
els = el.parent();
|
||||
}
|
||||
}
|
||||
|
||||
function personalizeInstallInstructions() {
|
||||
|
|
|
@ -683,6 +683,11 @@ function generateTOC() {
|
|||
|
||||
function bindToggle(el) {
|
||||
$('.toggleButton', el).click(function() {
|
||||
if ($(this).closest(".toggle, .toggleVisible")[0] != el) {
|
||||
// Only trigger the closest toggle header.
|
||||
return;
|
||||
}
|
||||
|
||||
if ($(el).is('.toggle')) {
|
||||
$(el).addClass('toggleVisible').removeClass('toggle');
|
||||
} else {
|
||||
|
@ -690,6 +695,7 @@ function bindToggle(el) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
function bindToggles(selector) {
|
||||
$(selector).each(function(i, el) {
|
||||
bindToggle(el);
|
||||
|
@ -809,10 +815,18 @@ function fixFocus() {
|
|||
}
|
||||
|
||||
function toggleHash() {
|
||||
var hash = $(window.location.hash);
|
||||
if (hash.is('.toggle')) {
|
||||
hash.find('.toggleButton').first().click();
|
||||
// Open all of the toggles for a particular hash.
|
||||
var els = $(document.getElementById(window.location.hash.substring(1)),
|
||||
$("a[name='" + window.location.hash.substring(1) + "']"));
|
||||
while (els.length) {
|
||||
for (var i = 0; i < els.length; i++) {
|
||||
var el = $(els[i]);
|
||||
if (el.is('.toggle')) {
|
||||
el.find('.toggleButton').first().click();
|
||||
}
|
||||
}
|
||||
els = el.parent();
|
||||
}
|
||||
}
|
||||
|
||||
function personalizeInstallInstructions() {
|
||||
|
@ -3248,10 +3262,10 @@ div#blog .read {
|
|||
}
|
||||
|
||||
.toggleButton { cursor: pointer; }
|
||||
.toggle .collapsed { display: block; }
|
||||
.toggle .expanded { display: none; }
|
||||
.toggleVisible .collapsed { display: none; }
|
||||
.toggleVisible .expanded { display: block; }
|
||||
.toggle > .collapsed { display: block; }
|
||||
.toggle > .expanded { display: none; }
|
||||
.toggleVisible > .collapsed { display: none; }
|
||||
.toggleVisible > .expanded { display: block; }
|
||||
|
||||
table.codetable { margin-left: auto; margin-right: auto; border-style: none; }
|
||||
table.codetable td { padding-right: 10px; }
|
||||
|
|
|
@ -445,10 +445,10 @@ div#blog .read {
|
|||
}
|
||||
|
||||
.toggleButton { cursor: pointer; }
|
||||
.toggle .collapsed { display: block; }
|
||||
.toggle .expanded { display: none; }
|
||||
.toggleVisible .collapsed { display: none; }
|
||||
.toggleVisible .expanded { display: block; }
|
||||
.toggle > .collapsed { display: block; }
|
||||
.toggle > .expanded { display: none; }
|
||||
.toggleVisible > .collapsed { display: none; }
|
||||
.toggleVisible > .expanded { display: block; }
|
||||
|
||||
table.codetable { margin-left: auto; margin-right: auto; border-style: none; }
|
||||
table.codetable td { padding-right: 10px; }
|
||||
|
|
Loading…
Reference in New Issue