-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
272 additions
and
230 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 10 additions & 3 deletions
13
lib/asciinema_web/controllers/api/live_stream_controller.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/asciinema_web/trailing_format.ex → lib/asciinema_web/plug/trailing_format.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
defmodule AsciinemaWeb.UrlHelpers do | ||
use Phoenix.VerifiedRoutes, | ||
endpoint: AsciinemaWeb.Endpoint, | ||
router: AsciinemaWeb.Router | ||
|
||
alias AsciinemaWeb.Endpoint | ||
|
||
def profile_path(_conn, user), do: profile_path(user) | ||
|
||
def profile_path(%Plug.Conn{} = conn), do: profile_path(conn.assigns.current_user) | ||
|
||
def profile_path(%{id: id, username: username}) do | ||
if username do | ||
~p"/~#{username}" | ||
else | ||
~p"/u/#{id}" | ||
end | ||
end | ||
|
||
def profile_url(user) do | ||
Endpoint.url() <> profile_path(user) | ||
end | ||
|
||
def asciicast_file_path(asciicast) do | ||
~p"/a/#{asciicast}" <> "." <> ext(asciicast) | ||
end | ||
|
||
def asciicast_file_url(asciicast) do | ||
url(~p"/a/#{asciicast}") <> "." <> ext(asciicast) | ||
end | ||
|
||
defp ext(asciicast) do | ||
case asciicast.version do | ||
1 -> "json" | ||
2 -> "cast" | ||
end | ||
end | ||
|
||
@http_to_ws %{"http" => "ws", "https" => "wss"} | ||
|
||
def ws_producer_url(stream) do | ||
uri = Endpoint.struct_url() | ||
scheme = @http_to_ws[uri.scheme] | ||
path = "/ws/S/#{stream.producer_token}" | ||
|
||
to_string(%{uri | scheme: scheme, path: path}) | ||
end | ||
|
||
def ws_public_url(stream) do | ||
uri = Endpoint.struct_url() | ||
scheme = @http_to_ws[uri.scheme] | ||
param = Phoenix.Param.to_param(stream) | ||
path = "/ws/s/#{param}" | ||
|
||
to_string(%{uri | scheme: scheme, path: path}) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.