Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge next br changes in #183

Open
wants to merge 59 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
3c74e16
fix devcards docstring
metasoarous Nov 11, 2021
913c431
add highlight.js styles
metasoarous Nov 11, 2021
497b9d4
add highlight.js library
metasoarous Nov 11, 2021
bde89cf
update package-lock.json
metasoarous Nov 11, 2021
dcc9f05
update dependencies
metasoarous Nov 11, 2021
3fd2dab
initial async/parallel ns evaluation implementation (with markdown co…
metasoarous Nov 11, 2021
f51dff7
update mathjax for async math processing
metasoarous Nov 14, 2021
91fc11d
add notes about omission flags making it through to live view
metasoarous Nov 14, 2021
b28ea81
add styles and js for higlightjs to static output
metasoarous Nov 14, 2021
c254505
fix compute-out-path for single files
metasoarous Nov 14, 2021
f4bb327
fix initial page load not working
metasoarous Nov 14, 2021
c195ea5
complete static export implementation
metasoarous Nov 14, 2021
9601ac6
add result for ns evaluation form
metasoarous Nov 14, 2021
9c45d95
add file to evaluation representation
metasoarous Nov 14, 2021
f74770f
make sure each browser tab has it's own uid
metasoarous Nov 14, 2021
cb116dc
comments
metasoarous Nov 14, 2021
54ff1bc
finish implementing live view components
metasoarous Nov 14, 2021
8f061b4
add details to block components in app
metasoarous Nov 17, 2021
540b0eb
fixed the way hanging comments start new blocks
metasoarous Nov 18, 2021
2e3d361
add stdout and stderr to results
metasoarous Nov 18, 2021
1317c16
old example cleanup
metasoarous Nov 18, 2021
9387c5b
move mathjax typesetting to just happen when blocks are updating acro…
metasoarous Nov 18, 2021
7402e11
move app error boundaries to block level
metasoarous Nov 18, 2021
db32176
attempt to get toggle to show dependencies
metasoarous Nov 18, 2021
7692296
add cljc to path
metasoarous Nov 18, 2021
1a7ed80
updating npm packages
metasoarous Nov 18, 2021
1488d33
set Computer Modern as default fonts
metasoarous Nov 22, 2021
4c3625b
moved higlight-js code out into a separate GH repo for jsdelivr
metasoarous Nov 22, 2021
cca01e9
process markdown metadata
metasoarous Nov 22, 2021
d7f069b
remove code example from oz.next
metasoarous Nov 22, 2021
6c5a304
clean up async block layout, and final fix on mathjax application
metasoarous Nov 22, 2021
6027b1f
improve error handling
metasoarous Nov 24, 2021
a2ad743
finish laying out stdout/stderr/stacktrace presentation
metasoarous Nov 24, 2021
8a0919b
stop blocks from running downstream of an error
metasoarous Nov 25, 2021
5198c8f
add comments, clean up old logging
metasoarous Nov 25, 2021
cbf5699
update app status view to reflect aborted evaluations
metasoarous Nov 25, 2021
8cd528c
remove old stylesheet references
metasoarous Nov 25, 2021
958034c
set default font sizes and spacing to em system
metasoarous Nov 27, 2021
c46805e
add support for explicitly declaring var definitions, mutations and d…
metasoarous Nov 27, 2021
dd8f030
add beholder
metasoarous Nov 29, 2021
269719d
version 2.0.0-alpha1
metasoarous Nov 29, 2021
ec24d18
add build targets
metasoarous Nov 29, 2021
86af5fb
unwrap :p blocks with single :img entry and fix broken markdown comme…
metasoarous Dec 5, 2021
c1994a1
add slideshow component sketches
metasoarous Dec 5, 2021
332ddbb
add imperfect client id assignment logic
metasoarous Dec 5, 2021
ef3aa17
add some deps and bump oz alpha
metasoarous Dec 5, 2021
dd68d68
add build targets
metasoarous Dec 5, 2021
8d25236
add build targets
metasoarous Dec 9, 2021
432de12
added styling-options doc
Dec 10, 2021
3ea45b9
Merge pull request #180 from Cyrik/next
metasoarous Dec 10, 2021
f71f2e2
revert vega versions to get working
metasoarous Dec 11, 2021
e2e595c
add notebook-demo.clj
metasoarous Dec 11, 2021
ee65f4a
alpha3 version bump
metasoarous Dec 11, 2021
a8a097b
update fonts in static compilation targets
metasoarous Dec 11, 2021
49cb0bf
fix ns evaluation; implement basic defmulti dispath redefinition
metasoarous Dec 21, 2021
4196fc9
fix adjacent code blocks being misprocessed
metasoarous Dec 22, 2021
4b0f9d9
add build targets
metasoarous Dec 22, 2021
2902076
update vega libs
metasoarous Dec 22, 2021
c983b57
add build targets
metasoarous Dec 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ resources/oz/public/js/cljs-runtime/
node_modules
resources/oz/public/js/devcards.js
resources/oz/public/js/manifest.edn
.clj-kondo
.lh
.lsp
.portal
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,9 @@ When you're done, one of the easiest ways to deploy is with the excellent `surge
You can also use GitHub Pages or S3 or really whatever if you prefer.
The great thing about static sites is that they are easy and cheap to deploy and scale, so you have plenty of options at your disposal.

## Styling options

[Styling options](doc/styling-options.md)

## Local CLJS development

Expand Down
19 changes: 14 additions & 5 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{:paths ["src/clj" "src/cljs" "resources"]
{:paths ["src/clj" "src/cljs" "src/cljc" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.1"}
org.clojure/clojurescript {:mvn/version "1.10.764"} ;; equivalent of :scope "provided"?
;; this appears to be necessary for fiwheel to work for some applications
org.clojure/tools.reader {:mvn/version "1.3.2"}
org.clojure/core.async {:mvn/version "0.4.490"}
org.clojure/core.async {:mvn/version "1.4.627"}
cheshire/cheshire {:mvn/version "5.8.1"}
clj-http/clj-http {:mvn/version "3.9.1"}
com.taoensso/sente {:mvn/version "1.13.1"}
com.taoensso/timbre {:mvn/version "4.10.0"}
com.taoensso/encore {:mvn/version "2.120.0"}
devcards/devcards {:mvn/version "0.2.6"}
reagent/reagent {:mvn/version "0.10.0"}
reagent/reagent {:mvn/version "1.1.0"}
;; consider using this for lazy loading clojupyter stuff
;com.clojure-goes-fast/lazy-require {:mvn/version "0.1.1"}
aleph/aleph {:mvn/version "0.4.6"}
Expand All @@ -32,7 +31,17 @@
respeced/respeced {:mvn/version "0.0.1"}
org.clojure/test.check {:mvn/version "0.10.0"}
hawk/hawk {:mvn/version "0.2.11"}
metasoarous/darkstar {:mvn/version "0.1.0"}}
com.nextjournal/beholder {:mvn/version "1.0.0"}
metasoarous/darkstar {:mvn/version "0.1.0"}
rewrite-clj/rewrite-clj {:mvn/version "1.0.644-alpha"}
org.clojure/tools.analyzer {:mvn/version "1.0.0"}
weavejester/dependency {:mvn/version "0.2.1"}
carocad/parcera {:mvn/version "0.11.6"}
org.antlr/antlr4-runtime {:mvn/version "4.7.1"}
io.replikativ/hasch {:mvn/version "0.3.7"}
org.clojure/tools.analyzer.jvm {:mvn/version "1.1.0"}
superstructor/re-highlight {:mvn/version "1.1.0"}}
;viebel/klipse {:mvn/version "7.10.6"}}
;applied-science/darkstar {:git/url "https://github.com/applied-science/darkstar/"
;:sha "ef93147377d09a3894959c2c43faabf1a527a7d5"}}
;timofreiberg/bultitude {:mvn/version "0.3.0"}
Expand Down
14 changes: 14 additions & 0 deletions dev/user.clj
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@
(oz/kill-watchers!)
(oz/live-view! "resources/oz/examples/clj/clj_test.clj")


(oz/build! [{:from "notebook-demo.clj"
:to "notebook-demo.html"}]
:port 9988)
;:template-fn (fn [& blocks] [:div {:style {:max-width 200
;:margin :auto
;:color :blue}}
;[:h1 "hello stever"]
;blocks])
;:header-extras [[:style "h1 {color: \"red\";}"]]}])
;{:from "src/clj/oz/next.clj"
;:to "oz-next.clj"}])


:end-examples)


Expand Down
111 changes: 111 additions & 0 deletions doc/build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Build

[`build!`](#static-site-generation): generate a static website from
directories of markdown, hiccup &/or interactive Vega-Lite & Vega visualizations, while being able to see changes live (as with `live-view!`)

## Static site generation

If you've ever thought, "man, I wish there was a static site generation
toolkit which had live code reloading of whatever page you're currently
editing, and it would be great if it was in Clojure and let me embed data
visualizations and math formulas via LaTeX in Markdown & Hiccup documents",
boy, are you in for a treat!

Oz now features exactly such features in the form of the `oz/build!`.
A very simple site might be generated with:

```clojure
(build!
[{:from "examples/static-site/src/"
:to "examples/static-site/build/"}])
```

The input formats currently supported by `oz/build!` are

* `md`: As described above, markdown with embedded Vega-Lite or Vega visualizations, Latex, and hiccup
* `json`, `edn`: You can directly supply hiccup data for more control over layout and content
* `clj`: Will `live-reload!` Clojure files (as described above), and render the last form evaluated as hiccup

Oz should handle image and css files it comes across by simply copying them over.
However, if you have any `json` or `edn` assets (datasets perhaps) which need to pass through unchanged,
you can separate these into their own build specification, like so:

```clojure
(defn site-template
[spec]
[:div {:style {:max-width 900 :margin-left "auto" :margin-right "auto"}}
spec])

(build!
[{:from "examples/static-site/src/site/"
:to "examples/static-site/build/"
:template-fn site-template}
;; If you have static assets, like datasets or imagines which need to be simply copied over
{:from "examples/static-site/src/assets/"
:to "examples/static-site/build/"
:as-assets? true}])
```

This can be a good way to separate document code from other static assets.

Specifying multiple builds like this can be used to do other things as well.
For example, if you wanted to render a particular set of pages using a different
template function (for example, so that your blog posts style differently than the main pages),
you can do that easily

```clojure
(defn blog-template
[spec]
(site-template
(let [{:as spec-meta :keys [title published-at tags]} (meta spec)]
[:div
[:h1 {:style {:line-height 1.35}} title]
[:p "Published on: " published-at]
[:p "Tags: " (string/join ", " tags)]
spec])))

(build!
[{:from "examples/static-site/src/site/"
:to "examples/static-site/build/"
:template-fn site-template}
{:from "examples/static-site/src/blog/"
:to "examples/static-site/build/blog/"
:template-fn blog-template}
;; If you have static assets, like datasets or imagines which need to be simply copied over
{:from "examples/static-site/src/assets/"
:to "examples/static-site/build/"
:as-assets? true}])
```

Note that the `blog-template` above is using metadata about the spec to inform how it renders.
This metadata can be written into Markdown files using a yaml markdown metadata header (see `/examples/static-site/src/`)

```
---
title: Oz static websites rock
tags: oz, dataviz
---

# Oz static websites!

Some markdown content...
```

The title in particular here will wind it's way into the `Title` metadata tag of your output HTML
document, and thus will be visible at the top of your browser window when you view the file.
This is a pattern that Jekyll and some other blogging engines use, and `markdown-clj` now
supports extracting this data.

Again, as you edit and save these files, the outputs just automatically update for you, both as
compiled HTML files, and in the live-view window which lets you see your changes as you make em.
If you need to change a template, or some other detail of the specs, you can simply rerun `build!`
with the modified arguments, and the most recently edited page will updated before your eyes.
This provides for a lovely live-view editing experience from the comfort of your favorite editor.

### Deploy

When you're done, one of the easiest ways to deploy is with the excellent `surge.sh` toolkit,
which makes static site deployment a breeze.
You can also use GitHub Pages or S3 or really whatever if you prefer.
The great thing about static sites is that they are easy and cheap to deploy and scale, so you
have plenty of options at your disposal.
62 changes: 62 additions & 0 deletions doc/styling-options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Styling options

## html

### from-format or mode

Used interchangeably, where from-format takes precedent. Possible values are:

:vega :vega-lite :markdown :md :pprint :print

Passes along any options to html-head.

## html-head

### description

Used as the meta "description" element. Otherwise set to "Oz document".

### title

Used as the "title" element. Otherwise set to "Oz document".

### author

Used as the meta "author" element. Otherwise empty.

### keywords

Used as the meta "keywords" element concatenated with ",". Should be a vector of strings.
If (:tag (meta doc)) it is merged on top.
Otherwise empty.

### omit-shortcut-icon? and shortcut-icon-url

If not true, a link shortcut-icon-url is used as the "link"
(displays as a little icon in the browser title bar) element. If empty "http://ozviz.io/oz.svg"
gets used.

### omit-styles?

If not true, "oz/public/css/style.css", "http://ozviz.io/fonts/lmroman12-regular.woff" and
"https://fonts.googleapis.com/css?family=Open+Sans" are included.

### omit-vega-libs?

If not true, the cdn versions of vega, vega-lite, and vega-embed are included.

### omit-highlightjs?

If not true, "metasoarous/highlight.js" is included per cdn.

### omit-mathjax?

If not true, "mathjax" is included per cdn.

### omit-charset?

If not true, "UTF-8" is set to as the default

### header-extras

Is passed along without modification at the end of the header. Must be valid hiccup.
Loading