Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

103 lines (99 sloc) 4.663 kb
(ns foreclojure.template
(:require [sandbar.stateful-session :as session])
(:use [hiccup.core :only [html]]
[ :only [doctype javascript-tag link-to]]
[foreclojure.config :only [config repo-url]]
[foreclojure.utils :only [page-attributes rendering-info login-url approver? can-submit?]]
[foreclojure.ring-utils :only [static-url]]
[foreclojure.version-utils :only [css js]]))
;; Global wrapping template
(defn html-doc [body]
(let [attrs (rendering-info (page-attributes body))
user (session/session-get :user)]
(doctype :html5)
[:title (:title attrs)]
[:link {:rel "alternate" :type "application/atom+xml" :title "Atom" :href "/problems/rss"}]
[:link {:rel "shortcut icon" :href (static-url "favicon2.ico")}]
[:style {:type "text/css"}
".syntaxhighlighter { overflow-y: hidden !important; }"]
(css "css/style.css" "css/demo_table.css" "css/shCore.css" "css/shThemeDefault.css")
(js "vendor/script/jquery-1.5.2.min.js" "vendor/script/jquery.dataTables.min.js")
(js "script/foreclojure.js")
(js "vendor/script/xregexp.js" "vendor/script/shCore.js" "vendor/script/shBrushClojure.js")
(js "vendor/script/ace/ace.js" "vendor/script/ace/mode-clojure.js")
[:script {:type "text/javascript"} "SyntaxHighlighter.all()"]]
(when (:fork-banner attrs)
[:div#github-banner [:a {:href repo-url
:alt "Fork 4Clojure on Github!"}]])
(link-to "/" [:img#logo {:src (static-url "images/4clj-logo-small.png")
:alt ""}])]
(for [[link text & [tabbed]]
[["/" "Main Page"]
["/problems" "Problem List"]
["/users" "Top Users"]
["/directions" "Help"]
["" "REPL" true]
["" "Docs" true]]]
[ (assoc (when tabbed {:target "_blank"})
:href link)
(if user
[:span#username (str "Logged in as " user)]
[:a#logout {:href "/logout"} "Logout"]]
[:a#login {:href (login-url)} "Login"]
[:a#register {:href "/register"} "Register"]])]]
(when user
(link-to "/login/update" "Account Settings")]
(when (:golfing-active config)
[:span ; deserves its own page, but just make it discoverable for now
(link-to "/league" "Leagues")])
(when (approver? user)
(link-to "/problems/unapproved" "View Unapproved Problems")])
(when (can-submit? user)
[:span (link-to "/problems/submit" "Submit a Problem")])])
[:div#content_body (:content attrs)]
"The content on is available under the EPL v 1.0 license."
(let [email ""]
[:a#contact {:href (str "mailto:" email)} "Contact us"]
(str " (" email ")")])]
"var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22844856-1']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
;; Content templates
(defn content-page [{:keys [heading heading-note sub-heading main]}]
(let [flash-message (session/flash-get :message)
flash-error (session/flash-get :error)]
(when heading [:div#heading heading])
(when heading-note [:div#heading-note heading-note])
(when sub-heading [:div#sub-heading sub-heading])
(when flash-message [:div.message
[:span#flash-text flash-message]])
(when flash-error [:div.message
[:span#error-text flash-error]])
(when main [:div#main main]))))
(defmacro def-page [page-name [& args] & code]
`(defn ~page-name [~@args]
(html-doc (do ~@code))))
Jump to Line
Something went wrong with that request. Please try again.