diff options
Diffstat (limited to 'shardweb/lib/shard_web')
19 files changed, 0 insertions, 818 deletions
diff --git a/shardweb/lib/shard_web/channels/room_channel.ex b/shardweb/lib/shard_web/channels/room_channel.ex deleted file mode 100644 index 7c3a16c..0000000 --- a/shardweb/lib/shard_web/channels/room_channel.ex +++ /dev/null @@ -1,72 +0,0 @@ -defmodule ShardWeb.RoomChannel do - use ShardWeb, :channel - - require Logger - - def join("room:" <> room_name, payload, socket) do - if authorized?(payload) do - - pid = Shard.Manager.find_or_start %SApp.Chat.Manifest{channel: room_name} - socket = assign(socket, :pid, pid) - - GenServer.cast(pid, {:subscribe, self()}) - send(self(), :after_join) - - {:ok, socket} - else - {:error, %{reason: "unauthorized"}} - end - end - - def handle_info(:after_join, socket) do - GenServer.call(socket.assigns.pid, {:read_history, nil, 100}) - |> Enum.each(fn {{pk, msgbin, _sign}, true} -> - {_ts, msg} = SData.term_unbin msgbin - nick = SApp.Identity.get_nick pk - push(socket, "shout", %{ - name: nick, - pk16: Shard.Keys.pk_display(pk), - message: msg, - }) - end) - {:noreply, socket} - end - - def handle_info({:chat_recv, _chan, {pk, msgbin, _sign}}, socket) do - {_ts, msg} = SData.term_unbin msgbin - nick = SApp.Identity.get_nick pk - Logger.info("#{inspect self()} :chat_recv #{inspect msg}") - push socket, "shout", %{"name" => nick, - "pk16" => Shard.Keys.pk_display(pk), - "message" => msg} - {:noreply, socket} - end - - def handle_info({:chat_send, _, _}, socket) do - {:noreply, socket} - end - - # Channels can be used in a request/response fashion - # by sending replies to requests from the client - def handle_in("ping", payload, socket) do - {:reply, {:ok, payload}, socket} - end - - # It is also common to receive messages from the client and - # broadcast to everyone in the current topic (room:lobby). - def handle_in("shout", payload, socket) do - pk = socket.assigns.pk - nick = SApp.Identity.get_nick pk - payload = Map.put(payload, "name", nick) - payload = Map.put(payload, "pk16", Shard.Keys.pk_display pk) - - GenServer.cast(socket.assigns.pid, {:chat_send, pk, payload["message"]}) - broadcast socket, "shout", payload - {:noreply, socket} - end - - # Add authorization logic here as required. - defp authorized?(_payload) do - true - end -end diff --git a/shardweb/lib/shard_web/channels/user_socket.ex b/shardweb/lib/shard_web/channels/user_socket.ex deleted file mode 100644 index a3aa1a5..0000000 --- a/shardweb/lib/shard_web/channels/user_socket.ex +++ /dev/null @@ -1,49 +0,0 @@ -defmodule ShardWeb.UserSocket do - use Phoenix.Socket - - require Logger - - ## Channels - channel "room:*", ShardWeb.RoomChannel - - ## Transports - transport :websocket, Phoenix.Transports.WebSocket - # transport :longpoll, Phoenix.Transports.LongPoll - - # Socket params are passed from the client and can - # be used to verify and authenticate a user. After - # verification, you can put default assigns into - # the socket that will be set for all channels, ie - # - # {:ok, assign(socket, :user_id, verified_user_id)} - # - # To deny connection, return `:error`. - # - # See `Phoenix.Token` documentation for examples in - # performing token verification on connect. - def connect(params, socket) do - case Base.decode16(params["pk"]) do - {:ok, pk} -> - if Shard.Keys.have_sk? pk do - socket = assign(socket, :pk, pk) - {:ok, socket} - else - Logger.warn("Invalid pk at user_socket.connect... #{params["pk"]}") - :error - end - _ -> :error - end - end - - # Socket id's are topics that allow you to identify all sockets for a given user: - # - # def id(socket), do: "user_socket:#{socket.assigns.user_id}" - # - # Would allow you to broadcast a "disconnect" event and terminate - # all active sockets and channels for a given user: - # - # ShardWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{}) - # - # Returning `nil` makes this socket anonymous. - def id(_socket), do: nil -end diff --git a/shardweb/lib/shard_web/controllers/identity_controller.ex b/shardweb/lib/shard_web/controllers/identity_controller.ex deleted file mode 100644 index a4f54e7..0000000 --- a/shardweb/lib/shard_web/controllers/identity_controller.ex +++ /dev/null @@ -1,40 +0,0 @@ -defmodule ShardWeb.IdentityController do - use ShardWeb, :controller - - def view(conn, _params) do - render conn, "view.html" - end - - def update(conn, params) do - pid = SApp.Identity.find_proc(conn.assigns.pk) - info = GenServer.call(pid, :get_info) - info = %{info | nick: params["nick"]} - GenServer.call(pid, {:set_info, info}) - redirect conn, to: identity_path(conn, :view) - end - - def switch(conn, params) do - case Base.decode16(params["pk"]) do - {:ok, pk} -> - if Shard.Keys.have_sk? pk do - conn - |> put_session(:pk, pk) - |> redirect(to: identity_path(conn, :view)) - else - conn - |> put_flash(:error, "No secret key found") - |> render("view.html") - end - _ -> - conn - |> put_flash(:error, "Bad argument") - |> render("view.html") - end - end - - def create(conn, _params) do - pk = Shard.Keys.new_identity - conn = put_session(conn, :pk, pk) - redirect conn, to: identity_path(conn, :view) - end -end diff --git a/shardweb/lib/shard_web/controllers/page_controller.ex b/shardweb/lib/shard_web/controllers/page_controller.ex deleted file mode 100644 index 261b5d6..0000000 --- a/shardweb/lib/shard_web/controllers/page_controller.ex +++ /dev/null @@ -1,27 +0,0 @@ -defmodule ShardWeb.PageController do - use ShardWeb, :controller - - def index(conn, _params) do - render conn, "index.html" - end - - def add_peer(conn, _params) do - try do - ip = conn.params["ip"] - port = conn.params["port"] - {:ok, ip_tuple} = case :inet.parse_address(to_charlist(ip)) do - {:ok, tup} -> {:ok, tup} - _ -> - case :inet.gethostbyname(to_charlist(ip)) do - {:ok, {:hostent, _, _, :inet, 4, [ip_tup | _]}} -> {:ok, ip_tup} - _ -> :error - end - end - {port_num, _} = Integer.parse port - SNet.Manager.add_peer({:inet, ip_tuple, port_num}) - rescue - _ -> nil - end - redirect conn, to: page_path(conn, :index) - end -end diff --git a/shardweb/lib/shard_web/controllers/room_controller.ex b/shardweb/lib/shard_web/controllers/room_controller.ex deleted file mode 100644 index d24649b..0000000 --- a/shardweb/lib/shard_web/controllers/room_controller.ex +++ /dev/null @@ -1,9 +0,0 @@ -defmodule ShardWeb.RoomController do - use ShardWeb, :controller - - def show(conn, %{"room" => room}) do - conn = put_gon(conn, chat_room: room) - render conn, "show.html", - room: room - end -end diff --git a/shardweb/lib/shard_web/endpoint.ex b/shardweb/lib/shard_web/endpoint.ex deleted file mode 100644 index fb8a48f..0000000 --- a/shardweb/lib/shard_web/endpoint.ex +++ /dev/null @@ -1,59 +0,0 @@ -defmodule ShardWeb.Endpoint do - use Phoenix.Endpoint, otp_app: :shardweb - - socket "/socket", ShardWeb.UserSocket - - # Serve at "/" the static files from "priv/static" directory. - # - # You should set gzip to true if you are running phoenix.digest - # when deploying your static files in production. - plug Plug.Static, - at: "/", from: :shardweb, gzip: false, - only: ~w(css fonts font-awesome images js favicon.ico robots.txt) - - # Code reloading can be explicitly enabled under the - # :code_reloader configuration of your endpoint. - if code_reloading? do - socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket - plug Phoenix.LiveReloader - plug Phoenix.CodeReloader - end - - plug Plug.Logger - - plug Plug.Parsers, - parsers: [:urlencoded, :multipart, :json], - pass: ["*/*"], - json_decoder: Poison - - plug Plug.MethodOverride - plug Plug.Head - - # The session will be stored in the cookie and signed, - # this means its contents can be read but not tampered with. - # Set :encryption_salt if you would also like to encrypt it. - plug Plug.Session, - store: :cookie, - key: "_shardweb_key", - signing_salt: "BkoHycu8" - - - plug PhoenixGon.Pipeline - - plug ShardWeb.Router - - @doc """ - Callback invoked for dynamically configuring the endpoint. - - It receives the endpoint configuration and checks if - configuration should be loaded from the system environment. - """ - def init(_key, config) do - if config[:load_from_system_env] do - port = System.get_env("PORT") || raise "expected the PORT environment variable to be set" - {:ok, Keyword.put(config, :http, [:inet6, port: port])} - else - {:ok, config} - end - end -end diff --git a/shardweb/lib/shard_web/gettext.ex b/shardweb/lib/shard_web/gettext.ex deleted file mode 100644 index e74cd43..0000000 --- a/shardweb/lib/shard_web/gettext.ex +++ /dev/null @@ -1,24 +0,0 @@ -defmodule ShardWeb.Gettext do - @moduledoc """ - A module providing Internationalization with a gettext-based API. - - By using [Gettext](https://hexdocs.pm/gettext), - your module gains a set of macros for translations, for example: - - import ShardWeb.Gettext - - # Simple translation - gettext "Here is the string to translate" - - # Plural translation - ngettext "Here is the string to translate", - "Here are the strings to translate", - 3 - - # Domain-based translation - dgettext "errors", "Here is the error message to translate" - - See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage. - """ - use Gettext, otp_app: :shardweb -end diff --git a/shardweb/lib/shard_web/router.ex b/shardweb/lib/shard_web/router.ex deleted file mode 100644 index 4311a29..0000000 --- a/shardweb/lib/shard_web/router.ex +++ /dev/null @@ -1,53 +0,0 @@ -defmodule ShardWeb.Router do - use ShardWeb, :router - - pipeline :browser do - plug :accepts, ["html"] - plug :fetch_session - plug :fetch_flash - plug :protect_from_forgery - plug :put_secure_browser_headers - plug Plug.Parsers, parsers: [:urlencoded] - plug :check_pk - end - - pipeline :api do - plug :accepts, ["json"] - end - - scope "/", ShardWeb do - pipe_through :browser # Use the default browser stack - - get "/", PageController, :index - post "/peer/add", PageController, :add_peer - - get "/identity", IdentityController, :view - post "/identity", IdentityController, :update - post "/identity/switch", IdentityController, :switch - post "/identity/create", IdentityController, :create - - get "/room/:room", RoomController, :show - end - - # Other scopes may use custom stacks. - # scope "/api", ShardWeb do - # pipe_through :api - # end - - def check_pk(conn, _kv) do - pk1 = get_session(conn, :pk) - {conn, pk} = if pk1 == nil || not Shard.Keys.have_sk? pk1 do - pk = Shard.Keys.get_any_identity - conn = put_session(conn, :pk, pk) - {conn, pk} - else - {conn, pk1} - end - nick = SApp.Identity.get_nick pk - conn - |> assign(:pk, pk) - |> assign(:nick, nick) - |> PhoenixGon.Controller.put_gon(pk: (pk|>Base.encode16)) - end - -end diff --git a/shardweb/lib/shard_web/templates/identity/view.html.eex b/shardweb/lib/shard_web/templates/identity/view.html.eex deleted file mode 100644 index 5e57e02..0000000 --- a/shardweb/lib/shard_web/templates/identity/view.html.eex +++ /dev/null @@ -1,59 +0,0 @@ -<!-- Page Heading --> -<div class="row"> - <div class="col-lg-12"> - <h1 class="page-header"> - <%= @nick %> <small><%= @pk |> Base.encode16 %></small> - </h1> - <ol class="breadcrumb"> - <li> - <i class="fa fa-users"></i> My identities - </li> - <li class="active"> - <i class="fa fa-user"></i> <%= @nick %> - </li> - </ol> - </div> -</div> -<!-- /.row --> - -<%= render ShardWeb.LayoutView, "flashes.html", assigns %> - - -<%= form_for @conn, identity_path(@conn, :update), [class: "form-horizontal"], fn f -> %> - <div class="form-group"> - <label class="col-sm-2 control-label">Public key:</label> - <div class="col-sm-10"> - <input type="text" value="<%= @pk |> Base.encode16 %>" class="form-control" disabled /> - </div> - </div> - <div class="form-group"> - <%= label :nick, "Nickname:", class: ["col-sm-2 control-label"] %> - <div class="col-sm-10"> - <%= text_input f, :nick, [class: "form-control", value: @nick] %> - </div> - </div> - <div class="form-group"> - <div class="col-sm-offset-2 col-sm-10"> - <%= submit "Update", [class: "btn btn-default"] %> - </div> - </div> -<% end %> - -<h4>Other identities</h4> - -<ul> - <%= for pk2 <- identity_list(), pk2 != @pk do %> - <li> - <%= form_for @conn, identity_path(@conn, :switch), [class: "form-inline"], fn f -> %> - <%= hidden_input f, :pk, value: (pk2 |> Base.encode16) %> - <%= submit "Switch to", [class: "btn btn-xs btn-success"] %> - <strong><%= get_nick pk2 %></strong> - <small><%= pk2 |> Base.encode16 %></small> - <% end %> - </li> - <% end %> -</ul> - -<%= form_for @conn, identity_path(@conn, :create), [class: "form-inline"], fn _f -> %> - <%= submit "Create new identity", [class: "btn btn-danger"] %> -<% end %> diff --git a/shardweb/lib/shard_web/templates/layout/app.html.eex b/shardweb/lib/shard_web/templates/layout/app.html.eex deleted file mode 100644 index e0cb9dc..0000000 --- a/shardweb/lib/shard_web/templates/layout/app.html.eex +++ /dev/null @@ -1,224 +0,0 @@ -<!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>Shard.</title> - - <!-- Bootstrap Core CSS --> - <link href="<%= static_path(@conn, "/css/bootstrap.min.css") %>" rel="stylesheet"> - - <!-- Custom CSS --> - <link href="<%= static_path(@conn, "/css/sb-admin.css") %>" rel="stylesheet"> - - <!-- Morris Charts CSS --> - <link href="<%= static_path(@conn, "/css/plugins/morris.css") %>" rel="stylesheet"> - - <!-- Custom Fonts --> - <link href="<%= static_path(@conn, "/font-awesome/css/font-awesome.min.css") %>" rel="stylesheet" type="text/css"> - - <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> - <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> - <!--[if lt IE 9]> - <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> - <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> - <![endif]--> - - <link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>"> -</head> - -<body> - - <div id="wrapper"> - - <!-- Navigation --> - <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"> - <!-- Brand and toggle get grouped for better mobile display --> - <div class="navbar-header"> - <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"> - <span class="sr-only">Toggle navigation</span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - <span class="icon-bar"></span> - </button> - <a class="navbar-brand" href="<%= page_path(@conn, :index) %>">Shard</a> - </div> - <!-- Top Menu Items --> - <ul class="nav navbar-right top-nav"> - <li class="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-envelope"></i> <b class="caret"></b></a> - <ul class="dropdown-menu message-dropdown"> - <li class="message-preview"> - <a href="#"> - <div class="media"> - <span class="pull-left"> - <img class="media-object" src="http://placehold.it/50x50" alt=""> - </span> - <div class="media-body"> - <h5 class="media-heading"><strong>John Smith</strong> - </h5> - <p class="small text-muted"><i class="fa fa-clock-o"></i> Yesterday at 4:32 PM</p> - <p>Lorem ipsum dolor sit amet, consectetur...</p> - </div> - </div> - </a> - </li> - <li class="message-preview"> - <a href="#"> - <div class="media"> - <span class="pull-left"> - <img class="media-object" src="http://placehold.it/50x50" alt=""> - </span> - <div class="media-body"> - <h5 class="media-heading"><strong>John Smith</strong> - </h5> - <p class="small text-muted"><i class="fa fa-clock-o"></i> Yesterday at 4:32 PM</p> - <p>Lorem ipsum dolor sit amet, consectetur...</p> - </div> - </div> - </a> - </li> - <li class="message-preview"> - <a href="#"> - <div class="media"> - <span class="pull-left"> - <img class="media-object" src="http://placehold.it/50x50" alt=""> - </span> - <div class="media-body"> - <h5 class="media-heading"><strong>John Smith</strong> - </h5> - <p class="small text-muted"><i class="fa fa-clock-o"></i> Yesterday at 4:32 PM</p> - <p>Lorem ipsum dolor sit amet, consectetur...</p> - </div> - </div> - </a> - </li> - <li class="message-footer"> - <a href="#">Read All New Messages</a> - </li> - </ul> - </li> - <li class="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-bell"></i> <b class="caret"></b></a> - <ul class="dropdown-menu alert-dropdown"> - <li> - <a href="#">Alert Name <span class="label label-default">Alert Badge</span></a> - </li> - <li> - <a href="#">Alert Name <span class="label label-primary">Alert Badge</span></a> - </li> - <li> - <a href="#">Alert Name <span class="label label-success">Alert Badge</span></a> - </li> - <li> - <a href="#">Alert Name <span class="label label-info">Alert Badge</span></a> - </li> - <li> - <a href="#">Alert Name <span class="label label-warning">Alert Badge</span></a> - </li> - <li> - <a href="#">Alert Name <span class="label label-danger">Alert Badge</span></a> - </li> - <li class="divider"></li> - <li> - <a href="#">View All</a> - </li> - </ul> - </li> - <li class="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> <%= @nick %> <b class="caret"></b></a> - <ul class="dropdown-menu"> - <li> - <a href="<%= identity_path(@conn, :view) %>"><i class="fa fa-fw fa-user"></i> Profile</a> - </li> - <li class="divider"></li> - <li> - <a href="#"><i class="fa fa-fw fa-envelope"></i> Inbox</a> - </li> - <li> - <a href="#"><i class="fa fa-fw fa-gear"></i> Settings</a> - </li> - <li> - <a href="#"><i class="fa fa-fw fa-power-off"></i> Log Out</a> - </li> - </ul> - </li> - </ul> - <!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens --> - <div class="collapse navbar-collapse navbar-ex1-collapse"> - <ul class="nav navbar-nav side-nav"> - <li class="<%= if @view_module == ShardWeb.IdentityView do "active" else "" end %>"> - <a href="<%= identity_path(@conn, :view) %>"><i class="fa fa-fw fa-user"></i> <%= @nick %></a> - </li> - <li class="<%= if @view_module == ShardWeb.RoomView do "active" else "" end %>"> - <a href="javascript:;" data-toggle="collapse" data-target="#demo"><i class="fa fa-fw fa-comments"></i> Chat rooms <i class="fa fa-fw fa-caret-down"></i></a> - <ul id="demo" class="<%= if @view_module != ShardWeb.RoomView do "collapse" else "" end %>"> - - - <%= for {_, %SApp.Chat.Manifest{channel: name}, _} <- shard_list() do %> - <li class="<%= if @view_module == ShardWeb.RoomView and @room == name do "custom_active" else "" end %>"> - <a href="<%= room_path(@conn, :show, name) %>">#<%= name %></a> - </li> - <% end %> - <li> - <a href="#" onclick="if(new_room=prompt('Enter name of room to join, without preceding # sign:'))window.location.href='/room/'+new_room;">Join room</a> - </li> - - - </ul> - </li> - <li class="<%= if @view_module == ShardWeb.PageView and @view_template == "index.html" do "active" else "" end %>"> - <a href="<%= page_path(@conn, :index) %>"><i class="fa fa-fw fa-globe"></i> Peer list</a> - </li> - <li> - <a href="#"><i class="fa fa-fw fa-gear"></i> Settings</a> - </li> - <li> - <a href="#"><i class="fa fa-fw fa-dashboard"></i> Dashboard</a> - </li> - </ul> - </div> - <!-- /.navbar-collapse --> - </nav> - - <div id="page-wrapper"> - - <div class="container-fluid"> - - - - <%= render @view_module, @view_template, assigns %> - - </div> - <!-- /.container-fluid --> - - </div> - <!-- /#page-wrapper --> - - </div> - <!-- /#wrapper --> - - <!-- jQuery --> - <script src="<%= static_path(@conn, "/js/jquery.js") %>"></script> - - <!-- Bootstrap Core JavaScript --> - <script src="<%= static_path(@conn, "/js/bootstrap.min.js") %>"></script> - - <!-- Morris Charts JavaScript --> - <script src="<%= static_path(@conn, "/js/plugins/morris/raphael.min.js") %>"></script> - <script src="<%= static_path(@conn, "/js/plugins/morris/morris.min.js") %>"></script> - <script src="<%= static_path(@conn, "/js/plugins/morris/morris-data.js") %>"></script> - - <%= render_gon_script(@conn) %> - <script src="<%= static_path(@conn, "/js/app.js") %>"></script> - -</body> - -</html> - diff --git a/shardweb/lib/shard_web/templates/layout/flashes.html.eex b/shardweb/lib/shard_web/templates/layout/flashes.html.eex deleted file mode 100644 index 5371f43..0000000 --- a/shardweb/lib/shard_web/templates/layout/flashes.html.eex +++ /dev/null @@ -1,24 +0,0 @@ - - <%= if get_flash(@conn, :info) do %> - <div class="row"> - <div class="col-lg-12"> - <div class="alert alert-info alert-dismissable"> - <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> - <i class="fa fa-info-circle"></i> <%= get_flash(@conn, :info) %> - </div> - </div> - </div> - <% end %> - <!-- /.row --> - - <%= if get_flash(@conn, :error) do %> - <div class="row"> - <div class="col-lg-12"> - <div class="alert alert-warning alert-dismissable"> - <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> - <i class="fa fa-info-circle"></i> <%= get_flash(@conn, :error) %> - </div> - </div> - </div> - <% end %> - <!-- /.row --> diff --git a/shardweb/lib/shard_web/templates/page/index.html.eex b/shardweb/lib/shard_web/templates/page/index.html.eex deleted file mode 100644 index f385528..0000000 --- a/shardweb/lib/shard_web/templates/page/index.html.eex +++ /dev/null @@ -1,47 +0,0 @@ -<!-- Page Heading --> -<div class="row"> - <div class="col-lg-12"> - <h1 class="page-header"> - Peer list - - </h1> - <ol class="breadcrumb"> - <li> - <i class="fa fa-dashboard"></i> Dashboard - </li> - <li class="active"> - <i class="fa fa-globe"></i> Peer list - </li> - </ol> - </div> -</div> -<!-- /.row --> - -<%= render ShardWeb.LayoutView, "flashes.html", assigns %> - -<table class="table table-striped"> - <tr> - <th>Peer ID</th> - <th>Address</th> - <th>Port</th> - </tr> - <%= for {{:inet, ip, port}, _pid, auth} <- conn_list() do %> - <tr> - <td> - <%= case auth do %> - <% nil -> %>(anonymous) - <% %SNet.Auth{his_pk: his_pk} -> %> <%= Shard.Keys.pk_display(his_pk) %> - <% end %> - </td> - <td><%= :inet_parse.ntoa(ip) %></td> - <td><%= port %></td> - </tr> - <% end %> -</table> - -<%= form_for @conn, page_path(@conn, :add_peer), [class: "form-inline"], fn f -> %> - <%= text_input f, :ip, [class: "form-control", placeholder: "Hostname / IP address"] %> - <%= text_input f, :port, [class: "form-control", placeholder: "Port", value: "4044"] %> - <%= submit "Add peer", [class: "btn btn-default"] %> -<% end %> - diff --git a/shardweb/lib/shard_web/templates/room/show.html.eex b/shardweb/lib/shard_web/templates/room/show.html.eex deleted file mode 100644 index 75960b4..0000000 --- a/shardweb/lib/shard_web/templates/room/show.html.eex +++ /dev/null @@ -1,36 +0,0 @@ -<!-- Page Heading --> -<div class="row"> - <div class="col-lg-12"> - <h1 class="page-header"> - #<%= @room %> - - </h1> - <ol class="breadcrumb"> - <li> - <i class="fa fa-comments"></i> Chat rooms - </li> - <li class="active"> - <i class="fa fa-comments"></i> #<%= @room %> - </li> - </ol> - </div> -</div> -<!-- /.row --> - -<%= render ShardWeb.LayoutView, "flashes.html", assigns %> - - - -<!-- The list of messages will appear here: --> -<ul id='msg-list' class='row' style='list-style: none; min-height:400px; padding: 10px; max-height: 400px; overflow: scroll'></ul> - -<div class="form-horizontal"> - <div class="form-group"> - <div class="col-sm-2 control-label"> - <strong><<%= @nick %>></strong> - </div> - <div class="col-sm-10"> - <input type="text" id="msg" class="form-control" placeholder="Your Message" autofocus> - </div> - </div> -</div> diff --git a/shardweb/lib/shard_web/views/error_helpers.ex b/shardweb/lib/shard_web/views/error_helpers.ex deleted file mode 100644 index f476548..0000000 --- a/shardweb/lib/shard_web/views/error_helpers.ex +++ /dev/null @@ -1,44 +0,0 @@ -defmodule ShardWeb.ErrorHelpers do - @moduledoc """ - Conveniences for translating and building error messages. - """ - - use Phoenix.HTML - - @doc """ - Generates tag for inlined form input errors. - """ - def error_tag(form, field) do - Enum.map(Keyword.get_values(form.errors, field), fn (error) -> - content_tag :span, translate_error(error), class: "help-block" - end) - end - - @doc """ - Translates an error message using gettext. - """ - def translate_error({msg, opts}) do - # When using gettext, we typically pass the strings we want - # to translate as a static argument: - # - # # Translate "is invalid" in the "errors" domain - # dgettext "errors", "is invalid" - # - # # Translate the number of files with plural rules - # dngettext "errors", "1 file", "%{count} files", count - # - # Because the error messages we show in our forms and APIs - # are defined inside Ecto, we need to translate them dynamically. - # This requires us to call the Gettext module passing our gettext - # backend as first argument. - # - # Note we use the "errors" domain, which means translations - # should be written to the errors.po file. The :count option is - # set by Ecto and indicates we should also apply plural rules. - if count = opts[:count] do - Gettext.dngettext(ShardWeb.Gettext, "errors", msg, msg, count, opts) - else - Gettext.dgettext(ShardWeb.Gettext, "errors", msg, opts) - end - end -end diff --git a/shardweb/lib/shard_web/views/error_view.ex b/shardweb/lib/shard_web/views/error_view.ex deleted file mode 100644 index a4b6eed..0000000 --- a/shardweb/lib/shard_web/views/error_view.ex +++ /dev/null @@ -1,16 +0,0 @@ -defmodule ShardWeb.ErrorView do - use ShardWeb, :view - - # If you want to customize a particular status code - # for a certain format, you may uncomment below. - # def render("500.html", _assigns) do - # "Internal Server Error" - # end - - # By default, Phoenix returns the status message from - # the template name. For example, "404.html" becomes - # "Not Found". - def template_not_found(template, _assigns) do - Phoenix.Controller.status_message_from_template(template) - end -end diff --git a/shardweb/lib/shard_web/views/identity_view.ex b/shardweb/lib/shard_web/views/identity_view.ex deleted file mode 100644 index 63d5a50..0000000 --- a/shardweb/lib/shard_web/views/identity_view.ex +++ /dev/null @@ -1,11 +0,0 @@ -defmodule ShardWeb.IdentityView do - use ShardWeb, :view - - def identity_list do - Shard.Keys.list_identities - end - - def get_nick(pk) do - SApp.Identity.get_nick pk - end -end diff --git a/shardweb/lib/shard_web/views/layout_view.ex b/shardweb/lib/shard_web/views/layout_view.ex deleted file mode 100644 index 2b12323..0000000 --- a/shardweb/lib/shard_web/views/layout_view.ex +++ /dev/null @@ -1,7 +0,0 @@ -defmodule ShardWeb.LayoutView do - use ShardWeb, :view - - def shard_list do - Shard.Manager.list_shards - end -end diff --git a/shardweb/lib/shard_web/views/page_view.ex b/shardweb/lib/shard_web/views/page_view.ex deleted file mode 100644 index 6bd8e4b..0000000 --- a/shardweb/lib/shard_web/views/page_view.ex +++ /dev/null @@ -1,14 +0,0 @@ -defmodule ShardWeb.PageView do - use ShardWeb, :view - - def conn_list do - SNet.Manager.list_connections - end - - def peer_id_to_str(id) do - id - |> binary_part(0, 8) - |> Base.encode16 - |> String.downcase - end -end diff --git a/shardweb/lib/shard_web/views/room_view.ex b/shardweb/lib/shard_web/views/room_view.ex deleted file mode 100644 index ebc2a60..0000000 --- a/shardweb/lib/shard_web/views/room_view.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule ShardWeb.RoomView do - use ShardWeb, :view -end |