From 2635c582eb3f37fdfe82e408885e675851eaf862 Mon Sep 17 00:00:00 2001 From: Gabriel Gonzalez Date: Thu, 20 Dec 2018 10:36:10 -0800 Subject: [PATCH] Add contributing instructions for the website (#760) This is so that I can link people to the `README` if they are interested in improving the site --- README.md | 6 +++--- default.nix | 2 +- dhall-try/README.md | 22 +++++++++++++++++++++ nix/shared.nix | 48 +++++++++------------------------------------ nix/website.nix | 34 ++++++++++++++++++++++++++++++++ release.nix | 4 ++-- 6 files changed, 71 insertions(+), 45 deletions(-) create mode 100644 dhall-try/README.md create mode 100644 nix/website.nix diff --git a/README.md b/README.md index 0e50f4b..59f36de 100644 --- a/README.md +++ b/README.md @@ -97,14 +97,14 @@ And each of them with `stack build `, for example: $ stack build dhall-json ``` -## Build the "Try Dhall" website +## Build the website Building the website from source is currently only supported for Nix on Linux. You can build the static assets by running: ```bash -$ nix-build --attr try-dhall +$ nix-build --attr website ``` ... then open `./result/index.html` in your browser. @@ -112,7 +112,7 @@ $ nix-build --attr try-dhall You can also download an archive containing the pre-built website from CI using this link: -* [try-dhall.tar.bz2](http://hydra.dhall-lang.org/job/dhall-haskell/master/tarball-try-dhall/latest/download-by-type/file/binary-dist) +* [website.tar.bz2](http://hydra.dhall-lang.org/job/dhall-haskell/master/tarball-website/latest/download-by-type/file/binary-dist) ## Contributing diff --git a/default.nix b/default.nix index 8c3f52b..f4ba5f9 100644 --- a/default.nix +++ b/default.nix @@ -11,5 +11,5 @@ in inherit (shared_ghcjs) dhall-try; - inherit (shared_ghcjs_linux) try-dhall; + inherit (shared_ghcjs_linux) website; } diff --git a/dhall-try/README.md b/dhall-try/README.md new file mode 100644 index 0000000..34981ac --- /dev/null +++ b/dhall-try/README.md @@ -0,0 +1,22 @@ +# `dhall-try` + +For installation or development instructions, see: + +* [`dhall-haskell` - `README`](https://github.com/dhall-lang/dhall-haskell/blob/master/README.md#build-the-website) + +## How to contribute + +You will most likely want to edit [`index.html`](./index.html) if you want to +improve the site. The vast majority of the site logic is embedded within that +monolithic document, including a substantial amount of inline JavaScript, inline +CSS, and all of the code examples. + +The [`src`](./src) directory contains the code for interpreting the live code +demo, powered by the `dhall`/`dhall-json` packages compiled to JavaScript using +GHCJS. You only need to modify that Haskell source code if you would like to +extend the site with new Haskell-derived functionality. + +The [`website.nix`](../nix/website.nix) file contains the top-level logic for +building the site, including bundling of JavaScript/CSS/image assets. You will +also want to refer to [`shared.nix`](../nix/shared.nix) for related logic to +build each bundled dependency. diff --git a/nix/shared.nix b/nix/shared.nix index 098f46c..b075ed5 100644 --- a/nix/shared.nix +++ b/nix/shared.nix @@ -229,47 +229,17 @@ let twitterBootstrap = pkgsNew.callPackage ./twitterBootstrap.nix { }; - try-dhall = pkgsNew.runCommand "try-dhall" {} '' - ${pkgsNew.coreutils}/bin/mkdir $out - ${pkgsNew.coreutils}/bin/mkdir $out/{css,img,js} - ${pkgsNew.coreutils}/bin/cp ${../dhall-try/index.html} $out/index.html - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.nodePackages.js-yaml}/lib/node_modules/js-yaml/dist/js-yaml.min.js $out/js - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.jQuery} $out/js/jquery.min.js - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.twitterBootstrap}/js/bootstrap.min.js $out/js - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.twitterBootstrap}/js/bootstrap.min.js.map $out/js - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.twitterBootstrap}/css/bootstrap.min.css $out/css - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.npm.codemirror}/lib/node_modules/codemirror/lib/codemirror.js $out/js - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.npm.codemirror}/lib/node_modules/codemirror/mode/haskell/haskell.js $out/js - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.npm.codemirror}/lib/node_modules/codemirror/mode/javascript/javascript.js $out/js - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.npm.codemirror}/lib/node_modules/codemirror/mode/yaml/yaml.js $out/js - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.npm.codemirror}/lib/node_modules/codemirror/lib/codemirror.css $out/css - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.haskell.packages.ghcjs.dhall-try}/bin/dhall-try.jsexe/all.min.js $out/js - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.dhall.prelude} $out/Prelude - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.logo.bash} $out/img/bash-logo.png - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.logo.clojure} $out/img/clojure-logo.svg - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.logo.dhallLarge} $out/img/dhall-large-logo.png - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.logo.dhallSmall} $out/img/dhall-small-logo.png - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.logo.github}/PNG/GitHub-Mark-32px.png $out/img/github-logo.png - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.logo.haskell} $out/img/haskell-logo.png - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.logo.kubernetes} $out/img/kubernetes-logo.svg - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.logo.json} $out/img/json-logo.svg - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.logo.nix} $out/img/nix-logo.png - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.logo.stackOverflow} $out/img/stack-overflow-logo.svg - ${pkgsNew.coreutils}/bin/ln --symbolic '${pkgsNew.logo.twitter}/Twitter Logos/Twitter Logos/Twitter_Logo_Blue/Twitter_Logo_Blue.svg' $out/img/twitter-logo.svg - ${pkgsNew.coreutils}/bin/ln --symbolic ${pkgsNew.logo.yaml} $out/img/yaml-logo.png - ${pkgsNew.coreutils}/bin/mkdir $out/nix-support - ${pkgsNew.coreutils}/bin/echo "doc none $out/index.html" > $out/nix-support/hydra-build-products - ''; + website = pkgsNew.callPackage ./website.nix {}; - tarball-try-dhall = pkgsStaticLinux.releaseTools.binaryTarball rec { - src = pkgsNew.try-dhall; + tarball-website = pkgsStaticLinux.releaseTools.binaryTarball rec { + src = pkgsNew.website; installPhase = '' - releaseName=try-dhall - ${pkgsNew.coreutils}/bin/install --target-directory "$TMPDIR/inst/try-dhall/" -D $src/index.html - ${pkgsNew.coreutils}/bin/install --target-directory "$TMPDIR/inst/try-dhall/img" -D $src/img/* - ${pkgsNew.coreutils}/bin/install --target-directory "$TMPDIR/inst/try-dhall/css" -D $src/css/* - ${pkgsNew.coreutils}/bin/install --target-directory "$TMPDIR/inst/try-dhall/js" -D $src/js/* + releaseName=website + ${pkgsNew.coreutils}/bin/install --target-directory "$TMPDIR/inst/website/" -D $src/index.html + ${pkgsNew.coreutils}/bin/install --target-directory "$TMPDIR/inst/website/img" -D $src/img/* + ${pkgsNew.coreutils}/bin/install --target-directory "$TMPDIR/inst/website/css" -D $src/css/* + ${pkgsNew.coreutils}/bin/install --target-directory "$TMPDIR/inst/website/js" -D $src/js/* ''; }; }; @@ -534,7 +504,7 @@ in tarball-dhall-json = makeTarball "dhall-json"; tarball-dhall-text = makeTarball "dhall-text"; - inherit (pkgs) tarball-try-dhall try-dhall-server try-dhall; + inherit (pkgs) tarball-website website; inherit (pkgs.haskell.packages."${compiler}") dhall dhall-bash dhall-json dhall-text dhall-try; diff --git a/nix/website.nix b/nix/website.nix new file mode 100644 index 0000000..92824dc --- /dev/null +++ b/nix/website.nix @@ -0,0 +1,34 @@ +{ coreutils, dhall, haskell, jQuery, logo, nodePackages, npm, runCommand +, twitterBootstrap +}: + +runCommand "try-dhall" {} '' + ${coreutils}/bin/mkdir $out + ${coreutils}/bin/mkdir $out/{css,img,js} + ${coreutils}/bin/cp ${../dhall-try/index.html} $out/index.html + ${coreutils}/bin/ln --symbolic ${nodePackages.js-yaml}/lib/node_modules/js-yaml/dist/js-yaml.min.js $out/js + ${coreutils}/bin/ln --symbolic ${jQuery} $out/js/jquery.min.js + ${coreutils}/bin/ln --symbolic ${twitterBootstrap}/js/bootstrap.min.js $out/js + ${coreutils}/bin/ln --symbolic ${twitterBootstrap}/js/bootstrap.min.js.map $out/js + ${coreutils}/bin/ln --symbolic ${twitterBootstrap}/css/bootstrap.min.css $out/css + ${coreutils}/bin/ln --symbolic ${npm.codemirror}/lib/node_modules/codemirror/lib/codemirror.js $out/js + ${coreutils}/bin/ln --symbolic ${npm.codemirror}/lib/node_modules/codemirror/mode/haskell/haskell.js $out/js + ${coreutils}/bin/ln --symbolic ${npm.codemirror}/lib/node_modules/codemirror/mode/javascript/javascript.js $out/js + ${coreutils}/bin/ln --symbolic ${npm.codemirror}/lib/node_modules/codemirror/mode/yaml/yaml.js $out/js + ${coreutils}/bin/ln --symbolic ${npm.codemirror}/lib/node_modules/codemirror/lib/codemirror.css $out/css + ${coreutils}/bin/ln --symbolic ${haskell.packages.ghcjs.dhall-try}/bin/dhall-try.jsexe/all.min.js $out/js + ${coreutils}/bin/ln --symbolic ${logo.bash} $out/img/bash-logo.png + ${coreutils}/bin/ln --symbolic ${logo.clojure} $out/img/clojure-logo.svg + ${coreutils}/bin/ln --symbolic ${logo.dhallLarge} $out/img/dhall-large-logo.png + ${coreutils}/bin/ln --symbolic ${logo.dhallSmall} $out/img/dhall-small-logo.png + ${coreutils}/bin/ln --symbolic ${logo.github}/PNG/GitHub-Mark-32px.png $out/img/github-logo.png + ${coreutils}/bin/ln --symbolic ${logo.haskell} $out/img/haskell-logo.png + ${coreutils}/bin/ln --symbolic ${logo.kubernetes} $out/img/kubernetes-logo.svg + ${coreutils}/bin/ln --symbolic ${logo.json} $out/img/json-logo.svg + ${coreutils}/bin/ln --symbolic ${logo.nix} $out/img/nix-logo.png + ${coreutils}/bin/ln --symbolic ${logo.stackOverflow} $out/img/stack-overflow-logo.svg + ${coreutils}/bin/ln --symbolic '${logo.twitter}/Twitter Logos/Twitter Logos/Twitter_Logo_Blue/Twitter_Logo_Blue.svg' $out/img/twitter-logo.svg + ${coreutils}/bin/ln --symbolic ${logo.yaml} $out/img/yaml-logo.png + ${coreutils}/bin/mkdir $out/nix-support + ${coreutils}/bin/echo "doc none $out/index.html" > $out/nix-support/hydra-build-products +'' diff --git a/release.nix b/release.nix index 1267cde..d946d2e 100644 --- a/release.nix +++ b/release.nix @@ -41,7 +41,7 @@ in shared.tarball-dhall-json shared.tarball-dhall-text - shared_ghcjs.tarball-try-dhall + shared_ghcjs.tarball-website # This is the only `dhall` build that runs the test suite coverage.dhall @@ -52,7 +52,7 @@ in "coverage-dhall" = coverage.dhall; - inherit (shared_ghcjs) tarball-try-dhall; + inherit (shared_ghcjs) tarball-website; inherit (shared) tarball-dhall