├── .envrc.sample ├── .gitignore ├── README.md ├── api ├── auth │ ├── github.go │ ├── github_test.go │ ├── user.go │ └── user_test.go ├── challenges │ ├── get.go │ ├── get_test.go │ ├── list.go │ └── list_test.go ├── server.go ├── submissions │ ├── download.go │ ├── download_test.go │ ├── list.go │ ├── list_test.go │ ├── upload.go │ └── upload_test.go ├── users │ ├── get.go │ └── me.go └── write │ └── write.go ├── boltdb ├── boltdb.go ├── challenges.go ├── challenges_test.go ├── users.go └── users_test.go ├── github ├── client.go └── client_test.go ├── main.go ├── mock ├── challenges.go ├── challenges_test.go ├── github.go ├── github_test.go ├── submissions.go ├── submissions_test.go ├── users.go └── users_test.go ├── model ├── challenge.go ├── challenge_test.go ├── errors.go ├── errors_test.go ├── github.go ├── lifecycle.go ├── participation.go ├── spec │ ├── challenges.go │ ├── submissions.go │ └── users.go ├── submission.go ├── submission_test.go ├── user.go └── user_test.go ├── seed.go └── web ├── .bowerrc ├── .gitignore ├── Gruntfile.js ├── README.md ├── assets ├── css │ ├── all.min.css │ └── main.css └── js │ ├── all.min.js │ └── main.js ├── bower.json ├── dist └── index.html ├── layout.html ├── package.json └── templates ├── challenge.html ├── home-challenge-current.html ├── home-challenge-past.html ├── home.html ├── profile.html ├── submission.html └── user-nav.html /.envrc.sample: -------------------------------------------------------------------------------- 1 | export GITHUB_CLIENTID=1234567890 2 | export GITHUB_SECRET=123456789012345678901234567890 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.test 2 | gochallenge 3 | .envrc 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Go Challenge App 2 | 3 | Go Challenge is off to a great start, and to make it even more 4 | awesome - we should build a great app to run the challenge. 5 | 6 | While the current process of emailing zips worked well, it requires 7 | some manual orchestration, and might not scale that well. After some 8 | discussion on [golang-challenge Slack channel](https://gophers.slack.com/messages/golang-challenge/), 9 | this project was born as a community effort to improve this process. 10 | 11 | The basic idea is to take some inspiration from [exercism.io](http://exercism.io/) project, 12 | and build a similar command line driven workflow for Go challenge. Of course, given a more 13 | restrictive nature of the challenge itself (compared to exercism.io's free-flow exercises), 14 | we'll have to modify bits and piece to make it fit the rules of the challenge. 15 | 16 | # How to contribute 17 | 18 | * [golang-challenge Slack channel](https://gophers.slack.com/messages/golang-challenge/) is the main 19 | discussion channel for this project - feel free to jump in and talk to people there. 20 | 21 | * [Github issues](https://github.com/GoChallenge/gochallenge/issues) - 22 | alternatively, if you have an idea that you want to discuss, feel free to open an 23 | issue on this project, and start the discussion. 24 | -------------------------------------------------------------------------------- /api/auth/github.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import ( 4 | "crypto/md5" 5 | "fmt" 6 | "math/rand" 7 | "net/http" 8 | "net/url" 9 | 10 | "github.com/gochallenge/gochallenge/model" 11 | "github.com/julienschmidt/httprouter" 12 | ) 13 | 14 | const authResultURL = "/#api_key=%s" 15 | const authErrorURL = "/#error=%s" 16 | 17 | // GithubInit initiates github authentication workflow 18 | func GithubInit(gh model.GithubAPI) httprouter.Handle { 19 | return func(w http.ResponseWriter, r *http.Request, 20 | _ httprouter.Params) { 21 | // TODO: write state into a signed cookie, and validate it in GithubVerify. 22 | // see http://godoc.org/golang.org/x/oauth2#Config.AuthCodeURL for details 23 | url := gh.AuthURL(state()) 24 | http.RedirectHandler(url, http.StatusFound).ServeHTTP(w, r) 25 | } 26 | } 27 | 28 | // GithubVerify verifies github callback information, and inits 29 | // user record 30 | func GithubVerify(gh model.GithubAPI, us model.Users) httprouter.Handle { 31 | return func(w http.ResponseWriter, r *http.Request, 32 | _ httprouter.Params) { 33 | var ( 34 | u *model.User 35 | loc string 36 | ) 37 | 38 | gu, err := getGithubUser(gh, r) 39 | u, err = setupUser(err, us, gu) 40 | 41 | if err != nil { 42 | loc = fmt.Sprintf(authErrorURL, url.QueryEscape(err.Error())) 43 | } else { 44 | loc = fmt.Sprintf(authResultURL, u.APIKey) 45 | } 46 | 47 | http.RedirectHandler(loc, http.StatusFound).ServeHTTP(w, r) 48 | } 49 | } 50 | 51 | func state() string { 52 | b := make([]byte, 32) 53 | for i := range b { 54 | b[i] = byte(rand.Intn(256)) 55 | } 56 | return fmt.Sprintf("%x", md5.Sum(b)) 57 | } 58 | 59 | func getGithubUser(gh model.GithubAPI, r *http.Request) (*model.GithubUser, error) { 60 | r.ParseForm() 61 | gc, err := gh.NewClientWithToken(r.FormValue("code")) 62 | if err != nil { 63 | return nil, err 64 | } 65 | 66 | return gh.User(gc) 67 | } 68 | 69 | func setupUser(err error, us model.Users, 70 | gu *model.GithubUser) (*model.User, error) { 71 | var u *model.User 72 | 73 | if err != nil { 74 | return u, err 75 | } 76 | 77 | if u, err = us.FindByGithubID(gu.ID); err == nil { 78 | // found existing user record, just return it 79 | return u, nil 80 | } 81 | 82 | if err != model.ErrNotFound { 83 | // got an error that does not indicate a missing user - fail 84 | return nil, err 85 | } 86 | 87 | // Couldn't find a user - add a new one 88 | if u, err = model.NewUser(); err != nil { 89 | return u, err 90 | } 91 | 92 | gu.Populate(u) 93 | err = us.Save(u) 94 | 95 | return u, err 96 | } 97 | -------------------------------------------------------------------------------- /api/auth/github_test.go: -------------------------------------------------------------------------------- 1 | package auth_test 2 | 3 | import ( 4 | "net/http" 5 | "net/http/httptest" 6 | "testing" 7 | 8 | "github.com/gochallenge/gochallenge/api" 9 | "github.com/gochallenge/gochallenge/mock" 10 | "github.com/gochallenge/gochallenge/model" 11 | "github.com/stretchr/testify/require" 12 | ) 13 | 14 | func TestGetGithub(t *testing.T) { 15 | gh := mock.NewGithub() 16 | a := api.New(api.Config{ 17 | Github: &gh, 18 | }) 19 | ts := httptest.NewServer(a) 20 | 21 | // A bit of a get to make GET request without following 22 | // a redirect 23 | trn := &http.Transport{} 24 | req, _ := http.NewRequest("GET", ts.URL+"/v1/auth/github", nil) 25 | res, err := trn.RoundTrip(req) 26 | 27 | require.NoError(t, err) 28 | defer res.Body.Close() 29 | 30 | require.Equal(t, "302 Found", res.Status) 31 | 32 | l := res.Header.Get("Location") 33 | require.NotEmpty(t, l) 34 | } 35 | 36 | func TestVerifyNewGithubUser(t *testing.T) { 37 | gh := mock.NewGithub() 38 | gu := &model.GithubUser{ 39 | ID: 12134, 40 | Name: "Jane Doe", 41 | Email: "jd@mailinator.com", 42 | AvatarURL: "http://localhost/avatar.png", 43 | } 44 | gh.SetUser(gu) 45 | 46 | us := mock.NewUsers() 47 | a := api.New(api.Config{ 48 | Github: &gh, 49 | Users: &us, 50 | }) 51 | ts := httptest.NewServer(a) 52 | 53 | trn := &http.Transport{} 54 | req, _ := http.NewRequest("GET", 55 | ts.URL+"/v1/auth/github_verify?code=123456", nil) 56 | res, err := trn.RoundTrip(req) 57 | defer res.Body.Close() 58 | 59 | // successful verification should redirect to the authenticated page 60 | require.NoError(t, err) 61 | require.Equal(t, http.StatusFound, res.StatusCode) 62 | 63 | // for a new user, we create a record and populate it with 64 | // some basic details from Github profile 65 | u, err := us.FindByGithubID(gu.ID) 66 | require.NoError(t, err) 67 | require.NotNil(t, u) 68 | require.Equal(t, gu.ID, u.GithubID) 69 | require.Equal(t, gu.Name, u.Name) 70 | require.Equal(t, gu.Email, u.Email) 71 | require.Equal(t, gu.AvatarURL, u.AvatarURL) 72 | require.NotEmpty(t, u.APIKey) 73 | 74 | loc := res.Header.Get("Location") 75 | require.Equal(t, "/#api_key="+u.APIKey, loc) 76 | } 77 | 78 | func TestVerifyGithubFailed(t *testing.T) { 79 | gh := mock.NewGithub() 80 | // we don't setup github user here, so mock API calls should error 81 | us := mock.NewUsers() 82 | a := api.New(api.Config{ 83 | Github: &gh, 84 | Users: &us, 85 | }) 86 | ts := httptest.NewServer(a) 87 | 88 | trn := &http.Transport{} 89 | req, _ := http.NewRequest("GET", 90 | ts.URL+"/v1/auth/github_verify?code=123456", nil) 91 | res, err := trn.RoundTrip(req) 92 | defer res.Body.Close() 93 | 94 | // verification errors are reported back to the client page 95 | require.NoError(t, err) 96 | require.Equal(t, http.StatusFound, res.StatusCode) 97 | 98 | loc := res.Header.Get("Location") 99 | require.Equal(t, "/#error=Error+communicating+with+Github+API", loc) 100 | } 101 | -------------------------------------------------------------------------------- /api/auth/user.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/gochallenge/gochallenge/model" 7 | ) 8 | 9 | // HTTPHeader containing API key for the request 10 | const HTTPHeader = "Auth-ApiKey" 11 | 12 | // User that is authenticated in the given request 13 | func User(r *http.Request, us model.Users) (*model.User, error) { 14 | k := r.Header.Get(HTTPHeader) 15 | if k == "" { 16 | return nil, model.ErrAuthFailure 17 | } 18 | 19 | u, err := us.FindByAPIKey(k) 20 | if err == model.ErrNotFound { 21 | // If user is not found here - it means the API key is wrong, 22 | // so rewriting it back as auth failure error 23 | err = model.ErrAuthFailure 24 | } 25 | return u, err 26 | } 27 | -------------------------------------------------------------------------------- /api/auth/user_test.go: -------------------------------------------------------------------------------- 1 | package auth_test 2 | 3 | import ( 4 | "bytes" 5 | "net/http" 6 | "testing" 7 | 8 | "github.com/gochallenge/gochallenge/api/auth" 9 | "github.com/gochallenge/gochallenge/mock" 10 | "github.com/gochallenge/gochallenge/model" 11 | "github.com/stretchr/testify/require" 12 | ) 13 | 14 | func TestUserAuth(t *testing.T) { 15 | u := &model.User{ 16 | ID: 5, 17 | Name: "Jane Doe", 18 | APIKey: "c001c0ffee", 19 | } 20 | us := mock.NewUsers() 21 | us.Save(u) 22 | 23 | req, err := http.NewRequest("GET", "/", bytes.NewReader([]byte{})) 24 | require.NoError(t, err) 25 | 26 | // when no auth header is set - auth error 27 | _, err = auth.User(req, &us) 28 | require.Equal(t, model.ErrAuthFailure, err) 29 | 30 | // when a correct auth header is set - valid user returned 31 | // req.Header["Auth-ApiKey"] = []string{u.APIKey} 32 | req.Header.Set("Auth-ApiKey", u.APIKey) 33 | u0, err := auth.User(req, &us) 34 | require.NoError(t, err) 35 | require.Equal(t, u, u0) 36 | 37 | // when invalid auth header is set - auth error 38 | req.Header.Set("Auth-ApiKey", "badc0ffee") 39 | u0, err = auth.User(req, &us) 40 | require.Equal(t, model.ErrAuthFailure, err) 41 | } 42 | -------------------------------------------------------------------------------- /api/challenges/get.go: -------------------------------------------------------------------------------- 1 | package challenges 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/http" 7 | "strings" 8 | 9 | "github.com/gochallenge/gochallenge/api/write" 10 | "github.com/gochallenge/gochallenge/model" 11 | "github.com/julienschmidt/httprouter" 12 | ) 13 | 14 | type writerFunc func(error, http.ResponseWriter, *model.Challenge) error 15 | 16 | const gogetMeta = `` 17 | 18 | // Get challenge details. 19 | // The challenge is identified via "id" route parameter, which 20 | // can take the form of following string values: 21 | // * current - currently running challenge, or an error 22 | // if there isn't one 23 | // * 123 - numerical ID of the challenge 24 | // * challenge-123 - prefixed numerical ID of the challenge. 25 | func Get(cs model.Challenges) httprouter.Handle { 26 | return func(w http.ResponseWriter, r *http.Request, 27 | ps httprouter.Params) { 28 | 29 | c, err := findChallenge(cs, ps.ByName("id")) 30 | 31 | if err = responder(r)(err, w, c); err != nil { 32 | write.Error(w, r, err) 33 | } 34 | } 35 | } 36 | 37 | // find a challenge given the value if requested ID string 38 | func findChallenge(cs model.Challenges, id string) (*model.Challenge, error) { 39 | var cid model.ChallengeID 40 | idx := strings.Replace(id, "challenge-", "", 1) 41 | 42 | if idx == "current" { 43 | return cs.Current() 44 | } else if err := cid.Atoid(idx); err == nil { 45 | return cs.Find(cid) 46 | } else { 47 | return nil, err 48 | } 49 | } 50 | 51 | // determine response format by request parameters 52 | func responder(r *http.Request) writerFunc { 53 | if err := r.ParseForm(); err == nil && r.Form.Get("go-get") == "1" { 54 | return gogeter 55 | } 56 | return jsonifier 57 | } 58 | 59 | // render a challenge in a way interpretable by go get tool 60 | func gogeter(err error, w http.ResponseWriter, c *model.Challenge) error { 61 | if err != nil { 62 | return err 63 | } 64 | if c.Git == "" { 65 | return model.ErrNoRemote 66 | } 67 | 68 | s := fmt.Sprintf(gogetMeta, c.Import, c.Git) 69 | w.Header().Set("Content-Type", "text/html; charset=utf-8") 70 | _, err = w.Write([]byte(s)) 71 | return err 72 | } 73 | 74 | // render a challenge as json 75 | func jsonifier(err error, w http.ResponseWriter, c *model.Challenge) error { 76 | if err != nil { 77 | return err 78 | } 79 | return json.NewEncoder(w).Encode(c) 80 | } 81 | -------------------------------------------------------------------------------- /api/challenges/get_test.go: -------------------------------------------------------------------------------- 1 | package challenges_test 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io/ioutil" 7 | "net/http" 8 | "net/http/httptest" 9 | "testing" 10 | "time" 11 | 12 | "github.com/gochallenge/gochallenge/api" 13 | "github.com/gochallenge/gochallenge/mock" 14 | "github.com/gochallenge/gochallenge/model" 15 | "github.com/stretchr/testify/require" 16 | ) 17 | 18 | func getBody(t *testing.T, path string, c0 model.Challenge) (*http.Response, []byte) { 19 | cs := mock.NewChallenges() 20 | a := api.New(api.Config{ 21 | Challenges: &cs, 22 | }) 23 | ts := httptest.NewServer(a) 24 | cs.Save(&c0) 25 | 26 | res, err := http.Get(ts.URL + path) 27 | 28 | require.NoError(t, err, "GET "+path+" should not error") 29 | defer res.Body.Close() 30 | body, err := ioutil.ReadAll(res.Body) 31 | require.NoError(t, err, "GET "+path+" should read the body") 32 | 33 | return res, body 34 | } 35 | 36 | func testGettingChallenge(t *testing.T, path string, c0 model.Challenge) { 37 | res, body := getBody(t, path, c0) 38 | 39 | c1 := model.Challenge{} 40 | err := json.Unmarshal(body, &c1) 41 | 42 | require.NoError(t, err, "GET "+path+" unmarshal errored") 43 | require.Equal(t, c0, c1, "GET "+path+" unmarshalled incorrectly") 44 | require.Contains(t, res.Header.Get("Content-Type"), "application/json") 45 | } 46 | 47 | func TestGetChallenge(t *testing.T) { 48 | c0 := model.Challenge{ 49 | ID: 123, 50 | Name: "The Challenge", 51 | Status: model.Open, 52 | Start: time.Date(2015, 3, 1, 0, 0, 0, 0, time.UTC), 53 | End: time.Date(2015, 3, 14, 0, 0, 0, 0, time.UTC), 54 | } 55 | path := fmt.Sprintf("/v1/challenges/%d", c0.ID) 56 | 57 | testGettingChallenge(t, path, c0) 58 | } 59 | 60 | func TestGetCurrentChallenge(t *testing.T) { 61 | c0 := model.Challenge{ 62 | ID: mock.CurrentID, 63 | Name: "The Current Challenge", 64 | Start: time.Date(2015, 3, 1, 0, 0, 0, 0, time.UTC), 65 | End: time.Date(2015, 3, 14, 0, 0, 0, 0, time.UTC), 66 | } 67 | path := "/v1/challenges/current" 68 | 69 | testGettingChallenge(t, path, c0) 70 | } 71 | 72 | func TestGetCurrentChallengeMissing(t *testing.T) { 73 | cs := mock.NewChallenges() 74 | a := api.New(api.Config{ 75 | Challenges: &cs, 76 | }) 77 | ts := httptest.NewServer(a) 78 | 79 | path := "/v1/challenges/current" 80 | res, err := http.Get(ts.URL + path) 81 | 82 | require.NoError(t, err, "GET "+path+" should not error") 83 | defer res.Body.Close() 84 | require.Equal(t, http.StatusNotFound, res.StatusCode) 85 | } 86 | 87 | func TestGoGetChallenge(t *testing.T) { 88 | c0 := model.Challenge{ 89 | ID: mock.CurrentID, 90 | Name: "The Current Challenge", 91 | Import: "gochallenge.org/gochallenge-x", 92 | Git: "https://github.com/author/challengex", 93 | } 94 | path := fmt.Sprintf("/code/challenge-%03d?go-get=1", mock.CurrentID) 95 | 96 | res, body := getBody(t, path, c0) 97 | 98 | require.Contains(t, res.Header.Get("Content-Type"), "text/html") 99 | 100 | meta := fmt.Sprintf(``, 101 | c0.Import, c0.Git) 102 | require.Contains(t, string(body), meta, 103 | "go get response did not return correct meta tag") 104 | } 105 | -------------------------------------------------------------------------------- /api/challenges/list.go: -------------------------------------------------------------------------------- 1 | package challenges 2 | 3 | import ( 4 | "encoding/json" 5 | "net/http" 6 | 7 | "github.com/gochallenge/gochallenge/api/write" 8 | "github.com/gochallenge/gochallenge/model" 9 | "github.com/julienschmidt/httprouter" 10 | ) 11 | 12 | // List all available challenges 13 | func List(cs model.Challenges) httprouter.Handle { 14 | return func(w http.ResponseWriter, r *http.Request, 15 | ps httprouter.Params) { 16 | 17 | cx, err := cs.All() 18 | err = writeChallenges(err, w, cx) 19 | 20 | if err != nil { 21 | write.Error(w, r, err) 22 | } 23 | } 24 | } 25 | 26 | func writeChallenges(err error, w http.ResponseWriter, cx []*model.Challenge) error { 27 | if err != nil { 28 | return err 29 | } 30 | 31 | return json.NewEncoder(w).Encode(cx) 32 | } 33 | -------------------------------------------------------------------------------- /api/challenges/list_test.go: -------------------------------------------------------------------------------- 1 | package challenges_test 2 | 3 | import ( 4 | "encoding/json" 5 | "io/ioutil" 6 | "net/http" 7 | "net/http/httptest" 8 | "testing" 9 | "time" 10 | 11 | "github.com/gochallenge/gochallenge/api" 12 | "github.com/gochallenge/gochallenge/mock" 13 | "github.com/gochallenge/gochallenge/model" 14 | "github.com/stretchr/testify/require" 15 | ) 16 | 17 | func TestList(t *testing.T) { 18 | cs := mock.NewChallenges() 19 | a := api.New(api.Config{ 20 | Challenges: &cs, 21 | }) 22 | ts := httptest.NewServer(a) 23 | 24 | c0 := model.Challenge{ 25 | ID: 123, 26 | Name: "The Challenge", 27 | Status: model.Closed, 28 | Start: time.Date(2015, 3, 1, 0, 0, 0, 0, time.UTC), 29 | End: time.Date(2015, 3, 14, 0, 0, 0, 0, time.UTC), 30 | } 31 | cs.Save(&c0) 32 | 33 | c1 := model.Challenge{ 34 | ID: 124, 35 | Name: "The Challenge Two", 36 | Status: model.Open, 37 | Start: time.Date(2015, 4, 1, 0, 0, 0, 0, time.UTC), 38 | End: time.Date(2015, 4, 14, 0, 0, 0, 0, time.UTC), 39 | } 40 | cs.Save(&c1) 41 | 42 | res, err := http.Get(ts.URL + "/v1/challenges") 43 | defer res.Body.Close() 44 | 45 | require.NoError(t, err) 46 | require.Equal(t, http.StatusOK, res.StatusCode) 47 | require.Contains(t, res.Header.Get("Content-Type"), "application/json") 48 | 49 | b, err := ioutil.ReadAll(res.Body) 50 | require.NoError(t, err) 51 | 52 | var cx []model.Challenge 53 | err = json.Unmarshal(b, &cx) 54 | require.NoError(t, err) 55 | require.Equal(t, []model.Challenge{c0, c1}, cx) 56 | } 57 | -------------------------------------------------------------------------------- /api/server.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "net/http" 5 | "strings" 6 | 7 | "github.com/gochallenge/gochallenge/api/auth" 8 | "github.com/gochallenge/gochallenge/api/challenges" 9 | "github.com/gochallenge/gochallenge/api/submissions" 10 | "github.com/gochallenge/gochallenge/api/users" 11 | "github.com/gochallenge/gochallenge/model" 12 | "github.com/julienschmidt/httprouter" 13 | "github.com/justinas/alice" 14 | "github.com/morhekil/mw" 15 | ) 16 | 17 | const assetsPath = "web/dist/assets" 18 | const indexPath = "web/dist/index.html" 19 | 20 | // Config of the API setup 21 | type Config struct { 22 | Challenges model.Challenges 23 | Submissions model.Submissions 24 | Users model.Users 25 | Github model.GithubAPI 26 | } 27 | 28 | func server(cfg Config) *httprouter.Router { 29 | r := httprouter.New() 30 | r.GET("/v1/challenges", challenges.List(cfg.Challenges)) 31 | r.GET("/v1/challenges/:id", challenges.Get(cfg.Challenges)) 32 | r.GET("/v1/challenges/:id/submissions", 33 | submissions.List(cfg.Challenges, cfg.Submissions, cfg.Users)) 34 | r.GET("/v1/submissions/:id/download", 35 | submissions.Download(cfg.Submissions, cfg.Users)) 36 | r.POST("/v1/challenges/:id/submissions", 37 | submissions.Post(cfg.Challenges, cfg.Submissions, cfg.Users)) 38 | r.GET("/v1/auth/github", auth.GithubInit(cfg.Github)) 39 | r.GET("/v1/auth/github_verify", auth.GithubVerify(cfg.Github, cfg.Users)) 40 | r.GET("/v1/users/:id", users.Get(cfg.Users)) 41 | r.GET("/v1/user", users.Me(cfg.Users)) 42 | r.GET("/code/:id", challenges.Get(cfg.Challenges)) 43 | 44 | r.ServeFiles("/assets/*filepath", http.Dir(assetsPath)) 45 | r.GET("/", indexHTML) 46 | return r 47 | } 48 | 49 | func indexHTML(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { 50 | w.Header().Set("Content-Type", "text/html") 51 | http.ServeFile(w, r, indexPath) 52 | } 53 | 54 | // New server created and configured as an instance of martini server 55 | func New(cfg Config) http.Handler { 56 | return alice.New( 57 | mw.Recover, 58 | mw.Logger, 59 | headerMiddleware, 60 | ).Then(server(cfg)) 61 | } 62 | 63 | func headerMiddleware(h http.Handler) http.Handler { 64 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 65 | switch { 66 | case strings.HasPrefix(r.URL.Path, "/v1/"): 67 | w.Header().Set("Content-Type", "application/json; charset=utf-8") 68 | case strings.HasPrefix(r.URL.Path, "/code"): 69 | w.Header().Set("Content-Type", "application/json; charset=utf-8") 70 | } 71 | h.ServeHTTP(w, r) 72 | }) 73 | } 74 | -------------------------------------------------------------------------------- /api/submissions/download.go: -------------------------------------------------------------------------------- 1 | package submissions 2 | 3 | import ( 4 | "net/http" 5 | "strconv" 6 | 7 | "github.com/gochallenge/gochallenge/api/auth" 8 | "github.com/gochallenge/gochallenge/api/write" 9 | "github.com/gochallenge/gochallenge/model" 10 | "github.com/julienschmidt/httprouter" 11 | ) 12 | 13 | // Download archived code of a submission 14 | func Download(ss model.Submissions, us model.Users) httprouter.Handle { 15 | return func(w http.ResponseWriter, r *http.Request, 16 | ps httprouter.Params) { 17 | 18 | u, err := auth.User(r, us) 19 | s, err := findSubmission(err, ss, ps.ByName("id")) 20 | err = ensureAccess(err, u, s) 21 | 22 | if err != nil { 23 | write.Error(w, r, err) 24 | return 25 | } 26 | 27 | w.Header().Set("Content-Type", "application/zip") 28 | w.Header().Set("Content-Disposition", "attachment; filename=code.zip") 29 | w.Header().Set("Content-Length", strconv.Itoa(len(*s.Data))) 30 | w.Write(*s.Data) 31 | } 32 | } 33 | 34 | func findSubmission(err error, ss model.Submissions, 35 | sid string) (*model.Submission, error) { 36 | if err != nil { 37 | return nil, err 38 | } 39 | return ss.Find(sid) 40 | } 41 | 42 | func ensureAccess(err error, u *model.User, s *model.Submission) error { 43 | if err != nil { 44 | return err 45 | } 46 | if !readable(u, s) { 47 | return model.ErrAccessDenied 48 | } 49 | return nil 50 | } 51 | -------------------------------------------------------------------------------- /api/submissions/download_test.go: -------------------------------------------------------------------------------- 1 | package submissions_test 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "net/http" 7 | "net/http/httptest" 8 | "testing" 9 | 10 | "github.com/gochallenge/gochallenge/api" 11 | "github.com/gochallenge/gochallenge/mock" 12 | "github.com/gochallenge/gochallenge/model" 13 | "github.com/stretchr/testify/require" 14 | ) 15 | 16 | func TestDownloadSubmission(t *testing.T) { 17 | ss := mock.NewSubmissions() 18 | us := mock.NewUsers() 19 | a := api.New(api.Config{ 20 | Submissions: &ss, 21 | Users: &us, 22 | }) 23 | ts := httptest.NewServer(a) 24 | 25 | u0, err := model.NewUser() 26 | require.NoError(t, err) 27 | us.Save(u0) 28 | 29 | d0 := []byte("badc0ffee") 30 | s0 := &model.Submission{ 31 | ID: "0000-abcd", 32 | Type: model.LvlNormal, 33 | Data: &d0, 34 | User: u0, 35 | } 36 | ss.Add(s0) 37 | 38 | res, err := get(ts, fmt.Sprintf("/submissions/%s/download", s0.ID), u0) 39 | defer res.Body.Close() 40 | 41 | require.NoError(t, err) 42 | require.Equal(t, http.StatusOK, res.StatusCode) 43 | 44 | require.Equal(t, "application/zip", res.Header.Get("Content-Type")) 45 | 46 | b, err := ioutil.ReadAll(res.Body) 47 | require.NoError(t, err) 48 | 49 | require.Equal(t, string(d0), string(b)) 50 | } 51 | 52 | func TestDownloadSubmissionMissing(t *testing.T) { 53 | ss := mock.NewSubmissions() 54 | us := mock.NewUsers() 55 | a := api.New(api.Config{ 56 | Submissions: &ss, 57 | Users: &us, 58 | }) 59 | ts := httptest.NewServer(a) 60 | 61 | u0, err := model.NewUser() 62 | require.NoError(t, err) 63 | us.Save(u0) 64 | 65 | res, err := get(ts, "/submissions/123/download", u0) 66 | defer res.Body.Close() 67 | 68 | require.NoError(t, err) 69 | require.Equal(t, http.StatusNotFound, res.StatusCode) 70 | } 71 | 72 | func TestDownloadNoAuth(t *testing.T) { 73 | ss := mock.NewSubmissions() 74 | a := api.New(api.Config{ 75 | Submissions: &ss, 76 | }) 77 | ts := httptest.NewServer(a) 78 | 79 | path := fmt.Sprintf("/v1/submissions/%s/download", "123") 80 | res, err := http.Get(ts.URL + path) 81 | defer res.Body.Close() 82 | 83 | require.NoError(t, err) 84 | require.Equal(t, http.StatusUnauthorized, res.StatusCode) 85 | } 86 | -------------------------------------------------------------------------------- /api/submissions/list.go: -------------------------------------------------------------------------------- 1 | package submissions 2 | 3 | import ( 4 | "encoding/json" 5 | "net/http" 6 | 7 | "github.com/gochallenge/gochallenge/api/auth" 8 | "github.com/gochallenge/gochallenge/api/write" 9 | "github.com/gochallenge/gochallenge/model" 10 | "github.com/julienschmidt/httprouter" 11 | ) 12 | 13 | // List all available submissions for a challenge 14 | func List(cs model.Challenges, ss model.Submissions, 15 | us model.Users) httprouter.Handle { 16 | return func(w http.ResponseWriter, r *http.Request, 17 | ps httprouter.Params) { 18 | var sx []*model.Submission 19 | 20 | u, err := auth.User(r, us) 21 | c, err := findChallenge(err, cs, ps.ByName("id")) 22 | sx, err = listSubmissions(err, ss, c, u) 23 | err = writeSubmissions(err, w, sx) 24 | 25 | if err != nil { 26 | write.Error(w, r, err) 27 | } 28 | } 29 | } 30 | 31 | func listSubmissions(err error, ss model.Submissions, 32 | c *model.Challenge, u *model.User) ([]*model.Submission, error) { 33 | var subs []*model.Submission 34 | // non-initialised array will marshal to "null", not to "[]", 35 | // so this is a little hack to work around that 36 | subs = make([]*model.Submission, 0) 37 | 38 | if err != nil { 39 | return subs, err 40 | } 41 | sx, err := ss.AllForChallenge(c) 42 | if err != nil { 43 | return subs, err 44 | } 45 | 46 | for _, s := range sx { 47 | if readable(u, s) { 48 | subs = append(subs, s) 49 | } 50 | } 51 | return subs, nil 52 | } 53 | 54 | func writeSubmissions(err error, w http.ResponseWriter, 55 | sx []*model.Submission) error { 56 | 57 | if err != nil { 58 | return err 59 | } 60 | return json.NewEncoder(w).Encode(sx) 61 | } 62 | 63 | func readable(u *model.User, s *model.Submission) bool { 64 | return s.User != nil && u.ID == s.User.ID 65 | } 66 | -------------------------------------------------------------------------------- /api/submissions/list_test.go: -------------------------------------------------------------------------------- 1 | package submissions_test 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io/ioutil" 7 | "net/http" 8 | "net/http/httptest" 9 | "testing" 10 | "time" 11 | 12 | "github.com/gochallenge/gochallenge/api" 13 | "github.com/gochallenge/gochallenge/api/auth" 14 | "github.com/gochallenge/gochallenge/mock" 15 | "github.com/gochallenge/gochallenge/model" 16 | "github.com/stretchr/testify/require" 17 | ) 18 | 19 | func get(ts *httptest.Server, path string, 20 | u *model.User) (*http.Response, error) { 21 | req, err := http.NewRequest("GET", ts.URL+"/v1"+path, nil) 22 | if err != nil { 23 | return nil, err 24 | } 25 | req.Header.Set(auth.HTTPHeader, u.APIKey) 26 | 27 | hc := &http.Client{} 28 | return hc.Do(req) 29 | } 30 | 31 | func TestList(t *testing.T) { 32 | cs := mock.NewChallenges() 33 | ss := mock.NewSubmissions() 34 | us := mock.NewUsers() 35 | a := api.New(api.Config{ 36 | Challenges: &cs, 37 | Submissions: &ss, 38 | Users: &us, 39 | }) 40 | ts := httptest.NewServer(a) 41 | 42 | c0 := &model.Challenge{ 43 | ID: 123, 44 | Name: "The Challenge", 45 | Status: model.Open, 46 | Start: time.Date(2015, 3, 1, 0, 0, 0, 0, time.UTC), 47 | End: time.Date(2015, 3, 14, 0, 0, 0, 0, time.UTC), 48 | } 49 | cs.Save(c0) 50 | 51 | u0, err := model.NewUser() 52 | us.Save(u0) 53 | require.NoError(t, err) 54 | s0 := model.Submission{ 55 | ID: "0000-abcd", 56 | Challenge: c0, 57 | User: u0, 58 | Type: model.LvlNormal, 59 | } 60 | ss.Add(&s0) 61 | 62 | u1, err := model.NewUser() 63 | us.Save(u0) 64 | require.NoError(t, err) 65 | s1 := model.Submission{ 66 | ID: "0000-fedc", 67 | User: u1, 68 | Challenge: c0, 69 | Type: model.LvlFun, 70 | } 71 | ss.Add(&s1) 72 | 73 | url := fmt.Sprintf("/challenges/%d/submissions", c0.ID) 74 | res, err := get(ts, url, u0) 75 | defer res.Body.Close() 76 | 77 | require.NoError(t, err) 78 | require.Equal(t, "200 OK", res.Status) 79 | 80 | b, err := ioutil.ReadAll(res.Body) 81 | require.NoError(t, err) 82 | 83 | b01, _ := json.Marshal([]model.Submission{s0}) 84 | require.Equal(t, string(b01)+"\n", string(b)) 85 | } 86 | 87 | func TestListEmpty(t *testing.T) { 88 | cs := mock.NewChallenges() 89 | ss := mock.NewSubmissions() 90 | us := mock.NewUsers() 91 | a := api.New(api.Config{ 92 | Challenges: &cs, 93 | Submissions: &ss, 94 | Users: &us, 95 | }) 96 | ts := httptest.NewServer(a) 97 | 98 | u0, err := model.NewUser() 99 | require.NoError(t, err) 100 | us.Save(u0) 101 | c0 := &model.Challenge{ 102 | ID: 123, 103 | Name: "The Challenge", 104 | Status: model.Open, 105 | Start: time.Date(2015, 3, 1, 0, 0, 0, 0, time.UTC), 106 | End: time.Date(2015, 3, 14, 0, 0, 0, 0, time.UTC), 107 | } 108 | cs.Save(c0) 109 | 110 | url := fmt.Sprintf("/challenges/%d/submissions", c0.ID) 111 | res, err := get(ts, url, u0) 112 | defer res.Body.Close() 113 | 114 | require.NoError(t, err) 115 | require.Equal(t, http.StatusOK, res.StatusCode) 116 | require.Contains(t, res.Header.Get("Content-Type"), "application/json") 117 | 118 | b, err := ioutil.ReadAll(res.Body) 119 | require.NoError(t, err) 120 | require.Equal(t, "[]\n", string(b)) 121 | } 122 | 123 | func TestListMissing(t *testing.T) { 124 | cs := mock.NewChallenges() 125 | us := mock.NewUsers() 126 | a := api.New(api.Config{ 127 | Challenges: &cs, 128 | Users: &us, 129 | }) 130 | ts := httptest.NewServer(a) 131 | 132 | u0, err := model.NewUser() 133 | require.NoError(t, err) 134 | us.Save(u0) 135 | 136 | res, err := get(ts, "/challenges/123/submissions", u0) 137 | defer res.Body.Close() 138 | 139 | require.NoError(t, err) 140 | require.Equal(t, http.StatusNotFound, res.StatusCode) 141 | } 142 | -------------------------------------------------------------------------------- /api/submissions/upload.go: -------------------------------------------------------------------------------- 1 | package submissions 2 | 3 | import ( 4 | "encoding/base64" 5 | "encoding/json" 6 | "fmt" 7 | "io" 8 | "io/ioutil" 9 | "mime" 10 | "mime/multipart" 11 | "net/http" 12 | "strings" 13 | "time" 14 | 15 | "github.com/gochallenge/gochallenge/api/auth" 16 | "github.com/gochallenge/gochallenge/api/write" 17 | "github.com/gochallenge/gochallenge/model" 18 | "github.com/julienschmidt/httprouter" 19 | ) 20 | 21 | // Post new sumission 22 | func Post(cs model.Challenges, ss model.Submissions, us model.Users) httprouter.Handle { 23 | return func(w http.ResponseWriter, r *http.Request, 24 | ps httprouter.Params) { 25 | var s model.Submission 26 | 27 | u, err := auth.User(r, us) 28 | s.Challenge, err = findChallenge(err, cs, ps.ByName("id")) 29 | err = readSubmission(err, &s, r) 30 | err = storeSubmission(err, ss, &s, u) 31 | err = writeSubmission(err, w, s) 32 | 33 | write.Error(w, r, err) 34 | } 35 | } 36 | 37 | // find a challenge given the value of requested ID string 38 | func findChallenge(err error, cs model.Challenges, 39 | id string) (*model.Challenge, error) { 40 | if err != nil { 41 | return nil, err 42 | } 43 | 44 | var cid model.ChallengeID 45 | err = cid.Atoid(id) 46 | if err != nil { 47 | return nil, err 48 | } 49 | return cs.Find(cid) 50 | } 51 | 52 | func readSubmission(err error, s *model.Submission, r *http.Request) error { 53 | var bnd string 54 | 55 | if err != nil { 56 | return err 57 | } 58 | 59 | if bnd, err = boundary(r); err != nil { 60 | return err 61 | } 62 | 63 | mr := multipart.NewReader(r.Body, bnd) 64 | for ; err == nil; err = parsePart(mr, s) { 65 | } 66 | 67 | // io.EOF means we completed the parsing, this is not a reportable 68 | // error 69 | if err == io.EOF { 70 | err = nil 71 | } 72 | 73 | return err 74 | } 75 | 76 | func boundary(r *http.Request) (string, error) { 77 | ct := r.Header.Get("Content-Type") 78 | mt, args, err := mime.ParseMediaType(ct) 79 | if err != nil { 80 | return "", err 81 | } 82 | 83 | bnd := args["boundary"] 84 | if !strings.HasPrefix(mt, "multipart/") || bnd == "" { 85 | return "", fmt.Errorf("invalid content type %s", ct) 86 | } 87 | return bnd, err 88 | } 89 | 90 | // Parse the next part of multipart message, and handle its content 91 | // depending on this part's content type 92 | func parsePart(mr *multipart.Reader, s *model.Submission) error { 93 | var ( 94 | p *multipart.Part 95 | mt string 96 | err error 97 | ) 98 | if p, err = mr.NextPart(); err != nil { 99 | return err 100 | } 101 | 102 | mt, _, err = mime.ParseMediaType(p.Header.Get("Content-Type")) 103 | if err != nil { 104 | return err 105 | } 106 | 107 | switch mt { 108 | case "application/json": 109 | err = parseJSON(s, p) 110 | case "application/zip": 111 | err = parseZip(s, p) 112 | } 113 | 114 | return err 115 | } 116 | 117 | // JSON part is submission's metadata 118 | func parseJSON(s *model.Submission, p *multipart.Part) error { 119 | b, err := ioutil.ReadAll(p) 120 | if err != nil { 121 | return err 122 | } 123 | return json.Unmarshal(b, s) 124 | } 125 | 126 | // ZIP part is submission's binary archive 127 | func parseZip(s *model.Submission, p *multipart.Part) error { 128 | var ( 129 | b []byte 130 | err error 131 | ) 132 | 133 | if p.Header.Get("Content-Transfer-Encoding") == "base64" { 134 | // decode base64 135 | dc := base64.NewDecoder(base64.StdEncoding, p) 136 | b, err = ioutil.ReadAll(dc) 137 | } else { 138 | // default to binary content 139 | b, err = ioutil.ReadAll(p) 140 | } 141 | if err != nil { 142 | return err 143 | } 144 | s.Data = &b 145 | 146 | return nil 147 | } 148 | 149 | func writeSubmission(err error, w http.ResponseWriter, 150 | s model.Submission) error { 151 | 152 | if err != nil { 153 | return err 154 | } 155 | return json.NewEncoder(w).Encode(s) 156 | } 157 | 158 | func storeSubmission(err error, ss model.Submissions, s *model.Submission, u *model.User) error { 159 | if err != nil { 160 | return err 161 | } 162 | s.User = u 163 | s.Created = time.Now().UTC() 164 | return ss.Add(s) 165 | } 166 | -------------------------------------------------------------------------------- /api/submissions/upload_test.go: -------------------------------------------------------------------------------- 1 | package submissions_test 2 | 3 | import ( 4 | "archive/zip" 5 | "bytes" 6 | "encoding/json" 7 | "fmt" 8 | "io" 9 | "io/ioutil" 10 | "net/http" 11 | "net/http/httptest" 12 | "strings" 13 | "testing" 14 | 15 | "github.com/gochallenge/gochallenge/api" 16 | "github.com/gochallenge/gochallenge/api/auth" 17 | "github.com/gochallenge/gochallenge/mock" 18 | "github.com/gochallenge/gochallenge/model" 19 | "github.com/stretchr/testify/require" 20 | ) 21 | 22 | func TestPostMultipart(t *testing.T) { 23 | ss := mock.NewSubmissions() 24 | cs := mock.NewChallenges() 25 | us := mock.NewUsers() 26 | 27 | c0 := &model.Challenge{ 28 | ID: 1, 29 | Status: model.Open, 30 | } 31 | cs.Save(c0) 32 | 33 | // Creating a pre-existing submission, to make sure 34 | // an ID for the new one will be assigned correctly 35 | ss.Add(&model.Submission{ 36 | ID: "1", 37 | }) 38 | 39 | u0, err := model.NewUser() 40 | require.NoError(t, err) 41 | us.Save(u0) 42 | 43 | a := api.New(api.Config{ 44 | Challenges: &cs, 45 | Submissions: &ss, 46 | Users: &us, 47 | }) 48 | ts := httptest.NewServer(a) 49 | 50 | path := fmt.Sprintf("/v1/challenges/%d/submissions", c0.ID) 51 | bnd := "c0ffee" 52 | 53 | // the data here is a zipped file "test.txt", containing word "test" 54 | data := fmt.Sprintf(`--%[1]s 55 | Content-Type: application/json; charset=UTF-8 56 | 57 | {"type":"normal"} 58 | --%[1]s 59 | Content-Type: application/zip 60 | Content-Transfer-Encoding: base64 61 | 62 | UEsDBAoAAAAAAONob0bGNbk7BQAAAAUAAAAIABwAdGVzdC50eHRVVAkAA0rpBFVO6QRVdXgLAAEE9QEA 63 | AAQUAAAAdGVzdApQSwECHgMKAAAAAADjaG9GxjW5OwUAAAAFAAAACAAYAAAAAAABAAAApIEAAAAAdGVz 64 | dC50eHRVVAUAA0rpBFV1eAsAAQT1AQAABBQAAABQSwUGAAAAAAEAAQBOAAAARwAAAAAA 65 | --%[1]s-- 66 | `, bnd) 67 | buf := strings.NewReader(data) 68 | res, err := postAsUser(t, u0.APIKey, ts.URL+path, bnd, buf) 69 | defer res.Body.Close() 70 | 71 | require.NoError(t, err) 72 | b, err := ioutil.ReadAll(res.Body) 73 | require.NoError(t, err) 74 | 75 | require.Equal(t, "200 OK", res.Status) 76 | 77 | var sx model.Submission 78 | err = json.Unmarshal(b, &sx) 79 | require.NoError(t, err) 80 | require.Equal(t, "2", sx.ID) 81 | 82 | sl, err := ss.Find(sx.ID) 83 | testSubmissionData(t, sl, map[string]string{ 84 | "test.txt": "test\x0a", 85 | }) 86 | require.Equal(t, u0, sl.User) 87 | require.Equal(t, c0, sl.Challenge) 88 | } 89 | 90 | func testSubmissionData(t *testing.T, sx *model.Submission, ex map[string]string) { 91 | var b []byte 92 | 93 | // Test that the data can be unzipped 94 | z, err := zip.NewReader(bytes.NewReader(*sx.Data), int64(len(*sx.Data))) 95 | require.NoError(t, err, "zip reader init failed") 96 | files := map[string]string{} 97 | 98 | // Load all files into a map 99 | for _, f := range z.File { 100 | zf, err := f.Open() 101 | if err == nil { 102 | b, err = ioutil.ReadAll(zf) 103 | files[f.Name] = string(b) 104 | } 105 | require.NoError(t, err) 106 | } 107 | 108 | // And verify that the map is the same as the expected one 109 | require.Equal(t, ex, files) 110 | } 111 | 112 | func TestPostToWrongChallenge(t *testing.T) { 113 | cs := mock.NewChallenges() 114 | us := mock.NewUsers() 115 | a := api.New(api.Config{ 116 | Challenges: &cs, 117 | Users: &us, 118 | }) 119 | ts := httptest.NewServer(a) 120 | 121 | u0, err := model.NewUser() 122 | require.NoError(t, err) 123 | us.Save(u0) 124 | 125 | path := fmt.Sprintf("/v1/challenges/%d/submissions", 123) 126 | buf := strings.NewReader("somedata") 127 | res, err := postAsUser(t, u0.APIKey, ts.URL+path, "xxx", buf) 128 | defer res.Body.Close() 129 | 130 | require.NoError(t, err) 131 | require.Equal(t, http.StatusNotFound, res.StatusCode) 132 | } 133 | 134 | func TestPostWithInvalidKey(t *testing.T) { 135 | cs := mock.NewChallenges() 136 | c0 := &model.Challenge{ 137 | ID: 1, 138 | Status: model.Open, 139 | } 140 | cs.Save(c0) 141 | us := mock.NewUsers() 142 | a := api.New(api.Config{ 143 | Challenges: &cs, 144 | Users: &us, 145 | }) 146 | ts := httptest.NewServer(a) 147 | 148 | path := fmt.Sprintf("/v1/challenges/%d/submissions", c0.ID) 149 | buf := strings.NewReader("somedata") 150 | res, err := postAsUser(t, "deadbeef", ts.URL+path, "xxx", buf) 151 | defer res.Body.Close() 152 | 153 | require.NoError(t, err) 154 | require.Equal(t, http.StatusUnauthorized, res.StatusCode) 155 | } 156 | 157 | func postAsUser(t *testing.T, ukey string, uri string, bnd string, 158 | body io.Reader) (*http.Response, error) { 159 | 160 | r, err := http.NewRequest("POST", uri, body) 161 | require.NoError(t, err) 162 | r.Header.Set("Content-Type", "multipart/related; boundary="+bnd) 163 | r.Header.Set(auth.HTTPHeader, ukey) 164 | 165 | client := &http.Client{} 166 | return client.Do(r) 167 | } 168 | -------------------------------------------------------------------------------- /api/users/get.go: -------------------------------------------------------------------------------- 1 | package users 2 | 3 | import ( 4 | "encoding/json" 5 | "net/http" 6 | 7 | "github.com/gochallenge/gochallenge/model" 8 | "github.com/julienschmidt/httprouter" 9 | ) 10 | 11 | func Get(us model.Users) httprouter.Handle { 12 | return func(w http.ResponseWriter, r *http.Request, 13 | ps httprouter.Params) { 14 | 15 | u, err := findUser(us, ps.ByName("id")) 16 | if err != nil { 17 | w.WriteHeader(http.StatusNotFound) 18 | return 19 | } 20 | if err = json.NewEncoder(w).Encode(u); err != nil { 21 | w.WriteHeader(http.StatusInternalServerError) 22 | } 23 | } 24 | } 25 | 26 | // find a user of a specified ID. 27 | func findUser(us model.Users, idstr string) (*model.User, error) { 28 | var ( 29 | id model.UserID 30 | u *model.User 31 | err error 32 | ) 33 | 34 | err = id.Atoid(idstr) 35 | if err != nil { 36 | return nil, err 37 | } 38 | u, err = us.Find(id) 39 | if err != nil { 40 | return nil, err 41 | } 42 | return u, nil 43 | } 44 | -------------------------------------------------------------------------------- /api/users/me.go: -------------------------------------------------------------------------------- 1 | package users 2 | 3 | import ( 4 | "encoding/json" 5 | "net/http" 6 | 7 | "github.com/gochallenge/gochallenge/model" 8 | "github.com/julienschmidt/httprouter" 9 | ) 10 | 11 | func Me(us model.Users) httprouter.Handle { 12 | return func(w http.ResponseWriter, r *http.Request, 13 | ps httprouter.Params) { 14 | 15 | apiKey := r.Header.Get("Auth-ApiKey") 16 | u, err := us.FindByAPIKey(apiKey) 17 | if err != nil { 18 | w.WriteHeader(http.StatusUnauthorized) 19 | return 20 | } 21 | if err = json.NewEncoder(w).Encode(u); err != nil { 22 | w.WriteHeader(http.StatusInternalServerError) 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /api/write/write.go: -------------------------------------------------------------------------------- 1 | package write 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | 7 | "github.com/gochallenge/gochallenge/model" 8 | ) 9 | 10 | var errcodes = map[model.Error]int{ 11 | model.ErrNotFound: 404, 12 | model.ErrAuthFailure: 401, 13 | } 14 | 15 | // Error is being reported back to an API client 16 | func Error(w http.ResponseWriter, _ *http.Request, err error) { 17 | if err == nil { 18 | return 19 | } 20 | 21 | switch err.(type) { 22 | case model.Error: 23 | code, ok := errcodes[err.(model.Error)] 24 | if !ok { 25 | code = http.StatusBadRequest 26 | } 27 | w.WriteHeader(code) 28 | w.Write([]byte(fmt.Sprintf("%s", err))) 29 | default: 30 | w.WriteHeader(http.StatusBadRequest) 31 | w.Write([]byte(fmt.Sprintf("%s", err))) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /boltdb/boltdb.go: -------------------------------------------------------------------------------- 1 | package boltdb 2 | 3 | import ( 4 | "bytes" 5 | "encoding/binary" 6 | "encoding/gob" 7 | "time" 8 | 9 | "github.com/boltdb/bolt" 10 | "github.com/gochallenge/gochallenge/model" 11 | ) 12 | 13 | type boltf func(tx *bolt.Tx) error 14 | 15 | // Open Bolt database at the given file name 16 | func Open(file string) (*bolt.DB, error) { 17 | opt := &bolt.Options{ 18 | Timeout: 1 * time.Second, 19 | } 20 | return bolt.Open(file, 0600, opt) 21 | } 22 | 23 | // chain executes a given chain of database operations within a single 24 | // transaction, which is provided as the first argument 25 | func chain(tx func(func(tx *bolt.Tx) error) error, ops ...boltf) error { 26 | return tx(func(tx *bolt.Tx) error { 27 | var err error 28 | for _, op := range ops { 29 | if err = op(tx); err != nil { 30 | break 31 | } 32 | } 33 | return err 34 | }) 35 | } 36 | 37 | // initialises bolt bucket for challenges 38 | func initBucket(bkt []byte) boltf { 39 | return func(tx *bolt.Tx) error { 40 | _, err := tx.CreateBucketIfNotExists(bkt) 41 | return err 42 | } 43 | } 44 | 45 | // store record in the bucket under the given key 46 | func store(bkt []byte, k interface{}, u interface{}) boltf { 47 | return func(tx *bolt.Tx) error { 48 | var b bytes.Buffer 49 | 50 | kb, err := vtoKey(k) 51 | if err != nil { 52 | return err 53 | } 54 | if err := gob.NewEncoder(&b).Encode(u); err != nil { 55 | return err 56 | } 57 | return tx.Bucket(bkt).Put(kb, b.Bytes()) 58 | } 59 | } 60 | 61 | // retrieve a record stored in the bucket under the given key 62 | func load(bkt []byte, k interface{}, u interface{}) boltf { 63 | return func(tx *bolt.Tx) error { 64 | var b *[]byte 65 | 66 | kb, err := vtoKey(k) 67 | if err != nil { 68 | return err 69 | } 70 | if err := atoBytes(bkt, kb, &b)(tx); err != nil { 71 | return err 72 | } 73 | return decode(b, u) 74 | } 75 | } 76 | 77 | // iterates through all objects in the bucket, returning the first 78 | // one matching given predicate function 79 | func first(bkt []byte, f func(interface{}) bool, x interface{}) boltf { 80 | return func(tx *bolt.Tx) error { 81 | var err error 82 | bk := tx.Bucket(bkt).Cursor() 83 | 84 | for k, v := bk.First(); k != nil && err == nil; k, v = bk.Next() { 85 | if err = decode(&v, x); err == nil && f(x) { 86 | // the matching record is found, stop here 87 | return nil 88 | } 89 | } 90 | // no matching record was found, if there're no errors either - 91 | // return ErrNotFound 92 | if err == nil { 93 | err = model.ErrNotFound 94 | } 95 | return err 96 | } 97 | } 98 | 99 | // returns a value stored in the bucket under the given string key 100 | func atoBytes(bkt []byte, k []byte, b **[]byte) boltf { 101 | return func(tx *bolt.Tx) error { 102 | v := tx.Bucket(bkt).Get(k) 103 | 104 | // bolt returns an empty result for unknown key lookup, 105 | // return ErrNotFound in this case 106 | if v == nil { 107 | return model.ErrNotFound 108 | } 109 | *b = &v 110 | return nil 111 | } 112 | } 113 | 114 | // decodes a record from the given byte slice 115 | func decode(b *[]byte, u interface{}) error { 116 | return gob.NewDecoder(bytes.NewReader(*b)).Decode(u) 117 | } 118 | 119 | // converts given value into its key representation. 120 | // Key are stored as big-endian-encoded binary values, to allow 121 | // Bolt to sort them automatically 122 | func vtoKey(id interface{}) ([]byte, error) { 123 | b := new(bytes.Buffer) 124 | err := binary.Write(b, binary.BigEndian, id) 125 | return b.Bytes(), err 126 | } 127 | 128 | // converts a binary into into its value representation 129 | func keytoV(b []byte, v interface{}) error { 130 | r := bytes.NewReader(b) 131 | return binary.Read(r, binary.BigEndian, v) 132 | } 133 | 134 | // find the last key value in the bucket, saving it into the given 135 | // interface pointer. If the bucket is empty, no error is returned, and 136 | // the value is not changed 137 | func lastKey(tx *bolt.Tx, bkt []byte, id interface{}) error { 138 | // Bolt stores its key in an ordered fashion, which means 139 | // (as we store our keys as big-endian byte arrays, too) 140 | // we can simply grab the latest key and use its value 141 | bk := tx.Bucket(bkt) 142 | k, _ := bk.Cursor().Last() 143 | if k == nil { 144 | return nil 145 | } 146 | return keytoV(k, id) 147 | } 148 | -------------------------------------------------------------------------------- /boltdb/challenges.go: -------------------------------------------------------------------------------- 1 | package boltdb 2 | 3 | import ( 4 | "github.com/boltdb/bolt" 5 | "github.com/gochallenge/gochallenge/model" 6 | ) 7 | 8 | var bktChallenges = []byte("Chals") 9 | 10 | // Challenges repository 11 | type Challenges struct { 12 | db *bolt.DB 13 | } 14 | 15 | // NewChallenges returns a new initialised struct of challenges 16 | func NewChallenges(db *bolt.DB) (Challenges, error) { 17 | err := db.Update(initBucket(bktChallenges)) 18 | return Challenges{db}, err 19 | } 20 | 21 | // Save a challenge into the repo 22 | func (cs *Challenges) Save(c *model.Challenge) error { 23 | return chain(cs.db.Update, 24 | prefillChallenge(c), 25 | store(bktChallenges, &c.ID, c), 26 | ) 27 | } 28 | 29 | // Find a challenge in the repository by its id 30 | func (cs *Challenges) Find(id model.ChallengeID) (*model.Challenge, error) { 31 | var chal model.Challenge 32 | return &chal, cs.db.View(load(bktChallenges, id, &chal)) 33 | } 34 | 35 | // All challenges currently available 36 | func (cs *Challenges) All() ([]*model.Challenge, error) { 37 | var chals []*model.Challenge 38 | 39 | err := cs.db.View(getChallenges(&chals)) 40 | return chals, err 41 | } 42 | 43 | // Current challenge, according to the rules defined on challenge 44 | // model itself 45 | func (cs *Challenges) Current() (*model.Challenge, error) { 46 | var chal model.Challenge 47 | 48 | // TODO: this can be optimised by keeping a pointer to 49 | // the current challenge in the database. When retrieved, 50 | // the challenge can be re-verified as current, and only 51 | // if it is out of date - full re-scan be triggered 52 | f := func(c interface{}) bool { 53 | return c.(*model.Challenge).Current() 54 | } 55 | return &chal, cs.db.View(first(bktChallenges, f, &chal)) 56 | } 57 | 58 | // 59 | // Low-level database operations 60 | // 61 | 62 | // get all challenges from the database 63 | func getChallenges(chals *[]*model.Challenge) boltf { 64 | return func(tx *bolt.Tx) error { 65 | bkt := tx.Bucket(bktChallenges) 66 | 67 | err := bkt.ForEach(func(_, v []byte) error { 68 | chal := model.Challenge{} 69 | if err := decode(&v, &chal); err != nil { 70 | return err 71 | } 72 | *chals = append(*chals, &chal) 73 | return nil 74 | }) 75 | return err 76 | } 77 | } 78 | 79 | // prefills challenge's ID with the next available unique value. If challenge 80 | // already has its ID set - does nothing. 81 | func prefillChallenge(c *model.Challenge) boltf { 82 | return func(tx *bolt.Tx) error { 83 | if c.ID != 0 { 84 | return nil 85 | } 86 | var id model.ChallengeID 87 | if err := lastKey(tx, bktChallenges, &id); err != nil { 88 | return err 89 | } 90 | c.ID = id + 1 91 | return nil 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /boltdb/challenges_test.go: -------------------------------------------------------------------------------- 1 | package boltdb_test 2 | 3 | import ( 4 | "io/ioutil" 5 | "math/rand" 6 | "os" 7 | "testing" 8 | "time" 9 | 10 | "github.com/gochallenge/gochallenge/boltdb" 11 | "github.com/gochallenge/gochallenge/model" 12 | "github.com/gochallenge/gochallenge/model/spec" 13 | "github.com/stretchr/testify/assert" 14 | "github.com/stretchr/testify/require" 15 | ) 16 | 17 | func TestChallengeBoltRepo(t *testing.T) { 18 | f, err := ioutil.TempFile("", "gctestboltdb") 19 | require.NoError(t, err) 20 | defer os.Remove(f.Name()) 21 | 22 | db, err := boltdb.Open(f.Name()) 23 | require.NoError(t, err) 24 | cs, err := boltdb.NewChallenges(db) 25 | require.NoError(t, err) 26 | 27 | cur := model.Challenge{ 28 | ID: model.ChallengeID(rand.Intn(100) + 1e3), 29 | Name: "Currently Running Challenge", 30 | Start: time.Now().Add(-24 * time.Hour), 31 | End: time.Now().Add(24 * time.Hour), 32 | } 33 | assert.True(t, cur.Current(), "current challenge must be current") 34 | 35 | spec.MustBehaveLikeChallenges(t, &cs, &cur) 36 | } 37 | -------------------------------------------------------------------------------- /boltdb/users.go: -------------------------------------------------------------------------------- 1 | package boltdb 2 | 3 | import ( 4 | "github.com/boltdb/bolt" 5 | "github.com/gochallenge/gochallenge/model" 6 | ) 7 | 8 | var bktUsers = []byte("Users") 9 | 10 | // Users repository 11 | type Users struct { 12 | db *bolt.DB 13 | } 14 | 15 | // NewUsers returns bolt-backed Users repo 16 | func NewUsers(db *bolt.DB) (Users, error) { 17 | err := db.Update(initBucket(bktUsers)) 18 | return Users{db: db}, err 19 | } 20 | 21 | // Save a user into the repo. If this is a new user record, and it doesn't 22 | // have its ID specified yet - it will be set to the next available value 23 | func (us *Users) Save(u *model.User) error { 24 | return chain(us.db.Update, 25 | prefillUser(u), 26 | store(bktUsers, &u.ID, u), 27 | ) 28 | } 29 | 30 | // Find returns a user record for the given ID 31 | func (us *Users) Find(id model.UserID) (*model.User, error) { 32 | var u model.User 33 | return &u, us.db.View(load(bktUsers, id, &u)) 34 | } 35 | 36 | // FindByGithubID returns a user record with the given Github ID 37 | func (us *Users) FindByGithubID(ghid int) (*model.User, error) { 38 | return us.findBy(func(u interface{}) bool { 39 | return u.(*model.User).GithubID == ghid 40 | }) 41 | } 42 | 43 | // FindByAPIKey returns a user record with the given API key 44 | func (us *Users) FindByAPIKey(k string) (*model.User, error) { 45 | return us.findBy(func(u interface{}) bool { 46 | return u.(*model.User).APIKey == k 47 | }) 48 | } 49 | 50 | // 51 | // Low-level database operations 52 | // 53 | 54 | func (us *Users) findBy(f func(interface{}) bool) (*model.User, error) { 55 | var u model.User 56 | return &u, us.db.View(first(bktUsers, f, &u)) 57 | } 58 | 59 | // prefills user's ID with the next available unique value. If user already 60 | // has its ID set - does nothing. 61 | func prefillUser(u *model.User) boltf { 62 | return func(tx *bolt.Tx) error { 63 | if u.ID != 0 { 64 | return nil 65 | } 66 | var id model.UserID 67 | if err := lastKey(tx, bktUsers, &id); err != nil { 68 | return err 69 | } 70 | u.ID = id + 1 71 | return nil 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /boltdb/users_test.go: -------------------------------------------------------------------------------- 1 | package boltdb_test 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | "testing" 7 | 8 | "github.com/gochallenge/gochallenge/boltdb" 9 | "github.com/gochallenge/gochallenge/model/spec" 10 | "github.com/stretchr/testify/require" 11 | ) 12 | 13 | func TestUsersBoltRepo(t *testing.T) { 14 | f, err := ioutil.TempFile("", "gctestboltdb") 15 | require.NoError(t, err) 16 | defer os.Remove(f.Name()) 17 | 18 | db, err := boltdb.Open(f.Name()) 19 | require.NoError(t, err) 20 | us, err := boltdb.NewUsers(db) 21 | require.NoError(t, err) 22 | 23 | spec.MustBehaveLikeUsers(t, &us) 24 | } 25 | -------------------------------------------------------------------------------- /github/client.go: -------------------------------------------------------------------------------- 1 | package github 2 | 3 | import ( 4 | "encoding/json" 5 | "net/http" 6 | "os" 7 | "strings" 8 | 9 | "github.com/gochallenge/gochallenge/model" 10 | "golang.org/x/oauth2" 11 | ) 12 | 13 | const githubOAuthURL = "https://github.com/login/oauth/authorize" 14 | const githubOTokenURL = "https://github.com/login/oauth/access_token" 15 | const githubAPIUser = "https://api.github.com/user" 16 | const githubScope = "user:email" 17 | 18 | // NewClient return new configured Github client 19 | func NewClient() github { 20 | conf := &oauth2.Config{ 21 | ClientID: os.Getenv("GITHUB_CLIENTID"), 22 | ClientSecret: os.Getenv("GITHUB_SECRET"), 23 | Scopes: strings.Split(githubScope, ","), 24 | Endpoint: oauth2.Endpoint{ 25 | AuthURL: githubOAuthURL, 26 | TokenURL: githubOTokenURL, 27 | }, 28 | } 29 | return github{ 30 | config: conf, 31 | } 32 | } 33 | 34 | // Github is an implementation of Github API talking to the Github server 35 | type github struct { 36 | config *oauth2.Config 37 | } 38 | 39 | // AuthURL generates authentication URL to redirect user to, 40 | // using provided string as the state 41 | func (gh *github) AuthURL(s string) string { 42 | return gh.config.AuthCodeURL(s) 43 | } 44 | 45 | // NewClientWithToken returns an http.Client that can be used 46 | // for authenticated communications with Github API 47 | func (gh *github) NewClientWithToken(t string) (*http.Client, error) { 48 | var ( 49 | tok *oauth2.Token 50 | err error 51 | ) 52 | gc := gh.config 53 | if tok, err = gc.Exchange(oauth2.NoContext, t); err != nil || !tok.Valid() { 54 | return nil, model.ErrGithubAPIError 55 | } 56 | 57 | return gc.Client(oauth2.NoContext, tok), nil 58 | } 59 | 60 | // User details for the user that is currently authenticated 61 | func (gh github) User(hc *http.Client) (*model.GithubUser, error) { 62 | var gu model.GithubUser 63 | 64 | res, err := hc.Get(githubAPIUser) 65 | defer res.Body.Close() 66 | 67 | if err != nil { 68 | return nil, err 69 | } 70 | 71 | err = json.NewDecoder(res.Body).Decode(&gu) 72 | return &gu, err 73 | } 74 | -------------------------------------------------------------------------------- /github/client_test.go: -------------------------------------------------------------------------------- 1 | package github_test 2 | 3 | import ( 4 | "net/url" 5 | "testing" 6 | 7 | "github.com/gochallenge/gochallenge/github" 8 | "github.com/stretchr/testify/require" 9 | ) 10 | 11 | func TestAuthURL(t *testing.T) { 12 | gh := github.NewClient() 13 | loc := gh.AuthURL("c0ffee") 14 | require.Contains(t, loc, "https://github.com/login/oauth/authorize") 15 | require.Contains(t, loc, "c0ffee") 16 | 17 | u, _ := url.ParseRequestURI(loc) 18 | q := u.Query() 19 | require.Equal(t, "user:email", q.Get("scope")) 20 | require.NotEmpty(t, q.Get("state")) 21 | } 22 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "log" 7 | "math/rand" 8 | "net/http" 9 | "os" 10 | "strconv" 11 | "time" 12 | 13 | "github.com/boltdb/bolt" 14 | "github.com/gochallenge/gochallenge/api" 15 | "github.com/gochallenge/gochallenge/boltdb" 16 | "github.com/gochallenge/gochallenge/github" 17 | "github.com/gochallenge/gochallenge/mock" 18 | ) 19 | 20 | const boltdbMode = 0600 21 | const boltdbTimeout = 5 * time.Second 22 | 23 | func main() { 24 | var ( 25 | dbpath string 26 | port int 27 | ) 28 | rand.Seed(time.Now().UTC().UnixNano()) 29 | 30 | flag.StringVar(&dbpath, "db", os.TempDir()+"gochal.db", 31 | "full path to the location of database file") 32 | flag.IntVar(&port, "port", 8081, "port to listen on") 33 | flag.Parse() 34 | 35 | // if database file doesn't exist - we should seed it with 36 | // initial data, so let's save the file status before we opened it 37 | _, dbst := os.Stat(dbpath) 38 | 39 | db := open(dbpath) 40 | defer db.Close() 41 | 42 | cfg := config(db) 43 | fmt.Printf("dbst: %+v\n", dbst) 44 | if os.IsNotExist(dbst) { 45 | fmt.Println("seeding the database") 46 | seedChallenges(cfg.Challenges) 47 | } 48 | 49 | log.Fatal(http.ListenAndServe(":"+strconv.Itoa(port), 50 | api.New(cfg))) 51 | } 52 | 53 | // open bolt database at the given path 54 | func open(path string) *bolt.DB { 55 | db, err := bolt.Open(path, boltdbMode, &bolt.Options{ 56 | Timeout: boltdbTimeout, 57 | }) 58 | if err != nil { 59 | log.Fatal(err) 60 | } 61 | return db 62 | } 63 | 64 | // create dependency configuration for the service 65 | func config(db *bolt.DB) api.Config { 66 | cs, err := boltdb.NewChallenges(db) 67 | if err != nil { 68 | log.Fatal(err) 69 | } 70 | us, err := boltdb.NewUsers(db) 71 | if err != nil { 72 | log.Fatal(err) 73 | } 74 | 75 | ss := mock.NewSubmissions() 76 | gh := github.NewClient() 77 | 78 | return api.Config{ 79 | Challenges: &cs, 80 | Submissions: &ss, 81 | Users: &us, 82 | Github: &gh, 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /mock/challenges.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import "github.com/gochallenge/gochallenge/model" 4 | 5 | // CurrentID is an ID of a challenge that mock considers to be 6 | // the current one 7 | const CurrentID = 100001 8 | 9 | // Challenges repository, mocked out as in-memory map 10 | type Challenges struct { 11 | index map[model.ChallengeID]*model.Challenge 12 | ary []*model.Challenge 13 | lastID model.ChallengeID 14 | } 15 | 16 | // NewChallenges returns a new initialised struct of challenges 17 | func NewChallenges() Challenges { 18 | return Challenges{ 19 | index: make(map[model.ChallengeID]*model.Challenge), 20 | ary: make([]*model.Challenge, 0), 21 | } 22 | } 23 | 24 | // Save a challenge into the mock repo 25 | func (cs *Challenges) Save(c *model.Challenge) error { 26 | if c.ID == 0 { 27 | cs.lastID++ 28 | c.ID = cs.lastID 29 | } else if c.ID > cs.lastID { 30 | cs.lastID = c.ID 31 | } 32 | 33 | cs.ary = append(cs.ary, c) 34 | cs.index[c.ID] = c 35 | return nil 36 | } 37 | 38 | // Find a challenge in the repository by its id 39 | func (cs *Challenges) Find(id model.ChallengeID) (*model.Challenge, error) { 40 | var ( 41 | c *model.Challenge 42 | ok bool 43 | ) 44 | 45 | if c, ok = cs.index[id]; !ok { 46 | return nil, model.ErrNotFound 47 | } 48 | 49 | return c, nil 50 | } 51 | 52 | // All challenges currently available 53 | func (cs *Challenges) All() ([]*model.Challenge, error) { 54 | return cs.ary, nil 55 | } 56 | 57 | // Current challenge, mocked to return challenge with ID "0" 58 | func (cs *Challenges) Current() (*model.Challenge, error) { 59 | return cs.Find(CurrentID) 60 | } 61 | -------------------------------------------------------------------------------- /mock/challenges_test.go: -------------------------------------------------------------------------------- 1 | package mock_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/gochallenge/gochallenge/mock" 7 | "github.com/gochallenge/gochallenge/model" 8 | "github.com/gochallenge/gochallenge/model/spec" 9 | ) 10 | 11 | func TestChallengeMockRepo(t *testing.T) { 12 | cs := mock.NewChallenges() 13 | cur := model.Challenge{ 14 | ID: mock.CurrentID, 15 | } 16 | spec.MustBehaveLikeChallenges(t, &cs, &cur) 17 | } 18 | -------------------------------------------------------------------------------- /mock/github.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/gochallenge/gochallenge/model" 7 | ) 8 | 9 | // NewGithub mock 10 | func NewGithub() Github { 11 | return Github{} 12 | } 13 | 14 | // Github implements a mock for Github API client 15 | type Github struct { 16 | user *model.GithubUser 17 | } 18 | 19 | // AuthURL is a fake authentication URL that includes state string 20 | func (gh *Github) AuthURL(s string) string { 21 | return "http://localhost?state=" + s 22 | } 23 | 24 | // NewClientWithToken stubs token exchange, and just returns a plain 25 | // http client to simulate real client's behaviour 26 | func (gh *Github) NewClientWithToken(t string) (*http.Client, error) { 27 | hc := &http.Client{} 28 | return hc, nil 29 | } 30 | 31 | // User returns currently configured GithubUser to fake authentication 32 | // process, or ErrGithubAPIError if the users hasn't been set 33 | func (gh *Github) User(hc *http.Client) (*model.GithubUser, error) { 34 | if gh.user == nil { 35 | return nil, model.ErrGithubAPIError 36 | } 37 | 38 | return gh.user, nil 39 | } 40 | 41 | // SetUser to be considered a currently authenticated user for mock client 42 | func (gh *Github) SetUser(u *model.GithubUser) { 43 | gh.user = u 44 | } 45 | -------------------------------------------------------------------------------- /mock/github_test.go: -------------------------------------------------------------------------------- 1 | package mock_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/gochallenge/gochallenge/mock" 7 | "github.com/gochallenge/gochallenge/model" 8 | "github.com/stretchr/testify/require" 9 | ) 10 | 11 | func TestGithubMock(t *testing.T) { 12 | gh := mock.NewGithub() 13 | require.Contains(t, gh.AuthURL("hello"), "hello", 14 | "auth url should include state string") 15 | 16 | c, err := gh.NewClientWithToken("faketoken") 17 | require.NoError(t, err) 18 | 19 | // before a user is set - call to User API should error 20 | ux, err := gh.User(c) 21 | require.Equal(t, err, model.ErrGithubAPIError) 22 | 23 | // after a user is set - the call should succeed 24 | u0 := &model.GithubUser{ 25 | ID: 12345, 26 | } 27 | gh.SetUser(u0) 28 | ux, err = gh.User(c) 29 | require.NoError(t, err) 30 | require.Equal(t, u0, ux, "pre-set user should be returned") 31 | } 32 | -------------------------------------------------------------------------------- /mock/submissions.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "strconv" 5 | 6 | "github.com/gochallenge/gochallenge/model" 7 | ) 8 | 9 | // Submissions repository, mocked out as in-memory array 10 | type Submissions struct { 11 | ary []*model.Submission 12 | } 13 | 14 | // NewSubmissions returns a new initialised struct of submissions 15 | func NewSubmissions() Submissions { 16 | var ss []*model.Submission 17 | return Submissions{ 18 | ary: ss, 19 | } 20 | } 21 | 22 | // Add another submission to the mock repo 23 | func (ss *Submissions) Add(s *model.Submission) error { 24 | s.ID = strconv.Itoa(len(ss.ary) + 1) 25 | ss.ary = append(ss.ary, s) 26 | return nil 27 | } 28 | 29 | // Find a submission in the repository by its id 30 | func (ss *Submissions) Find(id string) (*model.Submission, error) { 31 | for _, s := range ss.ary { 32 | if s.ID == id { 33 | return s, nil 34 | } 35 | } 36 | return nil, model.ErrNotFound 37 | } 38 | 39 | // All submissions received 40 | func (ss *Submissions) All() ([]*model.Submission, error) { 41 | return ss.ary, nil 42 | } 43 | 44 | // AllForChallenge return submissions received for the given challenge 45 | func (ss *Submissions) AllForChallenge(c *model.Challenge) ([]*model.Submission, error) { 46 | var sx []*model.Submission 47 | sx = make([]*model.Submission, 0) 48 | 49 | for _, s := range ss.ary { 50 | if s.Challenge.ID == c.ID { 51 | sx = append(sx, s) 52 | } 53 | } 54 | return sx, nil 55 | } 56 | -------------------------------------------------------------------------------- /mock/submissions_test.go: -------------------------------------------------------------------------------- 1 | package mock_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/gochallenge/gochallenge/mock" 7 | "github.com/gochallenge/gochallenge/model" 8 | "github.com/gochallenge/gochallenge/model/spec" 9 | "github.com/stretchr/testify/require" 10 | ) 11 | 12 | func TestSubmissionsMockRepoSpec(t *testing.T) { 13 | ss := mock.NewSubmissions() 14 | spec.MustBehaveLikeSubmissions(t, &ss) 15 | } 16 | 17 | func TestNoSubmissionsAllForChallenge(t *testing.T) { 18 | c0 := &model.Challenge{ 19 | ID: 1, 20 | } 21 | ss := mock.NewSubmissions() 22 | 23 | // AllForChallenge should return empty array when there're 24 | // no submissions for a challenge 25 | sx, err := ss.AllForChallenge(c0) 26 | require.NoError(t, err, "all for challenge returned an error") 27 | require.Equal(t, []*model.Submission{}, sx, 28 | "empty submissions not returned correctly") 29 | } 30 | -------------------------------------------------------------------------------- /mock/users.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import "github.com/gochallenge/gochallenge/model" 4 | 5 | // Users represents users collection, mocked out as in-memory map 6 | type Users struct { 7 | index map[model.UserID]*model.User 8 | indexAPIKey map[string]*model.User 9 | cnt model.UserID 10 | } 11 | 12 | // NewUsers returns a new initialised users collection. 13 | func NewUsers() Users { 14 | return Users{ 15 | index: make(map[model.UserID]*model.User), 16 | indexAPIKey: make(map[string]*model.User), 17 | } 18 | } 19 | 20 | // Save user to the mock users. 21 | func (us *Users) Save(u *model.User) error { 22 | if u.ID == 0 { 23 | us.cnt++ 24 | u.ID = us.cnt 25 | } 26 | 27 | if _, ok := us.index[u.ID]; ok { 28 | return model.ErrDuplicateRecord 29 | } 30 | us.index[u.ID] = u 31 | us.indexAPIKey[u.APIKey] = u 32 | 33 | return nil 34 | } 35 | 36 | // Find searches for a user in the collection by its id. 37 | func (us *Users) Find(id model.UserID) (*model.User, error) { 38 | var ( 39 | u *model.User 40 | ok bool 41 | ) 42 | 43 | if u, ok = us.index[id]; !ok { 44 | return nil, model.ErrNotFound 45 | } 46 | return u, nil 47 | } 48 | 49 | // FindByAPIKey finds a user in the collection by its API Key. 50 | func (us *Users) FindByAPIKey(key string) (*model.User, error) { 51 | var ( 52 | u *model.User 53 | ok bool 54 | ) 55 | 56 | if u, ok = us.indexAPIKey[key]; !ok { 57 | return nil, model.ErrNotFound 58 | } 59 | return u, nil 60 | } 61 | 62 | // FindByGithubID finds a user in the collection by its Github ID 63 | func (us *Users) FindByGithubID(id int) (*model.User, error) { 64 | for _, u := range us.index { 65 | if u.GithubID == id { 66 | return u, nil 67 | } 68 | } 69 | return nil, model.ErrNotFound 70 | } 71 | -------------------------------------------------------------------------------- /mock/users_test.go: -------------------------------------------------------------------------------- 1 | package mock_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/gochallenge/gochallenge/mock" 7 | "github.com/gochallenge/gochallenge/model/spec" 8 | ) 9 | 10 | func TestUsersSpec(t *testing.T) { 11 | us := mock.NewUsers() 12 | spec.MustBehaveLikeUsers(t, &us) 13 | } 14 | -------------------------------------------------------------------------------- /model/challenge.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import ( 4 | "strconv" 5 | "time" 6 | ) 7 | 8 | // Challenges repository interface 9 | type Challenges interface { 10 | Save(*Challenge) error 11 | Find(ChallengeID) (*Challenge, error) 12 | Current() (*Challenge, error) 13 | All() ([]*Challenge, error) 14 | } 15 | 16 | // Author of a challenge 17 | type Author struct { 18 | Name string `json:"name"` 19 | } 20 | 21 | // ChallengeID type 22 | type ChallengeID int32 23 | 24 | // Atoid convert string value into ChallengeID 25 | func (uid *ChallengeID) Atoid(s string) error { 26 | n, err := strconv.Atoi(s) 27 | if err != nil { 28 | return err 29 | } 30 | 31 | *uid = ChallengeID(n) 32 | return nil 33 | } 34 | 35 | // Challenge type describes details of a Go challenge 36 | type Challenge struct { 37 | ID ChallengeID `json:"id"` 38 | Name string `json:"name"` 39 | Author Author `json:"author"` 40 | URL string `json:"url"` 41 | Import string `json:"import"` 42 | Git string `json:"-"` 43 | Status Lifecycle `json:"status"` 44 | Start time.Time `json:"start"` 45 | End time.Time `json:"end"` 46 | } 47 | 48 | // Current status of the challenge 49 | func (ch Challenge) Current() bool { 50 | now := time.Now() 51 | return ch.Start.Before(now) && ch.End.After(now) 52 | } 53 | -------------------------------------------------------------------------------- /model/challenge_test.go: -------------------------------------------------------------------------------- 1 | package model_test 2 | 3 | import ( 4 | "encoding/json" 5 | "strings" 6 | "testing" 7 | "time" 8 | 9 | "github.com/gochallenge/gochallenge/model" 10 | "github.com/stretchr/testify/assert" 11 | "github.com/stretchr/testify/require" 12 | ) 13 | 14 | func TestChallengeMarshal(t *testing.T) { 15 | c := model.Challenge{ 16 | ID: 10, 17 | Name: "The Challenge", 18 | Import: "http://github.com/gochallenge", 19 | Status: model.Open, 20 | Start: time.Date(2015, 3, 1, 0, 0, 0, 0, time.UTC), 21 | End: time.Date(2015, 3, 14, 0, 0, 0, 0, time.UTC), 22 | } 23 | s := strings.Replace(` 24 | { 25 | "id":10, 26 | "name":"The Challenge", 27 | "author":{"name":""}, 28 | "url":"", 29 | "import":"http://github.com/gochallenge", 30 | "status":"open", 31 | "start":"2015-03-01T00:00:00Z", 32 | "end":"2015-03-14T00:00:00Z" 33 | } 34 | `, "\n", "", -1) 35 | 36 | b, err := json.Marshal(c) 37 | require.NoError(t, err, "Challenge JSON marshalling failed") 38 | require.Equal(t, s, string(b), "Challenge JSON is incorrect") 39 | 40 | c1 := model.Challenge{} 41 | err = json.Unmarshal(b, &c1) 42 | require.NoError(t, err, "Challenge JSON unmarshalling failed") 43 | require.Equal(t, c, c1, "Challenge JSON unmarshalled incorrectly") 44 | } 45 | 46 | func TestChallengeCurrent(t *testing.T) { 47 | day := 24 * time.Hour 48 | 49 | assert.True(t, model.Challenge{ 50 | Start: time.Now().Add(-day), 51 | End: time.Now().Add(day), 52 | }.Current(), "current challenge reported as not current") 53 | 54 | assert.False(t, model.Challenge{ 55 | Start: time.Now().Add(day), 56 | End: time.Now().Add(2 * day), 57 | }.Current(), "future challenge reported as current") 58 | 59 | assert.False(t, model.Challenge{ 60 | Start: time.Now().Add(-2 * day), 61 | End: time.Now().Add(-day), 62 | }.Current(), "past challenge reported as current") 63 | } 64 | -------------------------------------------------------------------------------- /model/errors.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import "fmt" 4 | 5 | // Error type for errors returned by the model package 6 | type Error int 7 | 8 | // Errors defined and used by the application 9 | const ( 10 | ErrNotFound Error = iota 11 | ErrNoRemote 12 | ErrCryptoFailure 13 | ErrGithubAPIError 14 | ErrAuthFailure 15 | ErrNotImplemented 16 | ErrDuplicateRecord 17 | ErrAccessDenied 18 | ) 19 | 20 | var errmsgs = map[Error]string{ 21 | ErrNotFound: "Not found", 22 | ErrNoRemote: "Challenge does not have git remote", 23 | ErrCryptoFailure: "Error in cryptographical operation", 24 | ErrGithubAPIError: "Error communicating with Github API", 25 | ErrAuthFailure: "Invalid authentication", 26 | ErrNotImplemented: "Not implemented", 27 | ErrDuplicateRecord: "Record already exists", 28 | ErrAccessDenied: "Access denied", 29 | } 30 | 31 | func (e Error) Error() string { 32 | if s, ok := errmsgs[e]; ok { 33 | return s 34 | } 35 | return fmt.Sprintf("Error %d", e) 36 | } 37 | -------------------------------------------------------------------------------- /model/errors_test.go: -------------------------------------------------------------------------------- 1 | package model_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/gochallenge/gochallenge/model" 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | func TestErrorOutput(t *testing.T) { 11 | err := model.ErrNotFound 12 | require.Equal(t, err.Error(), "Not found") 13 | } 14 | -------------------------------------------------------------------------------- /model/github.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import "net/http" 4 | 5 | // GithubAPI is an interface defining available methods of a Github API client 6 | // implementation 7 | type GithubAPI interface { 8 | AuthURL(string) string 9 | NewClientWithToken(string) (*http.Client, error) 10 | User(*http.Client) (*GithubUser, error) 11 | } 12 | 13 | // GithubUser represents a user of Github. 14 | type GithubUser struct { 15 | ID int `json:"id"` 16 | Login string `json:"login"` 17 | Name string `json:"name"` 18 | Email string `json:"email"` 19 | AvatarURL string `json:"avatar_url"` 20 | HTMLURL string `json:"html_url"` 21 | } 22 | 23 | // Populate given user record with their Github account details 24 | func (gu *GithubUser) Populate(u *User) { 25 | choose := func(s1 string, s2 string) string { 26 | if s1 == "" { 27 | return s2 28 | } 29 | return s1 30 | } 31 | u.GithubID = gu.ID 32 | u.Name = choose(u.Name, gu.Name) 33 | u.Email = choose(u.Email, gu.Email) 34 | u.AvatarURL = choose(u.AvatarURL, gu.AvatarURL) 35 | u.GithubURL = choose(u.GithubURL, gu.HTMLURL) 36 | u.GithubLogin = choose(u.GithubLogin, gu.Login) 37 | } 38 | -------------------------------------------------------------------------------- /model/lifecycle.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import "fmt" 4 | 5 | // Lifecycle of a challenge 6 | type Lifecycle int 7 | 8 | // Steps of Go challenge lifecycle 9 | const ( 10 | Unreleased = iota // not released to public yet 11 | Open // open and running 12 | Closed // done and closed 13 | ) 14 | 15 | var lifecycleEncoder = map[Lifecycle]([]byte){ 16 | Unreleased: []byte(`"unreleased"`), 17 | Open: []byte(`"open"`), 18 | Closed: []byte(`"closed"`), 19 | } 20 | 21 | var lifecycleDecoder = map[string]Lifecycle{ 22 | `"unreleased"`: Unreleased, 23 | `"open"`: Open, 24 | `"closed"`: Closed, 25 | } 26 | 27 | // MarshalJSON marshals lifecycle into its string-based JSON form 28 | func (l Lifecycle) MarshalJSON() ([]byte, error) { 29 | if b, ok := lifecycleEncoder[l]; ok { 30 | return b, nil 31 | } 32 | 33 | return []byte{}, fmt.Errorf("Unexpected lifecycle value %d", l) 34 | } 35 | 36 | // UnmarshalJSON loads lifecycle from JSON form 37 | func (l *Lifecycle) UnmarshalJSON(b []byte) error { 38 | if nl, ok := lifecycleDecoder[string(b)]; ok { 39 | *l = nl 40 | return nil 41 | } 42 | return fmt.Errorf("Unknown lifecycle encoding %s", b) 43 | } 44 | -------------------------------------------------------------------------------- /model/participation.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import "fmt" 4 | 5 | // Participation level for a submission 6 | type Participation int 7 | 8 | // Possible levels of challenge participation 9 | const ( 10 | LvlNormal Participation = iota 11 | LvlBonus 12 | LvlFun 13 | LvlAnonymous 14 | ) 15 | 16 | var participationEncoder = map[Participation]([]byte){ 17 | LvlNormal: []byte(`"normal"`), 18 | LvlBonus: []byte(`"bonus"`), 19 | LvlFun: []byte(`"fun"`), 20 | LvlAnonymous: []byte(`"anonymous"`), 21 | } 22 | 23 | var participationDecoder = map[string]Participation{ 24 | `"normal"`: LvlNormal, 25 | `"bonus"`: LvlBonus, 26 | `"fun"`: LvlFun, 27 | `"anonymous"`: LvlAnonymous, 28 | } 29 | 30 | // MarshalJSON marshals participation into its string-based JSON form 31 | func (l Participation) MarshalJSON() ([]byte, error) { 32 | if b, ok := participationEncoder[l]; ok { 33 | return b, nil 34 | } 35 | 36 | return []byte{}, fmt.Errorf("Unexpected participation value %d", l) 37 | } 38 | 39 | // UnmarshalJSON loads participation from JSON form 40 | func (l *Participation) UnmarshalJSON(b []byte) error { 41 | if nl, ok := participationDecoder[string(b)]; ok { 42 | *l = nl 43 | return nil 44 | } 45 | return fmt.Errorf("Unknown participation encoding %s", b) 46 | } 47 | -------------------------------------------------------------------------------- /model/spec/challenges.go: -------------------------------------------------------------------------------- 1 | package spec 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | 7 | "github.com/gochallenge/gochallenge/model" 8 | "github.com/stretchr/testify/assert" 9 | "github.com/stretchr/testify/require" 10 | ) 11 | 12 | // MustBehaveLikeChallenges tests behaviour of the given challenges 13 | // repo, to make sure it conforms to the expected API 14 | func MustBehaveLikeChallenges(t *testing.T, cs model.Challenges, 15 | cur *model.Challenge) { 16 | 17 | c1 := model.Challenge{ 18 | Name: "The Test Challenge", 19 | Start: time.Date(2011, 1, 1, 0, 0, 0, 0, time.UTC), 20 | End: time.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC), 21 | } 22 | // just a sanity check to make sure the first challenge is 23 | // not the "current" one, to not trip over it in later tests 24 | assert.False(t, c1.Current(), "test challenge should not be current") 25 | 26 | // Find should return an error before the challenge was added 27 | _, err := cs.Find(c1.ID) 28 | require.Equal(t, model.ErrNotFound, err) 29 | 30 | // Adding the challenge to the repo, must succeed 31 | require.NoError(t, cs.Save(&c1)) 32 | 33 | // Now find should succeed, too, as the challenge has been added 34 | c, err := cs.Find(c1.ID) 35 | require.NoError(t, err, "existing challenge lookup should not error") 36 | require.Equal(t, *c, c1, "existing challenge should be returned") 37 | 38 | // Current challenge should return an error, as it doesn't exist 39 | c, err = cs.Current() 40 | require.Equal(t, model.ErrNotFound, err) 41 | 42 | // Current challenge should return the correct one, after it has 43 | // been added 44 | cs.Save(cur) 45 | c, err = cs.Current() 46 | require.NoError(t, err, "current challenge lookup should not error") 47 | require.Equal(t, *c, *cur, "current challenge should be returned") 48 | 49 | // All should return all added challenges 50 | cx, err := cs.All() 51 | require.NoError(t, err, "all challenges returned an error") 52 | require.Equal(t, 2, len(cx), "two challenges must be returned") 53 | 54 | cx0 := *cx[0] 55 | cx1 := *cx[1] 56 | require.True(t, (cx0 == *cur && cx1 == c1) || (cx1 == *cur && cx0 == c1), 57 | "saved challenges must be returned") 58 | 59 | // Adding another challenge with empty ID should set its ID to the 60 | // next available unique value 61 | c2 := model.Challenge{ 62 | Name: "New Challenge", 63 | Start: time.Date(2011, 1, 1, 0, 0, 0, 0, time.UTC), 64 | End: time.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC), 65 | } 66 | require.NoError(t, cs.Save(&c2), "new challenge should be saved") 67 | require.NotEqual(t, c2.ID, 0, "new challenge must have received an ID") 68 | require.NotEqual(t, c1.ID, c2.ID, "new ID must be diffent from c1.ID") 69 | require.NotEqual(t, cur.ID, c2.ID, "new ID must be diffent from cur.ID") 70 | } 71 | -------------------------------------------------------------------------------- /model/spec/submissions.go: -------------------------------------------------------------------------------- 1 | package spec 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | 7 | "github.com/gochallenge/gochallenge/model" 8 | "github.com/stretchr/testify/require" 9 | ) 10 | 11 | // MustBehaveLikeSubmissions tests behaviour of the submission repo 12 | // implementation, to make sure it conforms to the spec 13 | func MustBehaveLikeSubmissions(t *testing.T, ss model.Submissions) { 14 | c1 := model.Challenge{ 15 | ID: 123, 16 | } 17 | 18 | s1 := model.Submission{ 19 | ID: "01-c001c0ffee", 20 | Type: model.LvlBonus, 21 | Created: time.Now(), 22 | Challenge: &c1, 23 | } 24 | 25 | // Find should error before submission is added 26 | _, err := ss.Find(s1.ID) 27 | require.Equal(t, model.ErrNotFound, err) 28 | 29 | // Add should succeed 30 | err = ss.Add(&s1) 31 | require.NoError(t, err) 32 | 33 | // And now we should be able to find the same record by its ID 34 | sx, err := ss.Find(s1.ID) 35 | require.NoError(t, err) 36 | require.Equal(t, s1, *sx) 37 | 38 | // Let's add another submission, for another challenge this time 39 | c2 := model.Challenge{ 40 | ID: 987, 41 | } 42 | s2 := model.Submission{ 43 | ID: "02-badc0ffee", 44 | Type: model.LvlNormal, 45 | Created: time.Now(), 46 | Challenge: &c2, 47 | } 48 | err = ss.Add(&s2) 49 | require.NoError(t, err) 50 | 51 | // All should return both submissions 52 | sxs, err := ss.All() 53 | require.NoError(t, err) 54 | require.Equal(t, 2, len(sxs)) 55 | sx1 := *sxs[0] 56 | sx2 := *sxs[1] 57 | require.True(t, (sx1 == s1 && sx2 == s2) || (sx1 == s2 && sx2 == s1)) 58 | 59 | // But AllForChallenge should return one submission only 60 | sxs, err = ss.AllForChallenge(&c1) 61 | require.NoError(t, err) 62 | require.Equal(t, 1, len(sxs)) 63 | require.True(t, *sxs[0] == s1) 64 | } 65 | -------------------------------------------------------------------------------- /model/spec/users.go: -------------------------------------------------------------------------------- 1 | package spec 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/gochallenge/gochallenge/model" 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | // MustBehaveLikeUsers tests behaviour of the given implementation 11 | // of users repo 12 | func MustBehaveLikeUsers(t *testing.T, us model.Users) { 13 | // Create and save a user 14 | u1 := model.User{ 15 | Name: "Jane Doe", 16 | GithubID: 66235, 17 | APIKey: "deadc0ffee", 18 | } 19 | err := us.Save(&u1) 20 | require.NoError(t, err, "errored when saving a user") 21 | // ID should be auto-generated, if not specified 22 | require.NotEmpty(t, u1.ID, "User ID should be auto-generated") 23 | 24 | // added user record should find-able by its ID 25 | ux, err := us.Find(u1.ID) 26 | require.NoError(t, err, "errored when finding a user") 27 | require.Equal(t, u1, *ux) 28 | // but not if it's a wrong one 29 | ux, err = us.Find(u1.ID * 100) 30 | require.Equal(t, model.ErrNotFound, err) 31 | 32 | // and by its Github ID 33 | ux, err = us.FindByGithubID(u1.GithubID) 34 | require.NoError(t, err) 35 | require.Equal(t, u1, *ux) 36 | // but not if it's a wrong one 37 | ux, err = us.FindByGithubID(u1.GithubID * 100) 38 | require.Equal(t, model.ErrNotFound, err) 39 | 40 | // user, when added, should have the API key generated 41 | ak := u1.APIKey 42 | require.NotEmpty(t, ak) 43 | // which can be used to find the same user 44 | ux, err = us.FindByAPIKey(ak) 45 | require.NoError(t, err) 46 | require.Equal(t, u1, *ux) 47 | // but, again, not if it's a wrong one 48 | ux, err = us.FindByAPIKey("o_O") 49 | require.Equal(t, model.ErrNotFound, err) 50 | 51 | // the second user, when added, must receive a different ID 52 | // Create and save a user 53 | u2 := model.User{ 54 | Name: "Gordon Freeman", 55 | } 56 | err = us.Save(&u2) 57 | require.NoError(t, err) 58 | // ID should be auto-generated, if not specified 59 | require.NotEqual(t, u2.ID, 0, "User ID should be auto-generated") 60 | require.NotEqual(t, u1.ID, u2.ID) 61 | } 62 | -------------------------------------------------------------------------------- /model/submission.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import ( 4 | "encoding/json" 5 | "time" 6 | ) 7 | 8 | // Submissions repository interface 9 | type Submissions interface { 10 | All() ([]*Submission, error) 11 | AllForChallenge(*Challenge) ([]*Submission, error) 12 | Find(string) (*Submission, error) 13 | Add(*Submission) error 14 | } 15 | 16 | // Submission type describes details of a submitted solutions for a 17 | // challenge 18 | type Submission struct { 19 | ID string `json:"id"` 20 | User *User `json:"user"` 21 | Type Participation `json:"type"` 22 | Challenge *Challenge `json:"-"` 23 | Data *[]byte `json:"-"` 24 | Created time.Time `json:"created"` 25 | } 26 | 27 | // unexported type to use as a basis for JSON representation 28 | // of a submission, mostly to replace associated objects 29 | // with their IDs 30 | type submissionEx struct { 31 | ID string `json:"id"` 32 | UserID UserID `json:"user_id"` 33 | ChallengeID ChallengeID `json:"challenge_id"` 34 | Type Participation `json:"type"` 35 | Created time.Time `json:"created"` 36 | } 37 | 38 | // MarshalJSON exports submission data, substituting associations 39 | // with their IDs 40 | func (s Submission) MarshalJSON() ([]byte, error) { 41 | se := &submissionEx{ 42 | ID: s.ID, 43 | Type: s.Type, 44 | Created: s.Created, 45 | } 46 | if s.Challenge != nil { 47 | se.ChallengeID = s.Challenge.ID 48 | } 49 | if s.User != nil { 50 | se.UserID = s.User.ID 51 | } 52 | 53 | return json.Marshal(se) 54 | } 55 | 56 | // Unmarshal imports submission data, hydrating associated objects 57 | // based on their ID values received 58 | func (s *Submission) Unmarshal(b []byte, cs Challenges, us Users) error { 59 | var err error 60 | 61 | var se submissionEx 62 | if err = json.Unmarshal(b, &se); err != nil { 63 | return err 64 | } 65 | 66 | s.ID = se.ID 67 | s.Type = se.Type 68 | s.Created = se.Created 69 | 70 | if se.ChallengeID != 0 { 71 | s.Challenge, err = cs.Find(se.ChallengeID) 72 | } 73 | if err == nil && se.UserID != 0 { 74 | s.User, err = us.Find(se.UserID) 75 | } 76 | 77 | return err 78 | } 79 | -------------------------------------------------------------------------------- /model/submission_test.go: -------------------------------------------------------------------------------- 1 | package model_test 2 | 3 | import ( 4 | "encoding/json" 5 | "strings" 6 | "testing" 7 | "time" 8 | 9 | "github.com/gochallenge/gochallenge/mock" 10 | "github.com/gochallenge/gochallenge/model" 11 | "github.com/stretchr/testify/require" 12 | ) 13 | 14 | func TestSubmissionMarshal(t *testing.T) { 15 | cs := mock.NewChallenges() 16 | us := mock.NewUsers() 17 | c := &model.Challenge{ 18 | ID: 10, 19 | } 20 | cs.Save(c) 21 | u := &model.User{ 22 | ID: 5, 23 | Name: "Jane Doe", 24 | } 25 | us.Save(u) 26 | 27 | s := model.Submission{ 28 | ID: "1234-abcde", 29 | Type: model.LvlAnonymous, 30 | Challenge: c, 31 | User: u, 32 | Created: time.Date(2015, 3, 1, 10, 0, 0, 0, time.UTC), 33 | } 34 | js := strings.Replace(` 35 | { 36 | "id":"1234-abcde", 37 | "user_id":5, 38 | "challenge_id":10, 39 | "type":"anonymous", 40 | "created":"2015-03-01T10:00:00Z" 41 | } 42 | `, "\n", "", -1) 43 | 44 | b, err := json.Marshal(s) 45 | require.NoError(t, err, "Submission JSON marshalling failed") 46 | require.Equal(t, js, string(b), "Submission JSON is incorrect") 47 | 48 | sx := model.Submission{} 49 | err = sx.Unmarshal(b, &cs, &us) 50 | 51 | require.NoError(t, err, "Submission JSON unmarshalling failed") 52 | require.Equal(t, s, sx, "Submission JSON unmarshalled incorrectly") 53 | } 54 | -------------------------------------------------------------------------------- /model/user.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import ( 4 | "crypto/rand" 5 | "crypto/sha1" 6 | "fmt" 7 | "strconv" 8 | ) 9 | 10 | // Users collection interface 11 | type Users interface { 12 | Save(*User) error 13 | Find(UserID) (*User, error) 14 | FindByGithubID(int) (*User, error) 15 | FindByAPIKey(string) (*User, error) 16 | } 17 | 18 | // NewUser generates and populates with basic details new user record 19 | func NewUser() (*User, error) { 20 | u := &User{} 21 | err := u.ResetToken() 22 | return u, err 23 | } 24 | 25 | // UserID type 26 | type UserID int32 27 | 28 | // Atoid convert string value into UserID 29 | func (uid *UserID) Atoid(s string) error { 30 | n, err := strconv.Atoi(s) 31 | if err != nil { 32 | return err 33 | } 34 | 35 | *uid = UserID(n) 36 | return nil 37 | } 38 | 39 | // User of a challenge 40 | type User struct { 41 | ID UserID `json:"-"` 42 | Name string `json:"name"` 43 | Email string `json:"email,omitempty"` 44 | AvatarURL string `json:"avatar_url"` 45 | GithubID int `json:"-"` 46 | GithubURL string `json:"github_url"` 47 | GithubLogin string `json:"github_login"` 48 | APIKey string `json:"-"` 49 | } 50 | 51 | // ResetToken rewrites API key on the user record 52 | func (u *User) ResetToken() error { 53 | var err error 54 | 55 | u.APIKey, err = generateToken() 56 | return err 57 | } 58 | 59 | func generateToken() (string, error) { 60 | const length = sha1.BlockSize 61 | 62 | b := make([]byte, length) 63 | _, err := rand.Read(b) 64 | if err != nil { 65 | return "", ErrCryptoFailure 66 | } 67 | 68 | s1 := sha1.Sum(b) 69 | return fmt.Sprintf("%x", s1), nil 70 | } 71 | -------------------------------------------------------------------------------- /model/user_test.go: -------------------------------------------------------------------------------- 1 | package model_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/gochallenge/gochallenge/model" 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | func TestUserResetToken(t *testing.T) { 11 | u, err := model.NewUser() 12 | require.NoError(t, err) 13 | 14 | k := u.APIKey 15 | u.ResetToken() 16 | require.NotEmpty(t, u.APIKey) 17 | require.NotEqual(t, u.APIKey, k, "ResetToken must reset API key") 18 | } 19 | -------------------------------------------------------------------------------- /seed.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/gochallenge/gochallenge/model" 7 | ) 8 | 9 | func seedChallenges(cs model.Challenges) { 10 | c0 := &model.Challenge{ 11 | Name: "Go Challenge 1 - Drum Machine", 12 | URL: "http://golang-challenge.com/go-challenge1/", 13 | Import: "gc.falsum.me/code/challenge-001", 14 | Git: "https://github.com/morhekil/gc-1-drum_machine.git", 15 | Status: model.Closed, 16 | Author: model.Author{Name: "Matt Aimonetti"}, 17 | Start: time.Date(2015, 3, 1, 0, 0, 0, 0, time.UTC), 18 | End: time.Date(2015, 3, 14, 0, 0, 0, 0, time.UTC), 19 | } 20 | cs.Save(c0) 21 | 22 | c1 := &model.Challenge{ 23 | Name: "Go Challenge 2 - NaCl Crypto", 24 | URL: "http://golang-challenge.com/go-challenge2/", 25 | Import: "gc.falsum.me/code/challenge-002", 26 | Git: "https://github.com/morhekil/gc-2-nacl.git", 27 | Status: model.Open, 28 | Author: model.Author{Name: "Guillaume J. Charmes"}, 29 | Start: time.Date(2015, 4, 1, 0, 0, 0, 0, time.UTC), 30 | End: time.Date(2015, 4, 14, 0, 0, 0, 0, time.UTC), 31 | } 32 | cs.Save(c1) 33 | } 34 | -------------------------------------------------------------------------------- /web/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "assets/js/libs" 3 | } 4 | -------------------------------------------------------------------------------- /web/.gitignore: -------------------------------------------------------------------------------- 1 | assets/js/libs 2 | .grunt 3 | node_modules 4 | npm-debug.log 5 | -------------------------------------------------------------------------------- /web/Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | 'use strict'; 3 | 4 | grunt.initConfig({ 5 | clean: ['dist/'], 6 | 7 | jshint: ['assets/js/main.js'], 8 | 9 | uglify: { 10 | dist: { 11 | files: { 12 | 'assets/js/all.min.js': [ 13 | 'assets/js/libs/jquery/dist/jquery.min.js', 14 | 'assets/js/libs/bootstrap/dist/js/bootstrap.min.js', 15 | 'assets/js/libs/underscore/underscore-min.js', 16 | 'assets/js/libs/backbone/backbone.js', 17 | 'assets/js/main.js' 18 | ] 19 | } 20 | } 21 | }, 22 | 23 | cssmin: { 24 | dist: { 25 | files: { 26 | 'assets/css/all.min.css': [ 27 | 'assets/js/libs/bootstrap/dist/css/bootstrap.min.css', 28 | 'assets/css/main.css' 29 | ] 30 | } 31 | } 32 | }, 33 | 34 | processhtml: { 35 | dist: { 36 | files: { 37 | 'dist/index.html': ['layout.html'] 38 | } 39 | } 40 | }, 41 | 42 | copy: { 43 | dist: { 44 | files: [ 45 | {src: ['assets/img/**'], dest: 'dist/'} 46 | ] 47 | } 48 | }, 49 | 50 | watch: { 51 | js: { 52 | files: ['assets/js/*.js', '!assets/js/*.min.js', '!assets/js/libs/*'], 53 | tasks: ['default'] 54 | }, 55 | css: { 56 | files: ['assets/css/*.css', '!assets/css/*.min.css'], 57 | tasks: ['default'] 58 | }, 59 | img: { 60 | files: ['assets/img/*'], 61 | tasks: ['default'] 62 | }, 63 | html: { 64 | files: ['layout.html', 'templates/*.html'], 65 | tasks: ['default'] 66 | } 67 | } 68 | }); 69 | 70 | grunt.loadNpmTasks('grunt-contrib-clean'); 71 | grunt.loadNpmTasks('grunt-contrib-jshint'); 72 | grunt.loadNpmTasks('grunt-contrib-uglify'); 73 | grunt.loadNpmTasks('grunt-contrib-cssmin'); 74 | grunt.loadNpmTasks('grunt-processhtml'); 75 | grunt.loadNpmTasks('grunt-contrib-copy'); 76 | grunt.loadNpmTasks('grunt-contrib-watch'); 77 | 78 | grunt.registerTask('default', [ 79 | 'clean', 80 | 'jshint', 81 | 'uglify', 82 | 'cssmin', 83 | 'processhtml', 84 | 'copy' 85 | ]); 86 | }; 87 | -------------------------------------------------------------------------------- /web/README.md: -------------------------------------------------------------------------------- 1 | Working on the Front-End 2 | ======================== 3 | 4 | ## Overview. 5 | 6 | Go will serves static assets in `web/dist/*`. All files inside that directory 7 | are generated by `grunt`. 8 | 9 | ## Prerequisites 10 | 11 | * Make sure you've [Node.js](https://nodejs.org/) installed. 12 | * Install required packages in this directory: 13 | 14 | ``` 15 | npm install 16 | ``` 17 | 18 | * Install [bower](http://bower.io/): 19 | 20 | ``` 21 | npm install -g bower 22 | ``` 23 | 24 | * Install packages from bower: 25 | 26 | ``` 27 | bower install 28 | ``` 29 | 30 | * Install [grunt](http://gruntjs.com/): 31 | 32 | ``` 33 | npm install -g grunt-cli 34 | ``` 35 | 36 | * Run `grunt` to build `dist` files: 37 | 38 | ``` 39 | grunt 40 | ``` 41 | 42 | You should get output like following: 43 | 44 | ``` 45 | Running "clean:0" (clean) task 46 | Cleaning dist/...OK 47 | 48 | Running "jshint:0" (jshint) task 49 | >> 1 file lint free. 50 | 51 | Running "uglify:dist" (uglify) task 52 | File assets/js/all.min.js created: 206.13 kB → 159.99 kB 53 | 54 | Running "cssmin:dist" (cssmin) task 55 | File assets/css/all.min.css created. 56 | 57 | Running "processhtml:dist" (processhtml) task 58 | 59 | Running "copy:dist" (copy) task 60 | Created 1 directories 61 | 62 | Done, without errors. 63 | ``` 64 | 65 | * You can use `grunt watch` while developing. This will watches changes in `assets/js/*`, 66 | `assets/css/*`, `assets/img/*`, and HTML files. 67 | -------------------------------------------------------------------------------- /web/assets/css/all.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap v3.3.4 (http://getbootstrap.com) 3 | * Copyright 2011-2015 Twitter, Inc. 4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 5 | *//*! normalize.css v3.0.2 | MIT License | git.io/normalize */html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0}mark{color:#000;background:#ff0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}pre{overflow:auto}code,kbd,pre,samp{font-size:1em}button,input,optgroup,select,textarea{margin:0;font:inherit;color:inherit}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}input[type=checkbox],input[type=radio]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}textarea{overflow:auto}optgroup{font-weight:700}table{border-spacing:0;border-collapse:collapse}td,th{padding:0}/*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */@media print{*,:after,:before{color:#000!important;text-shadow:none!important;background:0 0!important;-webkit-box-shadow:none!important;box-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}a[href^="javascript:"]:after,a[href^="#"]:after{content:""}blockquote,pre{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}img,tr{page-break-inside:avoid}img{max-width:100%!important}h2,h3,p{orphans:3;widows:3}h2,h3{page-break-after:avoid}select{background:#fff!important}.navbar{display:none}.btn>.caret,.dropup>.btn>.caret{border-top-color:#000!important}.label{border:1px solid #000}.table{border-collapse:collapse!important}.table td,.table th{background-color:#fff!important}.table-bordered td,.table-bordered th{border:1px solid #ddd!important}}@font-face{font-family:'Glyphicons Halflings';src:url(../fonts/glyphicons-halflings-regular.eot);src:url(../fonts/glyphicons-halflings-regular.eot?#iefix) format('embedded-opentype'),url(../fonts/glyphicons-halflings-regular.woff2) format('woff2'),url(../fonts/glyphicons-halflings-regular.woff) format('woff'),url(../fonts/glyphicons-halflings-regular.ttf) format('truetype'),url(../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular) format('svg')}.glyphicon{position:relative;top:1px;display:inline-block;font-family:'Glyphicons Halflings';font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.glyphicon-asterisk:before{content:"\2a"}.glyphicon-plus:before{content:"\2b"}.glyphicon-eur:before,.glyphicon-euro:before{content:"\20ac"}.glyphicon-minus:before{content:"\2212"}.glyphicon-cloud:before{content:"\2601"}.glyphicon-envelope:before{content:"\2709"}.glyphicon-pencil:before{content:"\270f"}.glyphicon-glass:before{content:"\e001"}.glyphicon-music:before{content:"\e002"}.glyphicon-search:before{content:"\e003"}.glyphicon-heart:before{content:"\e005"}.glyphicon-star:before{content:"\e006"}.glyphicon-star-empty:before{content:"\e007"}.glyphicon-user:before{content:"\e008"}.glyphicon-film:before{content:"\e009"}.glyphicon-th-large:before{content:"\e010"}.glyphicon-th:before{content:"\e011"}.glyphicon-th-list:before{content:"\e012"}.glyphicon-ok:before{content:"\e013"}.glyphicon-remove:before{content:"\e014"}.glyphicon-zoom-in:before{content:"\e015"}.glyphicon-zoom-out:before{content:"\e016"}.glyphicon-off:before{content:"\e017"}.glyphicon-signal:before{content:"\e018"}.glyphicon-cog:before{content:"\e019"}.glyphicon-trash:before{content:"\e020"}.glyphicon-home:before{content:"\e021"}.glyphicon-file:before{content:"\e022"}.glyphicon-time:before{content:"\e023"}.glyphicon-road:before{content:"\e024"}.glyphicon-download-alt:before{content:"\e025"}.glyphicon-download:before{content:"\e026"}.glyphicon-upload:before{content:"\e027"}.glyphicon-inbox:before{content:"\e028"}.glyphicon-play-circle:before{content:"\e029"}.glyphicon-repeat:before{content:"\e030"}.glyphicon-refresh:before{content:"\e031"}.glyphicon-list-alt:before{content:"\e032"}.glyphicon-lock:before{content:"\e033"}.glyphicon-flag:before{content:"\e034"}.glyphicon-headphones:before{content:"\e035"}.glyphicon-volume-off:before{content:"\e036"}.glyphicon-volume-down:before{content:"\e037"}.glyphicon-volume-up:before{content:"\e038"}.glyphicon-qrcode:before{content:"\e039"}.glyphicon-barcode:before{content:"\e040"}.glyphicon-tag:before{content:"\e041"}.glyphicon-tags:before{content:"\e042"}.glyphicon-book:before{content:"\e043"}.glyphicon-bookmark:before{content:"\e044"}.glyphicon-print:before{content:"\e045"}.glyphicon-camera:before{content:"\e046"}.glyphicon-font:before{content:"\e047"}.glyphicon-bold:before{content:"\e048"}.glyphicon-italic:before{content:"\e049"}.glyphicon-text-height:before{content:"\e050"}.glyphicon-text-width:before{content:"\e051"}.glyphicon-align-left:before{content:"\e052"}.glyphicon-align-center:before{content:"\e053"}.glyphicon-align-right:before{content:"\e054"}.glyphicon-align-justify:before{content:"\e055"}.glyphicon-list:before{content:"\e056"}.glyphicon-indent-left:before{content:"\e057"}.glyphicon-indent-right:before{content:"\e058"}.glyphicon-facetime-video:before{content:"\e059"}.glyphicon-picture:before{content:"\e060"}.glyphicon-map-marker:before{content:"\e062"}.glyphicon-adjust:before{content:"\e063"}.glyphicon-tint:before{content:"\e064"}.glyphicon-edit:before{content:"\e065"}.glyphicon-share:before{content:"\e066"}.glyphicon-check:before{content:"\e067"}.glyphicon-move:before{content:"\e068"}.glyphicon-step-backward:before{content:"\e069"}.glyphicon-fast-backward:before{content:"\e070"}.glyphicon-backward:before{content:"\e071"}.glyphicon-play:before{content:"\e072"}.glyphicon-pause:before{content:"\e073"}.glyphicon-stop:before{content:"\e074"}.glyphicon-forward:before{content:"\e075"}.glyphicon-fast-forward:before{content:"\e076"}.glyphicon-step-forward:before{content:"\e077"}.glyphicon-eject:before{content:"\e078"}.glyphicon-chevron-left:before{content:"\e079"}.glyphicon-chevron-right:before{content:"\e080"}.glyphicon-plus-sign:before{content:"\e081"}.glyphicon-minus-sign:before{content:"\e082"}.glyphicon-remove-sign:before{content:"\e083"}.glyphicon-ok-sign:before{content:"\e084"}.glyphicon-question-sign:before{content:"\e085"}.glyphicon-info-sign:before{content:"\e086"}.glyphicon-screenshot:before{content:"\e087"}.glyphicon-remove-circle:before{content:"\e088"}.glyphicon-ok-circle:before{content:"\e089"}.glyphicon-ban-circle:before{content:"\e090"}.glyphicon-arrow-left:before{content:"\e091"}.glyphicon-arrow-right:before{content:"\e092"}.glyphicon-arrow-up:before{content:"\e093"}.glyphicon-arrow-down:before{content:"\e094"}.glyphicon-share-alt:before{content:"\e095"}.glyphicon-resize-full:before{content:"\e096"}.glyphicon-resize-small:before{content:"\e097"}.glyphicon-exclamation-sign:before{content:"\e101"}.glyphicon-gift:before{content:"\e102"}.glyphicon-leaf:before{content:"\e103"}.glyphicon-fire:before{content:"\e104"}.glyphicon-eye-open:before{content:"\e105"}.glyphicon-eye-close:before{content:"\e106"}.glyphicon-warning-sign:before{content:"\e107"}.glyphicon-plane:before{content:"\e108"}.glyphicon-calendar:before{content:"\e109"}.glyphicon-random:before{content:"\e110"}.glyphicon-comment:before{content:"\e111"}.glyphicon-magnet:before{content:"\e112"}.glyphicon-chevron-up:before{content:"\e113"}.glyphicon-chevron-down:before{content:"\e114"}.glyphicon-retweet:before{content:"\e115"}.glyphicon-shopping-cart:before{content:"\e116"}.glyphicon-folder-close:before{content:"\e117"}.glyphicon-folder-open:before{content:"\e118"}.glyphicon-resize-vertical:before{content:"\e119"}.glyphicon-resize-horizontal:before{content:"\e120"}.glyphicon-hdd:before{content:"\e121"}.glyphicon-bullhorn:before{content:"\e122"}.glyphicon-bell:before{content:"\e123"}.glyphicon-certificate:before{content:"\e124"}.glyphicon-thumbs-up:before{content:"\e125"}.glyphicon-thumbs-down:before{content:"\e126"}.glyphicon-hand-right:before{content:"\e127"}.glyphicon-hand-left:before{content:"\e128"}.glyphicon-hand-up:before{content:"\e129"}.glyphicon-hand-down:before{content:"\e130"}.glyphicon-circle-arrow-right:before{content:"\e131"}.glyphicon-circle-arrow-left:before{content:"\e132"}.glyphicon-circle-arrow-up:before{content:"\e133"}.glyphicon-circle-arrow-down:before{content:"\e134"}.glyphicon-globe:before{content:"\e135"}.glyphicon-wrench:before{content:"\e136"}.glyphicon-tasks:before{content:"\e137"}.glyphicon-filter:before{content:"\e138"}.glyphicon-briefcase:before{content:"\e139"}.glyphicon-fullscreen:before{content:"\e140"}.glyphicon-dashboard:before{content:"\e141"}.glyphicon-paperclip:before{content:"\e142"}.glyphicon-heart-empty:before{content:"\e143"}.glyphicon-link:before{content:"\e144"}.glyphicon-phone:before{content:"\e145"}.glyphicon-pushpin:before{content:"\e146"}.glyphicon-usd:before{content:"\e148"}.glyphicon-gbp:before{content:"\e149"}.glyphicon-sort:before{content:"\e150"}.glyphicon-sort-by-alphabet:before{content:"\e151"}.glyphicon-sort-by-alphabet-alt:before{content:"\e152"}.glyphicon-sort-by-order:before{content:"\e153"}.glyphicon-sort-by-order-alt:before{content:"\e154"}.glyphicon-sort-by-attributes:before{content:"\e155"}.glyphicon-sort-by-attributes-alt:before{content:"\e156"}.glyphicon-unchecked:before{content:"\e157"}.glyphicon-expand:before{content:"\e158"}.glyphicon-collapse-down:before{content:"\e159"}.glyphicon-collapse-up:before{content:"\e160"}.glyphicon-log-in:before{content:"\e161"}.glyphicon-flash:before{content:"\e162"}.glyphicon-log-out:before{content:"\e163"}.glyphicon-new-window:before{content:"\e164"}.glyphicon-record:before{content:"\e165"}.glyphicon-save:before{content:"\e166"}.glyphicon-open:before{content:"\e167"}.glyphicon-saved:before{content:"\e168"}.glyphicon-import:before{content:"\e169"}.glyphicon-export:before{content:"\e170"}.glyphicon-send:before{content:"\e171"}.glyphicon-floppy-disk:before{content:"\e172"}.glyphicon-floppy-saved:before{content:"\e173"}.glyphicon-floppy-remove:before{content:"\e174"}.glyphicon-floppy-save:before{content:"\e175"}.glyphicon-floppy-open:before{content:"\e176"}.glyphicon-credit-card:before{content:"\e177"}.glyphicon-transfer:before{content:"\e178"}.glyphicon-cutlery:before{content:"\e179"}.glyphicon-header:before{content:"\e180"}.glyphicon-compressed:before{content:"\e181"}.glyphicon-earphone:before{content:"\e182"}.glyphicon-phone-alt:before{content:"\e183"}.glyphicon-tower:before{content:"\e184"}.glyphicon-stats:before{content:"\e185"}.glyphicon-sd-video:before{content:"\e186"}.glyphicon-hd-video:before{content:"\e187"}.glyphicon-subtitles:before{content:"\e188"}.glyphicon-sound-stereo:before{content:"\e189"}.glyphicon-sound-dolby:before{content:"\e190"}.glyphicon-sound-5-1:before{content:"\e191"}.glyphicon-sound-6-1:before{content:"\e192"}.glyphicon-sound-7-1:before{content:"\e193"}.glyphicon-copyright-mark:before{content:"\e194"}.glyphicon-registration-mark:before{content:"\e195"}.glyphicon-cloud-download:before{content:"\e197"}.glyphicon-cloud-upload:before{content:"\e198"}.glyphicon-tree-conifer:before{content:"\e199"}.glyphicon-tree-deciduous:before{content:"\e200"}.glyphicon-cd:before{content:"\e201"}.glyphicon-save-file:before{content:"\e202"}.glyphicon-open-file:before{content:"\e203"}.glyphicon-level-up:before{content:"\e204"}.glyphicon-copy:before{content:"\e205"}.glyphicon-paste:before{content:"\e206"}.glyphicon-alert:before{content:"\e209"}.glyphicon-equalizer:before{content:"\e210"}.glyphicon-king:before{content:"\e211"}.glyphicon-queen:before{content:"\e212"}.glyphicon-pawn:before{content:"\e213"}.glyphicon-bishop:before{content:"\e214"}.glyphicon-knight:before{content:"\e215"}.glyphicon-baby-formula:before{content:"\e216"}.glyphicon-tent:before{content:"\26fa"}.glyphicon-blackboard:before{content:"\e218"}.glyphicon-bed:before{content:"\e219"}.glyphicon-apple:before{content:"\f8ff"}.glyphicon-erase:before{content:"\e221"}.glyphicon-hourglass:before{content:"\231b"}.glyphicon-lamp:before{content:"\e223"}.glyphicon-duplicate:before{content:"\e224"}.glyphicon-piggy-bank:before{content:"\e225"}.glyphicon-scissors:before{content:"\e226"}.glyphicon-bitcoin:before,.glyphicon-btc:before,.glyphicon-xbt:before{content:"\e227"}.glyphicon-jpy:before,.glyphicon-yen:before{content:"\00a5"}.glyphicon-rub:before,.glyphicon-ruble:before{content:"\20bd"}.glyphicon-scale:before{content:"\e230"}.glyphicon-ice-lolly:before{content:"\e231"}.glyphicon-ice-lolly-tasted:before{content:"\e232"}.glyphicon-education:before{content:"\e233"}.glyphicon-option-horizontal:before{content:"\e234"}.glyphicon-option-vertical:before{content:"\e235"}.glyphicon-menu-hamburger:before{content:"\e236"}.glyphicon-modal-window:before{content:"\e237"}.glyphicon-oil:before{content:"\e238"}.glyphicon-grain:before{content:"\e239"}.glyphicon-sunglasses:before{content:"\e240"}.glyphicon-text-size:before{content:"\e241"}.glyphicon-text-color:before{content:"\e242"}.glyphicon-text-background:before{content:"\e243"}.glyphicon-object-align-top:before{content:"\e244"}.glyphicon-object-align-bottom:before{content:"\e245"}.glyphicon-object-align-horizontal:before{content:"\e246"}.glyphicon-object-align-left:before{content:"\e247"}.glyphicon-object-align-vertical:before{content:"\e248"}.glyphicon-object-align-right:before{content:"\e249"}.glyphicon-triangle-right:before{content:"\e250"}.glyphicon-triangle-left:before{content:"\e251"}.glyphicon-triangle-bottom:before{content:"\e252"}.glyphicon-triangle-top:before{content:"\e253"}.glyphicon-console:before{content:"\e254"}.glyphicon-superscript:before{content:"\e255"}.glyphicon-subscript:before{content:"\e256"}.glyphicon-menu-left:before{content:"\e257"}.glyphicon-menu-right:before{content:"\e258"}.glyphicon-menu-down:before{content:"\e259"}.glyphicon-menu-up:before{content:"\e260"}*,:after,:before{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html{font-size:10px;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:1.42857143;color:#333;background-color:#fff}button,input,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit}a{color:#337ab7;text-decoration:none}a:focus,a:hover{color:#23527c;text-decoration:underline}a:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}figure{margin:0}img{vertical-align:middle}.carousel-inner>.item>a>img,.carousel-inner>.item>img,.img-responsive,.thumbnail a>img,.thumbnail>img{display:block;max-width:100%;height:auto}.img-rounded{border-radius:6px}.img-thumbnail{display:inline-block;max-width:100%;height:auto;padding:4px;line-height:1.42857143;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.img-circle{border-radius:50%}hr{margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}[role=button]{cursor:pointer}.h1,.h2,.h3,.h4,.h5,.h6,h1,h2,h3,h4,h5,h6{font-family:inherit;font-weight:500;line-height:1.1;color:inherit}.h1 .small,.h1 small,.h2 .small,.h2 small,.h3 .small,.h3 small,.h4 .small,.h4 small,.h5 .small,.h5 small,.h6 .small,.h6 small,h1 .small,h1 small,h2 .small,h2 small,h3 .small,h3 small,h4 .small,h4 small,h5 .small,h5 small,h6 .small,h6 small{font-weight:400;line-height:1;color:#777}.h1,.h2,.h3,h1,h2,h3{margin-top:20px;margin-bottom:10px}.h1 .small,.h1 small,.h2 .small,.h2 small,.h3 .small,.h3 small,h1 .small,h1 small,h2 .small,h2 small,h3 .small,h3 small{font-size:65%}.h4,.h5,.h6,h4,h5,h6{margin-top:10px;margin-bottom:10px}.h4 .small,.h4 small,.h5 .small,.h5 small,.h6 .small,.h6 small,h4 .small,h4 small,h5 .small,h5 small,h6 .small,h6 small{font-size:75%}.h1,h1{font-size:36px}.h2,h2{font-size:30px}.h3,h3{font-size:24px}.h4,h4{font-size:18px}.h5,h5{font-size:14px}.h6,h6{font-size:12px}p{margin:0 0 10px}.lead{margin-bottom:20px;font-size:16px;font-weight:300;line-height:1.4}@media (min-width:768px){.lead{font-size:21px}}.small,small{font-size:85%}.mark,mark{padding:.2em;background-color:#fcf8e3}.text-left{text-align:left}.text-right{text-align:right}.text-center{text-align:center}.text-justify{text-align:justify}.text-nowrap{white-space:nowrap}.text-lowercase{text-transform:lowercase}.text-uppercase{text-transform:uppercase}.text-capitalize{text-transform:capitalize}.text-muted{color:#777}.text-primary{color:#337ab7}a.text-primary:hover{color:#286090}.text-success{color:#3c763d}a.text-success:hover{color:#2b542c}.text-info{color:#31708f}a.text-info:hover{color:#245269}.text-warning{color:#8a6d3b}a.text-warning:hover{color:#66512c}.text-danger{color:#a94442}a.text-danger:hover{color:#843534}.bg-primary{color:#fff;background-color:#337ab7}a.bg-primary:hover{background-color:#286090}.bg-success{background-color:#dff0d8}a.bg-success:hover{background-color:#c1e2b3}.bg-info{background-color:#d9edf7}a.bg-info:hover{background-color:#afd9ee}.bg-warning{background-color:#fcf8e3}a.bg-warning:hover{background-color:#f7ecb5}.bg-danger{background-color:#f2dede}a.bg-danger:hover{background-color:#e4b9b9}.page-header{padding-bottom:9px;margin:40px 0 20px;border-bottom:1px solid #eee}ol,ul{margin-top:0;margin-bottom:10px}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}.list-unstyled{padding-left:0;list-style:none}.list-inline{padding-left:0;margin-left:-5px;list-style:none}.list-inline>li{display:inline-block;padding-right:5px;padding-left:5px}dl{margin-top:0;margin-bottom:20px}dd,dt{line-height:1.42857143}dt{font-weight:700}dd{margin-left:0}@media (min-width:768px){.dl-horizontal dt{float:left;width:160px;overflow:hidden;clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:180px}}abbr[data-original-title],abbr[title]{cursor:help;border-bottom:1px dotted #777}.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:10px 20px;margin:0 0 20px;font-size:17.5px;border-left:5px solid #eee}blockquote ol:last-child,blockquote p:last-child,blockquote ul:last-child{margin-bottom:0}blockquote .small,blockquote footer,blockquote small{display:block;font-size:80%;line-height:1.42857143;color:#777}blockquote .small:before,blockquote footer:before,blockquote small:before{content:'\2014 \00A0'}.blockquote-reverse,blockquote.pull-right{padding-right:15px;padding-left:0;text-align:right;border-right:5px solid #eee;border-left:0}.blockquote-reverse .small:before,.blockquote-reverse footer:before,.blockquote-reverse small:before,blockquote.pull-right .small:before,blockquote.pull-right footer:before,blockquote.pull-right small:before{content:''}.blockquote-reverse .small:after,.blockquote-reverse footer:after,.blockquote-reverse small:after,blockquote.pull-right .small:after,blockquote.pull-right footer:after,blockquote.pull-right small:after{content:'\00A0 \2014'}address{margin-bottom:20px;font-style:normal;line-height:1.42857143}code,kbd,pre,samp{font-family:Menlo,Monaco,Consolas,"Courier New",monospace}code{padding:2px 4px;font-size:90%;color:#c7254e;background-color:#f9f2f4;border-radius:4px}kbd{padding:2px 4px;font-size:90%;color:#fff;background-color:#333;border-radius:3px;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.25);box-shadow:inset 0 -1px 0 rgba(0,0,0,.25)}kbd kbd{padding:0;font-size:100%;font-weight:700;-webkit-box-shadow:none;box-shadow:none}pre{display:block;padding:9.5px;margin:0 0 10px;font-size:13px;line-height:1.42857143;color:#333;word-break:break-all;word-wrap:break-word;background-color:#f5f5f5;border:1px solid #ccc;border-radius:4px}pre code{padding:0;font-size:inherit;color:inherit;white-space:pre-wrap;background-color:transparent;border-radius:0}.pre-scrollable{max-height:340px;overflow-y:scroll}.container,.container-fluid{padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}@media (min-width:768px){.container{width:750px}}@media (min-width:992px){.container{width:970px}}@media (min-width:1200px){.container{width:1170px}}.row{margin-right:-15px;margin-left:-15px}.col-lg-1,.col-lg-10,.col-lg-11,.col-lg-12,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-md-1,.col-md-10,.col-md-11,.col-md-12,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-sm-1,.col-sm-10,.col-sm-11,.col-sm-12,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-xs-1,.col-xs-10,.col-xs-11,.col-xs-12,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9{position:relative;min-height:1px;padding-right:15px;padding-left:15px}.col-xs-1,.col-xs-10,.col-xs-11,.col-xs-12,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9{float:left}.col-xs-12{width:100%}.col-xs-11{width:91.66666667%}.col-xs-10{width:83.33333333%}.col-xs-9{width:75%}.col-xs-8{width:66.66666667%}.col-xs-7{width:58.33333333%}.col-xs-6{width:50%}.col-xs-5{width:41.66666667%}.col-xs-4{width:33.33333333%}.col-xs-3{width:25%}.col-xs-2{width:16.66666667%}.col-xs-1{width:8.33333333%}.col-xs-pull-12{right:100%}.col-xs-pull-11{right:91.66666667%}.col-xs-pull-10{right:83.33333333%}.col-xs-pull-9{right:75%}.col-xs-pull-8{right:66.66666667%}.col-xs-pull-7{right:58.33333333%}.col-xs-pull-6{right:50%}.col-xs-pull-5{right:41.66666667%}.col-xs-pull-4{right:33.33333333%}.col-xs-pull-3{right:25%}.col-xs-pull-2{right:16.66666667%}.col-xs-pull-1{right:8.33333333%}.col-xs-pull-0{right:auto}.col-xs-push-12{left:100%}.col-xs-push-11{left:91.66666667%}.col-xs-push-10{left:83.33333333%}.col-xs-push-9{left:75%}.col-xs-push-8{left:66.66666667%}.col-xs-push-7{left:58.33333333%}.col-xs-push-6{left:50%}.col-xs-push-5{left:41.66666667%}.col-xs-push-4{left:33.33333333%}.col-xs-push-3{left:25%}.col-xs-push-2{left:16.66666667%}.col-xs-push-1{left:8.33333333%}.col-xs-push-0{left:auto}.col-xs-offset-12{margin-left:100%}.col-xs-offset-11{margin-left:91.66666667%}.col-xs-offset-10{margin-left:83.33333333%}.col-xs-offset-9{margin-left:75%}.col-xs-offset-8{margin-left:66.66666667%}.col-xs-offset-7{margin-left:58.33333333%}.col-xs-offset-6{margin-left:50%}.col-xs-offset-5{margin-left:41.66666667%}.col-xs-offset-4{margin-left:33.33333333%}.col-xs-offset-3{margin-left:25%}.col-xs-offset-2{margin-left:16.66666667%}.col-xs-offset-1{margin-left:8.33333333%}.col-xs-offset-0{margin-left:0}@media (min-width:768px){.col-sm-1,.col-sm-10,.col-sm-11,.col-sm-12,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9{float:left}.col-sm-12{width:100%}.col-sm-11{width:91.66666667%}.col-sm-10{width:83.33333333%}.col-sm-9{width:75%}.col-sm-8{width:66.66666667%}.col-sm-7{width:58.33333333%}.col-sm-6{width:50%}.col-sm-5{width:41.66666667%}.col-sm-4{width:33.33333333%}.col-sm-3{width:25%}.col-sm-2{width:16.66666667%}.col-sm-1{width:8.33333333%}.col-sm-pull-12{right:100%}.col-sm-pull-11{right:91.66666667%}.col-sm-pull-10{right:83.33333333%}.col-sm-pull-9{right:75%}.col-sm-pull-8{right:66.66666667%}.col-sm-pull-7{right:58.33333333%}.col-sm-pull-6{right:50%}.col-sm-pull-5{right:41.66666667%}.col-sm-pull-4{right:33.33333333%}.col-sm-pull-3{right:25%}.col-sm-pull-2{right:16.66666667%}.col-sm-pull-1{right:8.33333333%}.col-sm-pull-0{right:auto}.col-sm-push-12{left:100%}.col-sm-push-11{left:91.66666667%}.col-sm-push-10{left:83.33333333%}.col-sm-push-9{left:75%}.col-sm-push-8{left:66.66666667%}.col-sm-push-7{left:58.33333333%}.col-sm-push-6{left:50%}.col-sm-push-5{left:41.66666667%}.col-sm-push-4{left:33.33333333%}.col-sm-push-3{left:25%}.col-sm-push-2{left:16.66666667%}.col-sm-push-1{left:8.33333333%}.col-sm-push-0{left:auto}.col-sm-offset-12{margin-left:100%}.col-sm-offset-11{margin-left:91.66666667%}.col-sm-offset-10{margin-left:83.33333333%}.col-sm-offset-9{margin-left:75%}.col-sm-offset-8{margin-left:66.66666667%}.col-sm-offset-7{margin-left:58.33333333%}.col-sm-offset-6{margin-left:50%}.col-sm-offset-5{margin-left:41.66666667%}.col-sm-offset-4{margin-left:33.33333333%}.col-sm-offset-3{margin-left:25%}.col-sm-offset-2{margin-left:16.66666667%}.col-sm-offset-1{margin-left:8.33333333%}.col-sm-offset-0{margin-left:0}}@media (min-width:992px){.col-md-1,.col-md-10,.col-md-11,.col-md-12,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9{float:left}.col-md-12{width:100%}.col-md-11{width:91.66666667%}.col-md-10{width:83.33333333%}.col-md-9{width:75%}.col-md-8{width:66.66666667%}.col-md-7{width:58.33333333%}.col-md-6{width:50%}.col-md-5{width:41.66666667%}.col-md-4{width:33.33333333%}.col-md-3{width:25%}.col-md-2{width:16.66666667%}.col-md-1{width:8.33333333%}.col-md-pull-12{right:100%}.col-md-pull-11{right:91.66666667%}.col-md-pull-10{right:83.33333333%}.col-md-pull-9{right:75%}.col-md-pull-8{right:66.66666667%}.col-md-pull-7{right:58.33333333%}.col-md-pull-6{right:50%}.col-md-pull-5{right:41.66666667%}.col-md-pull-4{right:33.33333333%}.col-md-pull-3{right:25%}.col-md-pull-2{right:16.66666667%}.col-md-pull-1{right:8.33333333%}.col-md-pull-0{right:auto}.col-md-push-12{left:100%}.col-md-push-11{left:91.66666667%}.col-md-push-10{left:83.33333333%}.col-md-push-9{left:75%}.col-md-push-8{left:66.66666667%}.col-md-push-7{left:58.33333333%}.col-md-push-6{left:50%}.col-md-push-5{left:41.66666667%}.col-md-push-4{left:33.33333333%}.col-md-push-3{left:25%}.col-md-push-2{left:16.66666667%}.col-md-push-1{left:8.33333333%}.col-md-push-0{left:auto}.col-md-offset-12{margin-left:100%}.col-md-offset-11{margin-left:91.66666667%}.col-md-offset-10{margin-left:83.33333333%}.col-md-offset-9{margin-left:75%}.col-md-offset-8{margin-left:66.66666667%}.col-md-offset-7{margin-left:58.33333333%}.col-md-offset-6{margin-left:50%}.col-md-offset-5{margin-left:41.66666667%}.col-md-offset-4{margin-left:33.33333333%}.col-md-offset-3{margin-left:25%}.col-md-offset-2{margin-left:16.66666667%}.col-md-offset-1{margin-left:8.33333333%}.col-md-offset-0{margin-left:0}}@media (min-width:1200px){.col-lg-1,.col-lg-10,.col-lg-11,.col-lg-12,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9{float:left}.col-lg-12{width:100%}.col-lg-11{width:91.66666667%}.col-lg-10{width:83.33333333%}.col-lg-9{width:75%}.col-lg-8{width:66.66666667%}.col-lg-7{width:58.33333333%}.col-lg-6{width:50%}.col-lg-5{width:41.66666667%}.col-lg-4{width:33.33333333%}.col-lg-3{width:25%}.col-lg-2{width:16.66666667%}.col-lg-1{width:8.33333333%}.col-lg-pull-12{right:100%}.col-lg-pull-11{right:91.66666667%}.col-lg-pull-10{right:83.33333333%}.col-lg-pull-9{right:75%}.col-lg-pull-8{right:66.66666667%}.col-lg-pull-7{right:58.33333333%}.col-lg-pull-6{right:50%}.col-lg-pull-5{right:41.66666667%}.col-lg-pull-4{right:33.33333333%}.col-lg-pull-3{right:25%}.col-lg-pull-2{right:16.66666667%}.col-lg-pull-1{right:8.33333333%}.col-lg-pull-0{right:auto}.col-lg-push-12{left:100%}.col-lg-push-11{left:91.66666667%}.col-lg-push-10{left:83.33333333%}.col-lg-push-9{left:75%}.col-lg-push-8{left:66.66666667%}.col-lg-push-7{left:58.33333333%}.col-lg-push-6{left:50%}.col-lg-push-5{left:41.66666667%}.col-lg-push-4{left:33.33333333%}.col-lg-push-3{left:25%}.col-lg-push-2{left:16.66666667%}.col-lg-push-1{left:8.33333333%}.col-lg-push-0{left:auto}.col-lg-offset-12{margin-left:100%}.col-lg-offset-11{margin-left:91.66666667%}.col-lg-offset-10{margin-left:83.33333333%}.col-lg-offset-9{margin-left:75%}.col-lg-offset-8{margin-left:66.66666667%}.col-lg-offset-7{margin-left:58.33333333%}.col-lg-offset-6{margin-left:50%}.col-lg-offset-5{margin-left:41.66666667%}.col-lg-offset-4{margin-left:33.33333333%}.col-lg-offset-3{margin-left:25%}.col-lg-offset-2{margin-left:16.66666667%}.col-lg-offset-1{margin-left:8.33333333%}.col-lg-offset-0{margin-left:0}}table{background-color:transparent}caption{padding-top:8px;padding-bottom:8px;color:#777;text-align:left}th{text-align:left}.table{width:100%;max-width:100%;margin-bottom:20px}.table>tbody>tr>td,.table>tbody>tr>th,.table>tfoot>tr>td,.table>tfoot>tr>th,.table>thead>tr>td,.table>thead>tr>th{padding:8px;line-height:1.42857143;vertical-align:top;border-top:1px solid #ddd}.table>thead>tr>th{vertical-align:bottom;border-bottom:2px solid #ddd}.table>caption+thead>tr:first-child>td,.table>caption+thead>tr:first-child>th,.table>colgroup+thead>tr:first-child>td,.table>colgroup+thead>tr:first-child>th,.table>thead:first-child>tr:first-child>td,.table>thead:first-child>tr:first-child>th{border-top:0}.table>tbody+tbody{border-top:2px solid #ddd}.table .table{background-color:#fff}.table-condensed>tbody>tr>td,.table-condensed>tbody>tr>th,.table-condensed>tfoot>tr>td,.table-condensed>tfoot>tr>th,.table-condensed>thead>tr>td,.table-condensed>thead>tr>th{padding:5px}.table-bordered,.table-bordered>tbody>tr>td,.table-bordered>tbody>tr>th,.table-bordered>tfoot>tr>td,.table-bordered>tfoot>tr>th,.table-bordered>thead>tr>td,.table-bordered>thead>tr>th{border:1px solid #ddd}.table-bordered>thead>tr>td,.table-bordered>thead>tr>th{border-bottom-width:2px}.table-striped>tbody>tr:nth-of-type(odd){background-color:#f9f9f9}.table-hover>tbody>tr:hover{background-color:#f5f5f5}table col[class*=col-]{position:static;display:table-column;float:none}table td[class*=col-],table th[class*=col-]{position:static;display:table-cell;float:none}.table>tbody>tr.active>td,.table>tbody>tr.active>th,.table>tbody>tr>td.active,.table>tbody>tr>th.active,.table>tfoot>tr.active>td,.table>tfoot>tr.active>th,.table>tfoot>tr>td.active,.table>tfoot>tr>th.active,.table>thead>tr.active>td,.table>thead>tr.active>th,.table>thead>tr>td.active,.table>thead>tr>th.active{background-color:#f5f5f5}.table-hover>tbody>tr.active:hover>td,.table-hover>tbody>tr.active:hover>th,.table-hover>tbody>tr:hover>.active,.table-hover>tbody>tr>td.active:hover,.table-hover>tbody>tr>th.active:hover{background-color:#e8e8e8}.table>tbody>tr.success>td,.table>tbody>tr.success>th,.table>tbody>tr>td.success,.table>tbody>tr>th.success,.table>tfoot>tr.success>td,.table>tfoot>tr.success>th,.table>tfoot>tr>td.success,.table>tfoot>tr>th.success,.table>thead>tr.success>td,.table>thead>tr.success>th,.table>thead>tr>td.success,.table>thead>tr>th.success{background-color:#dff0d8}.table-hover>tbody>tr.success:hover>td,.table-hover>tbody>tr.success:hover>th,.table-hover>tbody>tr:hover>.success,.table-hover>tbody>tr>td.success:hover,.table-hover>tbody>tr>th.success:hover{background-color:#d0e9c6}.table>tbody>tr.info>td,.table>tbody>tr.info>th,.table>tbody>tr>td.info,.table>tbody>tr>th.info,.table>tfoot>tr.info>td,.table>tfoot>tr.info>th,.table>tfoot>tr>td.info,.table>tfoot>tr>th.info,.table>thead>tr.info>td,.table>thead>tr.info>th,.table>thead>tr>td.info,.table>thead>tr>th.info{background-color:#d9edf7}.table-hover>tbody>tr.info:hover>td,.table-hover>tbody>tr.info:hover>th,.table-hover>tbody>tr:hover>.info,.table-hover>tbody>tr>td.info:hover,.table-hover>tbody>tr>th.info:hover{background-color:#c4e3f3}.table>tbody>tr.warning>td,.table>tbody>tr.warning>th,.table>tbody>tr>td.warning,.table>tbody>tr>th.warning,.table>tfoot>tr.warning>td,.table>tfoot>tr.warning>th,.table>tfoot>tr>td.warning,.table>tfoot>tr>th.warning,.table>thead>tr.warning>td,.table>thead>tr.warning>th,.table>thead>tr>td.warning,.table>thead>tr>th.warning{background-color:#fcf8e3}.table-hover>tbody>tr.warning:hover>td,.table-hover>tbody>tr.warning:hover>th,.table-hover>tbody>tr:hover>.warning,.table-hover>tbody>tr>td.warning:hover,.table-hover>tbody>tr>th.warning:hover{background-color:#faf2cc}.table>tbody>tr.danger>td,.table>tbody>tr.danger>th,.table>tbody>tr>td.danger,.table>tbody>tr>th.danger,.table>tfoot>tr.danger>td,.table>tfoot>tr.danger>th,.table>tfoot>tr>td.danger,.table>tfoot>tr>th.danger,.table>thead>tr.danger>td,.table>thead>tr.danger>th,.table>thead>tr>td.danger,.table>thead>tr>th.danger{background-color:#f2dede}.table-hover>tbody>tr.danger:hover>td,.table-hover>tbody>tr.danger:hover>th,.table-hover>tbody>tr:hover>.danger,.table-hover>tbody>tr>td.danger:hover,.table-hover>tbody>tr>th.danger:hover{background-color:#ebcccc}.table-responsive{min-height:.01%;overflow-x:auto}@media screen and (max-width:767px){.table-responsive{width:100%;margin-bottom:15px;overflow-y:hidden;-ms-overflow-style:-ms-autohiding-scrollbar;border:1px solid #ddd}.table-responsive>.table{margin-bottom:0}.table-responsive>.table>tbody>tr>td,.table-responsive>.table>tbody>tr>th,.table-responsive>.table>tfoot>tr>td,.table-responsive>.table>tfoot>tr>th,.table-responsive>.table>thead>tr>td,.table-responsive>.table>thead>tr>th{white-space:nowrap}.table-responsive>.table-bordered{border:0}.table-responsive>.table-bordered>tbody>tr>td:first-child,.table-responsive>.table-bordered>tbody>tr>th:first-child,.table-responsive>.table-bordered>tfoot>tr>td:first-child,.table-responsive>.table-bordered>tfoot>tr>th:first-child,.table-responsive>.table-bordered>thead>tr>td:first-child,.table-responsive>.table-bordered>thead>tr>th:first-child{border-left:0}.table-responsive>.table-bordered>tbody>tr>td:last-child,.table-responsive>.table-bordered>tbody>tr>th:last-child,.table-responsive>.table-bordered>tfoot>tr>td:last-child,.table-responsive>.table-bordered>tfoot>tr>th:last-child,.table-responsive>.table-bordered>thead>tr>td:last-child,.table-responsive>.table-bordered>thead>tr>th:last-child{border-right:0}.table-responsive>.table-bordered>tbody>tr:last-child>td,.table-responsive>.table-bordered>tbody>tr:last-child>th,.table-responsive>.table-bordered>tfoot>tr:last-child>td,.table-responsive>.table-bordered>tfoot>tr:last-child>th{border-bottom:0}}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;padding:0;margin-bottom:20px;font-size:21px;line-height:inherit;color:#333;border:0;border-bottom:1px solid #e5e5e5}label{display:inline-block;max-width:100%;margin-bottom:5px;font-weight:700}input[type=search]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}input[type=checkbox],input[type=radio]{margin:4px 0 0;margin-top:1px \9;line-height:normal}input[type=file]{display:block}input[type=range]{display:block;width:100%}select[multiple],select[size]{height:auto}input[type=checkbox]:focus,input[type=file]:focus,input[type=radio]:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}output{display:block;padding-top:7px;font-size:14px;line-height:1.42857143;color:#555}.form-control{display:block;width:100%;height:34px;padding:6px 12px;font-size:14px;line-height:1.42857143;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075);-webkit-transition:border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;-o-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.form-control:focus{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}.form-control::-moz-placeholder{color:#999;opacity:1}.form-control:-ms-input-placeholder{color:#999}.form-control::-webkit-input-placeholder{color:#999}.form-control[disabled],.form-control[readonly],fieldset[disabled] .form-control{background-color:#eee;opacity:1}.form-control[disabled],fieldset[disabled] .form-control{cursor:not-allowed}textarea.form-control{height:auto}input[type=search]{-webkit-appearance:none}@media screen and (-webkit-min-device-pixel-ratio:0){input[type=date],input[type=datetime-local],input[type=month],input[type=time]{line-height:34px}.input-group-sm input[type=date],.input-group-sm input[type=datetime-local],.input-group-sm input[type=month],.input-group-sm input[type=time],input[type=date].input-sm,input[type=datetime-local].input-sm,input[type=month].input-sm,input[type=time].input-sm{line-height:30px}.input-group-lg input[type=date],.input-group-lg input[type=datetime-local],.input-group-lg input[type=month],.input-group-lg input[type=time],input[type=date].input-lg,input[type=datetime-local].input-lg,input[type=month].input-lg,input[type=time].input-lg{line-height:46px}}.form-group{margin-bottom:15px}.checkbox,.radio{position:relative;display:block;margin-top:10px;margin-bottom:10px}.checkbox label,.radio label{min-height:20px;padding-left:20px;margin-bottom:0;font-weight:400;cursor:pointer}.checkbox input[type=checkbox],.checkbox-inline input[type=checkbox],.radio input[type=radio],.radio-inline input[type=radio]{position:absolute;margin-top:4px \9;margin-left:-20px}.checkbox+.checkbox,.radio+.radio{margin-top:-5px}.checkbox-inline,.radio-inline{position:relative;display:inline-block;padding-left:20px;margin-bottom:0;font-weight:400;vertical-align:middle;cursor:pointer}.checkbox-inline+.checkbox-inline,.radio-inline+.radio-inline{margin-top:0;margin-left:10px}.checkbox-inline.disabled,.checkbox.disabled label,.radio-inline.disabled,.radio.disabled label,fieldset[disabled] .checkbox label,fieldset[disabled] .checkbox-inline,fieldset[disabled] .radio label,fieldset[disabled] .radio-inline,fieldset[disabled] input[type=checkbox],fieldset[disabled] input[type=radio],input[type=checkbox].disabled,input[type=checkbox][disabled],input[type=radio].disabled,input[type=radio][disabled]{cursor:not-allowed}.form-control-static{min-height:34px;padding-top:7px;padding-bottom:7px;margin-bottom:0}.form-control-static.input-lg,.form-control-static.input-sm{padding-right:0;padding-left:0}.input-sm{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.input-sm{height:30px;line-height:30px}select[multiple].input-sm,textarea.input-sm{height:auto}.form-group-sm .form-control{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.form-group-sm .form-control{height:30px;line-height:30px}select[multiple].form-group-sm .form-control,textarea.form-group-sm .form-control{height:auto}.form-group-sm .form-control-static{height:30px;min-height:32px;padding:5px 10px;font-size:12px;line-height:1.5}.input-lg{height:46px;padding:10px 16px;font-size:18px;line-height:1.3333333;border-radius:6px}select.input-lg{height:46px;line-height:46px}select[multiple].input-lg,textarea.input-lg{height:auto}.form-group-lg .form-control{height:46px;padding:10px 16px;font-size:18px;line-height:1.3333333;border-radius:6px}select.form-group-lg .form-control{height:46px;line-height:46px}select[multiple].form-group-lg .form-control,textarea.form-group-lg .form-control{height:auto}.form-group-lg .form-control-static{height:46px;min-height:38px;padding:10px 16px;font-size:18px;line-height:1.3333333}.has-feedback{position:relative}.has-feedback .form-control{padding-right:42.5px}.form-control-feedback{position:absolute;top:0;right:0;z-index:2;display:block;width:34px;height:34px;line-height:34px;text-align:center;pointer-events:none}.input-lg+.form-control-feedback{width:46px;height:46px;line-height:46px}.input-sm+.form-control-feedback{width:30px;height:30px;line-height:30px}.has-success .checkbox,.has-success .checkbox-inline,.has-success .control-label,.has-success .help-block,.has-success .radio,.has-success .radio-inline,.has-success.checkbox label,.has-success.checkbox-inline label,.has-success.radio label,.has-success.radio-inline label{color:#3c763d}.has-success .form-control{border-color:#3c763d;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075)}.has-success .form-control:focus{border-color:#2b542c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #67b168;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #67b168}.has-success .input-group-addon{color:#3c763d;background-color:#dff0d8;border-color:#3c763d}.has-success .form-control-feedback{color:#3c763d}.has-warning .checkbox,.has-warning .checkbox-inline,.has-warning .control-label,.has-warning .help-block,.has-warning .radio,.has-warning .radio-inline,.has-warning.checkbox label,.has-warning.checkbox-inline label,.has-warning.radio label,.has-warning.radio-inline label{color:#8a6d3b}.has-warning .form-control{border-color:#8a6d3b;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075)}.has-warning .form-control:focus{border-color:#66512c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #c0a16b;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #c0a16b}.has-warning .input-group-addon{color:#8a6d3b;background-color:#fcf8e3;border-color:#8a6d3b}.has-warning .form-control-feedback{color:#8a6d3b}.has-error .checkbox,.has-error .checkbox-inline,.has-error .control-label,.has-error .help-block,.has-error .radio,.has-error .radio-inline,.has-error.checkbox label,.has-error.checkbox-inline label,.has-error.radio label,.has-error.radio-inline label{color:#a94442}.has-error .form-control{border-color:#a94442;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075)}.has-error .form-control:focus{border-color:#843534;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ce8483;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ce8483}.has-error .input-group-addon{color:#a94442;background-color:#f2dede;border-color:#a94442}.has-error .form-control-feedback{color:#a94442}.has-feedback label~.form-control-feedback{top:25px}.has-feedback label.sr-only~.form-control-feedback{top:0}.help-block{display:block;margin-top:5px;margin-bottom:10px;color:#737373}@media (min-width:768px){.form-inline .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.form-inline .form-control{display:inline-block;width:auto;vertical-align:middle}.form-inline .form-control-static{display:inline-block}.form-inline .input-group{display:inline-table;vertical-align:middle}.form-inline .input-group .form-control,.form-inline .input-group .input-group-addon,.form-inline .input-group .input-group-btn{width:auto}.form-inline .input-group>.form-control{width:100%}.form-inline .control-label{margin-bottom:0;vertical-align:middle}.form-inline .checkbox,.form-inline .radio{display:inline-block;margin-top:0;margin-bottom:0;vertical-align:middle}.form-inline .checkbox label,.form-inline .radio label{padding-left:0}.form-inline .checkbox input[type=checkbox],.form-inline .radio input[type=radio]{position:relative;margin-left:0}.form-inline .has-feedback .form-control-feedback{top:0}}.form-horizontal .checkbox,.form-horizontal .checkbox-inline,.form-horizontal .radio,.form-horizontal .radio-inline{padding-top:7px;margin-top:0;margin-bottom:0}.form-horizontal .checkbox,.form-horizontal .radio{min-height:27px}.form-horizontal .form-group{margin-right:-15px;margin-left:-15px}@media (min-width:768px){.form-horizontal .control-label{padding-top:7px;margin-bottom:0;text-align:right}}.form-horizontal .has-feedback .form-control-feedback{right:15px}@media (min-width:768px){.form-horizontal .form-group-lg .control-label{padding-top:14.33px}}@media (min-width:768px){.form-horizontal .form-group-sm .control-label{padding-top:6px}}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-size:14px;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:4px}.btn.active.focus,.btn.active:focus,.btn.focus,.btn:active.focus,.btn:active:focus,.btn:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.focus,.btn:focus,.btn:hover{color:#333;text-decoration:none}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,.125);box-shadow:inset 0 3px 5px rgba(0,0,0,.125)}.btn.disabled,.btn[disabled],fieldset[disabled] .btn{pointer-events:none;cursor:not-allowed;filter:alpha(opacity=65);-webkit-box-shadow:none;box-shadow:none;opacity:.65}.btn-default{color:#333;background-color:#fff;border-color:#ccc}.btn-default.active,.btn-default.focus,.btn-default:active,.btn-default:focus,.btn-default:hover,.open>.dropdown-toggle.btn-default{color:#333;background-color:#e6e6e6;border-color:#adadad}.btn-default.active,.btn-default:active,.open>.dropdown-toggle.btn-default{background-image:none}.btn-default.disabled,.btn-default.disabled.active,.btn-default.disabled.focus,.btn-default.disabled:active,.btn-default.disabled:focus,.btn-default.disabled:hover,.btn-default[disabled],.btn-default[disabled].active,.btn-default[disabled].focus,.btn-default[disabled]:active,.btn-default[disabled]:focus,.btn-default[disabled]:hover,fieldset[disabled] .btn-default,fieldset[disabled] .btn-default.active,fieldset[disabled] .btn-default.focus,fieldset[disabled] .btn-default:active,fieldset[disabled] .btn-default:focus,fieldset[disabled] .btn-default:hover{background-color:#fff;border-color:#ccc}.btn-default .badge{color:#fff;background-color:#333}.btn-primary{color:#fff;background-color:#337ab7;border-color:#2e6da4}.btn-primary.active,.btn-primary.focus,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.open>.dropdown-toggle.btn-primary{color:#fff;background-color:#286090;border-color:#204d74}.btn-primary.active,.btn-primary:active,.open>.dropdown-toggle.btn-primary{background-image:none}.btn-primary.disabled,.btn-primary.disabled.active,.btn-primary.disabled.focus,.btn-primary.disabled:active,.btn-primary.disabled:focus,.btn-primary.disabled:hover,.btn-primary[disabled],.btn-primary[disabled].active,.btn-primary[disabled].focus,.btn-primary[disabled]:active,.btn-primary[disabled]:focus,.btn-primary[disabled]:hover,fieldset[disabled] .btn-primary,fieldset[disabled] .btn-primary.active,fieldset[disabled] .btn-primary.focus,fieldset[disabled] .btn-primary:active,fieldset[disabled] .btn-primary:focus,fieldset[disabled] .btn-primary:hover{background-color:#337ab7;border-color:#2e6da4}.btn-primary .badge{color:#337ab7;background-color:#fff}.btn-success{color:#fff;background-color:#5cb85c;border-color:#4cae4c}.btn-success.active,.btn-success.focus,.btn-success:active,.btn-success:focus,.btn-success:hover,.open>.dropdown-toggle.btn-success{color:#fff;background-color:#449d44;border-color:#398439}.btn-success.active,.btn-success:active,.open>.dropdown-toggle.btn-success{background-image:none}.btn-success.disabled,.btn-success.disabled.active,.btn-success.disabled.focus,.btn-success.disabled:active,.btn-success.disabled:focus,.btn-success.disabled:hover,.btn-success[disabled],.btn-success[disabled].active,.btn-success[disabled].focus,.btn-success[disabled]:active,.btn-success[disabled]:focus,.btn-success[disabled]:hover,fieldset[disabled] .btn-success,fieldset[disabled] .btn-success.active,fieldset[disabled] .btn-success.focus,fieldset[disabled] .btn-success:active,fieldset[disabled] .btn-success:focus,fieldset[disabled] .btn-success:hover{background-color:#5cb85c;border-color:#4cae4c}.btn-success .badge{color:#5cb85c;background-color:#fff}.btn-info{color:#fff;background-color:#5bc0de;border-color:#46b8da}.btn-info.active,.btn-info.focus,.btn-info:active,.btn-info:focus,.btn-info:hover,.open>.dropdown-toggle.btn-info{color:#fff;background-color:#31b0d5;border-color:#269abc}.btn-info.active,.btn-info:active,.open>.dropdown-toggle.btn-info{background-image:none}.btn-info.disabled,.btn-info.disabled.active,.btn-info.disabled.focus,.btn-info.disabled:active,.btn-info.disabled:focus,.btn-info.disabled:hover,.btn-info[disabled],.btn-info[disabled].active,.btn-info[disabled].focus,.btn-info[disabled]:active,.btn-info[disabled]:focus,.btn-info[disabled]:hover,fieldset[disabled] .btn-info,fieldset[disabled] .btn-info.active,fieldset[disabled] .btn-info.focus,fieldset[disabled] .btn-info:active,fieldset[disabled] .btn-info:focus,fieldset[disabled] .btn-info:hover{background-color:#5bc0de;border-color:#46b8da}.btn-info .badge{color:#5bc0de;background-color:#fff}.btn-warning{color:#fff;background-color:#f0ad4e;border-color:#eea236}.btn-warning.active,.btn-warning.focus,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.open>.dropdown-toggle.btn-warning{color:#fff;background-color:#ec971f;border-color:#d58512}.btn-warning.active,.btn-warning:active,.open>.dropdown-toggle.btn-warning{background-image:none}.btn-warning.disabled,.btn-warning.disabled.active,.btn-warning.disabled.focus,.btn-warning.disabled:active,.btn-warning.disabled:focus,.btn-warning.disabled:hover,.btn-warning[disabled],.btn-warning[disabled].active,.btn-warning[disabled].focus,.btn-warning[disabled]:active,.btn-warning[disabled]:focus,.btn-warning[disabled]:hover,fieldset[disabled] .btn-warning,fieldset[disabled] .btn-warning.active,fieldset[disabled] .btn-warning.focus,fieldset[disabled] .btn-warning:active,fieldset[disabled] .btn-warning:focus,fieldset[disabled] .btn-warning:hover{background-color:#f0ad4e;border-color:#eea236}.btn-warning .badge{color:#f0ad4e;background-color:#fff}.btn-danger{color:#fff;background-color:#d9534f;border-color:#d43f3a}.btn-danger.active,.btn-danger.focus,.btn-danger:active,.btn-danger:focus,.btn-danger:hover,.open>.dropdown-toggle.btn-danger{color:#fff;background-color:#c9302c;border-color:#ac2925}.btn-danger.active,.btn-danger:active,.open>.dropdown-toggle.btn-danger{background-image:none}.btn-danger.disabled,.btn-danger.disabled.active,.btn-danger.disabled.focus,.btn-danger.disabled:active,.btn-danger.disabled:focus,.btn-danger.disabled:hover,.btn-danger[disabled],.btn-danger[disabled].active,.btn-danger[disabled].focus,.btn-danger[disabled]:active,.btn-danger[disabled]:focus,.btn-danger[disabled]:hover,fieldset[disabled] .btn-danger,fieldset[disabled] .btn-danger.active,fieldset[disabled] .btn-danger.focus,fieldset[disabled] .btn-danger:active,fieldset[disabled] .btn-danger:focus,fieldset[disabled] .btn-danger:hover{background-color:#d9534f;border-color:#d43f3a}.btn-danger .badge{color:#d9534f;background-color:#fff}.btn-link{font-weight:400;color:#337ab7;border-radius:0}.btn-link,.btn-link.active,.btn-link:active,.btn-link[disabled],fieldset[disabled] .btn-link{background-color:transparent;-webkit-box-shadow:none;box-shadow:none}.btn-link,.btn-link:active,.btn-link:focus,.btn-link:hover{border-color:transparent}.btn-link:focus,.btn-link:hover{color:#23527c;text-decoration:underline;background-color:transparent}.btn-link[disabled]:focus,.btn-link[disabled]:hover,fieldset[disabled] .btn-link:focus,fieldset[disabled] .btn-link:hover{color:#777;text-decoration:none}.btn-group-lg>.btn,.btn-lg{padding:10px 16px;font-size:18px;line-height:1.3333333;border-radius:6px}.btn-group-sm>.btn,.btn-sm{padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.btn-group-xs>.btn,.btn-xs{padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.btn-block{display:block;width:100%}.btn-block+.btn-block{margin-top:5px}input[type=button].btn-block,input[type=reset].btn-block,input[type=submit].btn-block{width:100%}.fade{opacity:0;-webkit-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{display:none}.collapse.in{display:block}tr.collapse.in{display:table-row}tbody.collapse.in{display:table-row-group}.collapsing{position:relative;height:0;overflow:hidden;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease;-webkit-transition-duration:.35s;-o-transition-duration:.35s;transition-duration:.35s;-webkit-transition-property:height,visibility;-o-transition-property:height,visibility;transition-property:height,visibility}.caret{display:inline-block;width:0;height:0;margin-left:2px;vertical-align:middle;border-top:4px dashed;border-right:4px solid transparent;border-left:4px solid transparent}.dropdown,.dropup{position:relative}.dropdown-toggle:focus{outline:0}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;font-size:14px;text-align:left;list-style:none;background-color:#fff;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #ccc;border:1px solid rgba(0,0,0,.15);border-radius:4px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,.175);box-shadow:0 6px 12px rgba(0,0,0,.175)}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:400;line-height:1.42857143;color:#333;white-space:nowrap}.dropdown-menu>li>a:focus,.dropdown-menu>li>a:hover{color:#262626;text-decoration:none;background-color:#f5f5f5}.dropdown-menu>.active>a,.dropdown-menu>.active>a:focus,.dropdown-menu>.active>a:hover{color:#fff;text-decoration:none;background-color:#337ab7;outline:0}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:focus,.dropdown-menu>.disabled>a:hover{color:#777}.dropdown-menu>.disabled>a:focus,.dropdown-menu>.disabled>a:hover{text-decoration:none;cursor:not-allowed;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.open>.dropdown-menu{display:block}.open>a{outline:0}.dropdown-menu-right{right:0;left:auto}.dropdown-menu-left{right:auto;left:0}.dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.42857143;color:#777;white-space:nowrap}.dropdown-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:990}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{content:"";border-top:0;border-bottom:4px solid}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:2px}@media (min-width:768px){.navbar-right .dropdown-menu{right:0;left:auto}.navbar-right .dropdown-menu-left{right:auto;left:0}}.btn-group,.btn-group-vertical{position:relative;display:inline-block;vertical-align:middle}.btn-group-vertical>.btn,.btn-group>.btn{position:relative;float:left}.btn-group-vertical>.btn.active,.btn-group-vertical>.btn:active,.btn-group-vertical>.btn:focus,.btn-group-vertical>.btn:hover,.btn-group>.btn.active,.btn-group>.btn:active,.btn-group>.btn:focus,.btn-group>.btn:hover{z-index:2}.btn-group .btn+.btn,.btn-group .btn+.btn-group,.btn-group .btn-group+.btn,.btn-group .btn-group+.btn-group{margin-left:-1px}.btn-toolbar{margin-left:-5px}.btn-toolbar .btn-group,.btn-toolbar .input-group{float:left}.btn-toolbar>.btn,.btn-toolbar>.btn-group,.btn-toolbar>.input-group{margin-left:5px}.btn-group>.btn:not(:first-child):not(:last-child):not(.dropdown-toggle){border-radius:0}.btn-group>.btn:first-child{margin-left:0}.btn-group>.btn:first-child:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn:last-child:not(:first-child),.btn-group>.dropdown-toggle:not(:first-child){border-top-left-radius:0;border-bottom-left-radius:0}.btn-group>.btn-group{float:left}.btn-group>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group>.btn-group:first-child:not(:last-child)>.btn:last-child,.btn-group>.btn-group:first-child:not(:last-child)>.dropdown-toggle{border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn-group:last-child:not(:first-child)>.btn:first-child{border-top-left-radius:0;border-bottom-left-radius:0}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn-group>.btn+.dropdown-toggle{padding-right:8px;padding-left:8px}.btn-group>.btn-lg+.dropdown-toggle{padding-right:12px;padding-left:12px}.btn-group.open .dropdown-toggle{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,.125);box-shadow:inset 0 3px 5px rgba(0,0,0,.125)}.btn-group.open .dropdown-toggle.btn-link{-webkit-box-shadow:none;box-shadow:none}.btn .caret{margin-left:0}.btn-lg .caret{border-width:5px 5px 0;border-bottom-width:0}.dropup .btn-lg .caret{border-width:0 5px 5px}.btn-group-vertical>.btn,.btn-group-vertical>.btn-group,.btn-group-vertical>.btn-group>.btn{display:block;float:none;width:100%;max-width:100%}.btn-group-vertical>.btn-group>.btn{float:none}.btn-group-vertical>.btn+.btn,.btn-group-vertical>.btn+.btn-group,.btn-group-vertical>.btn-group+.btn,.btn-group-vertical>.btn-group+.btn-group{margin-top:-1px;margin-left:0}.btn-group-vertical>.btn:not(:first-child):not(:last-child){border-radius:0}.btn-group-vertical>.btn:first-child:not(:last-child){border-top-right-radius:4px;border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn:last-child:not(:first-child){border-top-left-radius:0;border-top-right-radius:0;border-bottom-left-radius:4px}.btn-group-vertical>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group-vertical>.btn-group:first-child:not(:last-child)>.btn:last-child,.btn-group-vertical>.btn-group:first-child:not(:last-child)>.dropdown-toggle{border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn-group:last-child:not(:first-child)>.btn:first-child{border-top-left-radius:0;border-top-right-radius:0}.btn-group-justified{display:table;width:100%;table-layout:fixed;border-collapse:separate}.btn-group-justified>.btn,.btn-group-justified>.btn-group{display:table-cell;float:none;width:1%}.btn-group-justified>.btn-group .btn{width:100%}.btn-group-justified>.btn-group .dropdown-menu{left:auto}[data-toggle=buttons]>.btn input[type=checkbox],[data-toggle=buttons]>.btn input[type=radio],[data-toggle=buttons]>.btn-group>.btn input[type=checkbox],[data-toggle=buttons]>.btn-group>.btn input[type=radio]{position:absolute;clip:rect(0,0,0,0);pointer-events:none}.input-group{position:relative;display:table;border-collapse:separate}.input-group[class*=col-]{float:none;padding-right:0;padding-left:0}.input-group .form-control{position:relative;z-index:2;float:left;width:100%;margin-bottom:0}.input-group-lg>.form-control,.input-group-lg>.input-group-addon,.input-group-lg>.input-group-btn>.btn{height:46px;padding:10px 16px;font-size:18px;line-height:1.3333333;border-radius:6px}select.input-group-lg>.form-control,select.input-group-lg>.input-group-addon,select.input-group-lg>.input-group-btn>.btn{height:46px;line-height:46px}select[multiple].input-group-lg>.form-control,select[multiple].input-group-lg>.input-group-addon,select[multiple].input-group-lg>.input-group-btn>.btn,textarea.input-group-lg>.form-control,textarea.input-group-lg>.input-group-addon,textarea.input-group-lg>.input-group-btn>.btn{height:auto}.input-group-sm>.form-control,.input-group-sm>.input-group-addon,.input-group-sm>.input-group-btn>.btn{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.input-group-sm>.form-control,select.input-group-sm>.input-group-addon,select.input-group-sm>.input-group-btn>.btn{height:30px;line-height:30px}select[multiple].input-group-sm>.form-control,select[multiple].input-group-sm>.input-group-addon,select[multiple].input-group-sm>.input-group-btn>.btn,textarea.input-group-sm>.form-control,textarea.input-group-sm>.input-group-addon,textarea.input-group-sm>.input-group-btn>.btn{height:auto}.input-group .form-control,.input-group-addon,.input-group-btn{display:table-cell}.input-group .form-control:not(:first-child):not(:last-child),.input-group-addon:not(:first-child):not(:last-child),.input-group-btn:not(:first-child):not(:last-child){border-radius:0}.input-group-addon,.input-group-btn{width:1%;white-space:nowrap;vertical-align:middle}.input-group-addon{padding:6px 12px;font-size:14px;font-weight:400;line-height:1;color:#555;text-align:center;background-color:#eee;border:1px solid #ccc;border-radius:4px}.input-group-addon.input-sm{padding:5px 10px;font-size:12px;border-radius:3px}.input-group-addon.input-lg{padding:10px 16px;font-size:18px;border-radius:6px}.input-group-addon input[type=checkbox],.input-group-addon input[type=radio]{margin-top:0}.input-group .form-control:first-child,.input-group-addon:first-child,.input-group-btn:first-child>.btn,.input-group-btn:first-child>.btn-group>.btn,.input-group-btn:first-child>.dropdown-toggle,.input-group-btn:last-child>.btn-group:not(:last-child)>.btn,.input-group-btn:last-child>.btn:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.input-group-addon:first-child{border-right:0}.input-group .form-control:last-child,.input-group-addon:last-child,.input-group-btn:first-child>.btn-group:not(:first-child)>.btn,.input-group-btn:first-child>.btn:not(:first-child),.input-group-btn:last-child>.btn,.input-group-btn:last-child>.btn-group>.btn,.input-group-btn:last-child>.dropdown-toggle{border-top-left-radius:0;border-bottom-left-radius:0}.input-group-addon:last-child{border-left:0}.input-group-btn{position:relative;font-size:0;white-space:nowrap}.input-group-btn>.btn{position:relative}.input-group-btn>.btn+.btn{margin-left:-1px}.input-group-btn>.btn:active,.input-group-btn>.btn:focus,.input-group-btn>.btn:hover{z-index:2}.input-group-btn:first-child>.btn,.input-group-btn:first-child>.btn-group{margin-right:-1px}.input-group-btn:last-child>.btn,.input-group-btn:last-child>.btn-group{margin-left:-1px}.nav{padding-left:0;margin-bottom:0;list-style:none}.nav>li{position:relative;display:block}.nav>li>a{position:relative;display:block;padding:10px 15px}.nav>li>a:focus,.nav>li>a:hover{text-decoration:none;background-color:#eee}.nav>li.disabled>a{color:#777}.nav>li.disabled>a:focus,.nav>li.disabled>a:hover{color:#777;text-decoration:none;cursor:not-allowed;background-color:transparent}.nav .open>a,.nav .open>a:focus,.nav .open>a:hover{background-color:#eee;border-color:#337ab7}.nav .nav-divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.nav>li>a>img{max-width:none}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs>li{float:left;margin-bottom:-1px}.nav-tabs>li>a{margin-right:2px;line-height:1.42857143;border:1px solid transparent;border-radius:4px 4px 0 0}.nav-tabs>li>a:hover{border-color:#eee #eee #ddd}.nav-tabs>li.active>a,.nav-tabs>li.active>a:focus,.nav-tabs>li.active>a:hover{color:#555;cursor:default;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent}.nav-tabs.nav-justified{width:100%;border-bottom:0}.nav-tabs.nav-justified>li{float:none}.nav-tabs.nav-justified>li>a{margin-bottom:5px;text-align:center}.nav-tabs.nav-justified>.dropdown .dropdown-menu{top:auto;left:auto}@media (min-width:768px){.nav-tabs.nav-justified>li{display:table-cell;width:1%}.nav-tabs.nav-justified>li>a{margin-bottom:0}}.nav-tabs.nav-justified>li>a{margin-right:0;border-radius:4px}.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:focus,.nav-tabs.nav-justified>.active>a:hover{border:1px solid #ddd}@media (min-width:768px){.nav-tabs.nav-justified>li>a{border-bottom:1px solid #ddd;border-radius:4px 4px 0 0}.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:focus,.nav-tabs.nav-justified>.active>a:hover{border-bottom-color:#fff}}.nav-pills>li{float:left}.nav-pills>li>a{border-radius:4px}.nav-pills>li+li{margin-left:2px}.nav-pills>li.active>a,.nav-pills>li.active>a:focus,.nav-pills>li.active>a:hover{color:#fff;background-color:#337ab7}.nav-stacked>li{float:none}.nav-stacked>li+li{margin-top:2px;margin-left:0}.nav-justified{width:100%}.nav-justified>li{float:none}.nav-justified>li>a{margin-bottom:5px;text-align:center}.nav-justified>.dropdown .dropdown-menu{top:auto;left:auto}@media (min-width:768px){.nav-justified>li{display:table-cell;width:1%}.nav-justified>li>a{margin-bottom:0}}.nav-tabs-justified{border-bottom:0}.nav-tabs-justified>li>a{margin-right:0;border-radius:4px}.nav-tabs-justified>.active>a,.nav-tabs-justified>.active>a:focus,.nav-tabs-justified>.active>a:hover{border:1px solid #ddd}@media (min-width:768px){.nav-tabs-justified>li>a{border-bottom:1px solid #ddd;border-radius:4px 4px 0 0}.nav-tabs-justified>.active>a,.nav-tabs-justified>.active>a:focus,.nav-tabs-justified>.active>a:hover{border-bottom-color:#fff}}.tab-content>.tab-pane{display:none}.tab-content>.active{display:block}.nav-tabs .dropdown-menu{margin-top:-1px;border-top-left-radius:0;border-top-right-radius:0}.navbar{position:relative;min-height:50px;margin-bottom:20px;border:1px solid transparent}@media (min-width:768px){.navbar{border-radius:4px}}@media (min-width:768px){.navbar-header{float:left}}.navbar-collapse{padding-right:15px;padding-left:15px;overflow-x:visible;-webkit-overflow-scrolling:touch;border-top:1px solid transparent;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.1);box-shadow:inset 0 1px 0 rgba(255,255,255,.1)}.navbar-collapse.in{overflow-y:auto}@media (min-width:768px){.navbar-collapse{width:auto;border-top:0;-webkit-box-shadow:none;box-shadow:none}.navbar-collapse.collapse{display:block!important;height:auto!important;padding-bottom:0;overflow:visible!important}.navbar-collapse.in{overflow-y:visible}.navbar-fixed-bottom .navbar-collapse,.navbar-fixed-top .navbar-collapse,.navbar-static-top .navbar-collapse{padding-right:0;padding-left:0}}.navbar-fixed-bottom .navbar-collapse,.navbar-fixed-top .navbar-collapse{max-height:340px}@media (max-device-width:480px)and (orientation:landscape){.navbar-fixed-bottom .navbar-collapse,.navbar-fixed-top .navbar-collapse{max-height:200px}}.container-fluid>.navbar-collapse,.container-fluid>.navbar-header,.container>.navbar-collapse,.container>.navbar-header{margin-right:-15px;margin-left:-15px}@media (min-width:768px){.container-fluid>.navbar-collapse,.container-fluid>.navbar-header,.container>.navbar-collapse,.container>.navbar-header{margin-right:0;margin-left:0}}.navbar-static-top{z-index:1000;border-width:0 0 1px}@media (min-width:768px){.navbar-static-top{border-radius:0}}.navbar-fixed-bottom,.navbar-fixed-top{position:fixed;right:0;left:0;z-index:1030}@media (min-width:768px){.navbar-fixed-bottom,.navbar-fixed-top{border-radius:0}}.navbar-fixed-top{top:0;border-width:0 0 1px}.navbar-fixed-bottom{bottom:0;margin-bottom:0;border-width:1px 0 0}.navbar-brand{float:left;height:50px;padding:15px;font-size:18px;line-height:20px}.navbar-brand:focus,.navbar-brand:hover{text-decoration:none}.navbar-brand>img{display:block}@media (min-width:768px){.navbar>.container .navbar-brand,.navbar>.container-fluid .navbar-brand{margin-left:-15px}}.navbar-toggle{position:relative;float:right;padding:9px 10px;margin-top:8px;margin-right:15px;margin-bottom:8px;background-color:transparent;background-image:none;border:1px solid transparent;border-radius:4px}.navbar-toggle:focus{outline:0}.navbar-toggle .icon-bar{display:block;width:22px;height:2px;border-radius:1px}.navbar-toggle .icon-bar+.icon-bar{margin-top:4px}@media (min-width:768px){.navbar-toggle{display:none}}.navbar-nav{margin:7.5px -15px}.navbar-nav>li>a{padding-top:10px;padding-bottom:10px;line-height:20px}@media (max-width:767px){.navbar-nav .open .dropdown-menu{position:static;float:none;width:auto;margin-top:0;background-color:transparent;border:0;-webkit-box-shadow:none;box-shadow:none}.navbar-nav .open .dropdown-menu .dropdown-header,.navbar-nav .open .dropdown-menu>li>a{padding:5px 15px 5px 25px}.navbar-nav .open .dropdown-menu>li>a{line-height:20px}.navbar-nav .open .dropdown-menu>li>a:focus,.navbar-nav .open .dropdown-menu>li>a:hover{background-image:none}}@media (min-width:768px){.navbar-nav{float:left;margin:0}.navbar-nav>li{float:left}.navbar-nav>li>a{padding-top:15px;padding-bottom:15px}}.navbar-form{padding:10px 15px;margin-top:8px;margin-right:-15px;margin-bottom:8px;margin-left:-15px;border-top:1px solid transparent;border-bottom:1px solid transparent;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.1),0 1px 0 rgba(255,255,255,.1);box-shadow:inset 0 1px 0 rgba(255,255,255,.1),0 1px 0 rgba(255,255,255,.1)}@media (min-width:768px){.navbar-form .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.navbar-form .form-control{display:inline-block;width:auto;vertical-align:middle}.navbar-form .form-control-static{display:inline-block}.navbar-form .input-group{display:inline-table;vertical-align:middle}.navbar-form .input-group .form-control,.navbar-form .input-group .input-group-addon,.navbar-form .input-group .input-group-btn{width:auto}.navbar-form .input-group>.form-control{width:100%}.navbar-form .control-label{margin-bottom:0;vertical-align:middle}.navbar-form .checkbox,.navbar-form .radio{display:inline-block;margin-top:0;margin-bottom:0;vertical-align:middle}.navbar-form .checkbox label,.navbar-form .radio label{padding-left:0}.navbar-form .checkbox input[type=checkbox],.navbar-form .radio input[type=radio]{position:relative;margin-left:0}.navbar-form .has-feedback .form-control-feedback{top:0}}@media (max-width:767px){.navbar-form .form-group{margin-bottom:5px}.navbar-form .form-group:last-child{margin-bottom:0}}@media (min-width:768px){.navbar-form{width:auto;padding-top:0;padding-bottom:0;margin-right:0;margin-left:0;border:0;-webkit-box-shadow:none;box-shadow:none}}.navbar-nav>li>.dropdown-menu{margin-top:0;border-top-left-radius:0;border-top-right-radius:0}.navbar-fixed-bottom .navbar-nav>li>.dropdown-menu{margin-bottom:0;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-right-radius:0;border-bottom-left-radius:0}.navbar-btn{margin-top:8px;margin-bottom:8px}.navbar-btn.btn-sm{margin-top:10px;margin-bottom:10px}.navbar-btn.btn-xs{margin-top:14px;margin-bottom:14px}.navbar-text{margin-top:15px;margin-bottom:15px}@media (min-width:768px){.navbar-text{float:left;margin-right:15px;margin-left:15px}}@media (min-width:768px){.navbar-left{float:left!important}.navbar-right{float:right!important;margin-right:-15px}.navbar-right~.navbar-right{margin-right:0}}.navbar-default{background-color:#f8f8f8;border-color:#e7e7e7}.navbar-default .navbar-brand{color:#777}.navbar-default .navbar-brand:focus,.navbar-default .navbar-brand:hover{color:#5e5e5e;background-color:transparent}.navbar-default .navbar-nav>li>a,.navbar-default .navbar-text{color:#777}.navbar-default .navbar-nav>li>a:focus,.navbar-default .navbar-nav>li>a:hover{color:#333;background-color:transparent}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:focus,.navbar-default .navbar-nav>.active>a:hover{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav>.disabled>a,.navbar-default .navbar-nav>.disabled>a:focus,.navbar-default .navbar-nav>.disabled>a:hover{color:#ccc;background-color:transparent}.navbar-default .navbar-toggle{border-color:#ddd}.navbar-default .navbar-toggle:focus,.navbar-default .navbar-toggle:hover{background-color:#ddd}.navbar-default .navbar-toggle .icon-bar{background-color:#888}.navbar-default .navbar-collapse,.navbar-default .navbar-form{border-color:#e7e7e7}.navbar-default .navbar-nav>.open>a,.navbar-default .navbar-nav>.open>a:focus,.navbar-default .navbar-nav>.open>a:hover{color:#555;background-color:#e7e7e7}@media (max-width:767px){.navbar-default .navbar-nav .open .dropdown-menu>li>a{color:#777}.navbar-default .navbar-nav .open .dropdown-menu>li>a:focus,.navbar-default .navbar-nav .open .dropdown-menu>li>a:hover{color:#333;background-color:transparent}.navbar-default .navbar-nav .open .dropdown-menu>.active>a,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:focus,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:hover{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:focus,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:hover{color:#ccc;background-color:transparent}}.navbar-default .navbar-link{color:#777}.navbar-default .navbar-link:hover{color:#333}.navbar-default .btn-link{color:#777}.navbar-default .btn-link:focus,.navbar-default .btn-link:hover{color:#333}.navbar-default .btn-link[disabled]:focus,.navbar-default .btn-link[disabled]:hover,fieldset[disabled] .navbar-default .btn-link:focus,fieldset[disabled] .navbar-default .btn-link:hover{color:#ccc}.navbar-inverse{background-color:#222;border-color:#080808}.navbar-inverse .navbar-brand{color:#9d9d9d}.navbar-inverse .navbar-brand:focus,.navbar-inverse .navbar-brand:hover{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav>li>a,.navbar-inverse .navbar-text{color:#9d9d9d}.navbar-inverse .navbar-nav>li>a:focus,.navbar-inverse .navbar-nav>li>a:hover{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav>.active>a,.navbar-inverse .navbar-nav>.active>a:focus,.navbar-inverse .navbar-nav>.active>a:hover{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav>.disabled>a,.navbar-inverse .navbar-nav>.disabled>a:focus,.navbar-inverse .navbar-nav>.disabled>a:hover{color:#444;background-color:transparent}.navbar-inverse .navbar-toggle{border-color:#333}.navbar-inverse .navbar-toggle:focus,.navbar-inverse .navbar-toggle:hover{background-color:#333}.navbar-inverse .navbar-toggle .icon-bar{background-color:#fff}.navbar-inverse .navbar-collapse,.navbar-inverse .navbar-form{border-color:#101010}.navbar-inverse .navbar-nav>.open>a,.navbar-inverse .navbar-nav>.open>a:focus,.navbar-inverse .navbar-nav>.open>a:hover{color:#fff;background-color:#080808}@media (max-width:767px){.navbar-inverse .navbar-nav .open .dropdown-menu>.dropdown-header{border-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu .divider{background-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a{color:#9d9d9d}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:focus,.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:hover{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:focus,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:hover{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:focus,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:hover{color:#444;background-color:transparent}}.navbar-inverse .navbar-link{color:#9d9d9d}.navbar-inverse .navbar-link:hover{color:#fff}.navbar-inverse .btn-link{color:#9d9d9d}.navbar-inverse .btn-link:focus,.navbar-inverse .btn-link:hover{color:#fff}.navbar-inverse .btn-link[disabled]:focus,.navbar-inverse .btn-link[disabled]:hover,fieldset[disabled] .navbar-inverse .btn-link:focus,fieldset[disabled] .navbar-inverse .btn-link:hover{color:#444}.breadcrumb{padding:8px 15px;margin-bottom:20px;list-style:none;background-color:#f5f5f5;border-radius:4px}.breadcrumb>li{display:inline-block}.breadcrumb>li+li:before{padding:0 5px;color:#ccc;content:"/\00a0"}.breadcrumb>.active{color:#777}.pagination{display:inline-block;padding-left:0;margin:20px 0;border-radius:4px}.pagination>li{display:inline}.pagination>li>a,.pagination>li>span{position:relative;float:left;padding:6px 12px;margin-left:-1px;line-height:1.42857143;color:#337ab7;text-decoration:none;background-color:#fff;border:1px solid #ddd}.pagination>li:first-child>a,.pagination>li:first-child>span{margin-left:0;border-top-left-radius:4px;border-bottom-left-radius:4px}.pagination>li:last-child>a,.pagination>li:last-child>span{border-top-right-radius:4px;border-bottom-right-radius:4px}.pagination>li>a:focus,.pagination>li>a:hover,.pagination>li>span:focus,.pagination>li>span:hover{color:#23527c;background-color:#eee;border-color:#ddd}.pagination>.active>a,.pagination>.active>a:focus,.pagination>.active>a:hover,.pagination>.active>span,.pagination>.active>span:focus,.pagination>.active>span:hover{z-index:2;color:#fff;cursor:default;background-color:#337ab7;border-color:#337ab7}.pagination>.disabled>a,.pagination>.disabled>a:focus,.pagination>.disabled>a:hover,.pagination>.disabled>span,.pagination>.disabled>span:focus,.pagination>.disabled>span:hover{color:#777;cursor:not-allowed;background-color:#fff;border-color:#ddd}.pagination-lg>li>a,.pagination-lg>li>span{padding:10px 16px;font-size:18px}.pagination-lg>li:first-child>a,.pagination-lg>li:first-child>span{border-top-left-radius:6px;border-bottom-left-radius:6px}.pagination-lg>li:last-child>a,.pagination-lg>li:last-child>span{border-top-right-radius:6px;border-bottom-right-radius:6px}.pagination-sm>li>a,.pagination-sm>li>span{padding:5px 10px;font-size:12px}.pagination-sm>li:first-child>a,.pagination-sm>li:first-child>span{border-top-left-radius:3px;border-bottom-left-radius:3px}.pagination-sm>li:last-child>a,.pagination-sm>li:last-child>span{border-top-right-radius:3px;border-bottom-right-radius:3px}.pager{padding-left:0;margin:20px 0;text-align:center;list-style:none}.pager li{display:inline}.pager li>a,.pager li>span{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;border-radius:15px}.pager li>a:focus,.pager li>a:hover{text-decoration:none;background-color:#eee}.pager .next>a,.pager .next>span{float:right}.pager .previous>a,.pager .previous>span{float:left}.pager .disabled>a,.pager .disabled>a:focus,.pager .disabled>a:hover,.pager .disabled>span{color:#777;cursor:not-allowed;background-color:#fff}.label{display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em}a.label:focus,a.label:hover{color:#fff;text-decoration:none;cursor:pointer}.label:empty{display:none}.btn .label{position:relative;top:-1px}.label-default{background-color:#777}.label-default[href]:focus,.label-default[href]:hover{background-color:#5e5e5e}.label-primary{background-color:#337ab7}.label-primary[href]:focus,.label-primary[href]:hover{background-color:#286090}.label-success{background-color:#5cb85c}.label-success[href]:focus,.label-success[href]:hover{background-color:#449d44}.label-info{background-color:#5bc0de}.label-info[href]:focus,.label-info[href]:hover{background-color:#31b0d5}.label-warning{background-color:#f0ad4e}.label-warning[href]:focus,.label-warning[href]:hover{background-color:#ec971f}.label-danger{background-color:#d9534f}.label-danger[href]:focus,.label-danger[href]:hover{background-color:#c9302c}.badge{display:inline-block;min-width:10px;padding:3px 7px;font-size:12px;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;background-color:#777;border-radius:10px}.badge:empty{display:none}.btn .badge{position:relative;top:-1px}.btn-group-xs>.btn .badge,.btn-xs .badge{top:0;padding:1px 5px}a.badge:focus,a.badge:hover{color:#fff;text-decoration:none;cursor:pointer}.list-group-item.active>.badge,.nav-pills>.active>a>.badge{color:#337ab7;background-color:#fff}.list-group-item>.badge{float:right}.list-group-item>.badge+.badge{margin-right:5px}.nav-pills>li>a>.badge{margin-left:3px}.jumbotron{padding:30px 15px;margin-bottom:30px;color:inherit;background-color:#eee}.jumbotron .h1,.jumbotron h1{color:inherit}.jumbotron p{margin-bottom:15px;font-size:21px;font-weight:200}.jumbotron>hr{border-top-color:#d5d5d5}.container .jumbotron,.container-fluid .jumbotron{border-radius:6px}.jumbotron .container{max-width:100%}@media screen and (min-width:768px){.jumbotron{padding:48px 0}.container .jumbotron,.container-fluid .jumbotron{padding-right:60px;padding-left:60px}.jumbotron .h1,.jumbotron h1{font-size:63px}}.thumbnail{display:block;padding:4px;margin-bottom:20px;line-height:1.42857143;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:border .2s ease-in-out;-o-transition:border .2s ease-in-out;transition:border .2s ease-in-out}.thumbnail a>img,.thumbnail>img{margin-right:auto;margin-left:auto}a.thumbnail.active,a.thumbnail:focus,a.thumbnail:hover{border-color:#337ab7}.thumbnail .caption{padding:9px;color:#333}.alert{padding:15px;margin-bottom:20px;border:1px solid transparent;border-radius:4px}.alert h4{margin-top:0;color:inherit}.alert .alert-link{font-weight:700}.alert>p,.alert>ul{margin-bottom:0}.alert>p+p{margin-top:5px}.alert-dismissable,.alert-dismissible{padding-right:35px}.alert-dismissable .close,.alert-dismissible .close{position:relative;top:-2px;right:-21px;color:inherit}.alert-success{color:#3c763d;background-color:#dff0d8;border-color:#d6e9c6}.alert-success hr{border-top-color:#c9e2b3}.alert-success .alert-link{color:#2b542c}.alert-info{color:#31708f;background-color:#d9edf7;border-color:#bce8f1}.alert-info hr{border-top-color:#a6e1ec}.alert-info .alert-link{color:#245269}.alert-warning{color:#8a6d3b;background-color:#fcf8e3;border-color:#faebcc}.alert-warning hr{border-top-color:#f7e1b5}.alert-warning .alert-link{color:#66512c}.alert-danger{color:#a94442;background-color:#f2dede;border-color:#ebccd1}.alert-danger hr{border-top-color:#e4b9c0}.alert-danger .alert-link{color:#843534}@-webkit-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-o-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}.progress{height:20px;margin-bottom:20px;overflow:hidden;background-color:#f5f5f5;border-radius:4px;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.1);box-shadow:inset 0 1px 2px rgba(0,0,0,.1)}.progress-bar{float:left;width:0;height:100%;font-size:12px;line-height:20px;color:#fff;text-align:center;background-color:#337ab7;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,.15);-webkit-transition:width .6s ease;-o-transition:width .6s ease;transition:width .6s ease}.progress-bar-striped,.progress-striped .progress-bar{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);-webkit-background-size:40px 40px;background-size:40px 40px}.progress-bar.active,.progress.active .progress-bar{-webkit-animation:progress-bar-stripes 2s linear infinite;-o-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-bar-success{background-color:#5cb85c}.progress-striped .progress-bar-success{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.progress-bar-info{background-color:#5bc0de}.progress-striped .progress-bar-info{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.progress-bar-warning{background-color:#f0ad4e}.progress-striped .progress-bar-warning{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.progress-bar-danger{background-color:#d9534f}.progress-striped .progress-bar-danger{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.media{margin-top:15px}.media:first-child{margin-top:0}.media,.media-body{overflow:hidden;zoom:1}.media-body{width:10000px}.media-object{display:block}.media-right,.media>.pull-right{padding-left:10px}.media-left,.media>.pull-left{padding-right:10px}.media-body,.media-left,.media-right{display:table-cell;vertical-align:top}.media-middle{vertical-align:middle}.media-bottom{vertical-align:bottom}.media-heading{margin-top:0;margin-bottom:5px}.media-list{padding-left:0;list-style:none}.list-group{padding-left:0;margin-bottom:20px}.list-group-item{position:relative;display:block;padding:10px 15px;margin-bottom:-1px;background-color:#fff;border:1px solid #ddd}.list-group-item:first-child{border-top-left-radius:4px;border-top-right-radius:4px}.list-group-item:last-child{margin-bottom:0;border-bottom-right-radius:4px;border-bottom-left-radius:4px}a.list-group-item{color:#555}a.list-group-item .list-group-item-heading{color:#333}a.list-group-item:focus,a.list-group-item:hover{color:#555;text-decoration:none;background-color:#f5f5f5}.list-group-item.disabled,.list-group-item.disabled:focus,.list-group-item.disabled:hover{color:#777;cursor:not-allowed;background-color:#eee}.list-group-item.disabled .list-group-item-heading,.list-group-item.disabled:focus .list-group-item-heading,.list-group-item.disabled:hover .list-group-item-heading{color:inherit}.list-group-item.disabled .list-group-item-text,.list-group-item.disabled:focus .list-group-item-text,.list-group-item.disabled:hover .list-group-item-text{color:#777}.list-group-item.active,.list-group-item.active:focus,.list-group-item.active:hover{z-index:2;color:#fff;background-color:#337ab7;border-color:#337ab7}.list-group-item.active .list-group-item-heading,.list-group-item.active .list-group-item-heading>.small,.list-group-item.active .list-group-item-heading>small,.list-group-item.active:focus .list-group-item-heading,.list-group-item.active:focus .list-group-item-heading>.small,.list-group-item.active:focus .list-group-item-heading>small,.list-group-item.active:hover .list-group-item-heading,.list-group-item.active:hover .list-group-item-heading>.small,.list-group-item.active:hover .list-group-item-heading>small{color:inherit}.list-group-item.active .list-group-item-text,.list-group-item.active:focus .list-group-item-text,.list-group-item.active:hover .list-group-item-text{color:#c7ddef}.list-group-item-success{color:#3c763d;background-color:#dff0d8}a.list-group-item-success{color:#3c763d}a.list-group-item-success .list-group-item-heading{color:inherit}a.list-group-item-success:focus,a.list-group-item-success:hover{color:#3c763d;background-color:#d0e9c6}a.list-group-item-success.active,a.list-group-item-success.active:focus,a.list-group-item-success.active:hover{color:#fff;background-color:#3c763d;border-color:#3c763d}.list-group-item-info{color:#31708f;background-color:#d9edf7}a.list-group-item-info{color:#31708f}a.list-group-item-info .list-group-item-heading{color:inherit}a.list-group-item-info:focus,a.list-group-item-info:hover{color:#31708f;background-color:#c4e3f3}a.list-group-item-info.active,a.list-group-item-info.active:focus,a.list-group-item-info.active:hover{color:#fff;background-color:#31708f;border-color:#31708f}.list-group-item-warning{color:#8a6d3b;background-color:#fcf8e3}a.list-group-item-warning{color:#8a6d3b}a.list-group-item-warning .list-group-item-heading{color:inherit}a.list-group-item-warning:focus,a.list-group-item-warning:hover{color:#8a6d3b;background-color:#faf2cc}a.list-group-item-warning.active,a.list-group-item-warning.active:focus,a.list-group-item-warning.active:hover{color:#fff;background-color:#8a6d3b;border-color:#8a6d3b}.list-group-item-danger{color:#a94442;background-color:#f2dede}a.list-group-item-danger{color:#a94442}a.list-group-item-danger .list-group-item-heading{color:inherit}a.list-group-item-danger:focus,a.list-group-item-danger:hover{color:#a94442;background-color:#ebcccc}a.list-group-item-danger.active,a.list-group-item-danger.active:focus,a.list-group-item-danger.active:hover{color:#fff;background-color:#a94442;border-color:#a94442}.list-group-item-heading{margin-top:0;margin-bottom:5px}.list-group-item-text{margin-bottom:0;line-height:1.3}.panel{margin-bottom:20px;background-color:#fff;border:1px solid transparent;border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.05);box-shadow:0 1px 1px rgba(0,0,0,.05)}.panel-body{padding:15px}.panel-heading{padding:10px 15px;border-bottom:1px solid transparent;border-top-left-radius:3px;border-top-right-radius:3px}.panel-heading>.dropdown .dropdown-toggle{color:inherit}.panel-title{margin-top:0;margin-bottom:0;font-size:16px;color:inherit}.panel-title>.small,.panel-title>.small>a,.panel-title>a,.panel-title>small,.panel-title>small>a{color:inherit}.panel-footer{padding:10px 15px;background-color:#f5f5f5;border-top:1px solid #ddd;border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel>.list-group,.panel>.panel-collapse>.list-group{margin-bottom:0}.panel>.list-group .list-group-item,.panel>.panel-collapse>.list-group .list-group-item{border-width:1px 0;border-radius:0}.panel>.list-group:first-child .list-group-item:first-child,.panel>.panel-collapse>.list-group:first-child .list-group-item:first-child{border-top:0;border-top-left-radius:3px;border-top-right-radius:3px}.panel>.list-group:last-child .list-group-item:last-child,.panel>.panel-collapse>.list-group:last-child .list-group-item:last-child{border-bottom:0;border-bottom-right-radius:3px;border-bottom-left-radius:3px}.list-group+.panel-footer,.panel-heading+.list-group .list-group-item:first-child{border-top-width:0}.panel>.panel-collapse>.table,.panel>.table,.panel>.table-responsive>.table{margin-bottom:0}.panel>.panel-collapse>.table caption,.panel>.table caption,.panel>.table-responsive>.table caption{padding-right:15px;padding-left:15px}.panel>.table-responsive:first-child>.table:first-child,.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child,.panel>.table:first-child,.panel>.table:first-child>tbody:first-child>tr:first-child,.panel>.table:first-child>thead:first-child>tr:first-child{border-top-left-radius:3px;border-top-right-radius:3px}.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child td:first-child,.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child th:first-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child td:first-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child th:first-child,.panel>.table:first-child>tbody:first-child>tr:first-child td:first-child,.panel>.table:first-child>tbody:first-child>tr:first-child th:first-child,.panel>.table:first-child>thead:first-child>tr:first-child td:first-child,.panel>.table:first-child>thead:first-child>tr:first-child th:first-child{border-top-left-radius:3px}.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child td:last-child,.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child th:last-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child td:last-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child th:last-child,.panel>.table:first-child>tbody:first-child>tr:first-child td:last-child,.panel>.table:first-child>tbody:first-child>tr:first-child th:last-child,.panel>.table:first-child>thead:first-child>tr:first-child td:last-child,.panel>.table:first-child>thead:first-child>tr:first-child th:last-child{border-top-right-radius:3px}.panel>.table-responsive:last-child>.table:last-child,.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child,.panel>.table:last-child,.panel>.table:last-child>tbody:last-child>tr:last-child,.panel>.table:last-child>tfoot:last-child>tr:last-child{border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child td:first-child,.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child th:first-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child td:first-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child th:first-child,.panel>.table:last-child>tbody:last-child>tr:last-child td:first-child,.panel>.table:last-child>tbody:last-child>tr:last-child th:first-child,.panel>.table:last-child>tfoot:last-child>tr:last-child td:first-child,.panel>.table:last-child>tfoot:last-child>tr:last-child th:first-child{border-bottom-left-radius:3px}.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child td:last-child,.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child th:last-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child td:last-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child th:last-child,.panel>.table:last-child>tbody:last-child>tr:last-child td:last-child,.panel>.table:last-child>tbody:last-child>tr:last-child th:last-child,.panel>.table:last-child>tfoot:last-child>tr:last-child td:last-child,.panel>.table:last-child>tfoot:last-child>tr:last-child th:last-child{border-bottom-right-radius:3px}.panel>.panel-body+.table,.panel>.panel-body+.table-responsive,.panel>.table+.panel-body,.panel>.table-responsive+.panel-body{border-top:1px solid #ddd}.panel>.table>tbody:first-child>tr:first-child td,.panel>.table>tbody:first-child>tr:first-child th{border-top:0}.panel>.table-bordered,.panel>.table-responsive>.table-bordered{border:0}.panel>.table-bordered>tbody>tr>td:first-child,.panel>.table-bordered>tbody>tr>th:first-child,.panel>.table-bordered>tfoot>tr>td:first-child,.panel>.table-bordered>tfoot>tr>th:first-child,.panel>.table-bordered>thead>tr>td:first-child,.panel>.table-bordered>thead>tr>th:first-child,.panel>.table-responsive>.table-bordered>tbody>tr>td:first-child,.panel>.table-responsive>.table-bordered>tbody>tr>th:first-child,.panel>.table-responsive>.table-bordered>tfoot>tr>td:first-child,.panel>.table-responsive>.table-bordered>tfoot>tr>th:first-child,.panel>.table-responsive>.table-bordered>thead>tr>td:first-child,.panel>.table-responsive>.table-bordered>thead>tr>th:first-child{border-left:0}.panel>.table-bordered>tbody>tr>td:last-child,.panel>.table-bordered>tbody>tr>th:last-child,.panel>.table-bordered>tfoot>tr>td:last-child,.panel>.table-bordered>tfoot>tr>th:last-child,.panel>.table-bordered>thead>tr>td:last-child,.panel>.table-bordered>thead>tr>th:last-child,.panel>.table-responsive>.table-bordered>tbody>tr>td:last-child,.panel>.table-responsive>.table-bordered>tbody>tr>th:last-child,.panel>.table-responsive>.table-bordered>tfoot>tr>td:last-child,.panel>.table-responsive>.table-bordered>tfoot>tr>th:last-child,.panel>.table-responsive>.table-bordered>thead>tr>td:last-child,.panel>.table-responsive>.table-bordered>thead>tr>th:last-child{border-right:0}.panel>.table-bordered>tbody>tr:first-child>td,.panel>.table-bordered>tbody>tr:first-child>th,.panel>.table-bordered>tbody>tr:last-child>td,.panel>.table-bordered>tbody>tr:last-child>th,.panel>.table-bordered>tfoot>tr:last-child>td,.panel>.table-bordered>tfoot>tr:last-child>th,.panel>.table-bordered>thead>tr:first-child>td,.panel>.table-bordered>thead>tr:first-child>th,.panel>.table-responsive>.table-bordered>tbody>tr:first-child>td,.panel>.table-responsive>.table-bordered>tbody>tr:first-child>th,.panel>.table-responsive>.table-bordered>tbody>tr:last-child>td,.panel>.table-responsive>.table-bordered>tbody>tr:last-child>th,.panel>.table-responsive>.table-bordered>tfoot>tr:last-child>td,.panel>.table-responsive>.table-bordered>tfoot>tr:last-child>th,.panel>.table-responsive>.table-bordered>thead>tr:first-child>td,.panel>.table-responsive>.table-bordered>thead>tr:first-child>th{border-bottom:0}.panel>.table-responsive{margin-bottom:0;border:0}.panel-group{margin-bottom:20px}.panel-group .panel{margin-bottom:0;border-radius:4px}.panel-group .panel+.panel{margin-top:5px}.panel-group .panel-heading{border-bottom:0}.panel-group .panel-heading+.panel-collapse>.list-group,.panel-group .panel-heading+.panel-collapse>.panel-body{border-top:1px solid #ddd}.panel-group .panel-footer{border-top:0}.panel-group .panel-footer+.panel-collapse .panel-body{border-bottom:1px solid #ddd}.panel-default{border-color:#ddd}.panel-default>.panel-heading{color:#333;background-color:#f5f5f5;border-color:#ddd}.panel-default>.panel-heading+.panel-collapse>.panel-body{border-top-color:#ddd}.panel-default>.panel-heading .badge{color:#f5f5f5;background-color:#333}.panel-default>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#ddd}.panel-primary{border-color:#337ab7}.panel-primary>.panel-heading{color:#fff;background-color:#337ab7;border-color:#337ab7}.panel-primary>.panel-heading+.panel-collapse>.panel-body{border-top-color:#337ab7}.panel-primary>.panel-heading .badge{color:#337ab7;background-color:#fff}.panel-primary>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#337ab7}.panel-success{border-color:#d6e9c6}.panel-success>.panel-heading{color:#3c763d;background-color:#dff0d8;border-color:#d6e9c6}.panel-success>.panel-heading+.panel-collapse>.panel-body{border-top-color:#d6e9c6}.panel-success>.panel-heading .badge{color:#dff0d8;background-color:#3c763d}.panel-success>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#d6e9c6}.panel-info{border-color:#bce8f1}.panel-info>.panel-heading{color:#31708f;background-color:#d9edf7;border-color:#bce8f1}.panel-info>.panel-heading+.panel-collapse>.panel-body{border-top-color:#bce8f1}.panel-info>.panel-heading .badge{color:#d9edf7;background-color:#31708f}.panel-info>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#bce8f1}.panel-warning{border-color:#faebcc}.panel-warning>.panel-heading{color:#8a6d3b;background-color:#fcf8e3;border-color:#faebcc}.panel-warning>.panel-heading+.panel-collapse>.panel-body{border-top-color:#faebcc}.panel-warning>.panel-heading .badge{color:#fcf8e3;background-color:#8a6d3b}.panel-warning>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#faebcc}.panel-danger{border-color:#ebccd1}.panel-danger>.panel-heading{color:#a94442;background-color:#f2dede;border-color:#ebccd1}.panel-danger>.panel-heading+.panel-collapse>.panel-body{border-top-color:#ebccd1}.panel-danger>.panel-heading .badge{color:#f2dede;background-color:#a94442}.panel-danger>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#ebccd1}.embed-responsive{position:relative;display:block;height:0;padding:0;overflow:hidden}.embed-responsive .embed-responsive-item,.embed-responsive embed,.embed-responsive iframe,.embed-responsive object,.embed-responsive video{position:absolute;top:0;bottom:0;left:0;width:100%;height:100%;border:0}.embed-responsive-16by9{padding-bottom:56.25%}.embed-responsive-4by3{padding-bottom:75%}.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #e3e3e3;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.05);box-shadow:inset 0 1px 1px rgba(0,0,0,.05)}.well blockquote{border-color:#ddd;border-color:rgba(0,0,0,.15)}.well-lg{padding:24px;border-radius:6px}.well-sm{padding:9px;border-radius:3px}.close{float:right;font-size:21px;font-weight:700;line-height:1;color:#000;text-shadow:0 1px 0 #fff;filter:alpha(opacity=20);opacity:.2}.close:focus,.close:hover{color:#000;text-decoration:none;cursor:pointer;filter:alpha(opacity=50);opacity:.5}button.close{-webkit-appearance:none;padding:0;cursor:pointer;background:0 0;border:0}.modal-open{overflow:hidden}.modal{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1050;display:none;overflow:hidden;-webkit-overflow-scrolling:touch;outline:0}.modal.fade .modal-dialog{-webkit-transition:-webkit-transform .3s ease-out;-o-transition:-o-transform .3s ease-out;transition:transform .3s ease-out;-webkit-transform:translate(0,-25%);-ms-transform:translate(0,-25%);-o-transform:translate(0,-25%);transform:translate(0,-25%)}.modal.in .modal-dialog{-webkit-transform:translate(0,0);-ms-transform:translate(0,0);-o-transform:translate(0,0);transform:translate(0,0)}.modal-open .modal{overflow-x:hidden;overflow-y:auto}.modal-dialog{position:relative;width:auto;margin:10px}.modal-content{position:relative;background-color:#fff;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #999;border:1px solid rgba(0,0,0,.2);border-radius:6px;outline:0;-webkit-box-shadow:0 3px 9px rgba(0,0,0,.5);box-shadow:0 3px 9px rgba(0,0,0,.5)}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000}.modal-backdrop.fade{filter:alpha(opacity=0);opacity:0}.modal-backdrop.in{filter:alpha(opacity=50);opacity:.5}.modal-header{min-height:16.43px;padding:15px;border-bottom:1px solid #e5e5e5}.modal-header .close{margin-top:-2px}.modal-title{margin:0;line-height:1.42857143}.modal-body{position:relative;padding:15px}.modal-footer{padding:15px;text-align:right;border-top:1px solid #e5e5e5}.modal-footer .btn+.btn{margin-bottom:0;margin-left:5px}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.modal-footer .btn-block+.btn-block{margin-left:0}.modal-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}@media (min-width:768px){.modal-dialog{width:600px;margin:30px auto}.modal-content{-webkit-box-shadow:0 5px 15px rgba(0,0,0,.5);box-shadow:0 5px 15px rgba(0,0,0,.5)}.modal-sm{width:300px}}@media (min-width:992px){.modal-lg{width:900px}}.tooltip{position:absolute;z-index:1070;display:block;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:12px;font-weight:400;line-height:1.4;filter:alpha(opacity=0);opacity:0}.tooltip.in{filter:alpha(opacity=90);opacity:.9}.tooltip.top{padding:5px 0;margin-top:-3px}.tooltip.right{padding:0 5px;margin-left:3px}.tooltip.bottom{padding:5px 0;margin-top:3px}.tooltip.left{padding:0 5px;margin-left:-3px}.tooltip-inner{max-width:200px;padding:3px 8px;color:#fff;text-align:center;text-decoration:none;background-color:#000;border-radius:4px}.tooltip-arrow{position:absolute;width:0;height:0;border-color:transparent;border-style:solid}.tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-width:5px 5px 0;border-top-color:#000}.tooltip.top-left .tooltip-arrow{right:5px;bottom:0;margin-bottom:-5px;border-width:5px 5px 0;border-top-color:#000}.tooltip.top-right .tooltip-arrow{bottom:0;left:5px;margin-bottom:-5px;border-width:5px 5px 0;border-top-color:#000}.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-width:5px 5px 5px 0;border-right-color:#000}.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-width:5px 0 5px 5px;border-left-color:#000}.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-width:0 5px 5px;border-bottom-color:#000}.tooltip.bottom-left .tooltip-arrow{top:0;right:5px;margin-top:-5px;border-width:0 5px 5px;border-bottom-color:#000}.tooltip.bottom-right .tooltip-arrow{top:0;left:5px;margin-top:-5px;border-width:0 5px 5px;border-bottom-color:#000}.popover{position:absolute;top:0;left:0;z-index:1060;display:none;max-width:276px;padding:1px;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;font-weight:400;line-height:1.42857143;text-align:left;white-space:normal;background-color:#fff;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #ccc;border:1px solid rgba(0,0,0,.2);border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,.2);box-shadow:0 5px 10px rgba(0,0,0,.2)}.popover.top{margin-top:-10px}.popover.right{margin-left:10px}.popover.bottom{margin-top:10px}.popover.left{margin-left:-10px}.popover-title{padding:8px 14px;margin:0;font-size:14px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;border-radius:5px 5px 0 0}.popover-content{padding:9px 14px}.popover>.arrow,.popover>.arrow:after{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.popover>.arrow{border-width:11px}.popover>.arrow:after{content:"";border-width:10px}.popover.top>.arrow{bottom:-11px;left:50%;margin-left:-11px;border-top-color:#999;border-top-color:rgba(0,0,0,.25);border-bottom-width:0}.popover.top>.arrow:after{bottom:1px;margin-left:-10px;content:" ";border-top-color:#fff;border-bottom-width:0}.popover.right>.arrow{top:50%;left:-11px;margin-top:-11px;border-right-color:#999;border-right-color:rgba(0,0,0,.25);border-left-width:0}.popover.right>.arrow:after{bottom:-10px;left:1px;content:" ";border-right-color:#fff;border-left-width:0}.popover.bottom>.arrow{top:-11px;left:50%;margin-left:-11px;border-top-width:0;border-bottom-color:#999;border-bottom-color:rgba(0,0,0,.25)}.popover.bottom>.arrow:after{top:1px;margin-left:-10px;content:" ";border-top-width:0;border-bottom-color:#fff}.popover.left>.arrow{top:50%;right:-11px;margin-top:-11px;border-right-width:0;border-left-color:#999;border-left-color:rgba(0,0,0,.25)}.popover.left>.arrow:after{right:1px;bottom:-10px;content:" ";border-right-width:0;border-left-color:#fff}.carousel{position:relative}.carousel-inner{position:relative;width:100%;overflow:hidden}.carousel-inner>.item{position:relative;display:none;-webkit-transition:.6s ease-in-out left;-o-transition:.6s ease-in-out left;transition:.6s ease-in-out left}.carousel-inner>.item>a>img,.carousel-inner>.item>img{line-height:1}@media all and (transform-3d),(-webkit-transform-3d){.carousel-inner>.item{-webkit-transition:-webkit-transform .6s ease-in-out;-o-transition:-o-transform .6s ease-in-out;transition:transform .6s ease-in-out;-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-perspective:1000;perspective:1000}.carousel-inner>.item.active.right,.carousel-inner>.item.next{left:0;-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0)}.carousel-inner>.item.active.left,.carousel-inner>.item.prev{left:0;-webkit-transform:translate3d(-100%,0,0);transform:translate3d(-100%,0,0)}.carousel-inner>.item.active,.carousel-inner>.item.next.left,.carousel-inner>.item.prev.right{left:0;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}}.carousel-inner>.active,.carousel-inner>.next,.carousel-inner>.prev{display:block}.carousel-inner>.active{left:0}.carousel-inner>.next,.carousel-inner>.prev{position:absolute;top:0;width:100%}.carousel-inner>.next{left:100%}.carousel-inner>.prev{left:-100%}.carousel-inner>.next.left,.carousel-inner>.prev.right{left:0}.carousel-inner>.active.left{left:-100%}.carousel-inner>.active.right{left:100%}.carousel-control{position:absolute;top:0;bottom:0;left:0;width:15%;font-size:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,.6);filter:alpha(opacity=50);opacity:.5}.carousel-control.left{background-image:-webkit-linear-gradient(left,rgba(0,0,0,.5) 0,rgba(0,0,0,.0001) 100%);background-image:-o-linear-gradient(left,rgba(0,0,0,.5) 0,rgba(0,0,0,.0001) 100%);background-image:-webkit-gradient(linear,left top,right top,from(rgba(0,0,0,.5)),to(rgba(0,0,0,.0001)));background-image:linear-gradient(to right,rgba(0,0,0,.5) 0,rgba(0,0,0,.0001) 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00000000', GradientType=1);background-repeat:repeat-x}.carousel-control.right{right:0;left:auto;background-image:-webkit-linear-gradient(left,rgba(0,0,0,.0001) 0,rgba(0,0,0,.5) 100%);background-image:-o-linear-gradient(left,rgba(0,0,0,.0001) 0,rgba(0,0,0,.5) 100%);background-image:-webkit-gradient(linear,left top,right top,from(rgba(0,0,0,.0001)),to(rgba(0,0,0,.5)));background-image:linear-gradient(to right,rgba(0,0,0,.0001) 0,rgba(0,0,0,.5) 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#80000000', GradientType=1);background-repeat:repeat-x}.carousel-control:focus,.carousel-control:hover{color:#fff;text-decoration:none;filter:alpha(opacity=90);outline:0;opacity:.9}.carousel-control .glyphicon-chevron-left,.carousel-control .glyphicon-chevron-right,.carousel-control .icon-next,.carousel-control .icon-prev{position:absolute;top:50%;z-index:5;display:inline-block}.carousel-control .glyphicon-chevron-left,.carousel-control .icon-prev{left:50%;margin-left:-10px}.carousel-control .glyphicon-chevron-right,.carousel-control .icon-next{right:50%;margin-right:-10px}.carousel-control .icon-next,.carousel-control .icon-prev{width:20px;height:20px;margin-top:-10px;font-family:serif;line-height:1}.carousel-control .icon-prev:before{content:'\2039'}.carousel-control .icon-next:before{content:'\203a'}.carousel-indicators{position:absolute;bottom:10px;left:50%;z-index:15;width:60%;padding-left:0;margin-left:-30%;text-align:center;list-style:none}.carousel-indicators li{display:inline-block;width:10px;height:10px;margin:1px;text-indent:-999px;cursor:pointer;background-color:#000 \9;background-color:rgba(0,0,0,0);border:1px solid #fff;border-radius:10px}.carousel-indicators .active{width:12px;height:12px;margin:0;background-color:#fff}.carousel-caption{position:absolute;right:15%;bottom:20px;left:15%;z-index:10;padding-top:20px;padding-bottom:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,.6)}.carousel-caption .btn{text-shadow:none}@media screen and (min-width:768px){.carousel-control .glyphicon-chevron-left,.carousel-control .glyphicon-chevron-right,.carousel-control .icon-next,.carousel-control .icon-prev{width:30px;height:30px;margin-top:-15px;font-size:30px}.carousel-control .glyphicon-chevron-left,.carousel-control .icon-prev{margin-left:-15px}.carousel-control .glyphicon-chevron-right,.carousel-control .icon-next{margin-right:-15px}.carousel-caption{right:20%;left:20%;padding-bottom:30px}.carousel-indicators{bottom:20px}}.btn-group-vertical>.btn-group:after,.btn-group-vertical>.btn-group:before,.btn-toolbar:after,.btn-toolbar:before,.clearfix:after,.clearfix:before,.container-fluid:after,.container-fluid:before,.container:after,.container:before,.dl-horizontal dd:after,.dl-horizontal dd:before,.form-horizontal .form-group:after,.form-horizontal .form-group:before,.modal-footer:after,.modal-footer:before,.nav:after,.nav:before,.navbar-collapse:after,.navbar-collapse:before,.navbar-header:after,.navbar-header:before,.navbar:after,.navbar:before,.pager:after,.pager:before,.panel-body:after,.panel-body:before,.row:after,.row:before{display:table;content:" "}.btn-group-vertical>.btn-group:after,.btn-toolbar:after,.clearfix:after,.container-fluid:after,.container:after,.dl-horizontal dd:after,.form-horizontal .form-group:after,.modal-footer:after,.nav:after,.navbar-collapse:after,.navbar-header:after,.navbar:after,.pager:after,.panel-body:after,.row:after{clear:both}.center-block{display:block;margin-right:auto;margin-left:auto}.pull-right{float:right!important}.pull-left{float:left!important}.hide{display:none!important}.show{display:block!important}.invisible{visibility:hidden}.text-hide{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.hidden{display:none!important}.affix{position:fixed}@-ms-viewport{width:device-width}.visible-lg,.visible-lg-block,.visible-lg-inline,.visible-lg-inline-block,.visible-md,.visible-md-block,.visible-md-inline,.visible-md-inline-block,.visible-print,.visible-print-block,.visible-print-inline,.visible-print-inline-block,.visible-sm,.visible-sm-block,.visible-sm-inline,.visible-sm-inline-block,.visible-xs,.visible-xs-block,.visible-xs-inline,.visible-xs-inline-block{display:none!important}@media (max-width:767px){.visible-xs{display:block!important}table.visible-xs{display:table}tr.visible-xs{display:table-row!important}td.visible-xs,th.visible-xs{display:table-cell!important}}@media (max-width:767px){.visible-xs-block{display:block!important}}@media (max-width:767px){.visible-xs-inline{display:inline!important}}@media (max-width:767px){.visible-xs-inline-block{display:inline-block!important}}@media (min-width:768px)and (max-width:991px){.visible-sm{display:block!important}table.visible-sm{display:table}tr.visible-sm{display:table-row!important}td.visible-sm,th.visible-sm{display:table-cell!important}}@media (min-width:768px)and (max-width:991px){.visible-sm-block{display:block!important}}@media (min-width:768px)and (max-width:991px){.visible-sm-inline{display:inline!important}}@media (min-width:768px)and (max-width:991px){.visible-sm-inline-block{display:inline-block!important}}@media (min-width:992px)and (max-width:1199px){.visible-md{display:block!important}table.visible-md{display:table}tr.visible-md{display:table-row!important}td.visible-md,th.visible-md{display:table-cell!important}}@media (min-width:992px)and (max-width:1199px){.visible-md-block{display:block!important}}@media (min-width:992px)and (max-width:1199px){.visible-md-inline{display:inline!important}}@media (min-width:992px)and (max-width:1199px){.visible-md-inline-block{display:inline-block!important}}@media (min-width:1200px){.visible-lg{display:block!important}table.visible-lg{display:table}tr.visible-lg{display:table-row!important}td.visible-lg,th.visible-lg{display:table-cell!important}}@media (min-width:1200px){.visible-lg-block{display:block!important}}@media (min-width:1200px){.visible-lg-inline{display:inline!important}}@media (min-width:1200px){.visible-lg-inline-block{display:inline-block!important}}@media (max-width:767px){.hidden-xs{display:none!important}}@media (min-width:768px)and (max-width:991px){.hidden-sm{display:none!important}}@media (min-width:992px)and (max-width:1199px){.hidden-md{display:none!important}}@media (min-width:1200px){.hidden-lg{display:none!important}}@media print{.visible-print{display:block!important}table.visible-print{display:table}tr.visible-print{display:table-row!important}td.visible-print,th.visible-print{display:table-cell!important}}@media print{.visible-print-block{display:block!important}}@media print{.visible-print-inline{display:inline!important}}@media print{.visible-print-inline-block{display:inline-block!important}}@media print{.hidden-print{display:none!important}}body{padding-top:20px;padding-bottom:20px}.challenges,.footer,.header{padding-right:15px;padding-left:15px}.header{padding-bottom:20px;border-bottom:1px solid #e5e5e5}.header h3{margin-top:0;margin-bottom:0;line-height:40px}.footer{padding-top:19px;text-align:center;color:#666;border-top:1px solid #e5e5e5}@media (min-width:768px){.container{max-width:730px}}.jumbotron{text-align:center;border-bottom:1px solid #e5e5e5}.jumbotron .btn{padding:14px 24px;font-size:21px}.challenges{margin:40px 0}.challenges h3{padding-bottom:15px;border-bottom:1px solid #e5e5e5}.challenges p+h4{margin-top:28px}.past-challenges .challenge{border-bottom:1px solid #e5e5e5}@media screen and (min-width:768px){.challenges,.footer,.header{padding-right:0;padding-left:0}.header{margin-bottom:30px}.jumbotron{border-bottom:0}}.profile-properties{padding-left:20px}.profile-properties dd{margin-bottom:10px}.reset-api-key{margin-top:5px} -------------------------------------------------------------------------------- /web/assets/css/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 20px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | .header, 7 | .challenges, 8 | .footer { 9 | padding-right: 15px; 10 | padding-left: 15px; 11 | } 12 | 13 | .header { 14 | padding-bottom: 20px; 15 | border-bottom: 1px solid #e5e5e5; 16 | } 17 | 18 | .header h3 { 19 | margin-top: 0; 20 | margin-bottom: 0; 21 | line-height: 40px; 22 | } 23 | 24 | .footer { 25 | padding-top: 19px; 26 | text-align: center; 27 | color: #666; 28 | border-top: 1px solid #e5e5e5; 29 | } 30 | 31 | @media (min-width: 768px) { 32 | .container { 33 | max-width: 730px; 34 | } 35 | } 36 | 37 | .jumbotron { 38 | text-align: center; 39 | border-bottom: 1px solid #e5e5e5; 40 | } 41 | 42 | .jumbotron .btn { 43 | padding: 14px 24px; 44 | font-size: 21px; 45 | } 46 | 47 | .challenges { 48 | margin: 40px 0; 49 | } 50 | .challenges h3 { 51 | padding-bottom: 15px; 52 | border-bottom: 1px solid #e5e5e5; 53 | } 54 | .challenges p + h4 { 55 | margin-top: 28px; 56 | } 57 | 58 | .past-challenges .challenge { 59 | border-bottom: 1px solid #e5e5e5; 60 | } 61 | 62 | @media screen and (min-width: 768px) { 63 | .header, 64 | .challenges, 65 | .footer { 66 | padding-right: 0; 67 | padding-left: 0; 68 | } 69 | .header { 70 | margin-bottom: 30px; 71 | } 72 | .jumbotron { 73 | border-bottom: 0; 74 | } 75 | } 76 | 77 | .profile-properties { 78 | padding-left: 20px; 79 | } 80 | 81 | .profile-properties dd { 82 | margin-bottom: 10px; 83 | } 84 | 85 | .reset-api-key { 86 | margin-top: 5px; 87 | } 88 | -------------------------------------------------------------------------------- /web/assets/js/main.js: -------------------------------------------------------------------------------- 1 | /* globals jQuery, Backbone */ 2 | (function($) { 3 | 'use strict'; 4 | 5 | var 6 | apiVersion = 'v1', 7 | 8 | // Model and Collection. 9 | ChallengeModel, 10 | CurrentChallengeModel, 11 | ChallengeCollection, 12 | UserModel, 13 | CurrentUserModel, 14 | SubmissionModel, 15 | SubmissionCollection, 16 | 17 | // Views. 18 | CurrentChallengeView, 19 | PastChallengesView, 20 | PastChallengeItem, 21 | SubmissionsView, 22 | SubmissionItem, 23 | 24 | // Instances. 25 | CurrentChallenge, 26 | Challenges, 27 | 28 | // Router. 29 | Router, 30 | 31 | // URL for Model and Collection. 32 | getAPIURL = function(suffix) { 33 | return '/' + apiVersion + suffix; 34 | }; 35 | 36 | // ChallengeModel 37 | // -------------- 38 | // 39 | // ChallengeModel represents a single challenge. 40 | ChallengeModel = Backbone.Model.extend({ 41 | urlRoot: function() { 42 | return getAPIURL('/challenges'); 43 | }, 44 | parse: function(model) { 45 | // `import` is reserved word. 46 | if (model.import) { 47 | model.import_url = model.import; 48 | } 49 | return model; 50 | } 51 | }); 52 | 53 | // CurrentChallengeModel 54 | // --------------------- 55 | // 56 | // CurrentChallengeModel represents current challenge. 57 | CurrentChallengeModel = Backbone.Model.extend({ 58 | url: getAPIURL('/challenges/current') 59 | }); 60 | 61 | // CurrentChallenge 62 | // ---------------- 63 | // 64 | // Instance of CurrentChallengeModel. 65 | CurrentChallenge = new CurrentChallengeModel(); 66 | 67 | // ChallengeCollection 68 | // ------------------- 69 | // 70 | // ChallengeCollection represents challenges collection. 71 | ChallengeCollection = Backbone.Collection.extend({ 72 | model: ChallengeModel, 73 | url: function() { 74 | return getAPIURL('/challenges'); 75 | } 76 | }); 77 | 78 | // Challenges 79 | // ---------- 80 | // 81 | // Instance of ChallengeCollection. 82 | Challenges = new ChallengeCollection(); 83 | 84 | // UserModel 85 | // --------- 86 | // 87 | // UserModel represents user. Can be participant or evaluator. 88 | UserModel = Backbone.Model.extend({ 89 | defaults: { 90 | name: '', 91 | avatar_url: '', 92 | email: '' 93 | }, 94 | urlRoot: function() { 95 | return getAPIURL('/users'); 96 | } 97 | }); 98 | 99 | // CurrentUserModel 100 | // ---------------- 101 | // 102 | // CurrentUserModel represents current user. 103 | CurrentUserModel = UserModel.extend({ 104 | url: function() { 105 | return getAPIURL('/user'); 106 | } 107 | }); 108 | 109 | // SubmissionModel 110 | // --------------- 111 | // 112 | // SubmissionModel represents challenge submission. 113 | SubmissionModel = Backbone.Model.extend(); 114 | 115 | // SubmissionCollection 116 | // -------------------- 117 | // 118 | // SubmissionCollection represents all submissions of a challenge. 119 | SubmissionCollection = Backbone.Collection.extend({ 120 | model: SubmissionModel, 121 | challengeID: null, 122 | 123 | initialize: function(options) { 124 | this.challengeID = options.challengeID; 125 | }, 126 | 127 | url: function() { 128 | return getAPIURL('/challenges/' + this.challengeID + '/submissions'); 129 | } 130 | }); 131 | 132 | // CurrentChallengeView 133 | // -------------------- 134 | // 135 | // DOM Element for current challenge in home page. 136 | CurrentChallengeView = Backbone.View.extend({ 137 | initialize: function() { 138 | this.template = _.template($('#current-challenge-tpl').html()); 139 | this.content = this.$('.current-challenge-content'); 140 | 141 | this.listenTo(CurrentChallenge, 'sync', this.render); 142 | }, 143 | 144 | render: function(model) { 145 | this.content.html(this.template(model.toJSON())); 146 | return this; 147 | } 148 | }); 149 | 150 | // PastChallengesView 151 | // ------------------ 152 | // 153 | // DOM Element for past challenges in home page. 154 | PastChallengesView = Backbone.View.extend({ 155 | initialize: function() { 156 | this.listenTo(Challenges, 'reset', this.render); 157 | }, 158 | 159 | render: function() { 160 | Challenges.each(this.renderItem, this); 161 | }, 162 | 163 | renderItem: function(model) { 164 | if (model.get('status') === 'open') return; 165 | 166 | var view = new PastChallengeItem({model: model}); 167 | this.$el.append(view.render().el); 168 | } 169 | }); 170 | 171 | // PastChallengeItem 172 | // ----------------- 173 | // 174 | // DOM Element of a single challenge in PastChallengesView 175 | PastChallengeItem = Backbone.View.extend({ 176 | tagName: 'li', 177 | className: 'challenge', 178 | 179 | initialize: function() { 180 | this.template = _.template($('#past-challenge-item-tpl').html()); 181 | }, 182 | 183 | render: function() { 184 | this.$el.html(this.template(this.model.toJSON())); 185 | return this; 186 | } 187 | }); 188 | 189 | // SubmissionsView 190 | // --------------- 191 | // 192 | // DOM Element for submissions list. 193 | SubmissionsView = Backbone.View.extend({ 194 | render: function() { 195 | this.collection.each(this.renderItem, this); 196 | }, 197 | 198 | renderItem: function(model) { 199 | var view = new SubmissionItem({model: model}); 200 | this.$el.append(view.render().el); 201 | } 202 | }); 203 | 204 | // SubmissionItem 205 | // -------------- 206 | // 207 | // DOM Element for single submission in submissions list. 208 | SubmissionItem = Backbone.View.extend({ 209 | tagName: 'li', 210 | className: 'submission', 211 | 212 | initialize: function() { 213 | this.template = _.template($('#submission-item-tpl').html()); 214 | }, 215 | 216 | render: function() { 217 | console.log(this.model.toJSON()); 218 | this.$el.html(this.template(this.model.toJSON())); 219 | return this; 220 | } 221 | }); 222 | 223 | // Router 224 | // ------ 225 | Router = Backbone.Router.extend({ 226 | routes: { 227 | "challenges/:challenge_id": "viewChallenge", 228 | "api_key=*fragment": "getAPIKeyFromURL", 229 | "": "home", 230 | "profile": "viewProfile", 231 | "logout": "logout", 232 | "*path": "home" 233 | }, 234 | 235 | initialize: function() { 236 | this.userNavTemplate = _.template($('#user-nav-tpl').html()); 237 | this.profileTemplate = _.template($('#profile-tpl').html()); 238 | this.homeTemplate = _.template($('#home-tpl').html()); 239 | this.challengeTemplate = _.template($('#challenge-tpl').html()); 240 | 241 | this.userNav = $('.user-nav'); 242 | this.content = $('#content'); 243 | 244 | this.currentUser = null; 245 | this.renderUserNav(); 246 | }, 247 | 248 | home: function() { 249 | this.content.html(this.homeTemplate()); 250 | this.currentChallengeView = new CurrentChallengeView({ 251 | el: $('#current-challenge') 252 | }); 253 | this.pastChallengesView = new PastChallengesView({ 254 | el: $('#past-challenges') 255 | }); 256 | 257 | Challenges.fetch({reset: true}); 258 | CurrentChallenge.fetch(); 259 | }, 260 | 261 | viewChallenge: function(challenge_id) { 262 | var challenge = new ChallengeModel({ 263 | id: challenge_id 264 | }); 265 | 266 | challenge.once('sync', this._challengeRender, this); 267 | challenge.fetch(); 268 | }, 269 | 270 | _challengeRender: function(challenge) { 271 | this.content.html(this.challengeTemplate(challenge.toJSON())); 272 | this._challengeSubmissions(challenge); 273 | }, 274 | 275 | _challengeSubmissions: function(challenge) { 276 | var submissions = new SubmissionCollection({ 277 | challengeID: challenge.get('id') 278 | }); 279 | 280 | submissions.once('sync', this._challengeSubmissionsRender, this); 281 | submissions.fetch(); 282 | }, 283 | 284 | _challengeSubmissionsRender: function(submissions) { 285 | if (submissions.size() === 0) { 286 | $('.challenge-submissions').html( 287 | '
  • No submission for this challenge

  • ' 288 | ); 289 | } else { 290 | new SubmissionsView({ 291 | collection: submissions, 292 | el: $('.challenge-submissions') 293 | }).render(); 294 | } 295 | }, 296 | 297 | getAPIKeyFromURL: function() { 298 | var parts = location.hash.slice(1).split('='), 299 | api_key = ''; 300 | 301 | if (parts[0] === 'api_key') { 302 | api_key = parts[1]; 303 | } 304 | if (api_key !== '') { 305 | localStorage.setItem("api_key", decodeURIComponent(api_key)); 306 | this.renderUserNav(); 307 | } 308 | 309 | this.navigate("", {trigger: true}); 310 | }, 311 | 312 | renderUserNav: function() { 313 | var key = this.getAPIKey(); 314 | if (!key) { 315 | this.userNav.html(this.userNavTemplate({user: null})); 316 | return false; 317 | } 318 | 319 | this.currentUser = new CurrentUserModel(); 320 | this.currentUser.once('sync', function(){ 321 | this.userNav.html(this.userNavTemplate({ 322 | user: this.currentUser.toJSON() 323 | })); 324 | }, this); 325 | 326 | this.fetchCurrentUser(); 327 | }, 328 | 329 | getAPIKey: function() { 330 | return localStorage.getItem("api_key"); 331 | }, 332 | 333 | fetchCurrentUser: function() { 334 | this.currentUser.fetch({ 335 | beforeSend: $.proxy(this, 'setHeader'), 336 | error: $.proxy(this, 'fetchCurrentUserError') 337 | }); 338 | }, 339 | 340 | setHeader: function(xhr) { 341 | xhr.setRequestHeader("Auth-ApiKey", this.getAPIKey()); 342 | }, 343 | 344 | fetchCurrentUserError: function() { 345 | this.logout(); 346 | }, 347 | 348 | viewProfile: function() { 349 | if (!this.currentUser) { 350 | this.navigate("", {trigger: true}); 351 | return false; 352 | } 353 | 354 | this.currentUser.once('sync', function() { 355 | var user = this.currentUser.toJSON(); 356 | user.api_key = this.getAPIKey(); 357 | this.content.html(this.profileTemplate({ 358 | user: user 359 | })); 360 | }, this); 361 | this.fetchCurrentUser(); 362 | }, 363 | 364 | logout: function() { 365 | this.currentUser = null; 366 | localStorage.removeItem('api_key'); 367 | 368 | this.renderUserNav(); 369 | this.navigate("", {trigger: true}); 370 | } 371 | }); 372 | 373 | // Start router when DOM is ready. 374 | $(function() { 375 | new Router(); 376 | Backbone.history.start(); 377 | }); 378 | 379 | }(jQuery)); 380 | -------------------------------------------------------------------------------- /web/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gochallenge", 3 | "version": "0.0.1", 4 | "homepage": "https://github.com/GoChallenge/gochallenge", 5 | "authors": [ 6 | "gochallenge authors" 7 | ], 8 | "description": "App to run Go challenge", 9 | "main": "assets/js/main.js", 10 | "keywords": [ 11 | "gochallenge" 12 | ], 13 | "license": "MIT", 14 | "private": true, 15 | "ignore": [ 16 | "**/.*", 17 | "node_modules", 18 | "bower_components", 19 | "assets/js/libs", 20 | "test", 21 | "tests" 22 | ], 23 | "dependencies": { 24 | "backbone": "~1.1.2", 25 | "bootstrap": "~3.3.4", 26 | "jquery": "~2.1.3" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /web/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Go Challenge 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
    14 |
    15 | 21 |

    Go Challenge

    22 |
    23 | 24 |
    25 | 26 | 29 | 30 |
    31 | 32 | 33 | 34 | 35 | 36 | 37 | 40 | 41 | 44 | 45 | 48 | 49 | 52 | 53 | 56 | 57 | 60 | 61 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GoChallenge", 3 | "description": "App to run Go challenge", 4 | "version": "0.0.1", 5 | "homepage": "https://github.com/GoChallenge/gochallenge", 6 | "author": { 7 | "name": "Akeda Bagus", 8 | "url": "http://gedex.web.id" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git://github.com/GoChallenge/gochallenge.git" 13 | }, 14 | "bugs": { 15 | "url": "https://github.com/GoChallenge/gochallenge/issues" 16 | }, 17 | "licenses": [ 18 | { 19 | "type": "MIT", 20 | "url": "https://github.com/GoChallenge/gochallenge/raw/master/LICENSE" 21 | } 22 | ], 23 | "devDependencies": { 24 | "grunt": "~0.4.1", 25 | "grunt-contrib-jshint": "~0.8.0", 26 | "grunt-contrib-uglify": "^0.4.0", 27 | "grunt-contrib-cssmin": "~0.7.0", 28 | "grunt-contrib-copy": "~0.5.0", 29 | "grunt-contrib-clean": "~0.5.0", 30 | "grunt-processhtml": "~0.3.0", 31 | "grunt-contrib-watch": "^0.6.1" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /web/templates/challenge.html: -------------------------------------------------------------------------------- 1 |

    <%- name %>

    2 |
    3 |
    4 |

    Author

    5 |

    <%- author.name %>

    6 |
    7 |
    8 |

    Start

    9 |

    <%- start %>

    10 |
    11 |
    12 |

    End

    13 |

    <%- end %>

    14 |
    15 |
    16 |

    Status

    17 |

    18 | <% if (status === 'open') { %> 19 | Open 20 | <% } else { %> 21 | Closed 22 | <% } %> 23 |

    24 |
    25 |
    26 |

    Import URL

    27 |

    28 | <%- import_url %> 29 |

    30 |
    31 |
    32 |

    Submissions

    33 |
      34 |
    35 | -------------------------------------------------------------------------------- /web/templates/home-challenge-current.html: -------------------------------------------------------------------------------- 1 |

    <%- name %>

    2 |
    3 |
    4 |

    Author

    5 |

    <%- author.name %>

    6 |
    7 |
    8 |

    Start

    9 |

    <%- start %>

    10 |
    11 |
    12 |

    End

    13 |

    <%- end %>

    14 |
    15 |
    16 | More info 17 | 18 | -------------------------------------------------------------------------------- /web/templates/home-challenge-past.html: -------------------------------------------------------------------------------- 1 |
    <%- name %>
    2 |

    By <%- author.name %>

    3 | -------------------------------------------------------------------------------- /web/templates/home.html: -------------------------------------------------------------------------------- 1 |
    2 |

    Go Challenge

    3 |

    The Go Challenge is the world's first monthly programming challenge for Go developers (newbies included).

    4 |

    5 | Read more 6 |

    7 |
    8 | 9 |
    10 |
    11 |
    12 |

    Current Challenge

    13 |
    14 |

    No open challenge currently.

    15 |
    16 |
    17 |
    18 |
    19 |

    Past Challenges

    20 | 22 |
    23 |
    24 | -------------------------------------------------------------------------------- /web/templates/profile.html: -------------------------------------------------------------------------------- 1 |

    My Profile

    2 |
    3 |
    4 | <%- user.name %> 5 |
    6 |
    7 |
    8 |
    Name
    9 |
    <%- user.name %>
    10 |
    Email
    11 |
    <%- user.email %>
    12 |
    GitHub
    13 |
    <%- user.github_login %>
    14 | 15 |
    API Key
    16 |
    17 | <%- user.api_key %> 18 |
    19 | 20 |
    21 |
    22 |
    23 |
    24 |

    My Submissions

    25 | -------------------------------------------------------------------------------- /web/templates/submission.html: -------------------------------------------------------------------------------- 1 | <%- user.name %> 2 | <%- created %> 3 | -------------------------------------------------------------------------------- /web/templates/user-nav.html: -------------------------------------------------------------------------------- 1 | <% if (!user) { %> 2 | Login 3 | <% } else { %> 4 | 5 | 6 | <%- user.name %> 7 | 8 | 9 | 17 | <% } %> 18 | --------------------------------------------------------------------------------