S9-Style Slideshow in Sputnik
S9 is a tool written in Ruby
- Converts Markdown into a web presentation
- Requires FullerScreen
- https://addons.mozilla.org/en-US/firefox/addon/4650
- See http://slideshow.rubyforge.org/
We Likes It
...but not so excited about Ruby
Let's do the same in Sputnik
(But kudos to S9 for showing us the way!)
Make the Template
- Look at the HTML generated by S9
- Turn it into a Cosmo template
- Save it to http://sputnik.freewisdom.org/en/_templates_for_s9
- set "prototype" to "@Lua_Config"
The only complicated part is the $do_slides:
$do_slides[=[
<div class='slide'>
<h1>$heading</h1>
$content
</div>
]=]
Write an Action
We'll also need an "action".
It's simple: most of the work is done by markdown
module(..., package.seeall)
actions = {}
actions.slides = function(node, request, sputnik)
require"markdown"
local delim = "@@@@@@@@@@"
local html = ("\n"..markdown(node.content).."<h2>"):gsub("<h2>", "\n"..delim.."\n<h2>").."\n"..delim
return cosmo.f(node.templates.SLIDESHOW){
title = node.title,
do_slides = function()
for heading, content in html:gmatch("\n<h2>(.-)</h2>(.-)\n"..delim) do
cosmo.yield{heading=heading, content=content}
end
end
}
end
Save this to ~/sputnik/share/lua/5.1/sputnik/actions/s9.lua
Make a Slide Node
Let's make a node "Slideshow_Demo". (Yes, this one.)
- Put the markdown-formatted presentation in the body.
- Use H2 (
##) as slide titles
- Use H2 (
- Set
templatesto_templates_for_s9 - Set
actionstoslides="s9.slides"
Save.
Check that Slideshow_Demo displays fine. Now try "Slideshow_Demo.slides".
(Remember that you need "FullerScreen" - https://addons.mozilla.org/en-US/firefox/addon/4650)
Things to Try Next
We can also create a prototype
(Handy if we'll be making many slideshows).
- Create a node "@Slideshow"
- Set
templatesto_templates_for_s9 - Set
actionstoslides="s9.slides"
Then create new slideshow nodes by just setting prototype to `@Slideshow'