  (createMessage
     
     ;title
-    ;"hgjjhhjghjghj"
     (subs source 
       (+
         (.indexOf source ">"


(defn download-story [reference]
  (let [
    ;page (slurp (URLDecoder/decode reference))
    
    page (
      if (= (count (filter #(= (compare (% :reference) reference) 0 ) @stories )) 0)

     (swap! pages #(remove (fn [page] (= (:pageid page) num)) %)))


(defn download-zerohedge-byid [id]
  ;(println id)
  (slurp (str "http://www.zerohedge.com/?page=" id))
)

(defn check-page-cache-need-refresh [id]
  (if(
    or
      (< (count (filter #(= (compare (% :pageid) id) 0 ) @pages )) 1)
      (
        >
        (t/in-minutes 
          (t/interval 
            (f/parse  (f/formatters :date-hour-minute-second-ms) (.format (java.text.SimpleDateFormat. "yyyy-MM-dd'T'HH:mm:ss.SSS") (:downloaded (first (filter #(= (compare (% :pageid) id) 0 ) @pages ) ))))
            (f/parse  (f/formatters :date-hour-minute-second-ms) (.format (java.text.SimpleDateFormat. "yyyy-MM-dd'T'HH:mm:ss.SSS") (now)) )    
            
          )
        )
        (pagelifetime)
      )
    )
    (download-zerohedge-byid id)
  )
)

(defn refresh-page-cache [id array]

  (delete-page-by-number id)
