   data:haschild ex:person-name ;
   dc:title \"thing\" ;
   dc:description \"stuff\" ;
-  rdf:type data:h1 .
-
-ex:person-name rdf:type data:text-field ;
+  rdf:type w:h1 .
+
+ex:person-name rdf:type w:text-field ;
                data:rank 5 ;
                data:bindo ont:name ;
                dc:title \"Name\" ;
                dc:description \"The name of a person\" .
 
-ex:person-age rdf:type data:text-field ;
+ex:person-age rdf:type w:text-field ;
               data:rank 4 ;
               data:bindo ont:age ;
               dc:title \"Age\" ;
               dc:description \"The age of a person\".
 
-ex:pets-list rdf:type data:list ;
+ex:pets-list rdf:type w:list ;
              data:bindo ont:haspet ;
              dc:title \"Pets\" ;
              dc:description \"A list of the pets a person has\" .
 
 ")
 
-(def mini-view
+(def widgets
   "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
 @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
 @prefix data: <http://logangilmour.com/data-binder#> .
-@prefix ex: <http://logangilmour.com/example-view#> .
-@prefix ont: <http://logangilmour.com/example-ontology#> .
-
-data:root data:haschild ex:person-name .
-
-ex:person-name rdf:type data:paragraph .
-
-ex:person-name data:bindo ont:name .
-
+@prefix w: <http://logangilmour.com/bootstrap-widgets#> .
+
+w:projector rdfs:subClassOf data:relator .
+
+w:column8 rdfs:subClassOf data:container .
+
+w:column4 rdfs:subClassOf data:container .
+
+w:row rdfs:subClassOf data:container .
+
+w:list rdfs:subClassOf data:relator .
+
+w:deleter rdfs:subClassOf data:relator .
+
+w:paragraph rdfs:subClassOf data:relator .
+
+w:text-field rdfs:subClassOf data:relator .
+
+w:h1 rdfs:subClassOf data:container .
 ")
 
 (def data-binder "

                           (relate-right model (prop (:haschild db)) binding)))

        projector (first (relate-left model (prop (:projects db)) binding)) ;;TODO only works for container pointed at by projector for now.
        path (and projector (first (relate-right model (prop (:path db)) projector)))

        bindable (bound-func binding model)

        type (:type bindable)

        new-url-parts (if path
                  (conj url-parts (.getString (.asLiteral path)))
                  url-parts)

        sub-calls (map (fn [child] (s-rec child model url-parts)) children) ;; make the next part of the tree
        meta-data (get-meta-data binding model)]

    (cond
          (= type :relator)

          (let [statement (get-bound binding model) ;; fuckery for binding
                relation-getter (fn [data resource] (relator statement data resource))
                child-func (:value bindable)
                parent-func (:resource bindable)
                myp (first (relate-right model (prop (:path db)) binding))
                mypath (and myp (.getString (.asLiteral myp)))
                ]
            (fn [data child resource url built-url]

              (let [related (if child   ;; get sub-resources (a single one if partial rendering)
                              (seq [child])
                              (relation-getter data resource))
                    func (if child ;; get the bound function
                           (fn [uri bind active url meta vals]
                             (let [val (first vals)]
                               (child-func
                                uri (:uri val) bind meta (:html val))))
                           (fn [uri bind active url meta vals]
                             (parent-func
                              uri bind active url meta
                              (map (fn [val] (child-func
                                             uri (:uri val) bind meta (:html val))) vals))))
                    current (and mypath (get (parse-uri url) mypath))
                    active (and mypath (= current (.getURI resource)))
                    myurl (and mypath (str built-url mypath "/" (.getURI resource) "/")) ]
                (func (.getURI resource) ;; apply the bound function to the thing, the binding that points at the funtion, meta-data, and the finished children (should be ordered by now).
                      (.getURI binding)
                      active
                      (or myurl built-url)
                      meta-data
                      (map (fn [val] {:uri (first val) :html (second val)})
                           (map vector
                                (map #(.toString %) related) ;; TODO this is a little sketchy
                                (if (empty? sub-calls)
                                  (map literalize related)
                                  (map seq (apply map vector (map (fn [sub-call]
                                                                    (map
                                                                     (fn [val] (sub-call data nil val url built-url))
                                                                     related))
                                                                  sub-calls))))))))))
          (= type :container)
          (fn [data child resource url built-url]
            (let [func (:display bindable)
                  ppath (and path (.getString (.asLiteral path)))
                  p (get (parse-uri url) ppath)
                  projected (if (and p (res p))
                              (if (.containsResource data (res p))

(defroutes main-routes
  (GET "/async/*" [] (wrap-aleph-handler chat-handler))
  (GET "/view/*" [*]
       (page ((serializer (to-model example-view) (to-model widgets)) (build-query (to-model example-view) (to-model widgets) *) (res "http://logangilmour.com/example-ontology#person") *)))
  (route/resources "/")
  (route/not-found "Page not found"))

