Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'f/refheap' into develop

  • Loading branch information...
commit 50f3da1546caac82898f96a69809d3379ddaef8d 2 parents 12697df + b86221e
@amalloy amalloy authored
View
2  project.clj
@@ -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"]
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.