diff options
author | Alex Auvolat <alex@adnab.me> | 2018-10-12 15:52:42 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2018-10-12 15:52:42 +0200 |
commit | 0d358f6f699a5ce04ffe1bccf4f375b5f321391c (patch) | |
tree | b90a1093b3ac0cd1e7d3643abb34e87078b6072e /shardweb/lib/templates | |
parent | 1e91dc596fd2f7fdd96b7fd2fc50724f93e46529 (diff) | |
download | shard-0d358f6f699a5ce04ffe1bccf4f375b5f321391c.tar.gz shard-0d358f6f699a5ce04ffe1bccf4f375b5f321391c.zip |
Private chat interface
Diffstat (limited to 'shardweb/lib/templates')
-rw-r--r-- | shardweb/lib/templates/chat/chat.html.eex | 31 | ||||
-rw-r--r-- | shardweb/lib/templates/identity/list.html.eex | 12 | ||||
-rw-r--r-- | shardweb/lib/templates/layout/app.html.eex | 27 | ||||
-rw-r--r-- | shardweb/lib/templates/page/shard_list.html.eex | 17 |
4 files changed, 66 insertions, 21 deletions
diff --git a/shardweb/lib/templates/chat/chat.html.eex b/shardweb/lib/templates/chat/chat.html.eex index 86c2fb6..8a43acf 100644 --- a/shardweb/lib/templates/chat/chat.html.eex +++ b/shardweb/lib/templates/chat/chat.html.eex @@ -2,17 +2,32 @@ <div class="row"> <div class="col-lg-12"> <h1 class="page-header"> - #<%= @room %> - <small>public chat room</small> + <%= if @public do %> + #<%= @chan %> + <small>public chat room</small> + <% else %> + #<%= @nicks %> + <small>private chat</small> + <% end %> </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> + + <%= if @public do %> + <li> + <i class="fa fa-comments"></i> Chat rooms + </li> + <li class="active"> + <i class="fa fa-comments"></i> #<%= @chan %> + </li> + <% else %> + <li> + <i class="fa fa-user"></i> Private chat + </li> + <li class="active"> + <i class="fa fa-comments"></i> <%= @nicks %> + </li> + <% end %> </ol> </div> </div> diff --git a/shardweb/lib/templates/identity/list.html.eex b/shardweb/lib/templates/identity/list.html.eex index 1354264..007af3d 100644 --- a/shardweb/lib/templates/identity/list.html.eex +++ b/shardweb/lib/templates/identity/list.html.eex @@ -20,11 +20,21 @@ <table class="table table-striped"> <tr> <th>User name</th> + <th></th> <th>Public key</th> </tr> <%= for {_id, manifest, pid} <- people_list() do %> <tr> - <td><i class="fa fa-user"></i> <%= GenServer.call(pid, :get_info).nick %> </td> + <td><i class="fa fa-user"></i> <%= GenServer.call(pid, :get_info).nick %> + <%= if manifest.pk == @pk do %> + <span class="badge badge-success"><i class="fa fa-user"></i> myself</span> + <% end %> + </td> + <td> + <%= if manifest.pk != @pk do %> + <a class="btn btn-xs btn-primary" href="<%= chat_path(@conn, :privchat, manifest.pk |> Base.encode16) %>"><i class="fa fa-comments"></i> PM</a> + <% end %> + </td> <td><small><%= manifest.pk |> Base.encode16 %></small></td> </tr> <% end %> diff --git a/shardweb/lib/templates/layout/app.html.eex b/shardweb/lib/templates/layout/app.html.eex index 5a087f2..f49c8e6 100644 --- a/shardweb/lib/templates/layout/app.html.eex +++ b/shardweb/lib/templates/layout/app.html.eex @@ -153,28 +153,37 @@ <!-- 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 %>"> + <li class="<%= if @view_module == ShardWeb.IdentityView and @view_template == "self.html" do "active" else "" end %>"> <a href="<%= identity_path(@conn, :self) %>"><i class="fa fa-fw fa-user"></i> <%= @nick %></a> </li> - <li class="<%= if @view_module == ShardWeb.RoomView do "active" else "" end %>"> + <li class="<%= if @view_module == ShardWeb.ChatView and @view_template == "chat.html" and @public 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 %>"> + <ul id="demo" class="<%= if not (@view_module == ShardWeb.ChatView and @view_template == "chat.html" and @public) 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 %>"> + <%= for {id, %SApp.Chat.Manifest{channel: name}, _} <- shard_list() do %> + <li class="<%= if @shard == id do "custom_active" else "" end %>"> <a href="<%= chat_path(@conn, :chat, 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> + <a href="#" onclick="if(new_room=prompt('Enter name of room to join, without preceding # sign:'))window.location.href='<%= chat_path(@conn, :chat, "") %>'+new_room;">Join room</a> </li> </ul> </li> - <li> - <a href="<%= identity_path(@conn, :list) %>"><i class="fa fa-fw fa-users"></i> People</a> + <li class="<%= if (@view_module == ShardWeb.IdentityView and @view_template == "list.html") or (@view_module == ShardWeb.ChatView and @view_template == "chat.html" and not @public) do "active" else "" end %>"> + <a href="<%= identity_path(@conn, :list) %>"><i class="fa fa-fw fa-users"></i> People<i class="fa fa-fw fa-caret-down"></i></a> + <%= if (@view_module == ShardWeb.IdentityView and @view_template == "list.html") or (@view_module == ShardWeb.ChatView and @view_template == "chat.html" and not @public) do %> + <ul> + <%= for {id, %SApp.Chat.PrivChat.Manifest{pk_list: pk_list}, _} <- shard_list() do %> + <li class="<%= if id == @shard do "custom_active" else "" end %>"> + <a href="<%= chat_path(@conn, :privchat, str_of_pk_list(@conn, pk_list)) %>"><%= nicks_of_pk_list(@conn, pk_list) %></a> + </li> + <% end %> + </ul> + <% end %> </li> <li class="<%= if @view_module == ShardWeb.PageView and @view_template == "peer_list.html" do "active" else "" end %>"> <a href="<%= page_path(@conn, :peer_list) %>"><i class="fa fa-fw fa-globe"></i> Peer list</a> @@ -182,7 +191,7 @@ <li> <a href="#"><i class="fa fa-fw fa-gear"></i> Settings</a> </li> - <li> + <li class="<%= if @view_module == ShardWeb.PageView and @view_template == "shard_list.html" do "active" else "" end %>"> <a href="<%= page_path(@conn, :shard_list) %>"><i class="fa fa-fw fa-dashboard"></i> Dashboard</a> </li> </ul> diff --git a/shardweb/lib/templates/page/shard_list.html.eex b/shardweb/lib/templates/page/shard_list.html.eex index a0648d3..485bfa1 100644 --- a/shardweb/lib/templates/page/shard_list.html.eex +++ b/shardweb/lib/templates/page/shard_list.html.eex @@ -31,10 +31,21 @@ <%= case manifest do %> <% %SApp.Identity.Manifest{pk: pk} -> %><i class="fa fa-user"></i> <%= GenServer.call(pid, :get_info).nick %> - <small><%= Shard.Keys.pk_display pk %></small> - <% %SApp.Chat.Manifest{channel: chan} -> %><i class="fa fa-comments"></i> #<%= chan %> + <a href="<%= identity_path(@conn, :view, pk|>Base.encode16) %>"> + <small><%= Shard.Keys.pk_display pk %></small> + </a> + + <% %SApp.Chat.Manifest{channel: chan} -> %><i class="fa fa-comments"></i> + <a href="<%= chat_path(@conn, :chat, chan) %>"> + #<%= chan %> + </a> + <% %SApp.Chat.PrivChat.Manifest{pk_list: pk_list} -> %><i class="fa fa-comment"></i> - <%= pk_list |> Enum.map(&SApp.Identity.get_nick/1) |> Enum.join(", ") %> + <a href="<%= chat_path(@conn, :privchat, + (pk_list |> Enum.filter(&(&1!=@pk)) |> Enum.map(&Base.encode16/1) |> Enum.join(","))) %>"> + @<%= pk_list |> Enum.filter(&(&1!=@pk)) |> Enum.map(&SApp.Identity.get_nick/1) |> Enum.join(", ") %> + </a> + <% x -> %> <%= inspect x %> <% end %> </td> |