Permalink
Browse files

Back out the HTML generation. I'm rethinking the project workflow and…

… may implement this as a web service at some point
  • Loading branch information...
1 parent 29209b4 commit 4901229896d6da2e87b951dfd2fd8b9d91fc9392 @mtnygard committed Apr 20, 2012
Showing with 2 additions and 52 deletions.
  1. +2 −4 src/utree/core.clj
  2. +0 −48 src/utree/html.clj
View
@@ -1,7 +1,6 @@
(ns utree.core
(:use (clojure.java io))
- (:require (utree [dot :as dot]
- [html :as html]))
+ (:require (utree [dot :as dot]))
(:require (clojure [string :as str]))
(:gen-class))
@@ -16,8 +15,7 @@
`(defcommand ~@command-def)) command-defs)))
(defcommands
- (dot "filename" "Generate dot files from utility trees" dot/dot)
- (html "filename outdir" "Generate an HTML ordered list representing the tree" html/html-from-utility-tree))
+ (dot "filename" "Generate dot files from utility trees" dot/dot))
(defn lookup-command
[ns name]
View
@@ -1,48 +0,0 @@
-(ns utree.html
- (:use (utree parser graph))
- (:require [clojure.java.io :as io]
- [clojure.data.json :as json]
- [clojure.string :as str]))
-
-(def template-path "templates")
-
-(defn dir? [filename] (.isDirectory (io/file filename)))
-(defn copy [fromname toname] (io/copy (io/file fromname) (io/file toname)))
-(defn mkdir [dirname] (.mkdir (io/file dirname)))
-
-(defn assets [base pred]
- (map (memfn getPath) (filter pred (file-seq (io/file base)))))
-
-(defn replace-path [full from to]
- (str/replace full from to))
-
-(defn graph-node->tree [g n]
- (dissoc
- (merge (g n)
- {:id n}
- (when-let [children (seq (next-nodes g n))]
- (hash-map :children (vec (map #(graph-node->tree g %) children)))))
- :next
- :prev))
-
-(defn graph->nested-list [g n] (list (g n) (map #(graph->nested-list g %) (next-nodes g n))))
-
-(defn copy-assets
- [fromdir todir]
- (doseq [srcdir (assets fromdir dir?)]
- (mkdir (replace-path srcdir fromdir todir)))
- (doseq [srcfile (assets fromdir (complement dir?))]
- (copy srcfile (replace-path srcfile fromdir todir))))
-
-(defn html-from-utility-tree
- [filename outdir]
- "Generates an HTML view of the utility tree into the specified directory.
- Will write several files."
- (mkdir outdir)
- (copy-assets template-path outdir)
- (spit
- (io/file outdir "utility-tree.json")
- (with-out-str
- (json/pprint-json
- (graph-node->tree
- (file->graph filename) 0)))))

0 comments on commit 4901229

Please sign in to comment.