Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Upgrade Hiccup & fix tests #102

Closed
wants to merge 5 commits into from

3 participants

@MerelyAPseudonym

When I was trying to lein2 marg on a Compojure project, I got an exception about a missing function escape-html. In Hiccup's change to 1.0, it moved hiccup.core/encode-html into hiccup.util/encode-html, so I updated Marginalia's source accordingly.

In order to make sure upgrading Hiccup didn't break anything, I attempted to run Marginalia's tests. When those also spewed exceptions, I made a few edits to them too.

Josh Tilles added some commits
Josh Tilles Update dependencies and imports.
Let's see what breaks!
6f545d0
Josh Tilles Remove dependency on contrib.java-utils
When I tried to do a `lein2 test` it broke. Uh oh. Time to go debug the tests… `delete-file-recursively` wasn't even in 1.2's `java-utils`, it was in `contrib.io`. Weird.
06b5d90
Josh Tilles Replace outdated function 9895be2
Josh Tilles Fix wrong-number-of-args error when running the tests 1f4dc31
Josh Tilles Use the newer hiccup API 2f23964
@MerelyAPseudonym

(if I did anything "wrong", please let me know—this is my first GitHub pull request! So I'd be happy to change or redo anything if it means making your lives easier)

@dcj
dcj commented

I have just been bitten by this exact issue.
My application uses hiccup, and I just changed it to the 1.0.0 version
Now "lein marg" gives me the same problem described here.
In addition, I am not using lein2 yet, this is all with lein1.

I'd be great to have a version that worked with hiccup 1.0.0....

@fogus
Collaborator

This was fixed a while ago by pulling in Hiccup, but I did cherry-pick your test changes. Thank you!

@fogus fogus closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 27, 2012
  1. Update dependencies and imports.

    Josh Tilles authored
    Let's see what breaks!
  2. Remove dependency on contrib.java-utils

    Josh Tilles authored
    When I tried to do a `lein2 test` it broke. Uh oh. Time to go debug the tests… `delete-file-recursively` wasn't even in 1.2's `java-utils`, it was in `contrib.io`. Weird.
  3. Replace outdated function

    Josh Tilles authored
  4. Fix wrong-number-of-args error when running the tests

    Josh Tilles authored
  5. Use the newer hiccup API

    Josh Tilles authored
This page is out of date. Refresh to see the latest.
View
2  project.clj
@@ -5,7 +5,7 @@
[[org.clojure/clojure "1.3.0"]
[org.clojure/tools.namespace "0.1.1"]
[org.clojure/tools.cli "0.2.1"]
- [hiccup "0.3.7"]
+ [hiccup "1.0.0"]
[org.markdownj/markdownj "0.3.0-1.0.2b4"]]
:dev-dependencies
[[lein-clojars "0.6.0"]
View
76 src/marginalia/html.clj
@@ -1,7 +1,8 @@
(ns marginalia.html
"Utilities for converting parse results into html."
- (:use [hiccup.core :only (html escape-html)]
- [hiccup.page-helpers :only (doctype)])
+ (:use [hiccup.core :only (html)]
+ [hiccup.util :only (escape-html)]
+ [hiccup.page :only (html5)])
(:require [clojure.string :as str])
(:import [com.petebevin.markdown MarkdownProcessor]))
@@ -346,42 +347,40 @@
& `inline-css`) to be able to package the output as a single file (uberdoc if you will). It goes without
saying that all this is WIP and will prabably change in the future."
[project-metadata opt-resources header toc content]
- (html
- (doctype :html5)
- [:html
- [:head
- [:meta {:http-equiv "Content-Type" :content "text/html" :charset "utf-8"}]
- [:meta {:name "description" :content (:description project-metadata)}]
- (inline-css (str *resources* "shCore.css"))
- (css
- [:.syntaxhighlighter {:overflow "hidden !important"}])
- (inline-css (str *resources* "shThemeMarginalia.css"))
- reset-css
- header-css
- floating-toc-css
- general-css
- (inline-js (str *resources* "jquery-1.4.4.min.js"))
- (inline-js (str *resources* "xregexp-min.js"))
- (inline-js (str *resources* "shCore.js"))
- (inline-js (str *resources* "shBrushClojure.js"))
- opt-resources
- [:title (:name project-metadata) " -- Marginalia"]]
- [:body
- [:table
- header
- toc
- content]
- [:div {:class "footer"}
- "Generated by "
- [:a {:href "https://github.com/fogus/marginalia"} "Marginalia"]
- ".  "
- "Syntax highlighting provided by Alex Gorbatchev's "
- [:a {:href "http://alexgorbatchev.com/SyntaxHighlighter/"}
- "SyntaxHighlighter"]
- #_floating-toc]
- [:script {:type "text/javascript"}
- "SyntaxHighlighter.defaults['gutter'] = false;
- SyntaxHighlighter.all()"]]]))
+ (html5
+ [:head
+ [:meta {:http-equiv "Content-Type" :content "text/html" :charset "utf-8"}]
+ [:meta {:name "description" :content (:description project-metadata)}]
+ (inline-css (str *resources* "shCore.css"))
+ (css
+ [:.syntaxhighlighter {:overflow "hidden !important"}])
+ (inline-css (str *resources* "shThemeMarginalia.css"))
+ reset-css
+ header-css
+ floating-toc-css
+ general-css
+ (inline-js (str *resources* "jquery-1.4.4.min.js"))
+ (inline-js (str *resources* "xregexp-min.js"))
+ (inline-js (str *resources* "shCore.js"))
+ (inline-js (str *resources* "shBrushClojure.js"))
+ opt-resources
+ [:title (:name project-metadata) " -- Marginalia"]]
+ [:body
+ [:table
+ header
+ toc
+ content]
+ [:div {:class "footer"}
+ "Generated by "
+ [:a {:href "https://github.com/fogus/marginalia"} "Marginalia"]
+ ".  "
+ "Syntax highlighting provided by Alex Gorbatchev's "
+ [:a {:href "http://alexgorbatchev.com/SyntaxHighlighter/"}
+ "SyntaxHighlighter"]
+ #_floating-toc]
+ [:script {:type "text/javascript"}
+ "SyntaxHighlighter.defaults['gutter'] = false;
+ SyntaxHighlighter.all()"]]))
;; Syntax highlighting is done a bit differently than docco. Instead of embedding
@@ -406,7 +405,6 @@
(opt-resources-html project-metadata)
(header-html project-metadata)
(toc-html {:uberdoc? false} docs)
- "" ;; no floating toc
"")) ;; no contents
(defn single-page-html
View
20 test/marginalia/test/helpers.clj
@@ -1,7 +1,23 @@
(ns marginalia.test.helpers
(:use clojure.test)
- (:use [clojure.java.io :only (file)])
- (:use [clojure.contrib.java-utils :only (delete-file-recursively)]))
+ (:use [clojure.java.io :only (file delete-file)])
+ (:require marginalia.core))
+
+
+;; copied from http://clojuredocs.org/clojure_contrib/clojure.contrib.io/delete-file-recursively
+;; N.B. that Raynes's filesystem library could possibly replace this,
+;; but that's a separate task.
+(defn delete-file-recursively
+ "Delete file f. If it's a directory, recursively delete all its contents. Raise an exception if any deletion fails unless silently is true."
+ [f & [silently]]
+ (let [f (file f)]
+ (when (.isDirectory f)
+ (doseq [child (.listFiles f)]
+ (delete-file-recursively child silently)))
+ (delete-file f silently)))
+
+(defn find-clojure-file-paths [source-dir]
+ (marginalia.core/find-processable-file-paths source-dir #".clj$"))
(defn files-in [dir]
(seq (.listFiles (file dir))))
View
2  test/marginalia/test/multidoc.clj
@@ -6,7 +6,7 @@
(with-project "multi_page"
(fn [source-dir output-dir metadata]
(marginalia.core/multidoc! output-dir
- (marginalia.core/find-clojure-file-paths source-dir)
+ (find-clojure-file-paths source-dir)
metadata))
(is (= number-of-generated-pages 3)))
View
2  test/marginalia/test/uberdoc.clj
@@ -6,7 +6,7 @@
(with-project "single_page"
(fn [source-dir output-dir metadata]
(marginalia.core/uberdoc! (clojure.java.io/file output-dir "index.html")
- (marginalia.core/find-clojure-file-paths source-dir)
+ (find-clojure-file-paths source-dir)
metadata))
(is (= number-of-generated-pages 1)))
Something went wrong with that request. Please try again.