Skip to content
This repository
Newer
Older
100644 50 lines (43 sloc) 1.185 kb
f79cd1f6 »
2009-05-10 Rakefile: Copy images to output/; tweak logic.
1 SOURCE_HTML = FileList['text/**/*.html']
2 IMAGES = FileList['images/*']
dc815dca »
2009-05-10 Rakefile: constantised name of HTML output file.
3 OUTPUT_HTML = 'output/all.html'
4663b0b2 »
2009-05-05 Created Rakefile for generating PDF.
4
f79cd1f6 »
2009-05-10 Rakefile: Copy images to output/; tweak logic.
5 directory "output"
6
9f5cf905 »
2009-05-10 Rakefile: add descriptions for tasks.
7 desc "Copy images to output directory"
f79cd1f6 »
2009-05-10 Rakefile: Copy images to output/; tweak logic.
8 task :images => :output
9 task :images => IMAGES do |t|
10 IMAGES.each do |image|
11 cp image, "output"
12 end
13 end
14
9f5cf905 »
2009-05-10 Rakefile: add descriptions for tasks.
15 desc "Combine source HTML into single HTML file"
a341bdf4 »
2009-05-10 Rakefile: Check for broken links when making PDF
16 task OUTPUT_HTML => [:output, :images, :ilinks]
bd8beb06 »
2009-05-10 Rakefile: use SOURCE_HTML consistently.
17 file OUTPUT_HTML => SOURCE_HTML do |t|
4663b0b2 »
2009-05-05 Created Rakefile for generating PDF.
18 File.open(t.name,'w') do |out|
f79cd1f6 »
2009-05-10 Rakefile: Copy images to output/; tweak logic.
19 SOURCE_HTML.sort.each do |source|
4663b0b2 »
2009-05-05 Created Rakefile for generating PDF.
20 out.puts File.open(source).read
21 end
22 end
23 end
24
dc815dca »
2009-05-10 Rakefile: constantised name of HTML output file.
25 file 'output/vim-recipes.pdf' => OUTPUT_HTML do |t|
4663b0b2 »
2009-05-05 Created Rakefile for generating PDF.
26 system("prince #{t.prerequisites.first} #{t.name}")
27 end
28
9f5cf905 »
2009-05-10 Rakefile: add descriptions for tasks.
29 desc "Generate the PDF"
f79cd1f6 »
2009-05-10 Rakefile: Copy images to output/; tweak logic.
30 task :pdf => 'output/vim-recipes.pdf'
5871e9e2 »
2009-05-09 Add :ilinks task to display broken internal links.
31
9f5cf905 »
2009-05-10 Rakefile: add descriptions for tasks.
32 desc "Check for broken internal links"
a341bdf4 »
2009-05-10 Rakefile: Check for broken links when making PDF
33 task :ilinks do |t|
5871e9e2 »
2009-05-09 Add :ilinks task to display broken internal links.
34 require 'hpricot'
35 target = {}
36 source = {}
bd8beb06 »
2009-05-10 Rakefile: use SOURCE_HTML consistently.
37 SOURCE_HTML.each do |file|
5871e9e2 »
2009-05-09 Add :ilinks task to display broken internal links.
38 doc = Hpricot(File.open(file, 'r'))
39 doc.search("a[@href*='#']").each do |a|
40 source[a['href'][/[^#]+/]] = file
41 end
42 doc.search("*[@id]").each do |e|
43 target[e['id']] = 1
44 end
45 end
46 source.keys.each do |s|
47 $stderr.puts "Link #{s} from #{source[s]} is broken" unless target.key? s
48 end
49 end
Something went wrong with that request. Please try again.