Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Giant Merge #150

Closed
wants to merge 23 commits into from

3 participants

@grundprinzip

In case you want to merge the fixes and improvements from

#149, #143, #144, #139, #140, #130, #112, #126

this is the merged tree with all changes. :)

rkh and others added some commits
@rkh rkh Allow irb prompt for commandline slides 2c06683
@timfel timfel update sinatra version, so we can use tilt and it's preferred markdow…
…n engine redcloth instead of bluecloth
313aff7
@timfel timfel #options and #public are deprecated, use #settings and #public_folder…
… instead
5b8e113
@timfel timfel use recent sinatra 4ddf2f4
@grundprinzip grundprinzip Fixing print CSS
When printing the CSS file paths need to be rewritten
to match the absolute URIs used in PDFKit. In addition, it
is required to configure the print media style or 
the output will be buggy. 

In print mode, the position of the slide needs to be 
set explicitly to "relavtive" or more explict styling 
in the slide container will fail in print mode.
96d510d
@grundprinzip grundprinzip Templates
* allow templates to be configurable
* allow default template to be not present
* parsing of slide options
04dd4eb
@grundprinzip grundprinzip Templates for Statics and PDFs
* fixing positioning of a slide when using the onepage.css
ce08379
@grundprinzip grundprinzip Documentation for Templates a838d8c
@grundprinzip grundprinzip Proper formating for documentation bad2a58
@grundprinzip grundprinzip Documentation and Replacements
Replaced the ###CONTENT### string with something 
that does not break in Markdown :). Furthermore now
multiple replacements can be used in the slides, the 
documentation is in the README.
ea6046a
@grundprinzip grundprinzip Fixing syntax highlighting in static mode and PDF output 00f52a9
@grundprinzip grundprinzip Removing old init stuff f6a82a4
@grundprinzip grundprinzip Avoiding error if no @languages specified e900701
@grundprinzip grundprinzip Fixing bad logger variable in static mode 2b76bc2
@grundprinzip grundprinzip Merge remote-tracking branch 'timfel/replace-bluecloth' into altmaster a5abc87
@grundprinzip grundprinzip Cleanup
* Merging removal of deprecation warnings
* Adjusting code to use settings instead of options
53e6df7
@grundprinzip grundprinzip Fixing failing tests e685821
@grundprinzip grundprinzip Merge branch 'templating' into altmaster
Conflicts:
	lib/showoff.rb
ec8122d
@grundprinzip grundprinzip Merge remote-tracking branch 'rkh/patch-1' into altmaster 1792680
@grundprinzip grundprinzip Making PDF options configurable from the config file 3a68eaf
@grundprinzip grundprinzip CSS reset for pages after full-page was shown 8c2c10e
@grundprinzip grundprinzip Added example to example slides as required by CONTRIB.txt 2f42a88
@grundprinzip grundprinzip Merge branch 'templating' into altmaster
Conflicts:
	lib/showoff.rb
0eaf2a0
@grundprinzip

Since some of the changes were already pulled, I will close this request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 22, 2011
  1. @rkh
Commits on Oct 8, 2011
  1. @timfel

    update sinatra version, so we can use tilt and it's preferred markdow…

    timfel authored
    …n engine redcloth instead of bluecloth
  2. @timfel
  3. @timfel

    use recent sinatra

    timfel authored
Commits on Nov 12, 2011
  1. @grundprinzip

    Fixing print CSS

    grundprinzip authored
    When printing the CSS file paths need to be rewritten
    to match the absolute URIs used in PDFKit. In addition, it
    is required to configure the print media style or 
    the output will be buggy. 
    
    In print mode, the position of the slide needs to be 
    set explicitly to "relavtive" or more explict styling 
    in the slide container will fail in print mode.
Commits on Nov 13, 2011
  1. @grundprinzip

    Templates

    grundprinzip authored
    * allow templates to be configurable
    * allow default template to be not present
    * parsing of slide options
  2. @grundprinzip

    Templates for Statics and PDFs

    grundprinzip authored
    * fixing positioning of a slide when using the onepage.css
  3. @grundprinzip
  4. @grundprinzip
  5. @grundprinzip

    Documentation and Replacements

    grundprinzip authored
    Replaced the ###CONTENT### string with something 
    that does not break in Markdown :). Furthermore now
    multiple replacements can be used in the slides, the 
    documentation is in the README.
  6. @grundprinzip
  7. @grundprinzip

    Removing old init stuff

    grundprinzip authored
  8. @grundprinzip
Commits on Nov 14, 2011
  1. @grundprinzip
  2. @grundprinzip
  3. @grundprinzip

    Cleanup

    grundprinzip authored
    * Merging removal of deprecation warnings
    * Adjusting code to use settings instead of options
  4. @grundprinzip

    Fixing failing tests

    grundprinzip authored
  5. @grundprinzip

    Merge branch 'templating' into altmaster

    grundprinzip authored
    Conflicts:
    	lib/showoff.rb
  6. @grundprinzip
  7. @grundprinzip
  8. @grundprinzip
  9. @grundprinzip
  10. @grundprinzip

    Merge branch 'templating' into altmaster

    grundprinzip authored
    Conflicts:
    	lib/showoff.rb
This page is out of date. Refresh to see the latest.
View
8 Gemfile
@@ -1,11 +1,7 @@
source :rubygems
-gem "sinatra"
-gem "bluecloth"
-gem "nokogiri"
-gem "json"
-gem "gli",">= 1.2.5"
-gem "parslet"
+
+gemspec
group :development do
gem "mg"
View
97 README.rdoc
@@ -84,7 +84,23 @@ the following contents:
That represents two slides, the first contains just a large title, and the
second is faded into view showing the title and three bullets that are then
-incrementally shown. In order for ShowOff to see those slides, your
+incrementally shown. In addition you can configure a certain template for
+this slide overriding the default one:
+
+ !SLIDE[tpl=title]
+
+ # My Presentation #
+
+ !SLIDE bullets incremental
+
+ # Bullet Points #
+
+ * first point
+ * second point
+ * third point
+
+
+In order for ShowOff to see those slides, your
<tt>showoff.json</tt> file needs to look something like this:
{
@@ -95,19 +111,20 @@ incrementally shown. In order for ShowOff to see those slides, your
]
}
-If you have multiple sections in your talk, you can make this json array
-include all the sections you want to show in which order you want to show
-them.
+If you have multiple sections in your talk, you can make this json
+array include all the sections you want to show in which order you
+want to show them. Template configuration is done in
+<tt>showoff.json</tt> as well.
-Instead of a hash, you can use a plain string as an entry in the `sections`
-section of `showoff.json`.
-And if that plain string starts with '#' then it is interpreted not as a
-filename, but as markdown. This is used for inserting interstitial slides
-or notes -- for instance, Alex Chaffee's
-[Ruby Notes](http://github.com/alexch/ruby_notes)
-uses it to insert lab instructions between lecture slide sections, which may
-vary from venue to venue.
+Instead of a hash, you can use a plain string as an entry in the
+`sections` section of `showoff.json`. And if that plain string starts
+with '#' then it is interpreted not as a filename, but as
+markdown. This is used for inserting interstitial slides or notes --
+for instance, Alex Chaffee's [Ruby
+Notes](http://github.com/alexch/ruby_notes) uses it to insert lab
+instructions between lecture slide sections, which may vary from venue
+to venue.
If you want to keep the ability to emit an HTML document from your
Markdown source file -- say, for a TextMate preview or a GitHub rendering
@@ -446,6 +463,62 @@ You'll then need to install a version of wkhtmltopdf available at the {wkhtmltop
Then restart showoff, and navigate to <tt>/pdf</tt> (e.g. http://localhost/pdf) of your presentation and a PDF will be generated with the browser.
+= ShowOff Templates
+
+Templates can come handy if you need more than what you can achieve
+via CSS. To configure templates you'll have to specify them in the
+<tt>showoff.json</tt> by adding an entry called "templates". This
+entry is an object where you can specify as many templates as you
+want. The default template is marked with the "default" key.
+
+ {
+ "name": "Something",
+ "description": "Example Presentation",
+ "templates" : {
+ "default" : "tpl1.tpl",
+ "special" : "tpl2.tpl"
+ },
+ "sections": [
+ {"section":"one"}
+ ]
+ }
+
+If the "default" key is not given, no template will be used for the
+default slide. If you want to apply a certain layout to a slide you
+have to specify it in the slide header:
+
+ !SLIDE[tpl=special]
+ # Header
+
+== Template Commands
+
+You can place content anywhere in your template, but you have to
+explicitly mark the location using a special command:
+
+[~~~CONTENT~~~] is replaced by the slide content
+
+[~~~CURRENT_SLIDE~~~] is replaced by the current slide number
+
+[~~~NUM_SLIDES~~~] is replaced by the total number of slides
+
+[~~~CONFIG:*~~~] is replaced by any value (*) from the
+ <tt>showoff.json</tt> configuration. This can be used to
+ specify an author, venue etc. A simple example would be
+ <tt>~~~CONFIG:author~~~</tt>
+
+
+The usage of these replacements is not limited to templates, but
+anywhere in your slides.
+
+== Template Hints
+
+You can basically put everything you want into templates, but you
+should make sure that the CSS is applied fine. The best way to apply a
+custom layout is to create a container that uses absolute positioning
+and has width and height set to 100% which are then derived from the
+parent slide element.
+
+
= Completion
== ZSH completion
View
5 example/four/01slide.md
@@ -0,0 +1,5 @@
+!SLIDE[tpl=special]
+
+# A Template #
+
+Really? How many slides? -- ~~~NUM_SLIDES~~~
View
7 example/showoff.json
@@ -1,9 +1,14 @@
{
"name": "Something",
"description": "Example Presentation",
+ "author": "Foo Bar John",
+ "templates" : {
+ "special" : "simple.tpl"
+ },
"sections": [
{"section":"one"},
{"section":"two"},
- {"section":"three"}
+ {"section":"three"},
+ {"section":"four"}
]
}
View
2  example/simple.tpl
@@ -0,0 +1,2 @@
+<div class="border">~~~CONFIG:author~~~@~~~CURRENT_SLIDE~~~</div>
+<div class="main">~~~CONTENT~~~<div>
View
2  lib/commandline_parser.rb
@@ -4,7 +4,7 @@
class CommandlineParser < Parslet::Parser
rule(:prompt) do
- str('$') | str('#')
+ str('$') | str('#') | str('>>')
end
rule(:text) do
View
175 lib/showoff.rb
@@ -21,13 +21,7 @@
$stderr.puts 'pdf generation disabled - install pdfkit'
end
-begin
- require 'rdiscount'
-rescue LoadError
- require 'bluecloth'
- Object.send(:remove_const,:Markdown)
- Markdown = BlueCloth
-end
+require 'tilt'
class ShowOff < Sinatra::Application
@@ -36,32 +30,49 @@ class ShowOff < Sinatra::Application
attr_reader :cached_image_size
set :views, File.dirname(__FILE__) + '/../views'
- set :public, File.dirname(__FILE__) + '/../public'
+ set :public_folder, File.dirname(__FILE__) + '/../public'
set :verbose, false
set :pres_dir, '.'
set :pres_file, 'showoff.json'
+ set :pdf_options, {}
+ set :pres_template, nil
+ set :showoff_config, nil
def initialize(app=nil)
super(app)
@logger = Logger.new(STDOUT)
@logger.formatter = proc { |severity,datetime,progname,msg| "#{progname} #{msg}\n" }
- @logger.level = options.verbose ? Logger::DEBUG : Logger::WARN
+ @logger.level = settings.verbose ? Logger::DEBUG : Logger::WARN
dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
@logger.debug(dir)
showoff_dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
- options.pres_dir ||= Dir.pwd
+ settings.pres_dir ||= Dir.pwd
@root_path = "."
- options.pres_dir = File.expand_path(options.pres_dir)
- if (options.pres_file)
- ShowOffUtils.presentation_config_file = options.pres_file
+ settings.pres_dir = File.expand_path(settings.pres_dir)
+ if (settings.pres_file)
+ ShowOffUtils.presentation_config_file = settings.pres_file
end
+
+ # Load configuration for page size and template from the
+ # configuration JSON file
+ if File.exists?(ShowOffUtils.presentation_config_file)
+ showoff_json = JSON.parse(File.read(ShowOffUtils.presentation_config_file))
+ settings.showoff_config = showoff_json
+
+ # load pdf options
+ settings.pdf_options = ShowOffUtils.pdf_options()
+
+ # Set options for template and page size
+ settings.pres_template = showoff_json["templates"]
+ end
+
@cached_image_size = {}
- @logger.debug options.pres_dir
- @pres_name = options.pres_dir.split('/').pop
+ @logger.debug settings.pres_dir
+ @pres_name = settings.pres_dir.split('/').pop
require_ruby_files
end
@@ -71,12 +82,12 @@ def self.pres_dir_current
end
def require_ruby_files
- Dir.glob("#{options.pres_dir}/*.rb").map { |path| require path }
+ Dir.glob("#{settings.pres_dir}/*.rb").map { |path| require path }
end
helpers do
def load_section_files(section)
- section = File.join(options.pres_dir, section)
+ section = File.join(settings.pres_dir, section)
files = if File.directory? section
Dir.glob("#{section}/**/*").sort
else
@@ -87,23 +98,35 @@ def load_section_files(section)
end
def css_files
- Dir.glob("#{options.pres_dir}/*.css").map { |path| File.basename(path) }
+ Dir.glob("#{settings.pres_dir}/*.css").map { |path| File.basename(path) }
end
def js_files
- Dir.glob("#{options.pres_dir}/*.js").map { |path| File.basename(path) }
+ Dir.glob("#{settings.pres_dir}/*.js").map { |path| File.basename(path) }
end
def preshow_files
- Dir.glob("#{options.pres_dir}/_preshow/*").map { |path| File.basename(path) }.to_json
+ Dir.glob("#{settings.pres_dir}/_preshow/*").map { |path| File.basename(path) }.to_json
end
# todo: move more behavior into this class
class Slide
- attr_reader :classes, :text
- def initialize classes = ""
- @classes = ["content"] + classes.strip.chomp('>').split
+ attr_reader :classes, :text, :tpl
+ def initialize( context = "")
+
+ @tpl = "default"
+ @classes = ["content"]
+
+ # Parse the context string for options and content classes
+ if context and context.match(/(\[(.*?)\])?(.*)/)
+
+ options = ShowOffUtils.parse_options($2)
+ @tpl = options["tpl"] if options["tpl"]
+ @classes += $3.strip.chomp('>').split if $3
+
+ end
+
@text = ""
end
def <<(s)
@@ -131,7 +154,8 @@ def process_markdown(name, content, static=false, pdf=false)
until lines.empty?
line = lines.shift
if line =~ /^<?!SLIDE(.*)>?/
- slides << (slide = Slide.new($1))
+ ctx = $1 ? $1.strip : $1
+ slides << (slide = Slide.new(ctx))
else
slide << line
end
@@ -144,6 +168,7 @@ def process_markdown(name, content, static=false, pdf=false)
seq = 1
end
slides.each do |slide|
+ @slide_count += 1
md = ''
content_classes = slide.classes
@@ -156,27 +181,70 @@ def process_markdown(name, content, static=false, pdf=false)
@logger.debug "id: #{id}" if id
@logger.debug "classes: #{content_classes.inspect}"
@logger.debug "transition: #{transition}"
+ @logger.debug "tpl: #{slide.tpl} " if slide.tpl
# create html
md += "<div"
md += " id=\"#{id}\"" if id
md += " class=\"slide\" data-transition=\"#{transition}\">"
+
+
+ template = "~~~CONTENT~~~"
+ # Template handling
+ if settings.pres_template
+ # We allow specifying a new template even when default is
+ # not given.
+ if settings.pres_template.include?(slide.tpl) and
+ File.exists?(settings.pres_template[slide.tpl])
+ template = File.open(settings.pres_template[slide.tpl], "r").read()
+ end
+ end
+
+ # Extract the content of the slide
+ content = ""
if seq
- md += "<div class=\"#{content_classes.join(' ')}\" ref=\"#{name}/#{seq.to_s}\">\n"
- seq += 1
+ content += "<div class=\"#{content_classes.join(' ')}\" ref=\"#{name}/#{seq.to_s}\">\n"
else
- md += "<div class=\"#{content_classes.join(' ')}\" ref=\"#{name}\">\n"
+ content += "<div class=\"#{content_classes.join(' ')}\" ref=\"#{name}\">\n"
end
- sl = Markdown.new(slide.text).to_html
+ sl = Tilt[:markdown].new { slide.text }.render
sl = update_image_paths(name, sl, static, pdf)
- md += sl
- md += "</div>\n"
+ content += sl
+ content += "</div>\n"
+
+ # Apply the template to the slide and replace the key with
+ # content of the slide
+ md += process_content_for_replacements(template.gsub(/~~~CONTENT~~~/, content), @slide_count)
+
+ # Apply other configuration
+
md += "</div>\n"
final += update_commandline_code(md)
final = update_p_classes(final)
+
+ if seq
+ seq += 1
+ end
end
final
end
+ # This method processes the content of the slide and replaces
+ # content markers with their actual value information
+ def process_content_for_replacements(content, seq)
+ result = content.gsub("~~~CURRENT_SLIDE~~~", seq.to_s)
+ # Now check for any kind of options
+ content.scan(/(~~~CONFIG:(.*?)~~~)/).each do |match|
+ result.gsub!(match[0], settings.showoff_config[match[1]]) if settings.showoff_config.key?(match[1])
+ end
+
+ result
+ end
+
+ def process_content_for_all_slides(content, num_slides)
+ content.gsub("~~~NUM_SLIDES~~~", num_slides.to_s)
+ end
+
+
# find any lines that start with a <p>.(something) and turn them into <p class="something">
def update_p_classes(markdown)
markdown.gsub(/<p>\.(.*?) /, '<p class="\1">')
@@ -187,7 +255,7 @@ def update_image_paths(path, slide, static=false, pdf=false)
paths.pop
path = paths.join('/')
replacement_prefix = static ?
- ( pdf ? %(img src="file://#{options.pres_dir}/#{path}) : %(img src="./file/#{path}) ) :
+ ( pdf ? %(img src="file://#{settings.pres_dir}/#{path}) : %(img src="./file/#{path}) ) :
%(img src="/image/#{path})
slide.gsub(/img src=\"([^\/].*?)\"/) do |s|
img_path = File.join(path, $1)
@@ -265,7 +333,8 @@ def update_commandline_code(slide)
end
def get_slides_html(static=false, pdf=false)
- sections = ShowOffUtils.showoff_sections(options.pres_dir, @logger)
+ @slide_count = 0
+ sections = ShowOffUtils.showoff_sections(settings.pres_dir, @logger)
files = []
if sections
data = ''
@@ -279,13 +348,13 @@ def get_slides_html(static=false, pdf=false)
files = files.flatten
files = files.select { |f| f =~ /.md$/ }
files.each do |f|
- fname = f.gsub(options.pres_dir + '/', '').gsub('.md', '')
+ fname = f.gsub(settings.pres_dir + '/', '').gsub('.md', '')
data << process_markdown(fname, File.read(f), static, pdf)
end
end
end
end
- data
+ process_content_for_all_slides(data, @slide_count)
end
def inline_css(csses, pre = nil)
@@ -294,7 +363,7 @@ def inline_css(csses, pre = nil)
if pre
css_file = File.join(File.dirname(__FILE__), '..', pre, css_file)
else
- css_file = File.join(options.pres_dir, css_file)
+ css_file = File.join(settings.pres_dir, css_file)
end
css_content += File.read(css_file)
end
@@ -308,7 +377,7 @@ def inline_js(jses, pre = nil)
if pre
js_file = File.join(File.dirname(__FILE__), '..', pre, js_file)
else
- js_file = File.join(options.pres_dir, js_file)
+ js_file = File.join(settings.pres_dir, js_file)
end
js_content += File.read(js_file)
end
@@ -324,6 +393,11 @@ def index(static=false)
if static
@title = ShowOffUtils.showoff_title
@slides = get_slides_html(static)
+
+ # Identify which languages to bundle for highlighting
+ @languages = []
+ @languages += @slides.scan(/<pre class="(sh_.*?\w)"/).uniq.map{ |w| "sh_lang/#{w[0]}.min.js"}
+
@asset_path = "./"
end
erb :index
@@ -361,10 +435,10 @@ def assets_needed
assets << href if href
end
- css = Dir.glob("#{options.public}/**/*.css").map { |path| path.gsub(options.public + '/', '') }
+ css = Dir.glob("#{settings.public_folder}/**/*.css").map { |path| path.gsub(settings.public_folder + '/', '') }
assets << css
- js = Dir.glob("#{options.public}/**/*.js").map { |path| path.gsub(options.public + '/', '') }
+ js = Dir.glob("#{settings.public_folder}/**/*.js").map { |path| path.gsub(settings.public_folder + '/', '') }
assets << js
assets.uniq.join("\n")
@@ -382,12 +456,25 @@ def onepage(static=false)
def pdf(static=true)
@slides = get_slides_html(static, true)
@no_js = false
+
+ # Identify which languages to bundle for highlighting
+ @languages = []
+ @languages += @slides.scan(/<pre class="(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
+ # The css uses relative paths for images and we prepend the file url
+ html.gsub!(/url\(([^\/].*?)\)/) do |s|
+ "url(file://#{settings.pres_dir}/#{$1})"
+ end
+
+ # Todo fix javascript path
+
# PDFKit.new takes the HTML and any options for wkhtmltopdf
# run `wkhtmltopdf --extended-help` for a full list of options
- kit = PDFKit.new(html, :page_size => 'Letter', :orientation => 'Landscape')
+ kit = PDFKit.new(html, ShowOffUtils.pdf_options)
# Save the PDF to a file
file = kit.to_file('/tmp/preso.pdf')
@@ -406,7 +493,10 @@ def self.do_static(what)
end
name = showoff.instance_variable_get(:@pres_name)
path = showoff.instance_variable_get(:@root_path)
+ logger = showoff.instance_variable_get(:@logger)
+
data = showoff.send(what, true)
+
if data.is_a?(File)
FileUtils.cp(data.path, "#{name}.pdf")
else
@@ -433,7 +523,7 @@ def self.do_static(what)
# Set up file dir
file_dir = File.join(out, 'file')
FileUtils.makedirs(file_dir)
- pres_dir = showoff.options.pres_dir
+ pres_dir = showoff.settings.pres_dir
# ..., copy all user-defined styles and javascript files
Dir.glob("#{pres_dir}/*.{css,js}").each { |path|
@@ -451,7 +541,7 @@ def self.do_static(what)
File.open(css_path) do |file|
data = file.read
data.scan(/url\((.*)\)/).flatten.each do |path|
- @logger.debug path
+ logger.debug path
dir = File.dirname(path)
FileUtils.makedirs(File.join(file_dir, dir))
FileUtils.copy(File.join(pres_dir, path), File.join(file_dir, path))
@@ -475,7 +565,7 @@ def eval_ruby code
get %r{(?:image|file)/(.*)} do
path = params[:captures].first
- full_path = File.join(options.pres_dir, path)
+ full_path = File.join(settings.pres_dir, path)
send_file full_path
end
@@ -483,6 +573,7 @@ def eval_ruby code
@title = ShowOffUtils.showoff_title
what = params[:captures].first
what = 'index' if "" == what
+
if (what != "favicon.ico")
data = send(what)
if data.is_a?(File)
View
41 lib/showoff_utils.rb
@@ -1,4 +1,43 @@
class ShowOffUtils
+
+ # Helper method to parse a comma separated options string and stores
+ # the result in a dictionrary
+ #
+ # Example:
+ #
+ # "tpl=hpi,title=Over the rainbow"
+ #
+ # will be stored as
+ #
+ # { "tpl" => "hpi", "title" => "Over the rainbow" }
+ def self.parse_options(option_string="")
+ result = {}
+
+ if option_string
+ option_string.split(",").each do |element|
+ pair = element.split("=")
+ result[pair[0]] = pair.size > 1 ? pair[1] : nil
+ end
+ end
+
+ result
+ end
+
+ # Reads the options from the showoff configuration file if present
+ def self.pdf_options()
+
+ options = {:page_size => "Letter", :orientation => "Landscape",
+ :print_media_type => true}
+
+ if File.exists?(ShowOffUtils.presentation_config_file)
+ showoff_json = JSON.parse(File.read(ShowOffUtils.presentation_config_file), :symbolize_names => true)
+ options.merge(showoff_json[:pdf_options] || {})
+ else
+ options
+ end
+ end
+
+
def self.presentation_config_file
@presentation_config_file ||= 'showoff.json'
end
@@ -294,7 +333,7 @@ def self.lang(source_file)
EXTENSIONS[ext] || ext
end
- REQUIRED_GEMS = %w(bluecloth nokogiri showoff gli heroku)
+ REQUIRED_GEMS = %w(redcarpet showoff heroku)
# Creates the file that lists the gems for heroku
#
View
2  public/css/onepage.css
@@ -9,6 +9,7 @@
margin-left:auto;
margin-right:auto;
overflow:hidden;
+ position: relative;
border: 1px solid #333;
page-break-after: always
}
@@ -23,6 +24,7 @@
height: 600px;
overflow:hidden;
border: none;
+ position: relative;
page-break-after: always
}
}
View
4 public/css/showoff.css
@@ -368,7 +368,7 @@ a.fg-button { float:left; }
}
.slide .center {
- width: 600px;
+ width: 800px;
height: 600px;
display: table-cell;
text-align: center;
@@ -377,7 +377,7 @@ a.fg-button { float:left; }
#preso, .slide {
background: #fff;
- width: 600px;
+ width: 800px;
height: 600px;
margin-left:auto;
margin-right:auto;
View
5 public/js/onepage.js
@@ -1,5 +1,4 @@
function setupOnePage() {
- sh_highlightDocument('/js/sh_lang/', '.min.js')
-
+ sh_highlightDocument();
centerSlides($("#slides > .slide"))
-}
+}
View
16 public/js/showoff.js
@@ -28,6 +28,8 @@ function setupPreso(load_slides, prefix) {
}
preso_started = true
+
+ // Load slides fetches images
loadSlidesBool = load_slides
loadSlidesPrefix = prefix
loadSlides(loadSlidesBool, loadSlidesPrefix)
@@ -64,7 +66,7 @@ function loadSlides(load_slides, prefix) {
function initializePresentation(prefix) {
// unhide for height to work in static mode
- $("#slides").show();
+ $("#slides").show();
//center slides offscreen
centerSlides($('#slides > .slide'))
@@ -90,7 +92,11 @@ function initializePresentation(prefix) {
slidesLoaded = true
}
setupSlideParamsCheck();
- sh_highlightDocument(prefix+'/js/sh_lang/', '.min.js')
+ try {
+ sh_highlightDocument(prefix+'/js/sh_lang/', '.min.js')
+ } catch(e) {
+ sh_highlightDocument();
+ }
$("#preso").trigger("showoff:loaded");
}
@@ -101,7 +107,7 @@ function centerSlides(slides) {
}
function centerSlide(slide) {
- var slide_content = $(slide).children(".content").first()
+ var slide_content = $(slide).find(".content").first()
var height = slide_content.height()
var mar_top = (0.5 * parseFloat($(slide).height())) - (0.5 * parseFloat(height))
if (mar_top < 0) {
@@ -117,7 +123,7 @@ function setupMenu() {
var menu = new ListMenu()
slides.each(function(s, elem) {
- content = $(elem).children(".content")
+ content = $(elem).find(".content")
shortTxt = $(content).text().substr(0, 20)
path = $(content).attr('ref').split('/')
currSlide += 1
@@ -195,6 +201,8 @@ function showSlide(back_step) {
if (fullPage) {
$('#preso').css({'width' : '100%', 'overflow' : 'visible'});
currentSlide.css({'width' : '100%', 'text-align' : 'center', 'overflow' : 'visible'});
+ } else {
+ $('#preso').css({'width' : '', 'overflow' : ''});
}
percent = getSlidePercent()
View
4 showoff.gemspec
@@ -15,8 +15,8 @@ Gem::Specification.new do |s|
s.files += Dir.glob("bin/**/*")
s.files += Dir.glob("views/**/*")
s.files += Dir.glob("public/**/*")
- s.add_dependency "sinatra"
- s.add_dependency "bluecloth"
+ s.add_dependency "sinatra", "~> 1.3"
+ s.add_dependency "redcarpet"
s.add_dependency "nokogiri"
s.add_dependency "json"
s.add_dependency("gli",">= 1.3.2")
View
17 test/basic_test.rb
@@ -1,12 +1,27 @@
require File.expand_path "../test_helper", __FILE__
require 'pdf/inspector'
+context "ShowOff pdf tests" do
+
+ test "configure pdf options" do
+
+ ShowOffUtils.presentation_config_file = "test/fixtures/simple/showoff_pdf.json"
+ assert_equal "A4", ShowOffUtils.pdf_options[:page_size]
+ assert_equal false, ShowOffUtils.pdf_options[:print_media_type]
+
+ ShowOffUtils.presentation_config_file = "test/fixtures/simple/showoff.json"
+ assert_equal "Letter", ShowOffUtils.pdf_options[:page_size]
+
+ end
+
+end
+
context "ShowOff basic tests" do
def app
opt = {:verbose => false, :pres_dir => "test/fixtures/simple", :pres_file => 'showoff.json'}
ShowOff.set opt
- ShowOff.new
+ @showoff = ShowOff.new
end
setup do
View
2  test/fixtures/simple/showoff_pdf.json
@@ -0,0 +1,2 @@
+{ "name": "My Preso", "sections": [ {"section":"one"} ],
+"pdf_options" : { "page_size" : "A4", "print_media_type":false}}
View
3  test/utils_test.rb
@@ -21,10 +21,7 @@
ShowOffUtils.heroku('test')
files = Dir.glob('**/*')
content = File.read('Gemfile')
- assert_match 'bluecloth', content
- assert_match 'nokogiri', content
assert_match 'showoff', content
- assert_match 'gli', content
assert_match 'heroku', content
end
assert files.include?('config.ru')
View
6 views/header.erb
@@ -25,6 +25,12 @@
<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>
+<% end %>
+<% end %>
+
<% css_files.each do |css_file| %>
<link rel="stylesheet" href="file/<%= css_file %>" type="text/css"/>
<% end %>
View
4 views/onepage.erb
@@ -15,7 +15,7 @@
<%= inline_css(css_files) %>
<% 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') %>
+ <%= inline_js(['jquery-1.4.2.min.js', 'jquery-print.js', 'showoff.js', 'onepage.js', 'sh_main.min.js', 'core.js', 'showoffcore.js'] + @languages, 'public/js') %>
<script type="text/javascript">
$(document).ready(function() {
setupOnePage()
@@ -25,10 +25,8 @@
</head>
<body>
-
<div id="slides">
<%= @slides %>
</div>
-
</body>
</html>
Something went wrong with that request. Please try again.