Use event interface for GUI (fixes #383)

This commit is contained in:
Jakob Borg
2014-07-29 11:06:52 +02:00
parent 9c99d65716
commit e27d42935c
9 changed files with 361 additions and 171 deletions

View File

@@ -18,6 +18,12 @@ type translation struct {
}
func main() {
log.SetFlags(log.Lshortfile)
if u, p := userPass(); u == "" || p == "" {
log.Fatal("Need environment variables TRANSIFEX_USER and TRANSIFEX_PASS")
}
resp := req("https://www.transifex.com/api/2/project/syncthing/resource/gui/stats")
var stats map[string]stat
@@ -63,9 +69,14 @@ func main() {
json.NewEncoder(os.Stdout).Encode(langs)
}
func req(url string) *http.Response {
func userPass() (string, string) {
user := os.Getenv("TRANSIFEX_USER")
pass := os.Getenv("TRANSIFEX_PASS")
return user, pass
}
func req(url string) *http.Response {
user, pass := userPass()
req, err := http.NewRequest("GET", url, nil)
if err != nil {