Use actual asciicast width and height in example player usage

This commit is contained in:
Marcin Kulik 2016-01-11 16:14:46 +01:00
parent c86efba24c
commit 442181efe9
5 changed files with 15 additions and 5 deletions

View File

@ -106,6 +106,10 @@
margin-bottom: 5px margin-bottom: 5px
padding: 6px padding: 6px
pre
word-wrap: normal
overflow: auto
.special-label .special-label
font-size: 12px font-size: 12px
background-color: rgb(255, 239, 198) background-color: rgb(255, 239, 198)

View File

@ -65,6 +65,14 @@ class Asciicast < ActiveRecord::Base
collection collection
end end
def width
terminal_columns
end
def height
terminal_lines
end
def title=(value) def title=(value)
value ? super(value.strip[0...255]) : super value ? super(value.strip[0...255]) : super
end end

View File

@ -4,7 +4,7 @@ class AsciicastPagePresenter
attr_reader :routes, :asciicast, :current_user, :policy, :playback_options attr_reader :routes, :asciicast, :current_user, :policy, :playback_options
delegate :download_filename, to: :asciicast, prefix: true delegate :download_filename, :width, :height, to: :asciicast, prefix: true
def self.build(routes, asciicast, current_user, playback_options) def self.build(routes, asciicast, current_user, playback_options)
decorated_asciicast = asciicast.decorate decorated_asciicast = asciicast.decorate

View File

@ -1,9 +1,7 @@
class AsciicastSerializer < ActiveModel::Serializer class AsciicastSerializer < ActiveModel::Serializer
self.root = false self.root = false
attributes :id, :url, :snapshot attributes :id, :url, :snapshot, :width, :height
attribute :terminal_columns, key: :width
attribute :terminal_lines, key: :height
def id def id
object.to_param object.to_param

View File

@ -45,7 +45,7 @@
&lt;body> &lt;body>
&lt;div id="player-container">&lt;/div> &lt;div id="player-container">&lt;/div>
&lt;script> &lt;script>
asciinema_player.core.CreatePlayer('player-container', '/<%= page.asciicast_download_filename %>'); asciinema_player.core.CreatePlayer('player-container', '/<%= page.asciicast_download_filename %>', { width: <%= page.asciicast_width %>, height: <%= page.asciicast_height %> });
&lt;/script> &lt;/script>
&lt;/body> &lt;/body>
&lt;/html></code></pre> &lt;/html></code></pre>