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
This commit is contained in:
Corey
2015-01-23 17:06:37 -05:00
parent bf38f37224
commit 03cc86e159
4 changed files with 52 additions and 20 deletions

View File

@@ -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 {

View File

@@ -1,4 +1,4 @@
var elems = document.getElementsByTagName("pre");
for (var i = 0; i < elems.length; i++) {
hljs.highlightBlock(elems[i]);
}
}

9
doclet/resources/nav.js Normal file
View File

@@ -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")
}

View File

@@ -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!