Permalink
Browse files

Auto detection and embedding of 'style.css' file

  • Loading branch information...
1 parent 6db1eb2 commit 4836d49f259077bcbb38620a5e0b63d52401abdb @xHire committed May 25, 2011
Showing with 19 additions and 2 deletions.
  1. +11 −1 ebookmaker.rb
  2. +8 −1 lib/html.rb
View
@@ -130,6 +130,16 @@
exit
end
+# look for CSS
+print "==> Looking for style.css file... "
+if File.exists?('style.css')
+ puts "FOUND"
+ spec[:css] = true
+else
+ puts "NOT FOUND"
+ spec[:css] = false
+end
+
# find HTML content of the book
Dir.glob('*.html') do |f|
next unless f =~ /^\d+\.html$/ || f =~ /^\d+-.*\.html$/
@@ -139,7 +149,7 @@
# process HTML stubs
print "==> Processing HTML stubs... "
-Html.process_stubs
+Html.process_stubs spec[:css]
puts "DONE"
# copy images
View
@@ -1,5 +1,5 @@
module Html
- def self.process_stubs
+ def self.process_stubs css
Dir.glob($wd.to_s + '*.html.stub') do |fn|
name = fn.sub '.stub', ''
File.open name, "w" do |f|
@@ -9,6 +9,13 @@ def self.process_stubs
# head
f.puts '<head>'
f.puts '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'
+ if css
+ f.puts '<style type="text/css">'
+ File.readlines('style.css').each do |l|
+ f.puts l.chop
+ end
+ f.puts '</style>'
+ end
f.puts '</head>'
# body

0 comments on commit 4836d49

Please sign in to comment.