Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
346 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
(ns refheap.views.about | ||
(:require [clojure.java.io :as io] | ||
[refheap.views.common :refer [layout]] | ||
(:require [refheap.views.common :refer [layout static]] | ||
[compojure.core :refer [defroutes GET]])) | ||
|
||
(defroutes about-routes | ||
(GET "/about" [] | ||
(layout (slurp (io/resource "refheap/views/templates/about.mustache"))))) | ||
(GET "/about" [] (layout (static "refheap/views/templates/about.html")))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,52 @@ | ||
(ns refheap.views.common | ||
(:require [noir.session :as session] | ||
[stencil.core :as stencil] | ||
[refheap.models.paste :as paste] | ||
[clavatar.core :refer [gravatar]])) | ||
[stencil.core :as stencil] | ||
[clavatar.core :refer [gravatar]] | ||
[me.raynes.laser :refer [defdocument defragment] :as l] | ||
[clojure.java.io :refer [resource]])) | ||
|
||
(defn avatar [email size] | ||
(gravatar email :size size)) | ||
|
||
(defn logged-in [username] | ||
(stencil/render-file | ||
"refheap/views/templates/loggedin" | ||
{:user (when-let [user (or username | ||
(and (bound? #'session/*noir-session*) | ||
(:username (session/get :user))))] | ||
{:username user})})) | ||
(defn static [file] | ||
(-> file resource slurp l/unescaped)) | ||
|
||
(let [html (l/parse-fragment (resource "refheap/views/templates/loggedin.html")) | ||
logged-out (static "refheap/views/templates/loggedout.html")] | ||
(defn logged-in [username] | ||
(let [user (or username | ||
(and (bound? #'session/*noir-session*) | ||
(:username (session/get :user))))] | ||
(if user | ||
(l/fragment html | ||
(l/id= "userbutton") (comp (l/attr :href (str "/users/" user)) | ||
(l/content user))) | ||
logged-out)))) | ||
|
||
(defragment head (resource "refheap/views/templates/head.html") | ||
[title heads] | ||
(l/id= "last-include") #(if heads [% heads] %) | ||
(l/element= :title) (l/content (or title "Refheap"))) | ||
|
||
(defn layout [body & [head]] | ||
(stencil/render-file | ||
"refheap/views/templates/common" | ||
{:user (logged-in nil) | ||
:title (or (:title head) "RefHeap") | ||
:content body | ||
:head (when-let [head-file (:file head)] | ||
(stencil/render-file head-file (dissoc head :file :title)))})) | ||
(defragment body (resource "refheap/views/templates/commonbody.html") | ||
[contents] | ||
(l/id= "useri") (l/content (logged-in nil)) | ||
(l/id= "container") (l/content contents)) | ||
|
||
(defn body [contents] | ||
(stencil/render-file | ||
"refheap/views/templates/commonbody" | ||
{:user (logged-in nil) | ||
:content contents})) | ||
(let [html (l/parse (resource "refheap/views/templates/common.html"))] | ||
(defn layout | ||
([content] (layout content "Refheap" nil)) | ||
([content title] (layout content title nil)) | ||
([content title heads] | ||
(l/document | ||
html | ||
(l/element= :head) (l/content (head title heads)) | ||
(l/element= :body) (l/content (body content)))))) | ||
|
||
(defn page-buttons [base n per page] | ||
(stencil/render-file | ||
"refheap/views/templates/pagination" | ||
{:newer (when-not (= 1 page) {:base base, :page (dec page)}) | ||
:older (when-not (or (zero? n) (= page (paste/count-pages n per))) | ||
{:base base, :page (inc page)})})) | ||
(defragment page-buttons (resource "refheap/views/templates/pagination.html") | ||
[base n per page] | ||
(l/id= "newer") #(when-not (= 1 page) | ||
(assoc-in % [:attrs :href] (str base "?page=" (dec page)))) | ||
(l/id= "older") #(when-not (or (zero? n) (= page (paste/count-pages n per))) | ||
(assoc-in % [:attrs :href] (str base "?page=" (inc page))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
(ns refheap.views.legal | ||
(:require [clojure.java.io :as io] | ||
[compojure.core :refer [defroutes GET]] | ||
[refheap.views.common :refer [layout]])) | ||
(:require [compojure.core :refer [defroutes GET]] | ||
[refheap.views.common :refer [static layout]])) | ||
|
||
(defroutes legal-routes | ||
(GET "/legal/tos" [] | ||
(layout (slurp (io/resource "refheap/views/templates/tos.mustache")))) | ||
(GET "/legal/privacy" [] | ||
(layout (slurp (io/resource "refheap/views/templates/privacy.mustache"))))) | ||
(GET "/legal/tos" [] (layout (static "refheap/views/templates/tos.html"))) | ||
(GET "/legal/privacy" [] (layout (static "refheap/views/templates/privacy.html")))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.