From 90954c03b6f843d9cd52bd66ad6eba4e3f25cfff Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Sat, 12 Oct 2013 15:48:51 +0200 Subject: [PATCH] Add support to embed script for making the terminal font 2x bigger --- app/assets/stylesheets/_terminal-font.sass | 14 +++++++++----- app/assets/stylesheets/player/player.css.sass | 16 +++++++++++++--- app/assets/stylesheets/terminal.css.sass | 6 ++++++ app/helpers/asciicasts_helper.rb | 3 ++- app/views/asciicasts/_player.html.slim | 2 +- app/views/asciicasts/show.js.erb | 8 ++++++-- 6 files changed, 37 insertions(+), 12 deletions(-) diff --git a/app/assets/stylesheets/_terminal-font.sass b/app/assets/stylesheets/_terminal-font.sass index b81910a..179ae49 100644 --- a/app/assets/stylesheets/_terminal-font.sass +++ b/app/assets/stylesheets/_terminal-font.sass @@ -1,11 +1,7 @@ =terminal-font - // font metrics - font-family: 'Bitstream Vera Sans Mono', 'Courier New', monospace - font-size: 12px - - // line metrics + font-size: 12px line-height: 16px .line @@ -13,3 +9,11 @@ padding: 0 display: inline-block height: 16px + +=terminal-font-big + font-size: 24px + line-height: 32px + + .line + span + height: 32px diff --git a/app/assets/stylesheets/player/player.css.sass b/app/assets/stylesheets/player/player.css.sass index 39ead19..4c8bf8f 100644 --- a/app/assets/stylesheets/player/player.css.sass +++ b/app/assets/stylesheets/player/player.css.sass @@ -27,6 +27,16 @@ $color5: #edc951 .font-sample, .hud +terminal-font + &.big-font + .font-sample, .hud + +terminal-font-big + + .hud + height: 32px + bottom: 6px + left: 6px + right: 6px + .loading +player-overlay background-image: url(image-path("loader.gif")) @@ -64,9 +74,9 @@ $color5: #edc951 background-color: #eee opacity: 0 position: absolute - left: 2px - right: 2px - bottom: 2px + left: 3px + right: 3px + bottom: 3px height: 16px overflow: hidden color: black diff --git a/app/assets/stylesheets/terminal.css.sass b/app/assets/stylesheets/terminal.css.sass index ed841be..56d60b0 100644 --- a/app/assets/stylesheets/terminal.css.sass +++ b/app/assets/stylesheets/terminal.css.sass @@ -29,3 +29,9 @@ pre.terminal .fg8, .fg9, .fg10, .fg11, .fg12, .fg13, .fg14, .fg15 font-weight: bold + +.big-font + pre.terminal + +terminal-font-big + + padding: 6px diff --git a/app/helpers/asciicasts_helper.rb b/app/helpers/asciicasts_helper.rb index a184436..821ccbd 100644 --- a/app/helpers/asciicasts_helper.rb +++ b/app/helpers/asciicasts_helper.rb @@ -21,7 +21,8 @@ module AsciicastsHelper container_width: params[:container_width], renderer_class: renderer_class, auto_play: options.key?(:auto_play) ? !!options[:auto_play] : false, - hud: options.key?(:hud) ? !!options[:hud] : true + hud: options.key?(:hud) ? !!options[:hud] : true, + size: params[:size] || 'small' } end diff --git a/app/views/asciicasts/_player.html.slim b/app/views/asciicasts/_player.html.slim index f1aba68..2062c60 100644 --- a/app/views/asciicasts/_player.html.slim +++ b/app/views/asciicasts/_player.html.slim @@ -1,4 +1,4 @@ -.player +.player class="#{size}-font" javascript: $(function() { diff --git a/app/views/asciicasts/show.js.erb b/app/views/asciicasts/show.js.erb index 7cd75b8..9c48d7c 100644 --- a/app/views/asciicasts/show.js.erb +++ b/app/views/asciicasts/show.js.erb @@ -30,7 +30,11 @@ container.style.overflow = 'hidden'; container.style.padding = '0'; insertAfter(scriptTag, container); - var containerWidth = container.offsetWidth; - container.innerHTML = ''; + var params = 'container_width=' + container.offsetWidth; + var size = scriptTag.getAttribute('data-size'); + if (size) { + params += '&size=' + size; + } + container.innerHTML = ''; } })();