From f6a73e5bd6a5e2d7d4eb9c8a14bdf1a0c8a4ac4c Mon Sep 17 00:00:00 2001
From: Joris
Date: Tue, 4 Apr 2017 23:40:54 +0200
Subject: Bootstrap purescript
---
.gitignore | 4 ++++
.tmuxinator.yml | 10 ++++++++++
README.md | 19 +++++++++++++++++++
bower.json | 13 +++++++++++++
build | 2 ++
public/index.html | 10 ++++++++++
public/main.css | 6 ++++++
shell.nix | 16 ++++++++++++++++
src/Aliment.purs | 13 +++++++++++++
src/Main.purs | 13 +++++++++++++
src/Page.purs | 45 +++++++++++++++++++++++++++++++++++++++++++++
start | 2 ++
stop | 3 +++
watch | 2 ++
14 files changed, 158 insertions(+)
create mode 100644 .gitignore
create mode 100644 .tmuxinator.yml
create mode 100644 README.md
create mode 100644 bower.json
create mode 100755 build
create mode 100644 public/index.html
create mode 100644 public/main.css
create mode 100644 shell.nix
create mode 100644 src/Aliment.purs
create mode 100644 src/Main.purs
create mode 100644 src/Page.purs
create mode 100755 start
create mode 100755 stop
create mode 100755 watch
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 @@
+
+
+
+ Sucre
+
+
+
+
+
+
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 {}; {
+ 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
--
cgit v1.2.3