~subsetpark/bagatto

9ae10557ab06cf9ae7d908a974957923ab379984 — Zach Smith 6 months ago ca25d62
Update for 1.14.1
M bagatto-require.janet => bagatto-require.janet +1 -1
@@ 1,3 1,3 @@
(import bagatto :export true)
(import /bagatto :export true)
(import path)
(import sh :export true)

M bagatto.janet => bagatto.janet +1 -1
@@ 5,7 5,7 @@
(import jdn)
(import json)

(import src/multimarkdown)
(import /src/multimarkdown)

(defn- set-error-context!
  [k v]

M demo/basic-site/index.janet => demo/basic-site/index.janet +2 -2
@@ 104,7 104,7 @@
## paths. Here we specify a path that looks like this:
## "pages/{{ (slugify (item :basename)) }}.html".
(def page-path (bagatto/%p "pages" '%i :basename '% ".html"))
(def page-renderer (bagatto/renderer "templates/page" {:root "../"}))
(def page-renderer (bagatto/renderer "/templates/page" {:root "../"}))

(def site {# :index is a single file whose path we can specify as a
           # literal string.


@@ 116,7 116,7 @@
           # arguments. It will return a function which will take the
           # site data and output the contents of the index.
           :index {:dest "index.html"
                   :out (bagatto/renderer "templates/index" {:root "./"})}
                   :out (bagatto/renderer "/templates/index" {:root "./"})}
           # :css uses `:some` to refer directly to an entry in the
           # data specification. It doesn't provide an `:out` value;
           # therefore, Bagatto will just copy the file directly into

M demo/basic-site/templates/index.temple => demo/basic-site/templates/index.temple +2 -2
@@ 1,4 1,4 @@
{% (bagatto/include "templates/head") %}
{% (bagatto/include "/templates/head") %}

<h1>{{ (get-in args [:config :title]) }}</h1> 
<div>


@@ 17,4 17,4 @@
  </nav>
</div>
      
{% (bagatto/include "templates/foot") %}
{% (bagatto/include "/templates/foot") %}

M demo/basic-site/templates/page.temple => demo/basic-site/templates/page.temple +4 -2
@@ 1,6 1,8 @@
{% (bagatto/include "templates/head") %}
{% (bagatto/include "/templates/head") %}

<h1>{{ (get-in args [:_item :basename]) }}</h1>
<div class="mw6">
{- (bagatto/markdown->html (get-in args [:_item :contents])) -}
</div>
{% (bagatto/include "templates/foot") %}

{% (bagatto/include "/templates/foot") %}

M main.janet => main.janet +5 -5
@@ 1,10 1,10 @@
(import temple)
(import argparse :prefix "")

(import src/core)
(import src/error)
(import src/env)
(import repl)
(import /src/core)
(import /src/error)
(import /src/env)
(import /repl)

(defn- index-value
  [env sym index]


@@ 27,7 27,7 @@
  ```
  An environment including the `repl` module, for interactive development.
  ```
  (require "repl"))
  (require "/repl"))

(defn main [& args]
  (merge-into root-env core/bagatto)

M repl.janet => repl.janet +3 -3
@@ 1,6 1,6 @@
(import src/core)
(import src/threads)
(import src/writers)
(import /src/core)
(import /src/threads)
(import /src/writers)

(defn eval-data
  ```

M src/core.janet => src/core.janet +8 -8
@@ 1,20 1,20 @@
(import path)
(import temple)

(import src/util)
(import src/error)
(import src/threads)
(import src/loaders)
(import src/generators)
(import src/writers)
(import src/env)
(import /src/util)
(import /src/error)
(import /src/threads)
(import /src/loaders)
(import /src/generators)
(import /src/writers)
(import /src/env)

(def bagatto
  ```
  An environment populated by the "stdlib" we want to expose to
  template and index module authors.
  ```
  (require "bagatto-require"))
  (require "/bagatto-require"))

(defn thread-init
  [f]

M src/generators.janet => src/generators.janet +3 -3
@@ 1,9 1,9 @@
### Thread-closure creation for generator functions, ie, functions
### which take site data and a site spec and return one or more writer
### specs.
(import src/threads)
(import src/error)
(import src/env)
(import /src/threads)
(import /src/error)
(import /src/env)

(defn- set-cxt! [spec-name]
  (setdyn :error-context {:spec-name spec-name}))

M src/loaders.janet => src/loaders.janet +3 -3
@@ 1,6 1,6 @@
(import src/error)
(import src/threads)
(import src/env)
(import /src/error)
(import /src/threads)
(import /src/env)

(defn- set-cxt! [spec-name]
  (setdyn :error-context {:spec-name spec-name}))

M src/multimarkdown.janet => src/multimarkdown.janet +1 -1
@@ 1,5 1,5 @@
(import sh)
(import src/env)
(import /src/env)

(defn- metadata-keys
  [md]

M src/writers.janet => src/writers.janet +2 -2
@@ 1,7 1,7 @@
(import path)

(import src/util)
(import src/threads)
(import /src/util)
(import /src/threads)

(defn writer-init
  "Return an empty table to be used as path cache"

M test/bagatto.janet => test/bagatto.janet +3 -3
@@ 1,7 1,7 @@
(import testament :prefix "" :exit true)
(import temple)

(import bagatto)
(import /bagatto)

(temple/add-loader)



@@ 20,7 20,7 @@
    (is (== {:each @[["test/support/test.txt" @"test file contents\n"]]} (loader)))))

(deftest render
  (is (== @"2\n" (bagatto/render "test/support/test" {}))))
  (is (== @"2\n" (bagatto/render "/test/support/test" {}))))

(def unslug " Make A_Slug ")



@@ 31,7 31,7 @@
  (is (== "make-a-slug" (bagatto/slug-from-attr {:title unslug} :title))))

(deftest renderer
  (let [renderer (bagatto/renderer "test/support/test")]
  (let [renderer (bagatto/renderer "/test/support/test")]
    (is (== @"2\n" (renderer {})))))

(deftest %p

M test/core.janet => test/core.janet +2 -2
@@ 1,8 1,8 @@
(import testament :prefix "" :exit true)
(import src/core)
(import /src/core)

(defn- test-temple []
  (require "test/support/test"))
  (require "/test/support/test"))

(defn- test-bagatto [] (eval 'bagatto/json-data))


M test/generators.janet => test/generators.janet +1 -1
@@ 1,6 1,6 @@
(import testament :prefix "" :exit true)

(import src/generators)
(import /src/generators)

(defn- parent []
  @{:send (fn [self res] (put self :res res))})

M test/loaders.janet => test/loaders.janet +2 -2
@@ 1,7 1,7 @@
(import testament :prefix "" :exit true)

(import bagatto)
(import src/loaders)
(import /bagatto)
(import /src/loaders)

(defn- parent []
  @{:send (fn [self res] (put self :res res))})

M test/markdown.janet => test/markdown.janet +1 -1
@@ 1,5 1,5 @@
(import testament :prefix "" :exit true)
(import bagatto)
(import /bagatto)

(setdyn :executable-blacklist {})


M test/require.janet => test/require.janet +1 -1
@@ 1,5 1,5 @@
(import testament :prefix "" :exit true)
(import src/env)
(import /src/env)

(setdyn :executable-blacklist {})


M test/threads.janet => test/threads.janet +1 -1
@@ 1,5 1,5 @@
(import testament :prefix "" :exit true)
(import src/threads)
(import /src/threads)

(defn thread-init [f]
  (thread/new (fn [parent] (f parent))))