Skip to content

Commit

Permalink
Show streaming instructions on new user's profile
Browse files Browse the repository at this point in the history
  • Loading branch information
ku1ik committed May 9, 2024
1 parent 244f896 commit 83131bb
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 35 deletions.
92 changes: 58 additions & 34 deletions lib/asciinema_web/controllers/user/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -70,53 +70,77 @@
</div>
<% else %>
<%= if @user_is_self do %>
<h2>Record your first session</h2>
<div class="row">
<div class={"col-md-#{if @default_stream, do: 6, else: 12}"}>
<h2>Recording &amp; publishing</h2>

<p>
First, <a href="https://docs.asciinema.org/manual/cli/installation/">install
the asciinema CLI</a>.
</p>
<p>
First, <a href="https://docs.asciinema.org/manual/cli/installation/">install
the asciinema CLI</a>.
</p>

<p>Then, recording your terminal with:</p>
<p>Then, recording your terminal with:</p>

<pre><code>asciinema rec demo.cast</code></pre>
<pre><code>asciinema rec demo.cast</code></pre>

<p>
This starts a new recording session, where everything printed to
a terminal gets captured and saved to the demo.cast file in
<a href="https://docs.asciinema.org/manual/asciicast/v2/">asciicast</a>
format.
</p>
<p>
This starts a new recording session, where everything printed to
a terminal gets captured and saved to the demo.cast file in
<a href="https://docs.asciinema.org/manual/asciicast/v2/">asciicast</a>
format.
</p>

<p>To end the recording session, just exit the shell. This can be
done by pressing <kbd>ctrl+d</kbd> or entering <code>exit</code>.</p>
<p>To end the recording session, just exit the shell. This can be
done by pressing <kbd>ctrl+d</kbd> or entering <code>exit</code>.</p>

<p>Replay your recording with:</p>
<p>Replay your recording with:</p>

<pre><code>asciinema play demo.cast</code></pre>
<pre><code>asciinema play demo.cast</code></pre>

<p>You can pause/resume by pressing <kbd>space</kbd>, or end the
playback early by pressing <kbd>ctrl+c</kbd>.</p>
<p>You can pause/resume by pressing <kbd>space</kbd>, or end the
playback early by pressing <kbd>ctrl+c</kbd>.</p>

<p>Upload your recording with:</p>
<p>Upload your recording with:</p>

<pre><code>asciinema upload demo.cast</code></pre>
<pre><code>asciinema upload demo.cast</code></pre>

<p>The command prints a secret link to the recording page, where you
can view it. Feel free to share the link with anyone.</p>
<p>The command prints a secret link to the recording page, where it
can be viewed. Feel free to share this link with anyone.</p>

<p>
If you've already uploaded a recording and you don't see it here,
then associate it with your account by running
<a href="https://docs.asciinema.org/manual/cli/usage/#asciinema-auth">
<code>asciinema
auth</code>
</a>
in your terminal.
</p>
<p>
If you've already uploaded a recording and you don't see it here,
then associate it with your account by running
<a href="https://docs.asciinema.org/manual/cli/usage/#asciinema-auth">
<code>asciinema
auth</code>
</a>
in your terminal.
</p>

<p>See <a href="https://docs.asciinema.org/manual/cli/quick-start/">asciinema
CLI quick-start guide</a> for more examples.</p>
<p>See <a href="https://docs.asciinema.org/manual/cli/quick-start/">asciinema
CLI quick-start guide</a> for more examples.</p>
</div>

<%= if @default_stream do %>
<div class="col-md-6">
<h2>Live streaming</h2>

<p>
Live terminal streaming is a feature of the <a href="https://github.com/asciinema/asciinema/releases/tag/v3.0.0-rc.1">upcoming
asciinema CLI 3.0</a>.
</p>

<p>To start the live streaming session and expose it via <%= @conn.host %>, run:</p>

<pre><code>asciinema stream -r</code></pre>

<p>
View your live stream <a href={~p"/s/#{@default_stream}"}>here</a>. You can always access
it from the user drop-down menu in the top navigation bar.
</p>
</div>
<% end %>
</div>
<% else %>
<h2><%= username(@user) %> has no public recordings</h2>
<% end %>
Expand Down
4 changes: 3 additions & 1 deletion test/support/conn_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ defmodule AsciinemaWeb.ConnCase do
end

def log_in(conn, user) do
assign(conn, :current_user, user)
conn
|> assign(:current_user, user)
|> assign(:default_stream, nil)
end
end
end
Expand Down

0 comments on commit 83131bb

Please sign in to comment.