Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Welcome to Phoenix!</title>
defmodule MongoTest.Mixfile do
use Mix.Project
def project do
[app: :mongo_test,
version: "0.0.1",
elixir: "~> 1.0.4",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps]
mongo = Mongo.connect!
db = mongo |> Mongo.db("phoenix_bbs")
collection = db |> Mongo.Db.collection("comments")
Mongo.Server.close(mongo)
mongo = Mongo.connect!
db = mongo |> Mongo.db("phoenix_bbs")
collection = db |> Mongo.Db.collection("comments")
# init data
Mongo.Collection.drop collection
[
%{name: "hoge", title: "hoge", comment: "hogehoge"},
%{name: "huge", title: "huge", comment: "hugehuge"},
%{name: "darui", title: "blogger", comment: "darui"}
defmodule PhoenixChannels.Router do
use PhoenixChannels.Web, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
end
defmodule PhoenixChannels.RoomChannel do
use Phoenix.Channel
def join("rooms:lobby", auth_msg, socket) do
{:ok, socket}
end
def join("rooms:" <> _private_room_id, _auth_msg, socket) do
{:error, %{reason: "unauthorized"}}
end
import {Socket} from "phoenix"
// let socket = new Socket("/ws")
// socket.connect()
// let chan = socket.chan("topic:subtopic", {})
// chan.join().receive("ok", chan => {
// console.log("Success!")
// })
let chatInput = $("#chat-input")
<div class="jumbotron">
<h2>Welcome to Phoenix!</h2>
<p class="lead">Most frameworks make you choose between speed and a productive environment. <a href="http://phoenixframework.org">Phoenix</a> and <a href="http://elixir-lang.org">Elixir</a> give you both.</p>
</div>
<div class="row marketing">
<div class="col-lg-6">
<h4>Resources</h4>
<ul>
<li>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Hello Phoenix!</title>
defmodule Test do
def add(x, y) do
:test.add(x, y)
end
def str_size(str) do
:erlang.size(str)
end
end