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
padding: 6px
pre
word-wrap: normal
overflow: auto
.special-label
font-size: 12px
background-color: rgb(255, 239, 198)

View File

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

View File

@ -4,7 +4,7 @@ class AsciicastPagePresenter
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)
decorated_asciicast = asciicast.decorate

View File

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

View File

@ -45,7 +45,7 @@
&lt;body>
&lt;div id="player-container">&lt;/div>
&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;/body>
&lt;/html></code></pre>