aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--.tmuxinator.yml10
-rw-r--r--README.md19
-rw-r--r--bower.json13
-rwxr-xr-xbuild2
-rw-r--r--public/index.html10
-rw-r--r--public/main.css6
-rw-r--r--shell.nix16
-rw-r--r--src/Aliment.purs13
-rw-r--r--src/Main.purs13
-rw-r--r--src/Page.purs45
-rwxr-xr-xstart2
-rwxr-xr-xstop3
-rwxr-xr-xwatch2
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": "*"
+ }
+}
diff --git a/build b/build
new file mode 100755
index 0000000..d28f5eb
--- /dev/null
+++ b/build
@@ -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))
+ ]
diff --git a/start b/start
new file mode 100755
index 0000000..4dbcbcc
--- /dev/null
+++ b/start
@@ -0,0 +1,2 @@
+#!/bin/sh
+nix-shell --command "mux local"
diff --git a/stop b/stop
new file mode 100755
index 0000000..99d5355
--- /dev/null
+++ b/stop
@@ -0,0 +1,3 @@
+#!/bin/sh
+pkill webfsd
+tmux kill-session -t sucre
diff --git a/watch b/watch
new file mode 100755
index 0000000..3da092d
--- /dev/null
+++ b/watch
@@ -0,0 +1,2 @@
+#!/bin/sh
+pulp --watch --before clear build --to public/main.js