 ;; Interacting with the datastore - reading
 ;;--------------------------------------------------------------------
 
-(def baseurl "http://conj.io/api/v0/")
+(def baseurl "/api/v0/")
 
 (defn grim-succeed? [result]
   (= (:result result) :success))


(defmethod api/read-notes :web [config thing]
  {:pre [(isa? :def thing)]}
  (do-data-req thing "notes"))

(defmethod api/read-examples :web [config def-thing]
  {:pre [(isa? :def def-thing)]}
  (do-data-req def-thing "examples"))

(defmethod api/read-meta :web [config thing]
  (do-data-req thing "meta"))

(defmethod api/read-related :web [config def-thing]
  {:pre [(isa? :def def-thing)]}
  ;; FIXME: not implemented on the Grimoire side see clojure-grimoire/grimoire#152
  ;; Grimoire will yeild Succeed[Seq[qualifiedSymbol]]
  (let [version (thing->version def-thing)
        ?res    (do-data-req def-thing "related")]
    (if (succeed? ?res)
      (->> ?res result
         (map (comp #(path->thing (str (thing->path version) "/" %1)) :name))

      ?res)))

(defmethod api/list-groups :web [config]
  (do-thing-req config "groups" ->Group nil))

(defmethod api/list-artifacts :web [config group-thing]
  (do-thing-req config "artifacts" ->Artifact group-thing))

(defmethod api/list-versions :web [config artifact-thing]
  (do-thing-req config "versions" ->Version artifact-thing))

(defmethod api/list-namespaces :web [config version-thing]
  (do-thing-req config "namespaces" ->Ns version-thing))

(defmethod api/list-defs :web [config namespace-thing]
  (do-thing-req config "all" ->Def namespace-thing))

(defmethod api/thing->prior-versions :web [config thing]
  ;; FIXME: this is entirely common to fs/read's thing->versions
