Skip to content

Commit 46c64e9

Browse files
authored
Merge pull request #106 from devopsdays/fix-twitter-stuff
Allow twitter names to include @ symbol.
2 parents e6692c1 + c13bd9a commit 46c64e9

File tree

6 files changed

+23
-11
lines changed

6 files changed

+23
-11
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ addons:
88
go: 1.9
99
before_install:
1010
- go get github.com/mattn/goveralls
11-
- export DODPATH=$HOME/gopath/src/github.com/devopsdays/devopsdays-cli/sampleData
11+
- export DODPATH=$HOME/gopath/src/github.com/devopsdays/devopsdays-cli/testdata
1212
install:
1313
- make install
1414
script:

event/event.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ var qsCreateEvent = []*survey.Question{
2626
{
2727
Name: "twitter",
2828
Prompt: &survey.Input{
29-
Message: "Enter your devopsdays event twitter handle (defaults to devopsdays):",
30-
Help: "Twitter username should not include the @ symbol",
29+
Message: "Enter your devopsdays event twitter handle (defaults to @devopsdays):",
30+
Help: "Twitter username can include the @ symbol or not. Examples: '@devopsdays' or 'devopsdays",
3131
},
3232
Validate: func(val interface{}) error {
3333
if str, _ := val.(string); (str != "") && (helpers.ValidateField(str, "twitter") == false) {
34-
return errors.New("Please enter a valid Twitter handle. It should not have the @ symbol.")
34+
return errors.New("Please enter a valid Twitter handle. Spaces are not allowed.")
3535
}
3636
return nil
3737
},
@@ -163,7 +163,7 @@ func CreateEvent(city, year string) (err error) {
163163
Name: strings.Join([]string{strings.TrimSpace(year), "-", CityClean(city)}, ""),
164164
Year: year,
165165
City: city,
166-
EventTwitter: answers.Twitter,
166+
EventTwitter: helpers.TwitterClean(answers.Twitter),
167167
Description: answers.Description,
168168
GoogleAnalytics: answers.GoogleAnalytics,
169169
StartDate: answers.StartDate,

helpers/validate_field.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func ValidateField(input, field string) bool {
2525
return true
2626
}
2727
case "twitter":
28-
if (strings.ContainsAny(input, " ")) || (strings.ContainsAny(input, "@")) {
28+
if strings.ContainsAny(input, " ") {
2929
return false
3030
}
3131
return true

helpers/validate_field_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ func TestValidateField(t *testing.T) {
6262
})
6363
Convey("When the account name is @devopsdays", func() {
6464
twitter := "@devopsdays"
65-
Convey("Then the response should be false", func() {
66-
So(ValidateField(twitter, "twitter"), ShouldEqual, false)
65+
Convey("Then the response should be true", func() {
66+
So(ValidateField(twitter, "twitter"), ShouldEqual, true)
6767
})
6868
})
6969
})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
+++
2+
Title = "Matt Stratton"
3+
type = "speaker"
4+
website = "http://www.mattstratton.com"
5+
twitter = "mattstratton"
6+
facebook = "https://www.facebook.com/matt.stratton"
7+
linkedin = "https://www.linkedin.com/in/mattstratton/"
8+
github = "mattstratton"
9+
gitlab = "mattstratton"
10+
image = "matt-stratton.jpg"
11+
+++
12+

speaker/speaker.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ var qsCreateSpeaker = []*survey.Question{
4040
Name: "twitter",
4141
Prompt: &survey.Input{
4242
Message: "What is the speaker's Twitter? [optional]",
43-
Help: "Twitter username should not include the @ symbol",
43+
Help: "Twitter username can include the @ symbol or not. Examples: '@mattstratton' or 'mattstratton",
4444
},
4545
Validate: func(val interface{}) error {
4646
if str, _ := val.(string); (str != "") && (helpers.ValidateField(str, "twitter") == false) {
47-
return errors.New("Please enter a valid Twitter handle. It should not have the @ symbol.")
47+
return errors.New("Please enter a valid Twitter handle. It should not have any spaces.")
4848
}
4949
return nil
5050
},
@@ -180,7 +180,7 @@ func CreateSpeaker(speakerName, city, year string) (err error) {
180180
Name: names.NameClean(answers.Name),
181181
Title: answers.Name,
182182
Website: answers.Website,
183-
Twitter: answers.Twitter,
183+
Twitter: helpers.TwitterClean(answers.Twitter),
184184
Facebook: answers.Facebook,
185185
Linkedin: answers.Linkedin,
186186
Github: answers.Github,

0 commit comments

Comments
 (0)