@@ -183,6 +183,7 @@ func CreateSpeaker(speakerName, city, year string) (err error) {
183183
184184 if (imageQuery == "Y" ) || (imageQuery == "y" ) {
185185 imagePath = CreateSpeakerImage (helpers .NameClean (name ), city , year )
186+ fmt .Println (imagePath )
186187 } else {
187188 imagePath = ""
188189 }
@@ -252,7 +253,7 @@ func CreateSpeakerImage(speaker, city, year string) (imageFile string) {
252253 return fmt .Errorf ("please enter a proper path" )
253254 }
254255
255- if _ , err := os .Stat (s ); err = = nil {
256+ if _ , err := os .Stat (s ); err ! = nil {
256257 return fmt .Errorf ("File not found." )
257258 }
258259
@@ -262,26 +263,37 @@ func CreateSpeakerImage(speaker, city, year string) (imageFile string) {
262263 if err != nil {
263264 log .Fatal (err )
264265 }
265- // create the destPath better here
266266
267- re := regexp .MustCompile ("\\ .[^.]+$" )
267+ var eventStaticPath string
268+ eventStaticPath , err = helpers .EventStaticPath (city , year )
269+ if err != nil {
270+ log .Fatal (err )
271+ }
272+ fmt .Println (eventStaticPath )
273+
274+ if err := os .MkdirAll (filepath .Join (eventStaticPath , "speakers" ), 0777 ); err != nil {
275+ log .Fatal (err )
276+ }
277+
278+ re := regexp .MustCompile (`\.[^.]+$` )
268279 ext := strings .ToLower (re .FindString (srcPath ))
280+ fmt .Println ("extension is " + ext )
269281 switch ext {
270- case "jpg" :
282+ case ". jpg" :
271283 s := []string {strings .TrimSpace (speaker ), ".jpg" }
272- destPath := filepath .Join (helpers . EventContentPath ( city , year ) , "speakers" , strings .Join (s , "" ))
284+ destPath := filepath .Join (eventStaticPath , "speakers" , strings .Join (s , "" ))
273285 helpers .ResizeImage (srcPath , destPath , "jpg" , 600 , 600 )
274286 return strings .Join (s , "" )
275- case "jpeg" :
287+ case ". jpeg" :
276288 s := []string {strings .TrimSpace (speaker ), ".jpg" }
277- destPath := filepath .Join (helpers . EventContentPath ( city , year ) , "speakers" , strings .Join (s , "" ))
289+ destPath := filepath .Join (eventStaticPath , "speakers" , strings .Join (s , "" ))
278290 helpers .ResizeImage (srcPath , destPath , "jpg" , 600 , 600 )
279291 return strings .Join (s , "" )
280- case "png" :
292+ case ". png" :
281293 s := []string {strings .TrimSpace (speaker ), ".png" }
282- destPath := filepath .Join (helpers . EventContentPath ( city , year ) , "speakers" , strings .Join (s , "" ))
294+ destPath := filepath .Join (eventStaticPath , "speakers" , strings .Join (s , "" ))
283295 helpers .ResizeImage (srcPath , destPath , "png" , 600 , 600 )
284296 return strings .Join (s , "" )
285297 }
286- return ""
298+ return "busted "
287299}
0 commit comments