Permalink
Browse files

Fix code highlighting in PDF, improve inline CSS/JS logic. Fixes #161 #…

  • Loading branch information...
1 parent 1d2fbf6 commit 86ffe77b5f3d1add6dd6f4c5ee69ae6821ad011f @goncalossilva goncalossilva committed Mar 6, 2012
Showing with 40 additions and 32 deletions.
  1. +2 −2 lib/showoff.rb
  2. +0 −12 public/css/pdf.css
  3. +4 −4 views/header.erb
  4. +34 −14 views/onepage.erb
View
@@ -467,15 +467,15 @@ def onepage(static=false)
def pdf(static=true)
@slides = get_slides_html(static, true)
- @no_js = false
+ @inline = true
# Identify which languages to bundle for highlighting
@languages = @slides.scan(/<pre class=".*(?!sh_sourceCode)(sh_[\w-]+).*"/).uniq.map{ |w| "/sh_lang/#{w[0]}.min.js"}
html = erb :onepage
# TODO make a random filename
- # Process inline css and js for included images
+ # Process inline css and js for included images
# The css uses relative paths for images and we prepend the file url
html.gsub!(/url\([\"\']?(?!https?:\/\/)(.*?)[\"\']?\)/) do |s|
"url(file://#{settings.pres_dir}/#{$1})"
View
@@ -1,12 +0,0 @@
-.slide {
- margin: 0;
- padding: 0;
- width: 100%;
- height: 740px;
- margin-left:auto;
- margin-right:auto;
- overflow:hidden;
- page-break-after: always
-}
-
-@page { size: A4 landscape }
View
@@ -6,6 +6,10 @@
<link rel="stylesheet" href="<%= @asset_path %>css/reset.css" type="text/css"/>
<link rel="stylesheet" href="<%= @asset_path %>css/showoff.css" type="text/css"/>
+ <link type="text/css" href="<%= @asset_path %>css/fg.menu.css" media="screen" rel="stylesheet" />
+ <link type="text/css" href="<%= @asset_path %>css/theme/ui.all.css" media="screen" rel="stylesheet" />
+ <link type="text/css" href="<%= @asset_path %>css/sh_style.css" rel="stylesheet" />
+
<script type="text/javascript" src="<%= @asset_path %>js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<%= @asset_path %>js/jquery.cycle.all.js"></script>
<script type="text/javascript" src="<%= @asset_path %>js/jquery-print.js"></script>
@@ -21,10 +25,6 @@
<script type="text/javascript" src="<%= @asset_path %>js/showoffcore.js"></script>
<script type="text/javascript" src="<%= @asset_path %>js/coffee-script.js"></script>
- <link type="text/css" href="<%= @asset_path %>css/fg.menu.css" media="screen" rel="stylesheet" />
- <link type="text/css" href="<%= @asset_path %>css/theme/ui.all.css" media="screen" rel="stylesheet" />
- <link type="text/css" href="<%= @asset_path %>css/sh_style.css" rel="stylesheet" >
-
<% if @languages %>
<% @languages.each do |l| %>
<script type="text/javascript" src="<%= @asset_path %>js/<%= l %>"></script>
View
@@ -4,28 +4,48 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <title>Presentation</title>
+ <title><%= @title %></title>
- <%= inline_css(['reset.css', 'showoff.css', 'theme/ui.all.css', 'sh_style.css'], 'public/css') %>
- <% if @no_js %>
- <%= inline_css(['pdf.css'], 'public/css') %>
- <% else %>
- <%= inline_css(['onepage.css'], 'public/css') %>
- <% end %>
- <%= inline_css(css_files) %>
+ <% if @inline %>
- <% if !@no_js %>
- <%= inline_js(['jquery-1.4.2.min.js', 'jquery-print.js', 'showoff.js', 'onepage.js', 'sh_main.min.js', 'core.js', 'showoffcore.js'], 'public/js') %>
-
- <% if @languages %>
- <%= inline_js(@languages, 'public/js') %>
- <% end %>
+ <%= inline_css(['reset.css', 'showoff.css', 'theme/ui.all.css', 'sh_style.css', 'onepage.css'], 'public/css') %>
+ <%= inline_css(css_files) %>
+ <%= inline_js(['jquery-1.4.2.min.js', 'jquery-print.js', 'showoff.js', 'onepage.js', 'sh_main.min.js', 'core.js', 'showoffcore.js'], 'public/js') %>
+ <%= inline_js(@languages, 'public/js') if @languages %>
+ <%= inline_js(js_files) %>
<script type="text/javascript">
$(document).ready(function() {
setupOnePage()
});
</script>
+
+ <% else %>
+
+ <% ['reset.css', 'showoff.css', 'theme/ui.all.css', 'sh_style.css', 'onepage.css'].each do |css_file| %>
+ <link rel="stylesheet" href="<%= @asset_path %>css/<%= css_file %>" type="text/css"/>
+ <% end %>
+ <% css_files.each do |css_file| %>
+ <link rel="stylesheet" href="<%= @asset_path %>file/<%= css_file %>" type="text/css"/>
+ <% end %>
+
+ <% ['jquery-1.4.2.min.js', 'jquery-print.js', 'showoff.js', 'onepage.js', 'sh_main.min.js', 'core.js', 'showoffcore.js'].each do |js_file| %>
+ <script type="text/javascript" src="<%= @asset_path %>js/<%= js_file %>"></script>
+ <% end %>
+ <% js_files.each do |js_file| %>
+ <script type="text/javascript" src="<%= @asset_path %>file/<%= js_file %>"></script>
+ <% end %>
+ <% if @languages %>
+ <% @languages.each do |l| %>
+ <script type="text/javascript" src="<%= @asset_path %>js<%= l %>"></script>
+ <% end %>
+ <% end %>
+ <script type="text/javascript">
+ $(document).ready(function() {
+ setupOnePage()
+ });
+ </script>
+
<% end %>
</head>

0 comments on commit 86ffe77

Please sign in to comment.