Skip to content

Commit

Permalink
release v0.3.6 - fix path handling in svg images
Browse files Browse the repository at this point in the history
  • Loading branch information
erdostw committed Sep 17, 2019
1 parent 8feffe9 commit 684a391
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 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.5`
**Latest stable** version is `0.3.6`

**Latest snapshot** version is `0.3.6-SNAPSHOT`
**Latest snapshot** version is `0.3.7-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.5</version>
<version>0.3.6</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.5"]`
file: `[io.github.erdos/stencil-core "0.3.6"]`

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

Expand Down
4 changes: 2 additions & 2 deletions service/project.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(defproject io.github.erdos/stencil-service "0.3.5"
(defproject io.github.erdos/stencil-service "0.3.6"
:description "Web service for the Stencil templating engine"
:url "https://github.com/erdos/stencil"
: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.5"]
[io.github.erdos/stencil-core "0.3.6"]
[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.5
0.3.6
42 changes: 21 additions & 21 deletions src/stencil/model.clj
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
(assert (.isFile cts))
(let [parsed (with-open [r (io/input-stream cts)] (xml/parse r))]
{:source-file cts
:path (.getName cts)}))
::path (.getName cts)}))


(defn ->exec [xml-streamable]
Expand All @@ -116,7 +116,7 @@
(let [rels-path (str (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)})))
{::path rels-path, :source-file rels-file, :parsed (parse-relation rels-file)})))

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

Expand All @@ -125,14 +125,14 @@
(vals (:parsed main-document-rels)))]
{:content-types (parse-content-types (file dir "[Content_Types].xml"))
:source-folder dir
:relations {:path (str (file "_rels" ".rels"))
:relations {::path (str (file "_rels" ".rels"))
:source-file (file dir "_rels" ".rels")
:parsed package-rels}
:main {:path main-document
:main {::path main-document
:source-file (file dir main-document)
:executable (->exec (file dir main-document))
:style (when main-style-path
{:path main-style-path
{::path main-style-path
:source-file (file dir main-style-path)
:parsed (parse-style (file dir main-style-path))})
:relations main-document-rels
Expand All @@ -143,7 +143,7 @@
rel-type-slide}
(::type m))
:let [f (file (.getParentFile (file main-document)) (::target m))]]
{:path (str f)
{::path (str f)
:source-file (file dir f)
:executable (->exec (file dir f))
:relations (->rels f)}))}}))
Expand All @@ -164,7 +164,7 @@


(defn- resource-copier [x]
(assert (:path x))
(assert (::path x))
(assert (:source-file x))
(fn [writer]
(io!
Expand All @@ -189,7 +189,7 @@

(defn- eval-model-part [part data functions]
(assert (:executable part))
(assert (:path part))
(assert (::path part))
(if (:dynamic? (:executable part))
(eval-model-part-exec (:executable part) data functions)
{:writer (resource-copier part)}))
Expand Down Expand Up @@ -220,11 +220,11 @@
(cond-> m

;; 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)))
(and (seq @*extra-files*) (nil? (::path (:relations m))))
(assoc-in [:relations ::path]
(str (file (.getParentFile (file (::path m)))
"_rels"
(str (.getName (file (:path m))) ".rels"))))
(str (.getName (file (::path m))) ".rels"))))

;; add relations if any
(seq @*extra-files*)
Expand Down Expand Up @@ -268,33 +268,33 @@
;; relations files that are created on-the-fly
(into result
(for [m (tree-seq coll? seq evaled-template-model)
:when (and (map? m) (not (sorted? m)) (:path m))
:when (and (map? m) (not (sorted? m)) (::path m))
:when (:parsed (:relations m))
:when (not (:source-file (:relations m)))]
[(:path (:relations m)) (relation-writer (:parsed (:relations m)))]))
[(::path (:relations m)) (relation-writer (:parsed (:relations m)))]))

;; create writer for every item where :path is specified
;; create writer for every item where ::path is specified
(into result
(for [m (tree-seq coll? seq evaled-template-model)
:when (and (map? m) (not (sorted? m)) (:path m))
:when (and (map? m) (not (sorted? m)) (::path m))
:when (not= "External" (::mode m))
:when (not (contains? result (:path m)))]
[(:path m) (or (:writer (:result m)) (resource-copier m))]))
:when (not (contains? result (::path m)))]
[(::path m) (or (:writer (:result m)) (resource-copier m))]))

;; find all items in all relations
(into result
(for [m (tree-seq coll? seq evaled-template-model)
:when (and (map? m) (not (sorted? m)) (:relations m))
:let [src-parent (delay (file (or (:source-folder m)
(.getParentFile (file (:source-file m))))))
path-parent (some-> m :path file .getParentFile)]
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)))))]
:when (or (:writer relation) (not (contains? result path)))
:let [src (or (:source-file relation) (file @src-parent (::target relation)))]]
[path (or (:writer relation)
(resource-copier {:path path :source-file src}))]))))
(resource-copier {::path path :source-file src}))]))))


(defn template-model->writers-map
Expand Down Expand Up @@ -395,7 +395,7 @@
:new-id new-id
:old-id old-rel-id
:source-file (file (-> model :main :source-file file .getParentFile) (::target m))
:path new-path})))
::path new-path})))


(defmethod eval/eval-step :cmd/include [f local-data-map {frag-name :name}]
Expand Down

0 comments on commit 684a391

Please sign in to comment.