 
 
 (defn load-resource-url [url]
+  "Loads a html-resource from a URL."
   (-> url URI. e/html-resource))
 
 ; (def sample-res (load-resource-url "http://tvtropes.org/pmwiki/pmwiki.php/Anime/CowboyBebop"))
-
-
-(def base-path "/pmwiki/pmwiki.php/")
-(def base-url (str "http://tvtropes.org" base-path))
 
 (defn content-from-meta
   "Receives a html-resource and returns the content attribute of a meta type indexed by a property."

  [^String id]
  (-> id (s/split #"/") first (ut/if-empty "Unknown")))

(defn node-data-from-meta
  "Returns the relevant metadata of a html-resource as a map, including things
  we care about like the node label."
  [res]
  (let [og-url (content-from-meta res "og:url")
        og-host (ut/host-string-of og-url)
        og-title (content-from-meta res "og:title")
        og-image (content-from-meta res "og:image")
        og-type (-> (content-from-meta res "og:type") (ut/if-nil ""))
        id (-> (u/path-of og-url) (s/replace base-path ""))
        label (label-from-id id)]
    {:url   og-url
     :host  og-host
     :title og-title
     :image og-image
     :type  og-type
     :id    id
     :label label}))

(defn node-data-from-url
  "Returns a map with the metadata we can infer about a new from its URL.
  Assumes the url string conforms to the defined base-url, or will return nil."
  [^String url]
  (if (.startsWith url base-url)
    (let [og-host (ut/host-string-of url)
          id (-> (u/path-of url) (s/replace base-path ""))
          label (label-from-id id)]
      {:label label
       :id    id
       :host  og-host
       :url   url})
    nil))


      (get-wiki-links res (:host meta))
      (pmap node-data-from-url)
      (pmap #(db/create-or-merge-node conn %))
      (pmap #(db/relate-nodes conn :LINKSTO node %)))))