Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[WIP] Making class render again. Pagination is broken because of a ni…

…l start variable
  • Loading branch information...
commit 2c567f9fdf6a97982889f8f74506dd1378b915a2 1 parent 7502678
Aaron Bedra abedra authored
28 src/mycroft/class.clj
View
@@ -1,23 +1,27 @@
(ns mycroft.class
- (:use [mycroft.data :only (render-type)]
+ (:use [clojure.tools.logging :only (info)]
+ [mycroft.data :only (render-type)]
mycroft.selector)
(:require [mycroft.reflect :as reflect]
[mycroft.breadcrumb :as breadcrumb]))
(defn render
[cls options selection]
+ (info "Class" cls)
+ (info "Options" options)
+ (info "Selection" selection)
(let [obj (reflect/members cls)
selectors (:selectors options)
selection (select-in obj selectors)]
[:div
- [:div {:id "breadcrumb"}
- (breadcrumb/render cls options selection)]
- [:div
- (render-type {:superclasses (supers cls)}
- {})]
- [:div
- (render-type selection
- (if selectors
- options
- (assoc options :headers
- [:name :type :parameter-types :return-type :modifiers :declaring-class])))]]))
+ [:div {:id "breadcrumb"} (breadcrumb/render cls options selection)]
+ [:div (render-type {:superclasses (supers cls)} {})]
+ [:div (render-type selection
+ (if selectors
+ (do
+ (info "selectors present" options)
+ options)
+ (do
+ (info "selectors not present")
+ (assoc options :headers
+ [:name :type :parameter-types :return-type :modifiers :declaring-class]))))]]))
26 src/mycroft/data.clj
View
@@ -1,5 +1,6 @@
(ns mycroft.data
(:use clojure.pprint
+ [clojure.tools.logging :only (info)]
mycroft.selector
[hiccup.core :only (escape-html)])
(:require [mycroft.docs :as docs]
@@ -36,22 +37,30 @@
(defmulti render-type (fn [type options] (tag type)))
(defmethod render-type nil [this options]
+ (info "NIL")
(render-type "<nil>" options))
(defmethod render-type :Array [this options]
+ (info "Array")
(render-type (seq this) options))
(defmethod render-type java.util.Collection [this options]
+ (info "Collection")
(render-collection this options))
(defmethod render-type clojure.lang.ISeq [this options]
+ (info "ISeq")
(render-collection this options))
(defmethod render-type clojure.lang.IPersistentCollection [this options]
+ (info "IPersistentCollection")
(render-collection this options))
(defmethod render-type clojure.lang.IRef [this options]
+ (info "IRef")
(render-type @this (add-selector options :mycroft/deref)))
(defmethod render-type clojure.lang.Var [this options]
+ (info "Var")
(if (fn? (safe-deref this))
(docs/render this options)
(render-type (safe-deref this) (add-selector options :mycroft/deref))))
(defmethod render-type :default [this options]
+ (info "Default")
(render-string this options))
(prefer-method render-type clojure.lang.IPersistentCollection java.util.Collection)
@@ -121,13 +130,17 @@
(defn render-pagination
[{:keys [start] :as options} count has-more?]
+ (info "Pagination Count:" count)
+ (info "Pagination Options:" options)
+ (info "Pagination Has More?:" has-more?)
+ (info "Pagination Start:" start)
(when (or (not count)
(> count items-per-page))
[:div.buttons {:id "pagination"}
- (if (> start 0)
- [:a {:href (str "?" (breadcrumb/options->query-string (update-in options [:start] - items-per-page)))}
- "prev"]
- [:span.disabled-button "prev"])
+ ;; (if (> start 0)
+ ;; [:a {:href (str "?" (breadcrumb/options->query-string (update-in options [:start] - items-per-page)))}
+ ;; "prev"]
+ ;; [:span.disabled-button "prev"])
(when count
[:span
(str "Items " start "-" (min count (+ start items-per-page)) " of " count)])
@@ -169,8 +182,9 @@
content (take items-per-page content)]
(if (composite? content)
[:div
- (render-table content options)
- (render-pagination options count has-more?)]
+ (render-table content options)]
+ ;; Currently broken because of missing start
+ ;; (render-pagination options count has-more?)]
(render-type content options))))
5 src/mycroft/docs.clj
View
@@ -1,5 +1,6 @@
(ns mycroft.docs
- (:use [clojure.pprint :only (pprint)])
+ (:use [clojure.pprint :only (pprint)]
+ [clojure.tools.logging :only (info)])
(:require [clojure.string :as str]
[clojure.java.javadoc :as javadoc]
clojure.repl))
@@ -47,6 +48,8 @@
(defn render
"Render docstring and source for a var"
[var options]
+ (info "Doc Var:" var)
+ (info "Doc Options:" options)
[:div
[:h4 "Docstring"]
[:pre [:code (doc-string var)]]
13 src/mycroft/layouts/application.clj
View
@@ -21,17 +21,16 @@
"/javascripts/shBrushClojure.js")]
[:body {:id "browser"}
[:h2 {:class "logo"} [:a {:href "/" :class "home"} "Home"] [:a {:href "/index.html"} "Mycroft, a Clojure inspector"]]
- [:div {:id "content"}
- body]
- [:div {:id "footer"}
- "Clojure Mini-Browser"]]))
+ [:div {:id "content"} body]
+ [:div {:id "footer"} "Clojure Mini-Browser"]]))
(defn namespaces []
- (html
- (minib-layout "Namespaces" (namespace/browser))))
+ (minib-layout "Namespaces" (namespace/browser)))
(defn classes [params query-params]
- (let [classname (get params "*")
+ (info "params" params)
+ (info "query-params" query-params)
+ (let [classname (:* params)
cls (Class/forName classname)]
(minib-layout classname
(class/render cls query-params cls))))
Please sign in to comment.
Something went wrong with that request. Please try again.