Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'release/1.4.3'

  • Loading branch information...
commit 27c60d35a091f932d8d12ae450807a13000804f3 2 parents 6fca15d + 07e8899
@amalloy amalloy authored
View
2  project.clj
@@ -1,4 +1,4 @@
-(defproject foreclojure "1.4.2"
+(defproject foreclojure "1.4.3"
:description "4clojure - a website for lisp beginners"
:dependencies [[clojure "1.2.1"]
[clojure-contrib "1.2.0"]
View
49 resources/public/css/style.css
@@ -217,6 +217,30 @@ a.novisited {color: #00e;}
padding: 15px;
}
+
+/*
+ * By default only show the text label for the "Following" column on
+ * the users page. If they have javascript turned on (detected
+ * via. the js-enabled class set by our page's javascript) then turn
+ * off the text label and turn on the checkbox.
+ */
+#user-table input.following {
+ display: none;
+}
+
+#user-table span.following {
+ display: inline;
+}
+
+#user-table.js-enabled input.following {
+ display: inline;
+}
+
+#user-table.js-enabled span.following {
+ display: none;
+}
+
+
span.error, div.error {
color: red;
}
@@ -254,6 +278,7 @@ div#sub-heading {
}
div#main {
+ width: 100%;
display: block;
float: left;
clear: both;
@@ -368,6 +393,14 @@ table.my-table td {
font-size: 12px;
}
+tr.evenrow {
+ background-color: #E2E4FF;
+}
+
+tr.oddrow {
+ background-color: white;
+}
+
td.oddrank {
background-color: #DDF !important;
}
@@ -525,5 +558,21 @@ a.graph-class :hover {color: #445599;}
display: block;
}
+.solution-username {
+ font-weight: bold;
+}
+
+.solution-user-code {
+ background-color: #DDD;
+ padding: 15px;
+ margin-bottom: 25px;
+}
+.solution-code {
+ padding-left: 10px;
+}
+hr.solution {
+ margin-top: 20px;
+ margin-bottom: 20px;
+}
View
26 resources/public/script/foreclojure.js
@@ -22,7 +22,26 @@ $(document).ready(function() {
$(this).parents("form").attr("action", "/problem/edit").submit();
});
- $("form input.following").live("click", function(e) {
+ $("button.user-follow-button").live("click", function(e) {
+ e.preventDefault();
+ var $form = $(this).parents("form");
+ var $button = $(this);
+ $.ajax({type: "POST",
+ url: "/rest" + $form.attr("action"),
+ dataType: "json",
+ success: function(data) {
+ if (data) {
+ $button.text(data["next-label"]);
+ $form.attr("action", data["next-action"]);
+ }
+ },
+ });
+ return false;
+ });
+
+ $("#user-table").addClass("js-enabled");
+
+ $("#user-table input.following").live("click", function(e) {
e.preventDefault();
var $checkbox = $(this)
var $form = $checkbox.parents("form")
@@ -58,7 +77,7 @@ jQuery.fn.dataTableExt.oSort['difficulty-desc'] = function(a, b) {
function configureDataTables(){
$('#problem-table').dataTable( {
- "iDisplayLength": 25,
+ "iDisplayLength": 100,
"aaSorting": [[5, "desc"], [1, "asc"], [4, "desc"]],
"aoColumns": [
{"sType": "string"},
@@ -88,7 +107,8 @@ function configureDataTables(){
{"sType": "numeric"},
{"sType": "string"},
{"sType": "numeric"},
- {"sType": "string"}
+ {"sType": "string"},
+ {"sType": "string"}
]
} );
}
View
37 src/foreclojure/problems.clj
@@ -339,23 +339,26 @@ Return a map, {:message, :error, :url, :num-tests-passed}."
[:div.message (session/flash-get :message)]
[:div#problems-error.error (session/flash-get :error)]
[:h3 {:style "margin-top: -20px;"} "Solutions:"]
- (with-user [{:keys [following]}]
- (if (empty? following)
- [:p "You can only see solutions of users whom you follow. Click on any name from the " (link-to "/users" "users") " listing page to see their profile, and click follow from there."]
- (if (some (complement nil?) (map #(get-solution :public % problem-id) following))
- (interpose [:hr {:style "margin-top: 20px; margin-bottom: 20px;"}]
- (for [f-user-id following
- :let [f-user (:user (from-mongo
- (fetch-one :users
- :where {:_id f-user-id}
- :only [:user])))
- f-code (get-solution :public
- f-user-id problem-id)]
- :when f-code]
- [:div.follower-solution
- [:div.follower-username (str f-user "'s solution:")]
- [:pre.follower-code f-code]]))
- [:p "None of the users you follow have solved this problem yet!"]))))})
+ (with-user [{:keys [_id following]}]
+ (list
+ (let [user-code (get-solution :public _id problem-id)]
+ [:pre.solution-code.solution-user-code user-code])
+ (if (empty? following)
+ [:p "You can only see solutions of users whom you follow. Click on any name from the " (link-to "/users" "users") " listing page to see their profile, and click follow from there."]
+ (if (some (complement nil?) (map #(get-solution :public % problem-id) following))
+ (interpose [:hr.solution]
+ (for [f-user-id following
+ :let [f-user (:user (from-mongo
+ (fetch-one :users
+ :where {:_id f-user-id}
+ :only [:user])))
+ f-code (get-solution :public
+ f-user-id problem-id)]
+ :when f-code]
+ [:div.follower-solution
+ [:div.solution-username (str f-user "'s solution:")]
+ [:pre.solution-code f-code]]))
+ [:p "None of the users you follow have solved this problem yet!"])))))})
(defn show-solutions [id]
(let [problem-id (Integer. id)
View
29 src/foreclojure/users.clj
@@ -32,12 +32,14 @@
(group-by #(count (or (:solved %) []))
users)))]
(first
- (reduce (fn [[user-list rank] new-group]
+ (reduce (fn [[user-list position rank] new-group]
[(into user-list
(for [user (sort-by :user new-group)]
- (assoc user :rank rank)))
+ (into user {:rank rank
+ :position position})))
+ (inc position)
(+ rank (count new-group))])
- [[] 1]
+ [[] 1 1]
tied-groups))))
(defn get-top-100-and-current-user [username]
@@ -81,29 +83,28 @@
(defn following-checkbox [current-user-id following user-id user]
(when (and current-user-id (not= current-user-id user-id))
- (let [following? (some #{user-id} following)]
+ (let [following? (contains? following user-id)]
(form-to [:post (follow-url user (not following?))]
- [:input.following {:type "checkbox" :name "following"
- :checked following? :value following?}]))))
+ [:input.following {:type "checkbox" :checked following?}]
+ [:span.following (when following? "yes")]))))
(defn generate-user-list [user-set]
(let [[user-id following]
- (if (session/session-get :user)
+ (when (session/session-get :user)
(with-user [{:keys [_id following]}]
- [_id following])
- [nil nil])]
+ [_id (set following)]))]
(list
[:br]
[:table#user-table.my-table
[:thead
[:tr
- [:th {:style "width: 40px;"} "Rank"]
- [:th "Username"]
- [:th "Problems Solved"]
+ [:th {:style "width: 40px;" } "Rank"]
+ [:th {:style "width: 200px;"} "Username"]
+ [:th {:style "width: 180px;"} "Problems Solved"]
[:th "Following"]]]
- (map-indexed (fn [rownum {:keys [_id rank user contributor solved]}]
+ (map-indexed (fn [rownum {:keys [_id position rank user contributor solved]}]
[:tr (row-class rownum)
- [:td (rank-class rank) rank]
+ [:td (rank-class position) rank]
[:td
(when contributor [:span.contributor "* "])
[:a.user-profile-link {:href (str "/user/" user)} user]]
View
8 src/foreclojure/version.clj
@@ -1,15 +1,15 @@
(ns foreclojure.version
(:use [foreclojure.template :only [def-page]]
[foreclojure.config :only [repo-url]]
- [foreclojure.git :only [sha]]
+ [foreclojure.git :only [sha tag]]
[compojure.core :only [defroutes GET]]))
(def-page version []
{:title "About/version"
:content
- (if sha
- [:p "SHA: "
- [:a {:href (str repo-url "/tree/" sha)} sha]]
+ (if tag
+ [:p
+ [:a {:href (str repo-url "/tree/" sha)} tag]]
[:p "No git repository found"])})
(defroutes version-routes
Please sign in to comment.
Something went wrong with that request. Please try again.