Skip to content

Commit

Permalink
fix: handle windows file separators, release v0.3.8
Browse files Browse the repository at this point in the history
Co-authored-by: Bali Miklós <[email protected]>
  • Loading branch information
erdos and mbali committed Jul 15, 2020
1 parent a66b48e commit b133256
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ them to make the template more readable.

## Version

**Latest stable** version is `0.3.7`
**Latest stable** version is `0.3.8`

**Latest snapshot** version is `0.3.8-SNAPSHOT`
**Latest snapshot** version is `0.3.9-SNAPSHOT`

If you are using Maven, add the followings to your `pom.xml`:

Expand All @@ -52,7 +52,7 @@ The dependency:
<dependency>
<groupId>io.github.erdos</groupId>
<artifactId>stencil-core</artifactId>
<version>0.3.7</version>
<version>0.3.8</version>
</dependency>
```

Expand All @@ -67,7 +67,7 @@ And the [Clojars](https://clojars.org) repository:

Alternatively, if you are using Leiningen, add the following to
the `:dependencies` section of your `project.clj`
file: `[io.github.erdos/stencil-core "0.3.7"]`
file: `[io.github.erdos/stencil-core "0.3.8"]`

Previous versions are available on the [Stencil Clojars](https://clojars.org/io.github.erdos/stencil-core) page.

Expand Down
2 changes: 1 addition & 1 deletion service/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:license {:name "Eclipse Public License - v 2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.9.0"]
[io.github.erdos/stencil-core "0.3.8-SNAPSHOT"]
[io.github.erdos/stencil-core "0.3.8"]
[http-kit "2.2.0"]
[ring/ring-json "0.4.0"]]
:main stencil.service.core)
2 changes: 1 addition & 1 deletion src/STENCIL_VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.8-SNAPSHOT
0.3.8
14 changes: 8 additions & 6 deletions src/stencil/model.clj
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
;; throws error when not invoked from inside fragment context
(defmacro ^:private expect-fragment-context! [& bodies] `(do (assert *current-styles*) ~@bodies))

(defn- unix-path [^File f]
(some-> f .toPath FileHelper/toUnixSeparatedString))

(defn- parse-relation [rel-file]
(with-open [reader (io/input-stream (file rel-file))]
Expand Down Expand Up @@ -115,21 +117,21 @@
(let [package-rels (parse-relation (file dir "_rels" ".rels"))
main-document (some #(when (= rel-type-main (::type %)) (::target %)) (vals package-rels))
->rels (fn [f]
(let [rels-path (str (file (.getParentFile (file f)) "_rels" (str (.getName (file f)) ".rels")))
(let [rels-path (unix-path (file (.getParentFile (file f)) "_rels" (str (.getName (file f)) ".rels")))
rels-file (file dir rels-path)]
(when (.exists rels-file)
{::path rels-path, :source-file rels-file, :parsed (parse-relation rels-file)})))

main-document-rels (->rels main-document)

main-style-path (some #(when (= rel-type-style (::type %))
(str (file (.getParentFile (file main-document)) (::target %))))
(unix-path (file (.getParentFile (file main-document)) (::target %))))
(vals (:parsed main-document-rels)))
->exec (binding [merger/*only-includes* (boolean (:only-includes options-map))]
(bound-fn* ->exec))]
{:content-types (parse-content-types (file dir "[Content_Types].xml"))
:source-folder dir
:relations {::path (str (file "_rels" ".rels"))
:relations {::path (unix-path (file "_rels" ".rels"))
:source-file (file dir "_rels" ".rels")
:parsed package-rels}
:main {::path main-document
Expand All @@ -147,7 +149,7 @@
rel-type-slide}
(::type m))
:let [f (file (.getParentFile (file main-document)) (::target m))]]
{::path (str f)
{::path (unix-path f)
:source-file (file dir f)
:executable (->exec (file dir f))
:relations (->rels f)}))}}))
Expand Down Expand Up @@ -229,7 +231,7 @@
;; create a rels file for the current xml
(and (seq @*extra-files*) (nil? (::path (:relations m))))
(assoc-in [:relations ::path]
(str (file (.getParentFile (file (::path m)))
(unix-path (file (.getParentFile (file (::path m)))
"_rels"
(str (.getName (file (::path m))) ".rels"))))

Expand Down Expand Up @@ -297,7 +299,7 @@
path-parent (some-> m ::path file .getParentFile)]
relation (vals (:parsed (:relations m)))
:when (not= "External" (::mode relation))
:let [path (str (.normalize (.toPath (file path-parent (::target relation)))))]
:let [path (unix-path (.toFile (.normalize (.toPath (file path-parent (::target relation))))))]
:when (or (:writer relation) (not (contains? result path)))
:let [src (or (:source-file relation) (file @src-parent (::target relation)))]]
[path (or (:writer relation)
Expand Down

0 comments on commit b133256

Please sign in to comment.