diff --git a/doclet/resources/main.css b/doclet/resources/main.css index b82e02c..3adcf5c 100644 --- a/doclet/resources/main.css +++ b/doclet/resources/main.css @@ -30,7 +30,6 @@ a:hover { height: 100%; top: 0px; left: 0px; - position: fixed; overflow: auto; padding: 0px 0px 0px 10px; opacity: 0.6; @@ -54,9 +53,14 @@ a:hover { text-indent: 10px; } +.headbar { + padding: 5px 0px 5px 5px; + width: 100%; + border-bottom: 1px solid black +} + .content { padding: 20px 0px 20px 20px; - margin-left: 250px; } .content code { diff --git a/doclet/resources/main.js b/doclet/resources/main.js index a254ba7..6a15493 100644 --- a/doclet/resources/main.js +++ b/doclet/resources/main.js @@ -1,4 +1,4 @@ var elems = document.getElementsByTagName("pre"); for (var i = 0; i < elems.length; i++) { hljs.highlightBlock(elems[i]); -} \ No newline at end of file +} diff --git a/doclet/resources/nav.js b/doclet/resources/nav.js new file mode 100644 index 0000000..ebc7476 --- /dev/null +++ b/doclet/resources/nav.js @@ -0,0 +1,9 @@ +function goToHash(){ + if(window.location.hash != ""){ + document.getElementById("content-frame").src = window.location.hash.substr(1) + } +} + +function setHash(link){ + window.parent.location.hash = link.getAttribute("newHash") +} diff --git a/doclet/src/clojure/play_clj_doclet/html.clj b/doclet/src/clojure/play_clj_doclet/html.clj index d8ad688..6430595 100644 --- a/doclet/src/clojure/play_clj_doclet/html.clj +++ b/doclet/src/clojure/play_clj_doclet/html.clj @@ -20,7 +20,7 @@ (cons [:div {:class "ns"} ns] (for [{:keys [name]} groups] [:div {:class "name"} - [:a {:href (str->filename ns name) :target "content-frame"} + [:a {:href (str->filename ns name) :target "content-frame" :onClick (str "setHash(this)") :newHash (str->filename ns name)} name]])))]) (defn java-param @@ -61,16 +61,23 @@ [:pre raw]]]]) (defn create-site-file - [name content] - (html [:html - [:head - [:title name] - [:link {:rel "stylesheet" :href "highlight.css"}] - [:link {:rel "stylesheet" :href "main.css"}]] - [:body - content - [:script {:src "highlight.js"}] - [:script {:src "main.js"}]]])) + ([name content home-link-hash] + (html [:html + [:head + [:title name] + [:script {:src "nav.js"}] + [:link {:rel "stylesheet" :href "highlight.css"}] + [:link {:rel "stylesheet" :href "main.css"}]] + [:body + (when home-link-hash + [:div {:class "headbar"} + [:a {:href (str "index.html" (if (not-empty home-link-hash) + (str "#" home-link-hash) + "")) + :target "_top"} "Home"]]) + content + [:script {:src "highlight.js"}] + [:script {:src "main.js"}]]]))) (defn create-embed-file [content] @@ -83,25 +90,37 @@ (defn index-frameset [] - (html [:frameset - [:frame {:src "sidebar.html"} - :frame {:name "content-frame"}]])) + (html + [:html + [:head + [:title "play-clj docs"] + [:script {:src "nav.js"}] + [:link {:rel "stylesheet" :href "highlight.css"}] + [:link {:rel "stylesheet" :href "main.css"}]] + [:frameset {:cols "250px,100%" :onLoad "goToHash();"} + [:frame {:src "sidebar.html"}] + [:frame {:src "blank.html" :name "content-frame" :id "content-frame"}] + [:script {:src "highlight.js"}] + [:script {:src "main.js"}]]])) (defn create-site! [dir parsed-files] (.mkdir (io/file dir)) (copy-from-res dir "main.css") (copy-from-res dir "main.js") + (copy-from-res dir "nav.js") (copy-from-res dir "highlight.css") (copy-from-res dir "highlight.js") (doseq [[ns groups] parsed-files] (doseq [{:keys [name] :as group} groups] (spit (io/file dir (str->filename ns name)) - (create-site-file name (content group))))) + (create-site-file name (content group) (str->filename ns name))))) (spit (io/file dir "sidebar.html") - (sidebar parsed-files)) + (create-site-file "sidebar" (sidebar parsed-files) nil)) + (spit (io/file dir "blank.html") + (create-site-file "blank" nil "")) (spit (io/file dir "index.html") - (create-site-file "play-clj docs" (index-frameset))) + (index-frameset)) (println "Created" (str dir "/"))) (defn create-embed!