Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'release/1.8.1'

  • Loading branch information...
commit b5c1f1be5836d7ef7ed119c99519814b05878697 2 parents abe9d71 + f82a40e
@amalloy amalloy authored
View
2  README.md
@@ -16,7 +16,7 @@ Join us in #4clojure on freenode for help or discussion.
* Download and install [leiningen](https://github.com/technomancy/leiningen).
* Download and install [mongodb](http://www.mongodb.org/).
* The project uses
-[clojail](https://github.com/cognitivedissonance/clojail), which
+[clojail](https://github.com/flatland/clojail), which
requires a security policy setup in your home directory (because
Clojure's `eval` is unsafe if used improperly). Set up a file called
`.java.policy` in your home directory. The contents should look
View
2  config.clj
@@ -1,6 +1,6 @@
{:wrap-reload false
:db-host "localhost"
- :db-name "mydb"
+ :db-name "4clojure"
:db-user nil
:db-pwd nil
:jetty-port 8080
View
6 project.clj
@@ -1,4 +1,4 @@
-(defproject foreclojure "1.8.0.1"
+(defproject foreclojure "1.8.1"
:description "4clojure - a website for learning Clojure"
:dependencies [[clojure "1.2.1"]
[clojure-contrib "1.2.0"]
@@ -12,7 +12,7 @@
[useful "0.7.0-beta5"]
[amalloy/ring-gzip-middleware "[0.1.0,)"]
[amalloy/mongo-session "0.0.1"]
- [clj-github "1.0.1"]
+ [innuendo "0.1.1"]
[ring "0.3.7"]
[clj-config "0.1.0"]
[incanter/incanter-core "1.2.3"]
@@ -20,7 +20,7 @@
[commons-lang "2.6"]
[org.apache.commons/commons-email "1.2"]]
:dev-dependencies [[lein-ring "0.4.5"]
- [midje "1.1.1"]]
+ [midje "1.3.0"]]
:checksum-deps true
:main foreclojure.core
:ring {:handler foreclojure.core/app
View
2  src/foreclojure/mongo.clj
@@ -55,7 +55,7 @@
+ times))
{}))
solved-counts (frequencies (map int (mapcat :solved users)))
- total (reduce + (vals solved-counts))]
+ total (reduce + 0 (vals solved-counts))]
(send solved-stats (constantly (assoc scores :total total :solved-counts solved-counts)))))
(defn prepare-mongo []
View
8 src/foreclojure/problems.clj
@@ -8,7 +8,7 @@
(:use [foreclojure.utils :only [from-mongo get-user get-solved login-link flash-msg flash-error row-class approver? can-submit? send-email image-builder if-user with-user as-int maybe-update escape-html]]
[foreclojure.ring-utils :only [*url*]]
[foreclojure.template :only [def-page content-page]]
- [foreclojure.social :only [tweet-link gist!]]
+ [foreclojure.social :only [tweet-link]]
[foreclojure.feeds :only [create-feed]]
[foreclojure.users :only [golfer? get-user-id disable-codebox?]]
[foreclojure.solutions :only [save-solution get-solution]]
@@ -139,7 +139,7 @@
(defn mark-completed [problem code & [user]]
(let [user (or user (session/session-get :user))
{:keys [_id approved]} problem
- gist-link (html [:span.share
+ paste-link (html [:span.share
[:a.novisited {:href "/share/code"} "share"]
" this solution on github and twitter! "])
message
@@ -150,10 +150,10 @@
(str "Congratulations, you've solved the problem! See the "
"<a href='/problem/solutions/" _id "'>solutions</a>"
" that the users you follow have submitted, or "
- gist-link
+ paste-link
(next-problem-link _id)))
:else (str "You've solved the problem; "
- gist-link
+ paste-link
"You need to " (login-link "log in" (str "/problem/" _id)) " in order to save your solutions and track progress."))]
(session/session-put! :code [_id code])
{:message message, :error "", :url (str "/problem/" _id)}))
View
42 src/foreclojure/social.clj
@@ -1,5 +1,5 @@
(ns foreclojure.social
- (:require [clj-github.gists :as gist]
+ (:require [innuendo.core :as rheap]
[sandbar.stateful-session :as session])
(:import [java.net URLEncoder])
(:use [foreclojure.template :only [def-page]]
@@ -43,32 +43,29 @@
:only [:title]
:where {:_id id})))
-(defn gist!
- "Create a new gist containing a user's solution to a problem and
+(defn paste!
+ "Create a new paste containing a user's solution to a problem and
return its url."
[user-name problem-num solution]
(let [[user-name possessive] (if user-name
[user-name "'s"]
["anonymous" nil])
name (get-problem-title problem-num)
- filename (str user-name "-4clojure-solution" problem-num ".clj")
text (str ";; " user-name possessive " solution to " name "\n"
";; https://4clojure.com/problem/" problem-num
"\n\n"
solution)]
(try
- (->> (gist/new-gist {} filename text)
- :repo
- (str "https://gist.github.com/"))
+ (:url (rheap/create-paste text {:language "Clojure"}))
(catch Throwable _))))
-(defn tweet-solution [id gist-url & [link-text]]
+(defn tweet-solution [id paste-url & [link-text]]
(let [status-msg (str "Check out how I solved "
(let [title (get-problem-title id)]
(if (> (count title) 35)
(str "problem " id)
(str "\"" title "\"")))
- " on #4clojure " (clojure-hashtag) gist-url)]
+ " on #4clojure " (clojure-hashtag) paste-url)]
(tweet-link id status-msg link-text)))
(def-page share-page []
@@ -76,19 +73,20 @@
:content
(if-let [[id code] (session/session-get :code)]
(let [user (session/session-get :user)
- gist-url (gist! user id code)
- gist-link (if gist-url
- [:div {:id "shared-code-box"}
- [:div.code
- [:h3 "Your Solution"]
- [:pre {:class "brush: clojure;gutter: false;toolbar: false;light: true"} (escape-html code)]]
- [:br]
- [:div.share
- "Share this " (link-to gist-url "solution")
- " on " (tweet-solution id gist-url) "?"]]
- [:div.error
- "Failed to create gist of your solution"])]
- gist-link)
+ paste-url (paste! user id code)
+ paste-link (if paste-url
+ [:div {:id "shared-code-box"}
+ [:div.code
+ [:h3 "Your Solution"]
+ [:pre {:class "brush: clojure;gutter: false;toolbar: false;light: true"}
+ (escape-html code)]]
+ [:br]
+ [:div.share
+ "Share this " (link-to paste-url "solution")
+ " on " (tweet-solution id paste-url) "?"]]
+ [:div.error
+ "Failed to create paste of your solution"])]
+ paste-link)
[:div.error
"Sorry...I don't remember you solving anything recently!"])})
Please sign in to comment.
Something went wrong with that request. Please try again.