diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | .tmuxinator.yml | 10 | ||||
-rw-r--r-- | README.md | 19 | ||||
-rw-r--r-- | bower.json | 13 | ||||
-rwxr-xr-x | build | 2 | ||||
-rw-r--r-- | public/index.html | 10 | ||||
-rw-r--r-- | public/main.css | 6 | ||||
-rw-r--r-- | shell.nix | 16 | ||||
-rw-r--r-- | src/Aliment.purs | 13 | ||||
-rw-r--r-- | src/Main.purs | 13 | ||||
-rw-r--r-- | src/Page.purs | 45 | ||||
-rwxr-xr-x | start | 2 | ||||
-rwxr-xr-x | stop | 3 | ||||
-rwxr-xr-x | watch | 2 |
14 files changed, 158 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dbfb8e7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/public/main.js +/output/ +/bower_components/ +/node_modules/ diff --git a/.tmuxinator.yml b/.tmuxinator.yml new file mode 100644 index 0000000..be3eac8 --- /dev/null +++ b/.tmuxinator.yml @@ -0,0 +1,10 @@ +name: sucre + +windows: + - main: + layout: 1074,239x57,0,0{144x57,0,0,0,94x57,145,0,2} + panes: + - # Empty + - build: + - webfsd -r public -f index.html -p 9000 + - npm install pulp && bower install && ./watch diff --git a/README.md b/README.md new file mode 100644 index 0000000..3039512 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +Sucre +===== + +Getting started +--------------- + +Install nix and follow the instructions: + +``` sh +curl https://nixos.org/nix/install | sh +``` + +Launch: + +``` sh +./start +``` + +Open your browser at [http://localhost:9000](http://localhost:9000). diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..6ec6ec0 --- /dev/null +++ b/bower.json @@ -0,0 +1,13 @@ +{ + "name": "sucre", + "private": true, + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "output" + ], + "dependencies": { + "purescript-halogen": "*" + } +} @@ -0,0 +1,2 @@ +#!/bin/sh +pulp build --to public/main.js diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..f1bb196 --- /dev/null +++ b/public/index.html @@ -0,0 +1,10 @@ +<!doctype html> +<html> + <head> + <title>Sucre</title> + <link rel="stylesheet" href="main.css"> + </head> + <body> + <script src="main.js"></script> + </body> +</html> diff --git a/public/main.css b/public/main.css new file mode 100644 index 0000000..6388837 --- /dev/null +++ b/public/main.css @@ -0,0 +1,6 @@ +h1 { + text-align: center; + margin-bottom: 1em; + font-size: 46px; + color: #33AA00; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..283438f --- /dev/null +++ b/shell.nix @@ -0,0 +1,16 @@ +with import <nixpkgs> {}; { + env = stdenv.mkDerivation { + name = "env"; + buildInputs = with pkgs; [ + nodejs-7_x + nodePackages.bower + purescript + tmux + tmuxinator + webfs + ]; + shellHook = '' + export PATH=node_modules/.bin:$PATH; + ''; + }; +} diff --git a/src/Aliment.purs b/src/Aliment.purs new file mode 100644 index 0000000..e7c4fc8 --- /dev/null +++ b/src/Aliment.purs @@ -0,0 +1,13 @@ +module Aliment where + +all :: Array Aliment +all = + [ { name: "Oignon", gi: 15 } + , { name: "Olive", gi: 15 } + , { name: "Haricot rouge", gi: 35 } + ] + +type Aliment = + { name :: String + , gi :: Int + } diff --git a/src/Main.purs b/src/Main.purs new file mode 100644 index 0000000..3121aa5 --- /dev/null +++ b/src/Main.purs @@ -0,0 +1,13 @@ +module Main where + +import Prelude +import Control.Monad.Eff (Eff) +import Halogen.Aff as HA +import Halogen.VDom.Driver (runUI) + +import Page as Page + +main :: Eff (HA.HalogenEffects ()) Unit +main = HA.runHalogenAff do + body <- HA.awaitBody + runUI Page.component unit body diff --git a/src/Page.purs b/src/Page.purs new file mode 100644 index 0000000..83e4d73 --- /dev/null +++ b/src/Page.purs @@ -0,0 +1,45 @@ +module Page where + +import Prelude +import Data.Maybe (Maybe(..)) +import Halogen as H +import Halogen.HTML as HH + +import Aliment as Aliment +import Aliment (Aliment) + +type State = Unit + +data Query a = NoOp a + +data Message = Toggled Boolean + +component :: forall m . H.Component HH.HTML Query State Message m +component = + H.component + { initialState: const unit + , render + , eval + , receiver: const Nothing + } + where + render :: State -> H.ComponentHTML Query + render state = + HH.div + [] + [ HH.h1 [] [ HH.text "Sucre" ] + , HH.ul + [] + (map renderAliment Aliment.all) + ] + + eval :: Query ~> H.ComponentDSL State Query Message m + eval = case _ of + NoOp next -> pure next + +renderAliment :: Aliment -> H.ComponentHTML Query +renderAliment aliment = + HH.li + [] + [ HH.text (aliment.name <> ", index glycémique: " <> (show aliment.gi)) + ] @@ -0,0 +1,2 @@ +#!/bin/sh +nix-shell --command "mux local" @@ -0,0 +1,3 @@ +#!/bin/sh +pkill webfsd +tmux kill-session -t sucre @@ -0,0 +1,2 @@ +#!/bin/sh +pulp --watch --before clear build --to public/main.js |