Skip to content
Browse files

Show download count on artifact page

Fixes #26
  • Loading branch information...
1 parent da4247f commit d6472f824ec2dc53ee5ef5cd67746d77f1b8f405 @xeqi xeqi committed
View
2 resources/public/stylesheets/grid.css
@@ -12,7 +12,7 @@
.container_12 {
margin-left: auto;
margin-right: auto;
- width: 760px;
+ width: 960px;
}
/* Grid >> Global
View
7 resources/public/stylesheets/screen.css
@@ -46,8 +46,6 @@ p {
.article {
font-size: 20px;
-
- width: 660px;
padding-left: 40px;
padding-right: 40px;
padding-top: 20px;
@@ -277,4 +275,9 @@ p.hint {
.fork-notice {
font-style: italic;
font-size: 0.8em;
+}
+
+.downloads {
+ float: right;
+ font-size: 0.6em;
}
View
13 src/clojars/stats.clj
@@ -4,12 +4,13 @@
(defn all []
(read (java.io.PushbackReader. (java.io.FileReader.
(str (config/config :stats-dir)
- "all.edn")))))
+ "/all.edn")))))
(defn download-count [group-id artifact-id & [version]]
(let [ds ((all) [group-id artifact-id])]
- (if version
- (ds version)
- (->> ds
- (map second)
- (apply +)))))
+ (or (if version
+ (get ds version)
+ (->> ds
+ (map second)
+ (apply +)))
+ 0)))
View
2 src/clojars/stats/merge.clj
@@ -5,4 +5,4 @@
(read (java.io.PushbackReader. (java.io.FileReader.
filename))))
args)]
- (apply merge-with (partial merge-with +) stats)))
+ (prn (apply merge-with (partial merge-with +) stats))))
View
2 src/clojars/web/common.clj
@@ -44,7 +44,7 @@
:placeholder "Search jars..."}])]]
[:div {:class :clear}]]
[:div {:class "container_12 article"}
- [:article
+ [:article.clearfix
body]]
[:footer
(link-to "https://github.com/ato/clojars-web/wiki/About" "about")
View
82 src/clojars/web/jar.clj
@@ -10,6 +10,7 @@
[clojars.auth :refer [authorized?]]
[clojars.db :refer [find-jar jar-exists]]
[clojars.promote :refer [blockers]]
+ [clojars.stats :as stats]
[clojure.set :as set]
[ring.util.codec :refer [url-encode]]))
@@ -60,48 +61,61 @@
(defn show-jar [account jar recent-versions count]
(html-doc account (str (:jar_name jar) " " (:version jar))
- [:h1 (jar-link jar)]
- (:description jar)
- (when-let [homepage (:homepage jar)]
- [:p.homepage (safe-link-to homepage homepage)])
- [:div {:class "useit"}
- [:div {:class "lein"}
- [:h3 "leiningen"]
- [:pre
- (tag "[")
- (jar-name jar)
- [:span {:class :string} " \""
- (:version jar) "\""] (tag "]") ]]
+ [:div.grid_9.alpha
+ [:h1 (jar-link jar)]]
+ [:div.grid_3.omega
+ [:small.downloads
+ [:p
+ "Downloads: "
+ (stats/download-count (:group_name jar)
+ (:jar_name jar))
+ [:br]
+ "This version: "
+ (stats/download-count (:group_name jar)
+ (:jar_name jar)
+ (:version jar))]]]
+ [:div.grid_12.alpha.omega
+ (:description jar)
+ (when-let [homepage (:homepage jar)]
+ [:p.homepage (safe-link-to homepage homepage)])
+ [:div {:class "useit"}
+ [:div {:class "lein"}
+ [:h3 "leiningen"]
+ [:pre
+ (tag "[")
+ (jar-name jar)
+ [:span {:class :string} " \""
+ (:version jar) "\""] (tag "]") ]]
- [:div {:class "maven"}
- [:h3 "maven"]
- [:pre
- (tag "<dependency>\n")
- (tag " <groupId>") (:group_name jar) (tag "</groupId>\n")
- (tag " <artifactId>") (:jar_name jar) (tag "</artifactId>\n")
- (tag " <version>") (:version jar) (tag "</version>\n")
- (tag "</dependency>")]]
- (let [pom (jar-to-pom-map jar)]
- (list
+ [:div {:class "maven"}
+ [:h3 "maven"]
+ [:pre
+ (tag "<dependency>\n")
+ (tag " <groupId>") (:group_name jar) (tag "</groupId>\n")
+ (tag " <artifactId>") (:jar_name jar) (tag "</artifactId>\n")
+ (tag " <version>") (:version jar) (tag "</version>\n")
+ (tag "</dependency>")]]
+ (let [pom (jar-to-pom-map jar)]
+ (list
[:p "Pushed by " (user-link (:user jar)) " on "
- [:span {:title (str (java.util.Date. (:created jar)))} (simple-date (:created jar))]
- (if-let [url (commit-url pom)]
- [:span.commit-url " with " (link-to url "this commit")])]
+ [:span {:title (str (java.util.Date. (:created jar)))} (simple-date (:created jar))]
+ (if-let [url (commit-url pom)]
+ [:span.commit-url " with " (link-to url "this commit")])]
(fork-notice jar)
(promotion-details account jar)
(dependency-section "dependencies" "dependencies"
(remove #(not= (:scope %) "compile") (:dependencies pom)))
(when-not pom
[:p.error "Oops. We hit an error opening the metadata POM file for this jar "
- "so some details are not available."])))
- [:h3 "recent versions"]
- [:ul#versions
- (for [v recent-versions]
- [:li (link-to (url-for (assoc jar
- :version (:version v)))
- (:version v))])]
- [:p (link-to (str (jar-url jar) "/versions")
- (str "show all versions (" count " total)"))]]))
+ "so some details are not available."])))
+ [:h3 "recent versions"]
+ [:ul#versions
+ (for [v recent-versions]
+ [:li (link-to (url-for (assoc jar
+ :version (:version v)))
+ (:version v))])]
+ [:p (link-to (str (jar-url jar) "/versions")
+ (str "show all versions (" count " total)"))]]]))
(defn show-versions [account jar versions]
(html-doc account (str "all versions of "(jar-name jar))
View
3 test/clojars/test/test_helper.clj
@@ -38,6 +38,9 @@
(delete-file-recursively (io/file (config :repo)))
(delete-file-recursively (io/file (config :event-dir)))
(.mkdirs (io/file (config :event-dir)))
+ (delete-file-recursively (io/file (config :stats-dir)))
+ (.mkdirs (io/file (config :stats-dir)))
+ (spit (io/file (config :stats-dir) "all.edn") "{}")
(jdbc/with-connection (kdb/get-connection @kdb/_default)
(jdbc/do-commands
"delete from users;" "delete from jars;" "delete from groups;"))

0 comments on commit d6472f8

Please sign in to comment.
Something went wrong with that request. Please try again.