Fix snapshot HTML escaping

This commit is contained in:
Marcin Kulik 2015-04-03 16:04:00 +00:00
parent 8c50e7d1b1
commit a719251745
2 changed files with 13 additions and 15 deletions

View File

@ -1,7 +1,7 @@
module AsciicastsHelper module AsciicastsHelper
def player(asciicast, options = PlaybackOptions.new) def player(asciicast, options = PlaybackOptions.new)
render 'asciicasts/player', asciicast: serialized_asciicast(asciicast), render 'asciicasts/player', asciicast: AsciicastSerializer.new(asciicast),
options: options options: options
end end
@ -17,10 +17,6 @@ module AsciicastsHelper
private private
def serialized_asciicast(asciicast)
AsciicastSerializer.new(asciicast).to_json
end
def translate_asset_paths(css) def translate_asset_paths(css)
css.gsub(/['"]\/assets\/(.+?)(-\w{32})?\.(.+?)['"]/) { |m| css.gsub(/['"]\/assets\/(.+?)(-\w{32})?\.(.+?)['"]/) { |m|
path = assets.find_asset("#{$1}.#{$3}").pathname path = assets.find_asset("#{$1}.#{$3}").pathname

View File

@ -1,24 +1,25 @@
.player <div class="player"></div>
p.processing-info style="display: none" <p class="processing-info" style="display: none">
| This recording is being pre-processed at the moment. It will open automatically in a few seconds. This recording is being pre-processed at the moment. It will open automatically in a few seconds.
</p>
javascript: <script>
$(function() { $(function() {
var model = new Asciinema.Asciicast(#{asciicast.html_safe}); var model = new Asciinema.Asciicast(<%= asciicast.to_json.gsub('</', '<\/').html_safe %>);
function createPlayer() { function createPlayer() {
var source = new asciinema.HttpArraySource(model.get('stdout_frames_url'), #{options.speed}); var source = new asciinema.HttpArraySource(model.get('stdout_frames_url'), <%= options.speed %>);
var snapshot = model.get('snapshot'); var snapshot = model.get('snapshot');
var movie = new asciinema.Movie(model.get('width'), model.get('height'), source, snapshot, model.get('duration')); var movie = new asciinema.Movie(model.get('width'), model.get('height'), source, snapshot, model.get('duration'));
React.renderComponent( React.renderComponent(
asciinema.Player({ asciinema.Player({
fontSize: '#{options.size}', fontSize: '<%= options.size %>',
autoPlay: #{options.autoplay}, autoPlay: <%= options.autoplay %>,
loop: #{options.loop}, loop: <%= options.loop %>,
movie: movie, movie: movie,
theme: '#{h options.theme}', theme: '<%= h options.theme %>',
}), }),
$('.player')[0] $('.player')[0]
); );
@ -38,3 +39,4 @@ javascript:
tryCreatePlayer(); tryCreatePlayer();
}); });
</script>