From bf38f3722474e3c5d9e1439ee8cb5cf6b1a0eeec Mon Sep 17 00:00:00 2001 From: Corey Date: Fri, 23 Jan 2015 14:42:32 -0500 Subject: [PATCH 1/4] Migrated html generation to use frames --- doclet/src/clojure/play_clj_doclet/html.clj | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/doclet/src/clojure/play_clj_doclet/html.clj b/doclet/src/clojure/play_clj_doclet/html.clj index 11fa3bf..d8ad688 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)} + [:a {:href (str->filename ns name) :target "content-frame"} name]])))]) (defn java-param @@ -61,14 +61,13 @@ [:pre raw]]]]) (defn create-site-file - [name sidebar content] + [name content] (html [:html [:head [:title name] [:link {:rel "stylesheet" :href "highlight.css"}] [:link {:rel "stylesheet" :href "main.css"}]] [:body - sidebar content [:script {:src "highlight.js"}] [:script {:src "main.js"}]]])) @@ -82,6 +81,12 @@ (spit (io/file dir file-name) (-> file-name io/resource slurp))) +(defn index-frameset + [] + (html [:frameset + [:frame {:src "sidebar.html"} + :frame {:name "content-frame"}]])) + (defn create-site! [dir parsed-files] (.mkdir (io/file dir)) @@ -92,9 +97,11 @@ (doseq [[ns groups] parsed-files] (doseq [{:keys [name] :as group} groups] (spit (io/file dir (str->filename ns name)) - (create-site-file name (sidebar parsed-files) (content group))))) + (create-site-file name (content group))))) + (spit (io/file dir "sidebar.html") + (sidebar parsed-files)) (spit (io/file dir "index.html") - (create-site-file "play-clj docs" (sidebar parsed-files) nil)) + (create-site-file "play-clj docs" (index-frameset))) (println "Created" (str dir "/"))) (defn create-embed! From 03cc86e159a7f30c45eba0af039e1c7ac6de6cd4 Mon Sep 17 00:00:00 2001 From: Corey Date: Fri, 23 Jan 2015 17:06:37 -0500 Subject: [PATCH 2/4] Reworked doclet to work with frames Hash in url bar is page to load for frames When you click a nav link, it sets the hash If you go to nav link in new tab, and click home, it will load the same page, but in the frames --- doclet/resources/main.css | 8 +++- doclet/resources/main.js | 2 +- doclet/resources/nav.js | 9 ++++ doclet/src/clojure/play_clj_doclet/html.clj | 53 ++++++++++++++------- 4 files changed, 52 insertions(+), 20 deletions(-) create mode 100644 doclet/resources/nav.js 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! From c95dda06b17578121533991afa1aaaf1c23d8872 Mon Sep 17 00:00:00 2001 From: Corey Date: Fri, 23 Jan 2015 17:08:30 -0500 Subject: [PATCH 3/4] Renamed Home to Frames --- doclet/src/clojure/play_clj_doclet/html.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doclet/src/clojure/play_clj_doclet/html.clj b/doclet/src/clojure/play_clj_doclet/html.clj index 6430595..9ce92e0 100644 --- a/doclet/src/clojure/play_clj_doclet/html.clj +++ b/doclet/src/clojure/play_clj_doclet/html.clj @@ -74,7 +74,7 @@ [:a {:href (str "index.html" (if (not-empty home-link-hash) (str "#" home-link-hash) "")) - :target "_top"} "Home"]]) + :target "_top"} "Frames"]]) content [:script {:src "highlight.js"}] [:script {:src "main.js"}]]]))) From 86e21cc73dda4776f78ecb3190efe12a8f141598 Mon Sep 17 00:00:00 2001 From: oakes Date: Wed, 11 Feb 2015 17:01:02 -0500 Subject: [PATCH 4/4] Add touch-ups after frame redesign --- doclet/resources/main.css | 16 +------------- doclet/resources/nav.js | 12 +++++------ doclet/src/clojure/play_clj_doclet/html.clj | 23 ++++++++++----------- 3 files changed, 18 insertions(+), 33 deletions(-) diff --git a/doclet/resources/main.css b/doclet/resources/main.css index 3adcf5c..d0fb416 100644 --- a/doclet/resources/main.css +++ b/doclet/resources/main.css @@ -1,5 +1,3 @@ -/*! normalize.css v3.0.1 | MIT License | git.io/normalize */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0} - body { font-family: "Fira Sans", "Source Sans Pro", "Helvetica Neue", sans-serif; background-color: #293134; @@ -26,17 +24,11 @@ a:hover { transition-property: opacity; transition-duration: 200ms; transition-timing-function: cubic-bezier(.53,.4,.46,.75); - width: 240px; - height: 100%; - top: 0px; - left: 0px; - overflow: auto; - padding: 0px 0px 0px 10px; opacity: 0.6; } .sidebar:hover { - opacity: 0.9; + opacity: 0.9; } .ns { @@ -53,12 +45,6 @@ a:hover { text-indent: 10px; } -.headbar { - padding: 5px 0px 5px 5px; - width: 100%; - border-bottom: 1px solid black -} - .content { padding: 20px 0px 20px 20px; } diff --git a/doclet/resources/nav.js b/doclet/resources/nav.js index ebc7476..530f1d2 100644 --- a/doclet/resources/nav.js +++ b/doclet/resources/nav.js @@ -1,9 +1,9 @@ -function goToHash(){ - if(window.location.hash != ""){ - document.getElementById("content-frame").src = window.location.hash.substr(1) - } +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") +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 9ce92e0..adb5cd0 100644 --- a/doclet/src/clojure/play_clj_doclet/html.clj +++ b/doclet/src/clojure/play_clj_doclet/html.clj @@ -41,12 +41,17 @@ [:div {:class "j-doc"} text])]) (defn content - [{:keys [name docstring arglists java raw raw*]}] + [{:keys [name docstring arglists java raw raw*]} & [home-link-hash]] [:div {:class "content"} [:div {:class "item"} [:div {:class "clj"} (for [args arglists] - [:div {:class "c-head"} (pr-str args)]) + [:div {:class "c-head"} + (if home-link-hash + [:a {:href (str "index.html" (str "#" home-link-hash)) + :target "_top"} + (pr-str args)] + (pr-str args))]) [:div {:class "c-doc"} docstring]] (when (> (count java) 0) (list [:div {:class "c-head"} "Options"] @@ -61,7 +66,7 @@ [:pre raw]]]]) (defn create-site-file - ([name content home-link-hash] + ([name content] (html [:html [:head [:title name] @@ -69,12 +74,6 @@ [: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"} "Frames"]]) content [:script {:src "highlight.js"}] [:script {:src "main.js"}]]]))) @@ -114,11 +113,11 @@ (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) (str->filename ns name))))) + (create-site-file name (content group (str->filename ns name)))))) (spit (io/file dir "sidebar.html") - (create-site-file "sidebar" (sidebar parsed-files) nil)) + (create-site-file "sidebar" (sidebar parsed-files))) (spit (io/file dir "blank.html") - (create-site-file "blank" nil "")) + (create-site-file "blank" nil)) (spit (io/file dir "index.html") (index-frameset)) (println "Created" (str dir "/")))