Skip to content

Commit

Permalink
Trying to get JavaScript switchable between local and cloudflare
Browse files Browse the repository at this point in the history
Not working for two reasons:
1. `lein npm install` does not build packages on MacOS;
2. `{% ifequal js-from ":cloudflare" %}` breaks Selmer in  wiki.html but not in edit.html - WTF?
  • Loading branch information
simon-brooke committed Feb 8, 2020
1 parent ecd9d5a commit e00beaf
Show file tree
Hide file tree
Showing 8 changed files with 1,371 additions and 19 deletions.
1,339 changes: 1,339 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,20 @@
:jvm-opts ["-server"]

:plugins [[lein-ancient "0.5.5" :exclusions [org.clojure/clojure org.clojure/data.xml]]
[lein-bower "0.5.1"]
[lein-codox "0.10.3"]
[io.sarnowski/lein-docker "1.0.0"]
[lein-environ "1.0.0"]
[lein-marginalia "0.7.1" :exclusions [org.clojure/clojure]]
[lein-npm "0.6.2"]
[lein-ring "0.12.5" :exclusions [org.clojure/clojure]]]

:bower-dependencies [[simplemde "1.11.2"]
;; [vega-embed "3.0.0-beta.20"] ;; vega-embed currently not loaded from Bower because of
;; dependency conflict which will hopefully be resolved soon.
[vega-lite "2.0.0-beta.11"]
[mermaid "6.0.0"]]
:npm {:dependencies [[simplemde "1.11.2"]
[vega "5.8.0"]
[vega-embed "6.2.2"]
[vega-lite "4.1.1"]
[mermaid "8.4.6"]
[tablesort "5.2.0"]]
:root "resources/public/vendor"}

:docker {:image-name "simonbrooke/smeagol"
:dockerfile "Dockerfile"}
Expand Down
4 changes: 3 additions & 1 deletion resources/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
"backticks" smeagol.formatting/process-backticks}
:log-level :info ;; the minimum logging level; one of
;; :trace :debug :info :warn :error :fatal
:js-from :cloudflare ;; where to load JavaScript libraries
;; from: options are :local, :cloudflare
:passwd "resources/passwd"
;; where the password file is stored
:site-title "Smeagol"} ;; overall title of the site, used in
:site-title "Smeagol"} ;; overall title of the site, used in
;; page headings
9 changes: 7 additions & 2 deletions resources/templates/edit.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{% extends "templates/base.html" %}
{% block extra-headers %}
{% style "/vendor/simplemde/dist/simplemde.min.css" %}
{% script "/vendor/simplemde/dist/simplemde.min.js" %}
{% ifequal js-from ":cloudflare" %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/simplemde/1.11.2/simplemde.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/simplemde/1.11.2/simplemde.min.css" rel="stylesheet" type="text/css" />
{% else %}
{% style "/vendor/simplemde/dist/simplemde.min.css" %}
{% script "/vendor/simplemde/dist/simplemde.min.js" %}
{% endifequal %}
{% endblock %}

{% block content %}
Expand Down
19 changes: 10 additions & 9 deletions resources/templates/wiki.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{% extends "templates/base.html" %}

{% block extra-headers %}
{% style "vendor/mermaid/dist/mermaid.css" %}
<!-- there's at the time of writing (20170731) a problem with the dependencies of the Bower
package for vega-embed, so we're currently not installing either it or Vega locally.
TODO: fix -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/vega/3.0.0-rc2/vega.js"></script>
{% script "/vendor/vega-lite/build/vega-lite.js" %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vega-embed/3.0.0-beta.19/vega-embed.js"></script>

{% script "vendor/mermaid/dist/mermaid.js" %}
<!-- ifequal js-from ":cloudflare" -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/8.4.6/mermaid.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vega/5.9.1/vega.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vega-lite/4.1.1/vega-lite.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vega-embed/6.2.2/vega-embed.min.js"></script>
<!-- else -->
<!-- TODO: currently `lein npm install` fails to build packages on all platforms, and
fails SILENTLY. Consequently setting js-from to local is not advised. Investigting. -->
<!-- script "vendor/mermaid/dist/mermaid.js" %}
<!-- endifequal -->
{% endblock %}

{% block content %}
Expand Down
2 changes: 2 additions & 0 deletions src/smeagol/configuration.clj
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
'( {:from :smeagol-content-dir :to :content-dir}
{:from :smeagol-default-locale :to :default-locale}
{:from :smeagol-formatters :to :formatters :transform read-string}
{:from :smeagol-js-from :to :js-from :transform to-keyword}
{:from :smeagol-log-level :to :log-level :transform to-keyword}
{:from :smeagol-passwd :to :passwd}
{:from :smeagol-site-title :to :site-title}))
Expand Down Expand Up @@ -131,6 +132,7 @@
:smeagol-content-dir
:smeagol-default-locale
:smeagol-formatters
:smeagol-js-from
:smeagol-log-level
:smeagol-passwd
:smeagol-site-title)
Expand Down
2 changes: 1 addition & 1 deletion src/smeagol/formatting.clj
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
index
" = "
(yaml->json (str "$schema: https://vega.github.io/schema/vega-lite/v2.json\n" vega-src))
";\nvega.embed('#vis"
";\nvegaEmbed('#vis"
index
"', vl"
index
Expand Down
1 change: 1 addition & 0 deletions src/smeagol/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
(let [user (session/get :user)]
{:user user
:admin (auth/get-admin user)
:js-from (:js-from config)
:side-bar (md->html (slurp (cjio/file content-dir "_side-bar.md")))
:header (md->html (slurp (cjio/file content-dir "_header.md")))
:version (System/getProperty "smeagol.version")}))
Expand Down

0 comments on commit e00beaf

Please sign in to comment.