Skip to content
This repository has been archived by the owner on Nov 22, 2018. It is now read-only.

Commit

Permalink
merge from English version
Browse files Browse the repository at this point in the history
  • Loading branch information
mikespook committed Feb 19, 2013
2 parents c6e3c32 + 4c02382 commit c8f5c95
Show file tree
Hide file tree
Showing 92 changed files with 2,647 additions and 3,445 deletions.
35 changes: 35 additions & 0 deletions TRANSLATE
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Translating the Tour

A Tour of Go is a Go program that runs as a stand-alone web server or
an App Engine app. The version available at tour.golang.org is run from
App Engine. There are several localized versions of the tour, such as
this Chinese translation, also running on App Engine:

http://go-tour-zh.appspot.com

The Tour contains a slide named "Go local", which lists several of
these translations. If you are a native speaker of a language not on
that list and have some experience with Go, please consider providing
a translation of the Tour in your own language.

To translate the tour:

1. Translate the contents of tour.article
2. Provide localized verison fo the UI strings in js/lang.js
3. Sign up to App Engine and create an app named go-tour-LL,
where LL is the two-letter country code that applies best
to your chosen language. (This shouldn't cost you anything;
the Tour App usually runs inside App Engine's free quota.)
4. Deploy your version of the Tour to that app.
5. Announce to [email protected]

The Tour content changes occasionally, and you should keep your
translation up to date. To follow the development of the tour,
subscribe to the go-tour-commits mailing list:

https://groups.google.com/group/go-tour-commits

All new commits to the go-tour repository are mailed there.

Finally, if you have any questions about the Tour or Go,
please mail [email protected].
7 changes: 3 additions & 4 deletions appengine/app.yaml → app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ runtime: go
api_version: go1

handlers:
- url: /
static_files: static/index.html
upload: static/index.html
- url: /favicon.ico
static_files: static/favicon.ico
upload: static/favicon.ico
- url: /static
static_dir: static
- url: /talks
static_dir: talks
- url: /(compile|fmt)
- url: /(|compile|fmt|script\.js)
script: _go_app

nobuild_files: (solutions|prog)/.*
16 changes: 0 additions & 16 deletions appengine/README

This file was deleted.

44 changes: 0 additions & 44 deletions appengine/goplay/compile.go

This file was deleted.

50 changes: 0 additions & 50 deletions appengine/goplay/fmt.go

This file was deleted.

103 changes: 103 additions & 0 deletions gotour/appengine.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build appengine

package main

import (
"bufio"
"bytes"
"fmt"
"io"
"net/http"

"appengine"
"appengine/urlfetch"
)

const runUrl = "http://golang.org/compile"

func init() {
http.HandleFunc("/", rootHandler)
http.HandleFunc("/compile", compileHandler)
err := serveScripts("js", "playground.js")
if err != nil {
panic(err)
}
if err := initTour("."); err != nil {
panic(err)
}
}

func rootHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
if err := renderTour(w); err != nil {
c.Criticalf("template render: %v", err)
}
}

func compileHandler(w http.ResponseWriter, r *http.Request) {
if err := passThru(w, r); err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintln(w, "Compile server error.")
}
}

func passThru(w io.Writer, req *http.Request) error {
c := appengine.NewContext(req)
client := urlfetch.Client(c)
defer req.Body.Close()
r, err := client.Post(runUrl, req.Header.Get("Content-type"), req.Body)
if err != nil {
c.Errorf("making POST request:", err)
return err
}
defer r.Body.Close()
if _, err := io.Copy(w, r.Body); err != nil {
c.Errorf("copying response Body:", err)
return err
}
return nil
}

// prepContent returns a Reader that produces the content from the given
// Reader, but strips the prefix "#appengine: " from each line. It also drops
// any non-blank like that follows a series of 1 or more lines with the prefix.
func prepContent(in io.Reader) io.Reader {
var prefix = []byte("#appengine: ")
out, w := io.Pipe()
go func() {
r := bufio.NewReader(in)
drop := false
for {
b, err := r.ReadBytes('\n')
if err != nil && err != io.EOF {
w.CloseWithError(err)
return
}
if bytes.HasPrefix(b, prefix) {
b = b[len(prefix):]
drop = true
} else if drop {
if len(b) > 1 {
b = nil
}
drop = false
}
if len(b) > 0 {
w.Write(b)
}
if err == io.EOF {
w.Close()
return
}
}
}()
return out
}

// socketAddr returns the WebSocket handler address.
// The App Engine version does not provide a WebSocket handler.
func socketAddr() string { return "" }
37 changes: 0 additions & 37 deletions gotour/goplay.go

This file was deleted.

Loading

0 comments on commit c8f5c95

Please sign in to comment.