gwynm (owner)

Forks

Revisions

gist: 205883 Download_button fork
public
Public Clone URL: git://gist.github.com/205883.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/ruby
require 'rubygems'
require 'nokogiri'
require 'cgi'
 
zipfile = ARGV[0]
`mkdir /tmp/keycutter`
`cp #{zipfile} /tmp/keycutter/keycutter.zip`
`cd /tmp/keycutter && unzip -o keycutter.zip`
doc = Nokogiri::XML(open('/tmp/keycutter/index.apxl'))
slides = []
doc.xpath('//key:slide').each do |slide|
  data = ""
  slide.xpath('key:notes//sf:p').each do |notes_para|
    data += notes_para.text + " \n"
  end
  slides << data
end
 
File.open("output.html","w") do |f|
  f.puts "<html>
<head>
<style>
.note {
border:2px solid black;
padding:3px;
margin:3px;
width:30%;
height:7.2cm;
float:left;
font-size:9pt;
overflow:hidden;
}
.noteid {
font-size:14pt;
font-weight:bold;
float:right;
}
.breaker {
page-break-before:always;
height:2px;
clear:both;
}
</style>
</head>
<body>"
 
count = 1
slides.each do |data|
  f.puts "<div class='note'><div class='noteid'>#{count}</div>"
  f.puts CGI.escapeHTML(data).gsub("\n","<br/>")
  f.puts "</div>"
  f.puts "<div class='breaker'>&nbsp;</div>" if (count % 9) == 0
  count += 1
end
 
f.puts "</body>"
puts "Wrote #{count-1} slides"
end
`open output.html`