| OLD | NEW |
| 1 package main | 1 package main |
| 2 | 2 |
| 3 import ( | 3 import ( |
| 4 "bytes" | 4 "bytes" |
| 5 "crypto/md5" | 5 "crypto/md5" |
| 6 "database/sql" | 6 "database/sql" |
| 7 "encoding/base64" | 7 "encoding/base64" |
| 8 "encoding/json" | 8 "encoding/json" |
| 9 "flag" | 9 "flag" |
| 10 "fmt" | 10 "fmt" |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 log.Printf("Error: failed to fetch from
database: %q", err) | 430 log.Printf("Error: failed to fetch from
database: %q", err) |
| 431 continue | 431 continue |
| 432 } | 432 } |
| 433 tries = append(tries, Try{Hash: hash, CreateTS:
create_ts.Format("2006-02-01")}) | 433 tries = append(tries, Try{Hash: hash, CreateTS:
create_ts.Format("2006-02-01")}) |
| 434 } | 434 } |
| 435 } | 435 } |
| 436 var code string | 436 var code string |
| 437 if len(tries) == 0 { | 437 if len(tries) == 0 { |
| 438 code = DEFAULT_SAMPLE | 438 code = DEFAULT_SAMPLE |
| 439 } else { | 439 } else { |
| 440 » » » code = getCode(tries[len(tries)-1].Hash) | 440 » » » code = getCode(tries[0].Hash) |
| 441 } | 441 } |
| 442 if err := workspaceTemplate.Execute(w, Workspace{Tries: tries, C
ode: code, Name: name}); err != nil { | 442 if err := workspaceTemplate.Execute(w, Workspace{Tries: tries, C
ode: code, Name: name}); err != nil { |
| 443 log.Printf("ERROR: Failed to expand template: %q\n", err
) | 443 log.Printf("ERROR: Failed to expand template: %q\n", err
) |
| 444 } | 444 } |
| 445 } else if r.Method == "POST" { | 445 } else if r.Method == "POST" { |
| 446 name, err := newWorkspace() | 446 name, err := newWorkspace() |
| 447 if err != nil { | 447 if err != nil { |
| 448 http.Error(w, "Failed to create a new workspace.", 500) | 448 http.Error(w, "Failed to create a new workspace.", 500) |
| 449 return | 449 return |
| 450 } | 450 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 flag.Parse() | 600 flag.Parse() |
| 601 http.HandleFunc("/i/", imageHandler) | 601 http.HandleFunc("/i/", imageHandler) |
| 602 http.HandleFunc("/w/", workspaceHandler) | 602 http.HandleFunc("/w/", workspaceHandler) |
| 603 http.HandleFunc("/recent/", recentHandler) | 603 http.HandleFunc("/recent/", recentHandler) |
| 604 http.HandleFunc("/iframe/", iframeHandler) | 604 http.HandleFunc("/iframe/", iframeHandler) |
| 605 http.HandleFunc("/css/", cssHandler) | 605 http.HandleFunc("/css/", cssHandler) |
| 606 http.HandleFunc("/js/", jsHandler) | 606 http.HandleFunc("/js/", jsHandler) |
| 607 http.HandleFunc("/", mainHandler) | 607 http.HandleFunc("/", mainHandler) |
| 608 log.Fatal(http.ListenAndServe(*port, nil)) | 608 log.Fatal(http.ListenAndServe(*port, nil)) |
| 609 } | 609 } |
| OLD | NEW |