   (str (:cdn-url @config) "/" (-> jar :group_name fu/group->path) "/" (:jar_name jar) "/"))
 
 (defn maven-jar-url [jar]
- (str "http://search.maven.org/#"
-   (url-encode (apply format "artifactdetails|%s|%s|%s|jar"
-        ((juxt :group_name :jar_name :version) jar)))))
+  (str "http://search.maven.org/#"
+    (url-encode (apply format "artifactdetails|%s|%s|%s|jar"
+                  ((juxt :group_name :jar_name :version) jar)))))
 
 (let [github-re #"^https?://github.com/([^/]+/[^/]+)"]
 

    "If you are looking for URLs to jar files or "
    (link-to "https://github.com/clojars/clojars-web/wiki/Stable-SNAPSHOT-Identifiers" "stable identifiers")
    " for SNAPSHOT versions you can take a look at "
    (link-to  (repo-url jar) (str "the full Maven repository for " (jar-name jar) "."))]])

(defn show-versions [account jar versions]
  (html-doc (str "all versions of "(jar-name jar)) {:account account}
            [:div.light-article
             [:h1 "all versions of "(jar-link jar)]
             [:div.versions
              [:ul
               (for [v versions]
                 [:li.col-xs-12.col-sm-6.col-md-4.col-lg-3
                  (link-to (url-for (assoc jar :version (:version v)))
                           (:version v))])]]]
            [:div.light-article
             (repo-note jar)]))

(let [border-color "#e2e4e3"
      bg-color "#fff"

    (version-badge-url jar)
    (jar-url jar)))

;; handles link-to throwing an exception when given a non-url
(defn safe-link-to [url text]
  (try (link-to url text)
       (catch Exception e text)))

(defn fork-notice [jar]
  (if (jar-fork? jar)
    (list single-fork-notice)))

(defn breadcrumbs [{:keys [group_name jar_name version] :as jar}]
  ;; TODO: this could be made more semantic by attaching the metadata to #jar-title, but we're waiting on https://github.com/clojars/clojars-web/issues/482
  (structured-data/breadcrumbs
    (if (group-is-name? jar)
      [{:url  (str "https://clojars.org/" (jar-name jar))
        :name jar_name}]
      [{:url  (str "https://clojars.org/groups/" group_name)
        :name group_name}
       ;; TODO: Not sure if this is a dirty hack or a stroke of brilliance
       {:url  (str "https://clojars.org/" (jar-name jar)) 
        :name jar_name}])))

(defn github-link [jar]
  (if-let [gh-info (github-info jar)]
    (link-to (format "https://github.com/%s" gh-info)
      (helpers/retinized-image "/images/github-mark.png" "GitHub")
      gh-info)
    [:p.github
     (helpers/retinized-image "/images/github-mark.png" "GitHub")
     "N/A"]))

(defn leiningen-coordinates [jar]
  (list
    [:h2 "Leiningen/Boot"]
    [:div#leiningen-coordinates.package-config-example
     {:onClick "selectText('leiningen-coordinates');"}
     [:pre
      (tag "[")
      (jar-name jar)
      [:span.string " \""
       (:version jar) "\""] (tag "]")]]))

(defn clojure-cli-coordinates [jar]
  (list
    [:h2 "Clojure CLI/deps.edn"]
    [:div#deps-coordinates.package-config-example
     {:onClick "selectText('deps-coordinates');"}
     [:pre
      (jar-name jar)
      \space
      (tag "{")
      ":mvn/version "
      [:span.string \" (:version jar) \"]
      (tag "}")]]))

(defn gradle-coordinates [{:keys [group_name jar_name version]}]
  (list
    [:h2 "Gradle"]
    [:div#gradle-coordinates.package-config-example
     {:onClick "selectText('gradle-coordinates');"}
     [:pre
      "compile "
      [:span.string \' group_name ":" jar_name ":" version \']]]))

(defn maven-coordinates [{:keys [group_name jar_name version]}]
  (list
    [:h2 "Maven"]
    [:div#maven-coordinates.package-config-example
     {:onClick "selectText('maven-coordinates');"}
     [:pre
      (tag "<dependency>\n")
      (tag "  <groupId>") group_name (tag "</groupId>\n")
      (tag "  <artifactId>") jar_name (tag "</artifactId>\n")
      (tag "  <version>") version (tag "</version>\n")
      (tag "</dependency>")]]))

(defn coordinates [jar]
  (for [f [leiningen-coordinates
           clojure-cli-coordinates
           gradle-coordinates
           maven-coordinates]]
    (f jar)))

(defn pushed-by [jar]
  (list
    [:h4 "Pushed by"]
    (user-link (:user jar)) " on "
    [:span {:title (str (java.util.Date. (:created jar)))} (simple-date (:created jar))]
    (if-let [url (commit-url jar)]
      [:span.commit-url " with " (link-to url "this commit")])))

(defn versions [jar recent-versions count]
  (list
    [:h4 "Recent Versions"]
    [:ul#versions
     (for [v recent-versions]
       [:li (link-to (url-for (assoc jar
                                :version (:version v)))
              (:version v))])]
    ;; by default, 5 versions are shown. If there are only 5 to
    ;; see, then there's no reason to show the 'all versions' link
    (if (> count 5)
      [:p (link-to (str (jar-url jar) "/versions")
            (str "Show All Versions (" count " total)"))])))

(defn dependency-section [db title id dependencies]
  (if (seq dependencies)
    (list
      [:h3 title]
      [(keyword (str "ul#" id))
       (for [dep dependencies]
         [:li (dependency-link db dep)])])))

(defn dependencies [db {:keys [group_name jar_name version]}]
  (dependency-section db "Dependencies" "dependencies"
    (remove #(not= (:scope %) "compile")
      (map
        #(set/rename-keys % {:dep_group_name :group_name
                             :dep_jar_name   :jar_name
                             :dep_version    :version
                             :dep_scope      :scope})
        (db/find-dependencies db
          group_name jar_name version)))))

(defn homepage [{:keys [homepage]}]
  (if homepage
    (list
      [:h4 "Homepage"]
      (safe-link-to homepage homepage))))

(defn licenses [jar]
  (if-let [licenses (seq (:licenses jar))]
    (list
      [:h4 "License"]
      [:ul#licenses
       (for [{:keys [name url]} licenses]
         [:li (safe-link-to url name)])])))

(defn version-badge [jar]
  (list
    [:h4 "Version Badge"]
    [:p
     "Want to display the "
     (link-to (version-badge-url jar) "latest version")
     " of your project on Github? Use the markdown code below!"]
    [:textarea#version-badge
     {:readonly "readonly" :rows 6 :onClick "selectText('version-badge')"}
     (badge-markdown jar)]))

(defn show-jar [db reporter stats account
                {:keys [group_name jar_name version] :as jar}
                recent-versions count]
  (let [total-downloads        (-> (stats/download-count stats
                                     group_name jar_name)
                                 (stats/format-stats))
        downloads-this-version (-> (stats/download-count stats
                                     group_name jar_name version)
                                 (stats/format-stats))
        title                  (format "[%s/%s \"%s\"]"
                                 group_name jar_name version)]
    (html-doc
      title
      {:account     account
       :description (format "%s %s" title (:description jar))
       :label1      (str "Total downloads / this version")
       :data1       (format "%s / %s" total-downloads downloads-this-version)
       :label2      "Coordinates"
       :data2       (format "[%s \"%s\"]" (jar-name jar) version)}
      [:div.light-article.row
       (breadcrumbs jar)
       (helpers/select-text-script)
       [:div#jar-title.col-xs-12.col-sm-9
        [:h1 (jar-link jar)]
        [:p.description (:description jar)]
        [:ul#jar-info-bar.row
         [:li.col-xs-12.col-sm-4 (github-link jar)]
         [:li.col-xs-12.col-sm-4
          total-downloads
          " Downloads"]
         [:li.col-xs-12.col-sm-4
          downloads-this-version
          " This Version"]]
        (coordinates jar)
        (fork-notice jar)]
       [:ul#jar-sidebar.col-xs-12.col-sm-3
        [:li (pushed-by jar)]
        [:li (versions jar recent-versions count)]
        (if-let [dependencies (dependencies db jar)]
          [:li dependencies])
        (if-let [homepage (homepage jar)]
          [:li.homepage homepage])
        (if-let [licenses (licenses jar)]
          [:li.license licenses])
        [:li (version-badge jar)]]])))

(defn repo-note [jar]
  [:div
