Commits

Maxim Moiseev  committed 8bc2d77

finally expanding links and attaching the full url to a timeline item

  • Participants
  • Parent commits f1ae30b

Comments (0)

Files changed (1)

File src/cleesmic/CleesmicPlugin.fs

 
     let expandUrlAsync (shortUrl:string) onCompleted =
         let request = HttpWebRequest.CreateHttp(shortUrl)
+        request.Method <- "HEAD"
         async {
             try
                 let! response = request.AsyncGetResponse()
                 let expandedUrl = response.ResponseUri.ToString()
                 onCompleted expandedUrl
             with
-            | ex -> do System.Diagnostics.Debug.WriteLine("CLEESMIC: " + ex.ToString())
+            | ex -> do System.Diagnostics.Debug.WriteLine("CLEESMIC (" + shortUrl + ")\r\n" + ex.ToString())
         } |> Async.StartImmediate
 
     let getClckUrls text =
-        let rx = Regex("(http://)?clck.ru/.+", RegexOptions.Multiline)
+        let rx = Regex("(http://)?clck.ru/[a-zA-Z0-9]+", RegexOptions.Multiline)
         rx.Matches(text).Cast<Match>()
             |> Seq.map (fun m -> m.Value)
         
     member this.IsInitiallyExpanded = this.Self.IsInitiallyExpanded
 
     member this.SetCollapsedText (text) = 
-        System.Diagnostics.Debug.WriteLine("CLEESMIC: Setting CollapsedText to " + text)
+//        System.Diagnostics.Debug.WriteLine("CLEESMIC: Setting CollapsedText to " + text)
         _text <- text
         this.OnPropertyChanged("CollapsedText")
 
 
         member this.Process(itemContainer) =
             let expandAndAttach url =
-                System.Diagnostics.Debug.WriteLine("CLEESMIC: attaching")
                 let attachment = ClckUrlAttachment()
                 Clck.expandUrlAsync url (attachment.SetCollapsedText)
+                itemContainer.AddAttachment attachment
 
             itemContainer.TimelineItem.Text
                 |> Clck.getClckUrls 
             ()
         member this.Remove(_) =
             ()
-
-