aboutsummaryrefslogtreecommitdiff
path: root/shardweb/lib/shard_web/controllers
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2018-10-12 14:40:21 +0200
committerAlex Auvolat <alex@adnab.me>2018-10-12 14:40:21 +0200
commit1e91dc596fd2f7fdd96b7fd2fc50724f93e46529 (patch)
tree067d56e6fb9e215cc76dea5c9c82e61ef369d90e /shardweb/lib/shard_web/controllers
parentd15d5fbfc5133a9d0f0d99dbbfc023849f61cc37 (diff)
downloadshard-1e91dc596fd2f7fdd96b7fd2fc50724f93e46529.tar.gz
shard-1e91dc596fd2f7fdd96b7fd2fc50724f93e46529.zip
Move and reorganize some stuff
Diffstat (limited to 'shardweb/lib/shard_web/controllers')
-rw-r--r--shardweb/lib/shard_web/controllers/identity_controller.ex40
-rw-r--r--shardweb/lib/shard_web/controllers/page_controller.ex27
-rw-r--r--shardweb/lib/shard_web/controllers/room_controller.ex9
3 files changed, 0 insertions, 76 deletions
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