Skip to content

Commit d4f5a6e

Browse files
committed
initial commit
0 parents  commit d4f5a6e

Some content is hidden

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

78 files changed

+5899
-0
lines changed

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# App artifacts
2+
/_build
3+
/db
4+
/deps
5+
/*.ez
6+
7+
# Generated on crash by the VM
8+
erl_crash.dump
9+
10+
# Generated on crash by NPM
11+
npm-debug.log
12+
13+
# Static artifacts
14+
/assets/node_modules
15+
16+
# Since we are building assets from assets/,
17+
# we ignore priv/static. You may want to comment
18+
# this depending on your deployment strategy.
19+
/priv/static/
20+
21+
# Files matching config/*.secret.exs pattern contain sensitive
22+
# data and you should not commit them into version control.
23+
#
24+
# Alternatively, you may comment the line below and commit the
25+
# secrets files as long as you replace their contents by environment
26+
# variables.
27+
/config/*.secret.exs
28+
29+
/assets/node_modules/

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Notable
2+
3+
To start your Phoenix server:
4+
5+
* Install dependencies with `mix deps.get`
6+
* Create and migrate your database with `mix ecto.create && mix ecto.migrate`
7+
* Install Node.js dependencies with `cd assets && npm install`
8+
* Start Phoenix endpoint with `mix phx.server`
9+
10+
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
11+
12+
Ready to run in production? Please [check our deployment guides](http://www.phoenixframework.org/docs/deployment).
13+
14+
## Learn more
15+
16+
* Official website: http://www.phoenixframework.org/
17+
* Guides: http://phoenixframework.org/docs/overview
18+
* Docs: https://hexdocs.pm/phoenix
19+
* Mailing list: http://groups.google.com/group/phoenix-talk
20+
* Source: https://github.com/phoenixframework/phoenix

assets/js/app.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Brunch automatically concatenates all files in your
2+
// watched paths. Those paths can be configured at
3+
// config.paths.watched in "brunch-config.js".
4+
//
5+
// However, those files will only be executed if
6+
// explicitly imported. The only exception are files
7+
// in vendor, which are never wrapped in imports and
8+
// therefore are always executed.
9+
10+
// Import dependencies
11+
//
12+
// If you no longer want to use a dependency, remember
13+
// to also remove its path from "config.paths.watched".
14+
import "phoenix_html"
15+
16+
// Import local files
17+
//
18+
// Local files can be imported directly using relative
19+
// paths "./socket" or full ones "web/static/js/socket".
20+
21+
// import socket from "./socket"
22+
console.log("wow")

assets/js/socket.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// NOTE: The contents of this file will only be executed if
2+
// you uncomment its entry in "assets/js/app.js".
3+
4+
// To use Phoenix channels, the first step is to import Socket
5+
// and connect at the socket path in "lib/web/endpoint.ex":
6+
import {Socket} from "phoenix"
7+
8+
let socket = new Socket("/socket", {params: {token: window.userToken}})
9+
10+
// When you connect, you'll often need to authenticate the client.
11+
// For example, imagine you have an authentication plug, `MyAuth`,
12+
// which authenticates the session and assigns a `:current_user`.
13+
// If the current user exists you can assign the user's token in
14+
// the connection for use in the layout.
15+
//
16+
// In your "lib/web/router.ex":
17+
//
18+
// pipeline :browser do
19+
// ...
20+
// plug MyAuth
21+
// plug :put_user_token
22+
// end
23+
//
24+
// defp put_user_token(conn, _) do
25+
// if current_user = conn.assigns[:current_user] do
26+
// token = Phoenix.Token.sign(conn, "user socket", current_user.id)
27+
// assign(conn, :user_token, token)
28+
// else
29+
// conn
30+
// end
31+
// end
32+
//
33+
// Now you need to pass this token to JavaScript. You can do so
34+
// inside a script tag in "lib/web/templates/layout/app.html.eex":
35+
//
36+
// <script>window.userToken = "<%= assigns[:user_token] %>";</script>
37+
//
38+
// You will need to verify the user token in the "connect/2" function
39+
// in "lib/web/channels/user_socket.ex":
40+
//
41+
// def connect(%{"token" => token}, socket) do
42+
// # max_age: 1209600 is equivalent to two weeks in seconds
43+
// case Phoenix.Token.verify(socket, "user socket", token, max_age: 1209600) do
44+
// {:ok, user_id} ->
45+
// {:ok, assign(socket, :user, user_id)}
46+
// {:error, reason} ->
47+
// :error
48+
// end
49+
// end
50+
//
51+
// Finally, pass the token on connect as below. Or remove it
52+
// from connect if you don't care about authentication.
53+
54+
socket.connect()
55+
56+
// Now that you are connected, you can join channels with a topic:
57+
let channel = socket.channel("topic:subtopic", {})
58+
channel.join()
59+
.receive("ok", resp => { console.log("Joined successfully", resp) })
60+
.receive("error", resp => { console.log("Unable to join", resp) })
61+
62+
export default socket

assets/package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"repository": {},
3+
"license": "MIT",
4+
"dependencies": {
5+
"babel-preset-react": "^6.24.1",
6+
"css-loader": "^0.28.0",
7+
"extract-text-webpack-plugin": "^2.1.0",
8+
"node-sass": "^4.5.2",
9+
"phoenix": "file:../deps/phoenix",
10+
"phoenix_html": "file:../deps/phoenix_html",
11+
"react": "^15.5.4",
12+
"react-dom": "^15.5.4",
13+
"sass-loader": "^6.0.3",
14+
"style-loader": "^0.16.1"
15+
},
16+
"devDependencies": {
17+
"babel-core": "^6.24.1",
18+
"babel-loader": "^6.4.1",
19+
"babel-preset-env": "^1.4.0",
20+
"webpack": "^2.4.1"
21+
}
22+
}

assets/static/favicon.ico

1.23 KB
Binary file not shown.

assets/static/images/phoenix.png

13.6 KB
Loading

assets/static/robots.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2+
#
3+
# To ban all spiders from the entire site uncomment the next two lines:
4+
# User-agent: *
5+
# Disallow: /

assets/stylesheets/app.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* This file is for your main application css. */

assets/webpack.config.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"use strict";
2+
const path = require("path");
3+
const webpack = require("webpack");
4+
const ExtractTextPlugin = require("extract-text-webpack-plugin");
5+
6+
module.exports = {
7+
context: __dirname,
8+
entry: ["./stylesheets/app.scss", "./js/app.js"],
9+
output: {
10+
path: __dirname + '/../priv/static',
11+
filename: 'js/app.js',
12+
},
13+
module: {
14+
rules: [
15+
{
16+
test: /\.js$/,
17+
exclude: /(node_modules)/,
18+
loader: "babel-loader",
19+
},
20+
{
21+
test: /\.(sass|scss)$/,
22+
use: ExtractTextPlugin.extract({
23+
fallback: "style-loader",
24+
use: ["css-loader", "sass-loader"]
25+
})
26+
},
27+
],//end rules
28+
},
29+
plugins: [
30+
new webpack.LoaderOptionsPlugin({
31+
minimize: true,
32+
debug: false
33+
}),
34+
new ExtractTextPlugin({
35+
filename: (getPath) => {
36+
return getPath('css/app.css').replace('js/css', 'css');
37+
},
38+
allChunks: true
39+
})
40+
],
41+
}

0 commit comments

Comments
 (0)