Skip to content
Batteries for the web
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Batteries for the web


[ez-web "0.3.0"]

Works with Clojure and ClojureScript.


Core mirrors all functions in the various namespaces for convenience.


(require '[ez-web.paginator :refer [paginate]])
;; if a collection is sent it a count of the collection will be used as length
;; otherwise send in a length, number of pages you want and a position
(= (paginate (range 101) 10 5)
   {:prev-seq (4 3 2 1), :next-seq (6 7 8 9 10 11), :pages 11, :page 5, :next 6, :prev 4}


(require '[ez-web.breadcrumbs :refer [crumb]])
;; send in a string with an opts? map
(crumb "/path/in/your/website" opts?)
;; send in a vector of vectors with [[URI part 1, name of URI 1], [URI part 2, name of URI 2]]
(crumb [["path" "The path"] ["in" "Within"] ["your" "Thy Royal Highness'"] ["website" "Kingdom"]])

;; will give back a map with the keys
;; :crumb-data - the raw data
;; :last - the last bit that is not linked (since you're already on that URL)
;; :crumbs - a vector representation of the breadcrumbs. 
;;           works both with hiccup and enlive/html hiccup 
;;           style function

;; opts?
;; :last? [true] - true/false to have the last bit show up in the crumbs or not
;; :separator [" › "] - what to put in the separators between the uris
;; :separator-attrib [{:class "separator"}] - attrib map for the separator element
;; :holder [:ul] - element to hold the breadcrumbs in
;; :elem [:li] - element to hold each individual breadcrumb/separator in
;; :href-attrib - send in a map to add extra elements. will always have a calculated :href key
;; :base-uri - attach a base uri to the beginning of every breadcrumb


(require '[ez-web.sidemenu :refer [sidemenu]])

;; usage
(sidemenu uri children opts)

;; opts
;; keys and default options
;; base key is used for detemining which page you're currently on. only useful
;; if you're planning on having a link on the page to itself even though you're
;; at the root level

(let [{:keys [holder holder-attrib elem elem-attrib href-attrib base]
       :or {holder :ul holder-attrib {:class "sidemenu"}
            elem :li elem-attrib {} href-attrib {}
            base "/"} opts]

;; example
(sidemenu "/foo/bar"
          [["/" "Home"]
           ["/foo" "Foo" 
             ["/foo/bar" "Bar"]]
           ["/baz" "Baz"]])


<ul class="sidemenu">
   <a href="/">Home</a>
 <li class="active">
   <a href="/foo">Foo</a>
   <ul class="sub">
      <li class="active">
         <a href="/foo/bar">Bar</a>
   <a href="/baz">Baz</a>


(require '[ez-web.uri :refer [join-uri uri-last-part uri-but-last-part])

(= (join-uri "path" "to" "your" "website")

(= (uri-last-part "/path/to/your/website")
(= (uri-but-last-part "/path/to/your/website")


Copyright © 2014-2015 Emil Bengtsson

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Coram Deo

You can’t perform that action at this time.