Permalink
Browse files

much nicer looking output now

  • Loading branch information...
1 parent cba8859 commit 9da55b89721bef0d465bba44c1c1f43a4e1cc2b6 @schacon schacon committed Jan 20, 2011
Showing with 346 additions and 37 deletions.
  1. +3 −1 TODO.txt
  2. +28 −13 lib/git-scribe.rb
  3. +23 −19 site/default/index.html
  4. +281 −0 site/default/master.css
  5. +11 −4 site/default/page.html
View
@@ -1,15 +1,17 @@
To-Do List
=============
-* multi-page site
* custom site layouts
* auto-links to pdf/epub/mobi in site
* custom/alternate themes (stylesheets)
* cover page for site (author, about, etc)
* book cover (w/template)
* github pages publishing
* checking for proper tools
+* book search
* math formula
+* generate different languages from branches/tags (site, epub, mobi)
+* docbook import / direct from docbook
* workflow
- review / copy editing
View
@@ -132,7 +132,7 @@ def do_site
section.children.each do |item|
if item.name == 'dt' # section
c += 1
- sections[c] ||= {}
+ sections[c] ||= {'number' => c}
link = item.css('a').first
sections[c]['title'] = title = link.text
sections[c]['href'] = href = link['href']
@@ -145,7 +145,7 @@ def do_site
end
if item.name == 'dd' # subsection
item.css('dt').each do |sub|
- link = item.css('a').first
+ link = sub.css('a').first
data = {}
data['title'] = title = link.text
data['href'] = href = link['href']
@@ -157,23 +157,35 @@ def do_site
puts
end
+ pp sections
+
book_title = html.css('head > title').text
- content = html.css('div.section').first.to_html
- header = html.css('div.navheader').to_html
- footer = html.css('div.navfooter').to_html
+ content = html.css('body > div')[1]
+ content.css('.toc').first.remove
+ content = content.inner_html
+
+ puts content
+ sections.each do |s|
+ content.gsub!(s['href'], s['link'])
+ end
template_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'site', 'default'))
+
+ # copy the template files in
+ files = Dir.glob(template_dir + '/*')
+ FileUtils.cp_r files, '.'
+
Liquid::Template.file_system = Liquid::LocalFileSystem.new(template_dir)
index_template = Liquid::Template.parse(File.read(File.join(template_dir, 'index.html')))
page_template = Liquid::Template.parse(File.read(File.join(template_dir, 'page.html')))
# write the index page
+ main_data = {
+ 'book_title' => book_title,
+ 'sections' => sections
+ }
File.open('index.html', 'w+') do |f|
- data = {
- 'title' => book_title,
- 'sections' => sections
- }
- f.puts index_template.render( data )
+ f.puts index_template.render( main_data )
end
# write the title page
@@ -186,6 +198,7 @@ def do_site
'next' => sections[1],
'content' => content
}
+ data.merge!(main_data)
f.puts page_template.render( data )
end
@@ -194,11 +207,12 @@ def do_site
if i > 0 # skip title page
source = File.read(section['href'])
- puts source
-
html = Nokogiri::HTML.parse(source, nil, 'utf-8')
- content = html.css('div.section').first.to_html
+ content = html.css('body > div')[1].to_html
+ sections.each do |s|
+ content.gsub!(s['href'], s['link'])
+ end
File.open(section['link'], 'w+') do |f|
next_section = nil
@@ -213,6 +227,7 @@ def do_site
'next' => next_section,
'content' => content
}
+ data.merge!(main_data)
f.puts page_template.render( data )
end
#File.unlink(section['href'])
View
@@ -2,28 +2,32 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <link rel="stylesheet" href="stylesheets/handbookish.css" type="text/css" />
- <title>{{title}}</title>
+ <link rel="stylesheet" href="master.css" type="text/css" />
+ <title>{{book_title}}</title>
</head>
<body>
- <h1>{{title}}</h1>
- <hr/>
- <div>
- {{toc}}
- </div>
- <div>
- {% for section in sections %}
- <li>
+ <div class="content">
+ <h1>{{book_title}}</h1>
+ <hr/>
+ <div>
+ {{toc}}
+ </div>
+ <div id="toc">
+ <ul>
+ {% for section in sections %}
+ <li>
<h2><a href="{{ section.link }}">{{section.title}}</a></h2>
- {% if section.sub %}
- <ul>
- {% for sub in section.sub %}
- <li><a href="{{ sub.link }}">{{ sub.title }}</a></li>
- {% endfor %}
- </ul>
- {% endif %}
- </li>
- {% endfor %}
+ {% if section.sub %}
+ <ul>
+ {% for sub in section.sub %}
+ <li><a href="{{ sub.link }}">{{ sub.title }}</a></li>
+ {% endfor %}
+ </ul>
+ {% endif %}
+ </li>
+ {% endfor %}
+ </ul>
+ </div>
</div>
<hr/>
<a href="book.mobi">Mobi</a>
Oops, something went wrong.

0 comments on commit 9da55b8

Please sign in to comment.