Skip to content

Commit 32342b9

Browse files
committed
updating todo example
1 parent c267869 commit 32342b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+586
-632
lines changed

.babelrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
{
3+
"presets": [
4+
["env", {
5+
"targets": {
6+
"chrome": 52
7+
},
8+
"modules": "commonjs",
9+
"loose": true
10+
}]
11+
]
12+
}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/deps
55
/*.ez
66

7-
# Generate on crash by the VM
7+
# Generated on crash by the VM
88
erl_crash.dump
99

1010
# Static artifacts
@@ -22,3 +22,4 @@ erl_crash.dump
2222
# secrets file as long as you replace its contents by environment
2323
# variables.
2424
/config/prod.secret.exs
25+
web/static/js/build/

README.md

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

3-
A Todo app built using Elixirscript.
4-
5-
63
To start your Phoenix app:
74

85
* Install dependencies with `mix deps.get`
9-
* Create and migrate your database with `mix ecto.create && mix ecto.migrate`
106
* Install Node.js dependencies with `npm install`
117
* Start Phoenix endpoint with `mix phoenix.server`
128

139
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

brunch-config.js

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,74 +2,57 @@ exports.config = {
22
// See http://brunch.io/#documentation for docs.
33
files: {
44
javascripts: {
5-
joinTo: "js/app.js"
6-
75
// To use a separate vendor.js bundle, specify two files path
8-
// https://github.com/brunch/brunch/blob/stable/docs/config.md#files
6+
// http://brunch.io/docs/config#-files-
97
// joinTo: {
108
// "js/app.js": /^(web\/static\/js)/,
119
// "js/vendor.js": /^(web\/static\/vendor)|(deps)/
1210
// }
1311
//
1412
// To change the order of concatenation of files, explicitly mention here
15-
// https://github.com/brunch/brunch/tree/master/docs#concatenation
1613
// order: {
1714
// before: [
1815
// "web/static/vendor/js/jquery-2.1.1.js",
1916
// "web/static/vendor/js/bootstrap.min.js"
2017
// ]
2118
// }
19+
joinTo: 'js/app.js',
2220
},
2321
stylesheets: {
24-
joinTo: "css/app.css"
22+
joinTo: 'css/app.css',
23+
order: {
24+
// concat app.css last
25+
after: [ 'web/static/css/app.css' ],
26+
},
2527
},
26-
templates: {
27-
joinTo: "js/app.js"
28-
}
28+
templates: { joinTo: 'js/app.js' },
2929
},
30-
3130
conventions: {
3231
// This option sets where we should place non-css and non-js assets in.
3332
// By default, we set this to "/web/static/assets". Files in this directory
3433
// will be copied to `paths.public`, which is "priv/static" by default.
35-
assets: /^(web\/static\/assets)/
34+
assets: /^(web\/static\/assets)/,
3635
},
37-
3836
// Phoenix paths configuration
3937
paths: {
4038
// Dependencies and current project directories to watch
41-
watched: [
42-
"web/static",
43-
"test/static"
44-
],
45-
39+
watched: [ 'web/static', 'test/static' ],
4640
// Where to compile files to
47-
public: "priv/static"
41+
public: 'priv/static',
4842
},
49-
5043
// Configure your plugins
5144
plugins: {
5245
babel: {
46+
presets: [
47+
[
48+
'env',
49+
{ targets: { chrome: 52 }, modules: 'commonjs', loose: true },
50+
],
51+
],
5352
// Do not use ES6 compiler in vendor code
54-
ignore: [/web\/static\/vendor/]
53+
ignore: [ /web\/static\/vendor/ ],
5554
},
56-
elixirscript: {
57-
inputFolder: "web/static/exjs",
58-
outputFolder: "web/static/js",
59-
mainModule: "Todo"
60-
}
6155
},
62-
63-
modules: {
64-
autoRequire: {
65-
"js/app.js": ["web/static/js/main"]
66-
}
67-
},
68-
69-
npm: {
70-
enabled: true,
71-
// Whitelist the npm deps to be pulled in as front-end assets.
72-
// All other deps in package.json will be excluded from the bundle.
73-
whitelist: ["phoenix", "phoenix_html"]
74-
}
56+
modules: { autoRequire: { 'js/app.js': [ 'web/static/js/app' ] } },
57+
npm: { enabled: true },
7558
};

config/config.exs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ use Mix.Config
88
# Configures the endpoint
99
config :todo, Todo.Endpoint,
1010
url: [host: "localhost"],
11-
root: Path.dirname(__DIR__),
12-
secret_key_base: "iyanJp73OeHaopWgaSRc3dazQENLfmMw6/+gy7QGjAoLqE17fKBSJskQPFPs8Fbr",
13-
render_errors: [accepts: ~w(html json)],
11+
secret_key_base: "DSFpJTbLbzxovpyVZ0kynrtvPaeCpZHgWL9Dh7GRDZC6adtg4+7g7D52/uN1zpR+",
12+
render_errors: [view: Todo.ErrorView, accepts: ~w(html json)],
1413
pubsub: [name: Todo.PubSub,
1514
adapter: Phoenix.PubSub.PG2]
1615

@@ -22,8 +21,3 @@ config :logger, :console,
2221
# Import environment specific config. This must remain at the bottom
2322
# of this file so it overrides the configuration defined above.
2423
import_config "#{Mix.env}.exs"
25-
26-
# Configure phoenix generators
27-
config :phoenix, :generators,
28-
migration: true,
29-
binary_id: false

config/dev.exs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ config :todo, Todo.Endpoint,
1111
debug_errors: true,
1212
code_reloader: true,
1313
check_origin: false,
14-
watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin"]]
14+
watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin",
15+
cd: Path.expand("../", __DIR__)], mix: ["elixirscript.watch"]]
16+
1517

1618
# Watch static and templates for browser reloading.
1719
config :todo, Todo.Endpoint,
@@ -27,16 +29,6 @@ config :todo, Todo.Endpoint,
2729
# Do not include metadata nor timestamps in development logs
2830
config :logger, :console, format: "[$level] $message\n"
2931

30-
# Set a higher stacktrace during development.
31-
# Do not configure such in production as keeping
32-
# and calculating stacktraces is usually expensive.
32+
# Set a higher stacktrace during development. Avoid configuring such
33+
# in production as building large stacktraces may be expensive.
3334
config :phoenix, :stacktrace_depth, 20
34-
35-
# Configure your database
36-
config :todo, Todo.Repo,
37-
adapter: Ecto.Adapters.Postgres,
38-
username: "postgres",
39-
password: "postgres",
40-
database: "todo_dev",
41-
hostname: "localhost",
42-
pool_size: 10

config/prod.exs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ config :logger, level: :info
5555
#
5656
# config :todo, Todo.Endpoint, server: true
5757
#
58-
# You will also need to set the application root to `.` in order
59-
# for the new static assets to be served after a hot upgrade:
60-
#
61-
# config :todo, Todo.Endpoint, root: "."
6258

6359
# Finally import the config/prod.secret.exs
6460
# which should be versioned separately.

config/test.exs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,3 @@ config :todo, Todo.Endpoint,
88

99
# Print only warnings and errors during test
1010
config :logger, level: :warn
11-
12-
# Configure your database
13-
config :todo, Todo.Repo,
14-
adapter: Ecto.Adapters.Postgres,
15-
username: "postgres",
16-
password: "postgres",
17-
database: "todo_test",
18-
hostname: "localhost",
19-
pool: Ecto.Adapters.SQL.Sandbox
File renamed without changes.

lib/todo.ex

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ defmodule Todo do
44
# See http://elixir-lang.org/docs/stable/elixir/Application.html
55
# for more information on OTP Applications
66
def start(_type, _args) do
7-
import Supervisor.Spec, warn: false
7+
import Supervisor.Spec
88

9+
# Define workers and child supervisors to be supervised
910
children = [
1011
# Start the endpoint when the application starts
1112
supervisor(Todo.Endpoint, []),
12-
# Start the Ecto repository
13-
supervisor(Todo.Repo, []),
14-
worker(Todo.Store, []),
15-
# Here you could define other workers and supervisors as children
13+
worker(Todo.Store, [])
14+
# Start your own worker by calling: Todo.Worker.start_link(arg1, arg2, arg3)
1615
# worker(Todo.Worker, [arg1, arg2, arg3]),
1716
]
1817

0 commit comments

Comments
 (0)