Initial commit
This commit is contained in:
commit
a16cf2d34f
11 changed files with 296 additions and 0 deletions
17
.gitignore
vendored
Normal file
17
.gitignore
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
.rebar3
|
||||
rebar3
|
||||
_*
|
||||
.eunit
|
||||
*.o
|
||||
*.beam
|
||||
*.plt
|
||||
.erlang.cookie
|
||||
ebin
|
||||
log
|
||||
erl_crash.dump
|
||||
.rebar
|
||||
_rel
|
||||
_deps
|
||||
_plugins
|
||||
_tdeps
|
||||
logs
|
14
README.md
Normal file
14
README.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
elmdap
|
||||
==========
|
||||
|
||||
An LFE application
|
||||
|
||||
## Build
|
||||
```
|
||||
$ rebar3 lfe release
|
||||
```
|
||||
|
||||
## Test
|
||||
```
|
||||
$ rebar3 lfe test
|
||||
```
|
2
priv/.gitignore
vendored
Normal file
2
priv/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
elm-stuff/
|
||||
elm.js
|
19
priv/elm-package.json
Normal file
19
priv/elm-package.json
Normal file
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"version": "1.0.0",
|
||||
"summary": "helpful summary of your project, less than 80 characters",
|
||||
"repository": "https://github.com/user/project.git",
|
||||
"license": "BSD3",
|
||||
"source-directories": [
|
||||
"src"
|
||||
],
|
||||
"exposed-modules": [],
|
||||
"dependencies": {
|
||||
"debois/elm-mdl": "2.1.3 <= v < 3.0.0",
|
||||
"elm-lang/core": "3.0.0 <= v < 4.0.0",
|
||||
"evancz/elm-effects": "2.0.1 <= v < 3.0.0",
|
||||
"evancz/elm-html": "4.0.2 <= v < 5.0.0",
|
||||
"evancz/elm-http": "3.0.0 <= v < 4.0.0",
|
||||
"evancz/start-app": "2.0.2 <= v < 3.0.0"
|
||||
},
|
||||
"elm-version": "0.16.0 <= v < 0.17.0"
|
||||
}
|
128
priv/src/App.elm
Normal file
128
priv/src/App.elm
Normal file
|
@ -0,0 +1,128 @@
|
|||
module App (main) where
|
||||
|
||||
import StartApp
|
||||
import Effects exposing (Effects, Never)
|
||||
import Task exposing (Task)
|
||||
import Html exposing (Html)
|
||||
import Http
|
||||
import Material
|
||||
import Material.Color as Color
|
||||
import Material.Layout as Layout exposing (defaultLayoutModel)
|
||||
import Material.Scheme as Scheme
|
||||
import Material.Textfield as Textfield
|
||||
import Material.Button as Button
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ uid : String
|
||||
, password : String
|
||||
, authenticated : Bool
|
||||
, mdl : Material.Model
|
||||
}
|
||||
|
||||
|
||||
type Action
|
||||
= UpdateUID String
|
||||
| UpdatePassword String
|
||||
| Authenticate
|
||||
| AuthenticationResponse (Result Http.Error Bool)
|
||||
| MDL (Material.Action Action)
|
||||
| LayoutAction Layout.Action
|
||||
|
||||
|
||||
init : ( Model, Effects Action )
|
||||
init =
|
||||
( { uid = ""
|
||||
, password = ""
|
||||
, authenticated = False
|
||||
, mdl = Material.model
|
||||
}
|
||||
, Effects.none
|
||||
)
|
||||
|
||||
|
||||
update : Action -> Model -> ( Model, Effects Action )
|
||||
update action model =
|
||||
case action of
|
||||
MDL action' ->
|
||||
let
|
||||
( mdl', fx ) =
|
||||
Material.update MDL action' model.mdl
|
||||
in
|
||||
( { model | mdl = mdl' }, fx )
|
||||
|
||||
_ ->
|
||||
( model, Effects.none )
|
||||
|
||||
|
||||
uidInput : Textfield.Instance Material.Model Action
|
||||
uidInput =
|
||||
let
|
||||
model =
|
||||
Textfield.model
|
||||
in
|
||||
Textfield.instance
|
||||
0
|
||||
MDL
|
||||
{ model | label = Just { text = "User ID", float = True } }
|
||||
[ Textfield.fwdInput UpdateUID ]
|
||||
|
||||
|
||||
passwordInput : Textfield.Instance Material.Model Action
|
||||
passwordInput =
|
||||
let
|
||||
model =
|
||||
Textfield.model
|
||||
in
|
||||
Textfield.instance
|
||||
1
|
||||
MDL
|
||||
{ model | label = Just { text = "Password", float = True } }
|
||||
[ Textfield.fwdInput UpdatePassword ]
|
||||
|
||||
|
||||
submitButton : Button.Instance Material.Model Action
|
||||
submitButton =
|
||||
Button.instance
|
||||
0
|
||||
MDL
|
||||
Button.raised
|
||||
(Button.model True)
|
||||
[ Button.fwdClick Authenticate ]
|
||||
|
||||
|
||||
view : Signal.Address Action -> Model -> Html
|
||||
view address model =
|
||||
Layout.view
|
||||
(Signal.forwardTo address LayoutAction)
|
||||
defaultLayoutModel
|
||||
{ header = []
|
||||
, drawer = []
|
||||
, tabs = []
|
||||
, main =
|
||||
[ Html.h1 [] [ Html.text "Log In" ]
|
||||
, Html.div [] [ uidInput.view address model.mdl [] ]
|
||||
, Html.div [] [ passwordInput.view address model.mdl [] ]
|
||||
, Html.div [] [ submitButton.view address model.mdl [ Button.colored ] [ Html.text "Log In" ] ]
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
app : StartApp.App Model
|
||||
app =
|
||||
StartApp.start
|
||||
{ init = init
|
||||
, view = view
|
||||
, update = update
|
||||
, inputs = [ Layout.setupSignals LayoutAction ]
|
||||
}
|
||||
|
||||
|
||||
main : Signal Html
|
||||
main =
|
||||
Signal.map (Scheme.topWithScheme Color.Teal Color.Red) app.html
|
||||
|
||||
|
||||
port tasks : Signal (Task.Task Never ())
|
||||
port tasks =
|
||||
app.tasks
|
32
rebar.config
Normal file
32
rebar.config
Normal file
|
@ -0,0 +1,32 @@
|
|||
{erl_opts, [debug_info]}.
|
||||
{lfe_first_files, []}.
|
||||
|
||||
{deps, [
|
||||
{lfe, {git, "git://github.com/rvirding/lfe", {tag, "1.0"}}}
|
||||
]}.
|
||||
|
||||
{plugins, [
|
||||
{'lfe-compile', {git, "https://github.com/lfe-rebar3/compile.git", {tag, "0.3.0"}}}
|
||||
]}.
|
||||
|
||||
{provider_hooks, [
|
||||
{pre, [{compile, {lfe, compile}}]}
|
||||
]}.
|
||||
|
||||
{profiles, [
|
||||
{dev, [
|
||||
{plugins, [
|
||||
{'lfe-version', ".*", {git, "https://github.com/lfe-rebar3/version.git", {tag, "0.3.0"}}},
|
||||
{'lfe-repl', ".*", {git, "https://github.com/lfe-rebar3/repl.git", {tag, "0.2.0"}}},
|
||||
{'lfe-clean', ".*", {git, "https://github.com/lfe-rebar3/clean.git", {tag, "0.2.0"}}}
|
||||
]}
|
||||
]},
|
||||
|
||||
{test, [
|
||||
{eunit_compile_opts, [
|
||||
{src_dirs, ["test", "src"]}
|
||||
]},
|
||||
{deps, [
|
||||
{ltest, ".*", {git, "git://github.com/lfex/ltest.git", {tag, "0.8.0"}}}]}
|
||||
]}
|
||||
]}.
|
22
src/elmdap-app.lfe
Normal file
22
src/elmdap-app.lfe
Normal file
|
@ -0,0 +1,22 @@
|
|||
#|
|
||||
@doc
|
||||
elmdap public API
|
||||
@end
|
||||
|#
|
||||
|
||||
(defmodule elmdap-app
|
||||
(behaviour application)
|
||||
|
||||
;; Application callbacks
|
||||
(export (start 2)
|
||||
(stop 1)))
|
||||
|
||||
;;; API
|
||||
|
||||
(defun start (_type _args)
|
||||
(elmdap-sup:start_link))
|
||||
|
||||
(defun stop (_state)
|
||||
'ok)
|
||||
|
||||
;;; Internal functions
|
30
src/elmdap-sup.lfe
Normal file
30
src/elmdap-sup.lfe
Normal file
|
@ -0,0 +1,30 @@
|
|||
#|
|
||||
@doc
|
||||
elmdap top level supervisor
|
||||
@end
|
||||
|#
|
||||
|
||||
(defmodule elmdap-sup
|
||||
(behaviour supervisor)
|
||||
|
||||
;; API
|
||||
(export (start_link 0))
|
||||
|
||||
;; Supervisor callbacks
|
||||
(export (init 1)))
|
||||
|
||||
;;; API functions
|
||||
|
||||
(defun server-name ()
|
||||
'elmdap-sup)
|
||||
|
||||
(defun start_link ()
|
||||
(supervisor:start_link
|
||||
`#(local ,(server-name)) (MODULE) '()))
|
||||
|
||||
;;; Supervisor callbacks
|
||||
|
||||
(defun init (_args)
|
||||
`#(ok #(#(one_for_one 0 1) ())))
|
||||
|
||||
;;; Internal functions
|
16
src/elmdap.app.src
Normal file
16
src/elmdap.app.src
Normal file
|
@ -0,0 +1,16 @@
|
|||
{application, 'elmdap',
|
||||
[{description, "An LFE Application"},
|
||||
{vsn, "0.0.1"},
|
||||
{registered, []},
|
||||
{applications,
|
||||
[kernel,
|
||||
stdlib
|
||||
]},
|
||||
{mod, {'elmdap-app', []}},
|
||||
{env, []},
|
||||
{modules, []},
|
||||
|
||||
{contributors, []},
|
||||
{licenses, []},
|
||||
{links, []}
|
||||
]}.
|
4
src/elmdap.lfe
Normal file
4
src/elmdap.lfe
Normal file
|
@ -0,0 +1,4 @@
|
|||
(defmodule elmdap
|
||||
(export all))
|
||||
|
||||
;; Public API
|
12
test/unit-elmdap-tests.lfe
Normal file
12
test/unit-elmdap-tests.lfe
Normal file
|
@ -0,0 +1,12 @@
|
|||
(defmodule unit-elmdap-tests
|
||||
(behaviour ltest-unit)
|
||||
(export all)
|
||||
(import
|
||||
(from ltest
|
||||
(check-failed-assert 2)
|
||||
(check-wrong-assert-exception 2))))
|
||||
|
||||
(include-lib "ltest/include/ltest-macros.lfe")
|
||||
|
||||
(deftest elmdap-hello-world
|
||||
(is 'true))
|
Loading…
Reference in a new issue