Asciicasts#show (available at /:id)
parent
99a47393ab
commit
140cc1c0fc
@ -1,2 +1,25 @@
|
|||||||
module AsciicastsHelper
|
module AsciicastsHelper
|
||||||
|
|
||||||
|
def player_data(asciicast)
|
||||||
|
data = File.read(asciicast.stdout.path).split("\n", 2)[1]
|
||||||
|
time = File.read(asciicast.stdout_timing.path)
|
||||||
|
|
||||||
|
data_hex_array = data.bytes.map { |b| '\x' + format('%02x', b) }
|
||||||
|
var_data = "'#{data_hex_array.join}'"
|
||||||
|
|
||||||
|
time_lines = time.lines.map do |line|
|
||||||
|
delay, n = line.split
|
||||||
|
"[#{delay.to_f}, #{n.to_i}]"
|
||||||
|
end
|
||||||
|
var_time = "[#{time_lines.join(',')}]"
|
||||||
|
|
||||||
|
out = "<script>\n"
|
||||||
|
out << "var data = #{var_data};\n"
|
||||||
|
out << "var time = #{j var_time};\n"
|
||||||
|
out << "var cols = #{asciicast.terminal_columns};\n"
|
||||||
|
out << "var lines = #{asciicast.terminal_lines};\n"
|
||||||
|
out << "</script>"
|
||||||
|
out.html_safe
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
<h2>Some title</h2>
|
||||||
|
|
||||||
|
<ul class="asciicasts">
|
||||||
|
<% @asciicasts.each do |asciicast| %>
|
||||||
|
<li class="asciicast">
|
||||||
|
<a href="/<%= asciicast.id %>"><%= asciicast.id %></a>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
@ -1,4 +1,4 @@
|
|||||||
# This file is used by Rack-based servers to start the application.
|
# This file is used by Rack-based servers to start the application.
|
||||||
|
|
||||||
require ::File.expand_path('../config/environment', __FILE__)
|
require ::File.expand_path('../config/environment', __FILE__)
|
||||||
run T3rminalTv::Application
|
run AsciiIo::Application
|
||||||
|
Loading…
Reference in New Issue