Skip to content

Commit 2035f1a

Browse files
committed
More documentation. Making sure all modules begin with Todo.
1 parent 4dfd69d commit 2035f1a

File tree

8 files changed

+23
-29
lines changed

8 files changed

+23
-29
lines changed

README.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
# Todo
22

3+
An example of using ElixirScript with a Phoenix 1.3 application.
4+
The ElixirScript code is in the `lib/todo_frontend` directory.
5+
The frontend uses the [ElixirScriptReact](https://github.com/elixirscript/elixirscript_react) library to create the view.
6+
37
To start your Phoenix app:
48

59
* Install dependencies with `mix deps.get`
6-
* Install Node.js dependencies with `npm install`
7-
* Start Phoenix endpoint with `mix phoenix.server`
10+
* Install Node.js dependencies with `(cd assets && npm install && cd ..)`
11+
* Start Phoenix endpoint with `mix phx.server`
812

913
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
10-
11-
Ready to run in production? Please [check our deployment guides](http://www.phoenixframework.org/docs/deployment).
12-
13-
## Learn more
14-
15-
* Official website: http://www.phoenixframework.org/
16-
* Guides: http://phoenixframework.org/docs/overview
17-
* Docs: https://hexdocs.pm/phoenix
18-
* Mailing list: http://groups.google.com/group/phoenix-talk
19-
* Source: https://github.com/phoenixframework/phoenix

assets/js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ import '../css/app.css';
2121
// import socket from "./socket"
2222
import Elixir from './build/Elixir.App';
2323

24-
Elixir.start(Elixir.Main, []);
24+
Elixir.start(Elixir.Todo.Main, []);

lib/todo_frontend/data.ex

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,50 @@ defmodule Todo.Data do
66
"""
77

88
def list() do
9-
Data.Http.fetch("/api/todo").then(fn(response) ->
9+
Todo.Data.Http.fetch("/api/todo").then(fn(response) ->
1010
response.json()
1111
end).then(fn(todos) ->
1212
todos
1313
|> Enum.map(fn(x) -> %Todo.Todo{ id: x.id, completed: x.completed, title: x.title } end)
14-
|> Main.update()
14+
|> Todo.Main.update()
1515
end).catch(fn(err) ->
16-
Data.Http.log(err)
16+
Todo.Data.Http.log(err)
1717
end)
1818
end
1919

2020
def add(the_title) do
21-
Data.Http.fetch("/api/todo", ElixirScript.JS.map_to_object(%{
21+
Todo.Data.Http.fetch("/api/todo", ElixirScript.JS.map_to_object(%{
2222
"method" => "post",
2323
"headers" => %{
2424
"Content-type" => "application/json"
2525
},
26-
"body" => Data.Http.stringify(ElixirScript.JS.map_to_object(%{"title" => the_title}))
26+
"body" => Todo.Data.Http.stringify(ElixirScript.JS.map_to_object(%{"title" => the_title}))
2727
})).then(fn(response) ->
2828
list()
2929
end).catch(fn(err) ->
30-
Data.Http.log(err)
30+
Todo.Data.Http.log(err)
3131
end)
3232
end
3333

3434
def remove(id) do
35-
Data.Http.fetch("/api/todo/" <> id, ElixirScript.JS.map_to_object(%{ "method" => "delete" })).then(fn(response) ->
35+
Todo.Data.Http.fetch("/api/todo/" <> id, ElixirScript.JS.map_to_object(%{ "method" => "delete" })).then(fn(response) ->
3636
list()
3737
end).catch(fn(err) ->
38-
Data.Http.log(err)
38+
Todo.Data.Http.log(err)
3939
end)
4040
end
4141

4242
def update(id, completed) do
43-
Data.Http.fetch("/api/todo/" <> id, ElixirScript.JS.map_to_object(%{
43+
Todo.Data.Http.fetch("/api/todo/" <> id, ElixirScript.JS.map_to_object(%{
4444
"method" => "put",
4545
"headers" => %{
4646
"Content-type" => "application/json"
4747
},
48-
"body" => Data.Http.stringify(ElixirScript.JS.map_to_object(%{ "completed" => completed }))
48+
"body" => Todo.Data.Http.stringify(ElixirScript.JS.map_to_object(%{ "completed" => completed }))
4949
})).then(fn(response) ->
5050
list()
5151
end).catch(fn(err) ->
52-
Data.Http.log(err)
52+
Todo.Data.Http.log(err)
5353
end)
5454
end
5555
end

lib/todo_frontend/data_http.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule Data.Http do
1+
defmodule Todo.Data.Http do
22
@moduledoc """
33
An FFI module for fetching data in JavaScript.
44
"""

lib/todo_frontend/document.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule Document do
1+
defmodule Todo.Document do
22
@moduledoc """
33
An FFI module for interacting with the document module
44
in JavaScript.

lib/todo_frontend/main.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule Main do
1+
defmodule Todo.Main do
22
use ReactUI
33

44
@moduledoc """
@@ -98,7 +98,7 @@ defmodule Main do
9898
Todo.Data.add(event.target.value)
9999
ElixirScript.JS.mutate(event.target, "value", "")
100100
else
101-
Data.Http.log(event)
101+
Todo.Data.Http.log(event)
102102
end
103103
end
104104
end

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defmodule Todo.Mixfile do
1111
start_permanent: Mix.env == :prod,
1212
deps: deps(),
1313
elixir_script: [
14-
input: [Main],
14+
input: [Todo.Main],
1515
output: "assets/js/build"
1616
]
1717
]
File renamed without changes.

0 commit comments

Comments
 (0)