 
 (defn- url-path-for-docid [type docid]
   (if (= type :text)
-    (str "/v1/cases/" docid)
-    (str "/v1/cases/" docid "/" (name type))))
+    (str "v1/cases/" docid)
+    (str "v1/cases/" docid "/" (name type))))
+
+(defn- absolute-url-path-for-docid [type docid]
+  (str "/" (url-path-for-docid type docid)))
+
+(defn- file-path-for-docid [type docid format]
+  (str (url-path-for-docid type docid) "." format))
 
 (defn- doclinks [doc]
   (let [docid (:docid doc)]
     [{:name "Full Text"
-      :url (url-path-for-docid :text docid)}
+      :url (absolute-url-path-for-docid :text docid)}
      {:name "Citations to/from this"
-      :url (url-path-for-docid :citations docid)}]))
-
-(defn- file-path-for-docid [type docid]
-  (str "docs/" (files/docid-path docid) "-" (name type) ".html"))
+      :url (absolute-url-path-for-docid :citations docid)}]))
 
 (defmulti #^{:private true} gen-case-layout (fn [type doc] type))
 

(defn- prepare-citelinks [cites]
  (map (fn [doc]
         (assoc (escape-fields doc)
           :url (url-path-for-docid :text (:docid doc))
           :name (str/truncate (:name doc) 30)))
       (reverse (sort-by :date cites))))
  

    (tmpl/render :xhtml_page
                 :html_title (str (:name escaped) " - AltLaw")
                 :html_head (tmpl/render :default_html_head
                                         :norobots (= type :citations))
                 :html_body (gen-case-layout type escaped))))

(defn all-files [doc]
  (reduce (fn [m type]
            (assoc m (file-path-for-docid type (:docid doc) "html")
                   (gen-case-page type doc)))
          {} [:text :citations]))

