aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shard/lib/cli/cli.ex19
-rw-r--r--shardweb/assets/js/app.js6
-rw-r--r--shardweb/lib/controllers/directory_controller.ex4
-rw-r--r--shardweb/lib/templates/identity/view.html.eex4
-rw-r--r--shardweb/mix.exs3
5 files changed, 28 insertions, 8 deletions
diff --git a/shard/lib/cli/cli.ex b/shard/lib/cli/cli.ex
index d454a0b..380282d 100644
--- a/shard/lib/cli/cli.ex
+++ b/shard/lib/cli/cli.ex
@@ -170,6 +170,25 @@ defmodule SCLI do
state
end
+ defp handle_command(state, ["send_file", path]) do
+ {mime_type, 0} = System.cmd("file", ["-b", "--mime-type", path])
+ mime_type = String.trim mime_type
+ IO.puts("Guessed mime type: #{mime_type}")
+ handle_command(state, ["send_file", path, mime_type])
+ end
+
+ defp handle_command(state, ["send_file", path, mime_type]) do
+ if state.room_pid != nil do
+ {:ok, m, _} = SApp.File.create(path, mime_type)
+ uri = ShardURI.from_manifest(m)
+ IO.puts("sending URI: #{uri}")
+ SApp.Chat.chat_send(state.room_pid, state.pk, uri)
+ else
+ IO.puts("Not in a chat room!")
+ end
+ state
+ end
+
defp handle_command(state, _cmd) do
IO.puts "Invalid command"
state
diff --git a/shardweb/assets/js/app.js b/shardweb/assets/js/app.js
index 1e5ea62..f3372f1 100644
--- a/shardweb/assets/js/app.js
+++ b/shardweb/assets/js/app.js
@@ -20,7 +20,9 @@ import "phoenix_html"
import socket from "./socket"
-import routes from './phoenix-jsroutes'
+function parse_links(msg) {
+ return msg.replace(/shard:file:([0-9A-F]{64})/gi, '<a href="/raw/$1">$&</a>');
+}
var chat_channel = window.Gon.getAsset('chat_channel');
if (chat_channel != undefined)
@@ -30,7 +32,7 @@ if (chat_channel != undefined)
channel.on('shout', function (payload) { // listen to the 'shout' event
var li = document.createElement("li"); // creaet new list item DOM element
var name = payload.name || 'guest'; // get name from payload or set default
- li.innerHTML = '<b>&lt;' + name + '</b> <a href="' + routes.identityView(payload.fullpk) + '"><small>' + payload.pk16 + '</small></a><b>&gt;</b> ' + payload.message; // set li contents
+ li.innerHTML = '<b>&lt;' + name + '</b> <a href="/people/' + payload.fullpk + '"><small>' + payload.pk16 + '</small></a><b>&gt;</b> ' + parse_links(payload.message); // set li contents
// console.log(ul.scrollTop + ' ' + ul.scrollHeight + ' ' + ul.clientHeight);
var must_scroll = (ul.scrollTop >= ul.scrollHeight - ul.clientHeight - 10);
diff --git a/shardweb/lib/controllers/directory_controller.ex b/shardweb/lib/controllers/directory_controller.ex
index ad5c426..d1b7136 100644
--- a/shardweb/lib/controllers/directory_controller.ex
+++ b/shardweb/lib/controllers/directory_controller.ex
@@ -84,12 +84,12 @@ defmodule ShardWeb.DirectoryController do
info = SApp.File.get_info(pid)
if info[:missing_blocks] == 0 do
conn
- |> put_resp_content_type(info[:mime_type])
+ |> put_resp_content_type(String.trim(info[:mime_type]))
|> send_file(200, info[:path])
else
conn
|> put_status(:not_found)
- |> text("File not found or not yet completely downloaded.\n#{inspect(info)}")
+ |> text("File not found or not yet completely downloaded. Come back later!\n#{inspect(info)}")
end
end
end
diff --git a/shardweb/lib/templates/identity/view.html.eex b/shardweb/lib/templates/identity/view.html.eex
index c81caf6..cc58ed5 100644
--- a/shardweb/lib/templates/identity/view.html.eex
+++ b/shardweb/lib/templates/identity/view.html.eex
@@ -20,10 +20,10 @@
<%= render ShardWeb.LayoutView, "flashes.html", assigns %>
<%= if @view_pk != @pk do %>
- <a class="btn btn-s btn-primary" href="<%= chat_path(@conn, :privchat, @pk |> Base.encode16) %>"><i class="fa fa-comments"></i> PM</a>
+ <a class="btn btn-s btn-primary" href="<%= chat_path(@conn, :privchat, @view_pk |> Base.encode16) %>"><i class="fa fa-comments"></i> PM</a>
<% end %>
- <a class="btn btn-s btn-success" href="<%= directory_path(@conn, :view_pub, @pk |> Base.encode16, "collection") %>"><i class="fa fa-folder"></i> Public stuff</a>
+ <a class="btn btn-s btn-success" href="<%= directory_path(@conn, :view_pub, @view_pk |> Base.encode16, "collection") %>"><i class="fa fa-folder"></i> Public stuff</a>
<pre>
<%= inspect(SApp.Identity.get_info(@pid), pretty: true, width: 40) %>
diff --git a/shardweb/mix.exs b/shardweb/mix.exs
index 90fc530..3b6ccb7 100644
--- a/shardweb/mix.exs
+++ b/shardweb/mix.exs
@@ -7,7 +7,7 @@ defmodule ShardWeb.Mixfile do
version: "0.0.1",
elixir: "~> 1.4",
elixirc_paths: elixirc_paths(Mix.env),
- compilers: [:phoenix, :gettext] ++ Mix.compilers ++ [:jsroutes],
+ compilers: [:phoenix, :gettext] ++ Mix.compilers,
start_permanent: Mix.env == :prod,
deps: deps()
]
@@ -36,7 +36,6 @@ defmodule ShardWeb.Mixfile do
{:phoenix_pubsub, "~> 1.0"},
{:phoenix_html, "~> 2.10"},
{:phoenix_live_reload, "~> 1.0", only: :dev},
- {:phoenix_jsroutes, "~> 0.0.4"},
{:gettext, "~> 0.11"},
{:cowboy, "~> 1.0"},
{:phoenix_gon, "~> 0.4.0"},