Fix rendering of snapshot in the player

This commit is contained in:
Marcin Kulik 2013-08-05 00:14:09 +02:00
parent 62be399455
commit ade244e5d0
3 changed files with 9 additions and 5 deletions

View File

@ -64,10 +64,14 @@ class AsciiIo.Renderer.Base extends Backbone.View
@fixTerminalElementSize()
@fixPlayerContainerSize()
renderSnapshot: (text) ->
renderSnapshot: (snapshot) ->
return unless snapshot
i = 0
for line in text.split("\n")
fragments = [[line, AsciiIo.Brush.default()]]
for line in snapshot
fragments = _(line).map (fragment) ->
fragment[1].bright = fragment[1].bold
[fragment[0], new AsciiIo.Brush(fragment[1])]
@renderLine i, fragments, undefined
i++

View File

@ -24,7 +24,7 @@ module AsciicastsHelper
renderer_class: renderer_class,
auto_play: options.key?(:auto_play) ? !!options[:auto_play] : false,
hud: options.key?(:hud) ? !!options[:hud] : true,
snapshot: asciicast.snapshot
snapshot: asciicast.snapshot.to_json
}
end

View File

@ -13,7 +13,7 @@
rendererClass: <%= renderer_class.html_safe %>,
autoPlay: <%= auto_play %>,
hud: <%= hud %>,
snapshot: "<%= (j(snapshot)).html_safe %>"
snapshot: <%= snapshot.html_safe %>
});
});
</script>