Permalink
Browse files

Added example to example slides as required by CONTRIB.txt

  • Loading branch information...
1 parent e685821 commit 2f42a88e74f955c856caac3a411f1acbd80af029 @grundprinzip committed Nov 14, 2011
Showing with 26 additions and 8 deletions.
  1. +5 −0 example/four/01slide.md
  2. +6 −1 example/showoff.json
  3. +2 −0 example/simple.tpl
  4. +13 −7 lib/showoff.rb
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
20 lib/showoff.rb
@@ -175,6 +175,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
@@ -219,32 +220,36 @@ def process_markdown(name, content, static=false, pdf=false)
# Apply the template to the slide and replace the key with
# content of the slide
- md += process_content_for_replacements(template.gsub(/~~~CONTENT~~~/, content), seq, slides.size)
+ 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)
- seq += 1
+ 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, num)
- result = content.gsub("~~~CURRENT_SLIDE~~~", seq.to_s).
- gsub("~~~NUM_SLIDES~~~", num.to_s)
-
+ 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], options.showoff_config[match[1]]) if options.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">
@@ -335,6 +340,7 @@ def update_commandline_code(slide)
end
def get_slides_html(static=false, pdf=false)
+ @slide_count = 0
sections = ShowOffUtils.showoff_sections(options.pres_dir, @logger)
files = []
if sections
@@ -355,7 +361,7 @@ def get_slides_html(static=false, pdf=false)
end
end
end
- data
+ process_content_for_all_slides(data, @slide_count)
end
def inline_css(csses, pre = nil)

0 comments on commit 2f42a88

Please sign in to comment.