diff --git a/.travis.yml b/.travis.yml index b04c847..017eb27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ addons: go: 1.9 before_install: - go get github.com/mattn/goveralls -- export DODPATH=$HOME/gopath/src/github.com/devopsdays/devopsdays-cli/sampleData +- export DODPATH=$HOME/gopath/src/github.com/devopsdays/devopsdays-cli/testdata install: - make install script: diff --git a/event/event.go b/event/event.go index 0a6c1fc..bac855e 100644 --- a/event/event.go +++ b/event/event.go @@ -26,12 +26,12 @@ var qsCreateEvent = []*survey.Question{ { Name: "twitter", Prompt: &survey.Input{ - Message: "Enter your devopsdays event twitter handle (defaults to devopsdays):", - Help: "Twitter username should not include the @ symbol", + Message: "Enter your devopsdays event twitter handle (defaults to @devopsdays):", + Help: "Twitter username can include the @ symbol or not. Examples: '@devopsdays' or 'devopsdays", }, Validate: func(val interface{}) error { if str, _ := val.(string); (str != "") && (helpers.ValidateField(str, "twitter") == false) { - return errors.New("Please enter a valid Twitter handle. It should not have the @ symbol.") + return errors.New("Please enter a valid Twitter handle. Spaces are not allowed.") } return nil }, @@ -163,7 +163,7 @@ func CreateEvent(city, year string) (err error) { Name: strings.Join([]string{strings.TrimSpace(year), "-", CityClean(city)}, ""), Year: year, City: city, - EventTwitter: answers.Twitter, + EventTwitter: helpers.TwitterClean(answers.Twitter), Description: answers.Description, GoogleAnalytics: answers.GoogleAnalytics, StartDate: answers.StartDate, diff --git a/helpers/validate_field.go b/helpers/validate_field.go index 0d785c5..cb79eb8 100644 --- a/helpers/validate_field.go +++ b/helpers/validate_field.go @@ -25,7 +25,7 @@ func ValidateField(input, field string) bool { return true } case "twitter": - if (strings.ContainsAny(input, " ")) || (strings.ContainsAny(input, "@")) { + if strings.ContainsAny(input, " ") { return false } return true diff --git a/helpers/validate_field_test.go b/helpers/validate_field_test.go index 98c0333..7eed3fd 100644 --- a/helpers/validate_field_test.go +++ b/helpers/validate_field_test.go @@ -62,8 +62,8 @@ func TestValidateField(t *testing.T) { }) Convey("When the account name is @devopsdays", func() { twitter := "@devopsdays" - Convey("Then the response should be false", func() { - So(ValidateField(twitter, "twitter"), ShouldEqual, false) + Convey("Then the response should be true", func() { + So(ValidateField(twitter, "twitter"), ShouldEqual, true) }) }) }) diff --git a/sampleData/content/events/2017-ponyville/speakers/matt-stratton.md b/sampleData/content/events/2017-ponyville/speakers/matt-stratton.md new file mode 100644 index 0000000..edbd037 --- /dev/null +++ b/sampleData/content/events/2017-ponyville/speakers/matt-stratton.md @@ -0,0 +1,12 @@ ++++ +Title = "Matt Stratton" +type = "speaker" +website = "http://www.mattstratton.com" +twitter = "mattstratton" +facebook = "https://www.facebook.com/matt.stratton" +linkedin = "https://www.linkedin.com/in/mattstratton/" +github = "mattstratton" +gitlab = "mattstratton" +image = "matt-stratton.jpg" ++++ + diff --git a/speaker/speaker.go b/speaker/speaker.go index 9a0a2f8..3e7f3fd 100644 --- a/speaker/speaker.go +++ b/speaker/speaker.go @@ -40,11 +40,11 @@ var qsCreateSpeaker = []*survey.Question{ Name: "twitter", Prompt: &survey.Input{ Message: "What is the speaker's Twitter? [optional]", - Help: "Twitter username should not include the @ symbol", + Help: "Twitter username can include the @ symbol or not. Examples: '@mattstratton' or 'mattstratton", }, Validate: func(val interface{}) error { if str, _ := val.(string); (str != "") && (helpers.ValidateField(str, "twitter") == false) { - return errors.New("Please enter a valid Twitter handle. It should not have the @ symbol.") + return errors.New("Please enter a valid Twitter handle. It should not have any spaces.") } return nil }, @@ -180,7 +180,7 @@ func CreateSpeaker(speakerName, city, year string) (err error) { Name: names.NameClean(answers.Name), Title: answers.Name, Website: answers.Website, - Twitter: answers.Twitter, + Twitter: helpers.TwitterClean(answers.Twitter), Facebook: answers.Facebook, Linkedin: answers.Linkedin, Github: answers.Github,