Skip to content

Commit

Permalink
clean up dir structure
Browse files Browse the repository at this point in the history
  • Loading branch information
knowthen committed Jun 24, 2016
1 parent 7278b5f commit 69b49cf
Show file tree
Hide file tree
Showing 27 changed files with 1,434 additions and 99 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions first-app/Main1.elm → 04 first-app/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ initModel =

type Msg
= AddCalorie
| Clear


update : Msg -> Model -> Model
Expand All @@ -32,6 +33,9 @@ update msg model =
AddCalorie ->
model + 1

Clear ->
initModel



-- view
Expand All @@ -47,6 +51,11 @@ view model =
, onClick AddCalorie
]
[ text "Add" ]
, button
[ type' "button"
, onClick Clear
]
[ text "Clear" ]
]


Expand Down
48 changes: 48 additions & 0 deletions 05 scorekeeper-starter/app.css

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions 05 scorekeeper-starter/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

var gulp = require('gulp'),
http = require('http'),
st = require('st'),
exec = require('child_process').exec,
gutil = require('gulp-util'),
clear = require('clear'),
counter = 0;

var cmd = 'elm make ./Main.elm --output ./bundle.js';
clear();
gulp.task('default', ['server', 'watch', 'elm']);

gulp.task('watch', function(cb) {
gulp.watch('**/*.elm', ['elm']);
});

gulp.task('server', function(done) {
gutil.log(gutil.colors.blue('Starting server at http://localhost:4000'));
http.createServer(
st({
path: __dirname,
index: 'index.html',
cache: false
})
).listen(4000, done);
});

gulp.task('elm', function(cb) {
if (counter > 0){
clear();
}
exec(cmd, function(err, stdout, stderr) {
if (err){
gutil.log(gutil.colors.red('elm make: '),gutil.colors.red(stderr));
} else {
gutil.log(gutil.colors.green('elm make: '), gutil.colors.green(stdout));
}
cb();
});
counter++;
});
19 changes: 19 additions & 0 deletions 05 scorekeeper-starter/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Basketball Score Keeper</title>
<link rel="stylesheet" href="app.css">
</head>

<body>
<div id="app"></div>
<script src="bundle.js"></script>
<script>
var app = Elm.Main.embed(document.getElementById("app"));
</script>
</body>

</html>
17 changes: 17 additions & 0 deletions 05 scorekeeper-starter/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "beginner",
"version": "1.0.0",
"description": "",
"main": "bundle.js",
"devDependencies": {
"clear": "0.0.1",
"gulp": "^3.9.1",
"gulp-util": "^3.0.7",
"st": "^1.1.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
19 changes: 19 additions & 0 deletions DEVSETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Development Environment Setup Steps

1. Install Recent Version of **Nodejs** by downloading and running the installer found at https://nodejs.org/en/
2. Install **Elm** by keying the command `npm install -g elm`
3. Install the atom editor located at https://atom.io/
4. Install the **language-elm** using the atom package manager (apm), by keying the command `apm install language-elm`
5. Install **elm-oracle** by keying `npm install -g elm-oracle`
6. Determine the path where the `elm-oracle` command was installed by keying `which elm-oracle` on mac and unix or `where.exe elm-oracle` on windows. Copy the entire path and file name to the clipboard, for use in the next step
7. Open up Atom, then open up the preferences/settings by pressing `CMD + ,` or via the menu. Click `packages` then filter by `elm`. Find the language-elm package and click the `settings` button. Set the `elm-oracle` setting, by pasting the value we copied in the prior step.
10. Download the current version of **elm-format** found at https://github.com/avh4/elm-format
11. Unzip the downloaded file and move the `elm-format` executable to a location in your PATH variable, such as `mv ~/Downloads/elm-format /usr/local/bin/elm-format`
12. Install the `elm-format` Atom Package *(Note: different from elm-format command)*, by keying `apm install elm-format`
13. Start Atom, Open up Settings `CMD + ,`, click `Packages`, filter by `elm`, then click on the `elm-format` package's `settings` button. Set the `elm-format` command path setting and veryify the `format on save` checkbox is checked.
14. Install atom linter by keying `apm install linter`
15. Install the elm linger by keying `apm install linter-elm-make`
16. Locate and copy the path and file for the `elm-make` command by keying the command `which elm-make` for mac or `where.exe elm-make` on windows.
17. Open the `linter-elm-make` settings page in atom as you did in steps 7 and 13, then click the settings button next to `linter-elm-make` and then set the `elm-make` setting to the copied value from the prior step.

Your atom / elm dev environment should be good to go!
27 changes: 20 additions & 7 deletions first-app-improved/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,34 @@ import String


type alias Model =
{ calories : Int, input : Int }
{ calories : Int
, input : Int
, error : Maybe String
}


initModel : Model
initModel =
{ calories = 0, input = 0 }
{ calories = 0
, input = 0
, error = Nothing
}



-- update


type Msg
= AddMeal
= AddCalorie
| Input String
| Clear


update : Msg -> Model -> Model
update msg model =
case msg of
AddMeal ->
AddCalorie ->
{ model
| calories = model.calories + model.input
, input = 0
Expand All @@ -41,10 +47,16 @@ update msg model =
Input val ->
case String.toInt val of
Ok input ->
{ model | input = input }
{ model
| input = input
, error = Nothing
}

Err err ->
model
{ model
| input = 0
, error = Just err
}

Clear ->
initModel
Expand All @@ -69,9 +81,10 @@ view model =
)
]
[]
, div [] [ text (Maybe.withDefault "" model.error) ]
, button
[ type' "button"
, onClick AddMeal
, onClick AddCalorie
]
[ text "Add" ]
, button
Expand Down
92 changes: 0 additions & 92 deletions first-app/Main.elm

This file was deleted.

Loading

0 comments on commit 69b49cf

Please sign in to comment.