Skip to content

Commit

Permalink
Just reimplemented the whole thing.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnando committed Dec 23, 2010
1 parent 3f4bbf8 commit 52873f7
Show file tree
Hide file tree
Showing 571 changed files with 8,323 additions and 83,772 deletions.
8 changes: 4 additions & 4 deletions .gitignore
@@ -1,4 +1,4 @@
*.gem
spec/tmp/*
spec/fixtures/rails-guides/output
*.log
.DS_Store
pkg
tmp
Gemfile.lock
1 change: 1 addition & 0 deletions .rvmrc
@@ -0,0 +1 @@
rvm 1.9.2@kitabu
2 changes: 2 additions & 0 deletions Gemfile
@@ -0,0 +1,2 @@
source :rubygems
gemspec
68 changes: 0 additions & 68 deletions README.markdown

This file was deleted.

105 changes: 105 additions & 0 deletions README.rdoc
@@ -0,0 +1,105 @@
= kitabu

While Prince is too expensive (495USD for a single user license), the free version available at http://www.princexml.com/download/ generates a PDF with a small logo on the first page, which is removed when sent to a printer.

== Features

* Write PDF using Markdown, Textile, RDoc or plain HTML
* Book layout support
* Syntax highlight theme based on Textmate
* Generate a HTML, PDF and e-Pub files
* Table of Contents automatically generated from chapter titles

== Installation

To install Kitabu, you’ll need a working Ruby installation with Rubygems.
If you’re cool with it, just run the following command to install it.

gem install kitabu --pre

== Usage

To create a new e-book, just run

$ kitabu new mybook

This command creates a directory <tt>mybook</tt> with the following structure:

* mypdf
* code
* config
* kitabu.yml
* helper.rb
* images
* output
* Rakefile
* templates
* layout.css
* layout.html
* syntax.css
* user.css
* text

The <tt>config.yml</tt> file holds some information about your book; so you'll always change it.

Now it's time to write your e-book. All your book content will be placed on the text directory. Kitabu requires you to separate your book into chapters. A chapter is nothing but a directory that holds lots of text files. The e-book will be generated using every folder/file alphabetically. So be sure to use a sequential numbering as the name. Here's a sample:

* text
* 01_Introduction
* 01_introduction.markdown
* 02_What_is_Ruby_on_Rails
* 01_MVC.html
* 02_DRY.rdoc
* 03_Convention_Over_Configuration.markdown
* 03_Installing_Ruby_on_Rails
* 01_Installing.textile
* 02_Mac_OS_X_instructions.textile
* 03_Windows_instructions.markdown
* 04_Ubuntu_Linux_instructions.markdown

If you prefer, you can add a chapter per file:

* text
* 01_Introduction.markdown
* 02_What_is_Ruby_on_Rails.markdown
* 03_Installing_Ruby_on_Rails.markdown

Note that you can use any format you want at the same time. Just use one of the following extensions: <tt>.html</tt>, <tt>.markdown</tt>, <tt>.mkdn</tt>, <tt>.textile</tt> or <tt>.rdoc</tt>.

You'll want to see your progress eventually; it's time for you to generate the book PDF. Just run the command <tt>kitabu export</tt> and your book will be created on the <tt>output</tt> directory.

== Samples

I published two PDFs (portuguese only) exploring lots of features. Check it out:

* http://howtocode.com.br/downloads/rdoc.pdf
* http://howtocode.com.br/downloads/rails-application-templates.pdf

There's also an (probably) outdated Rails Guide section

== Maintainer

* Nando Vieira (http://nandovieira.com.br)

== License

(The MIT License)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 changes: 4 additions & 36 deletions Rakefile
@@ -1,37 +1,5 @@
require "rake"
require "jeweler"
require File.dirname(__FILE__) + "/lib/kitabu"
require "bundler"
Bundler::GemHelper.install_tasks

JEWEL = Jeweler::Tasks.new do |gem|
gem.name = "kitabu"
gem.version = ENV["VERSION"] || Kitabu::VERSION
gem.summary = "A framework for creating e-books from Markdown/Textile text markup using Ruby."
gem.description = <<-TXT
A framework for creating e-books from Markdown/Textile text markup using Ruby.
With Prince PDF generator, you'll be able to get high quality PDFs.
TXT

gem.authors = ["Nando Vieira"]
gem.email = "fnando.vieira@gmail.com"
gem.homepage = "http://fnando.github.com/public/kitabu.html"

gem.has_rdoc = false
gem.files = %w(Rakefile kitabu.gemspec VERSION README.markdown) + Dir["{bin,templates,lib}/**/*"]
gem.bindir = "bin"
gem.executables = "kitabu"

gem.add_dependency "activesupport", ">=2.3"
end

desc "Build and install the gem"
task :package => :build_gem do
FileUtils.cp "VERSION", File.expand_path("~/Sites/github/fnando.github.com/views/version/_#{JEWEL.gemspec.name}.haml")
end

desc "Generate gemspec and build gem"
task :build_gem do
File.open("VERSION", "w+") {|f| f << (ENV["VERSION"] || Kitabu::VERSION.to_s) }

Rake::Task["gemspec"].invoke
Rake::Task["build"].invoke
end
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

7 changes: 2 additions & 5 deletions bin/kitabu 100644 → 100755
@@ -1,8 +1,5 @@
#!/usr/bin/env ruby
# -*- mode: ruby -*-

require "rubygems"
require "kitabu"
require "kitabu/command"
require "optparse"

Kitabu::Command.run!
Kitabu::Cli.start
29 changes: 29 additions & 0 deletions examples/RailsGuides/config/helper.rb
@@ -0,0 +1,29 @@
# Put any Ruby code in here.
# Here's an example on how you can extend RedCloth (Textile) with new formatters.
#
# module RedCloth
# module Formatters
# module HTML
# def attention(options)
# %[<p class="attention">#{options[:text]}</p>]
# end
# end
# end
# end
#
# Then you can just use `attention. This is an important note!` on your text.
#
# You can add inline formatters as well. The approach is slightly different,
# but pretty straightforward.
#
# Add your formatter to `RedCloth::INLINE_FORMATTERS` and implement the method, making sure that it
# replaces the content using `String#gsub!`.
#
# module RedCloth
# def my_formatter(text)
# text.gsub!(/Hello/, "Hi")
# end
# end
#
# RedCloth::INLINE_FORMATTERS << :my_formatter
#
48 changes: 48 additions & 0 deletions examples/RailsGuides/config/kitabu.yml
@@ -0,0 +1,48 @@
# The book's title. Will be used everywhere!
title: "Rails Guides: Getting Started"

# The book's language.
language: en

# Your book copyright info.
# Here's some examples:
#
# Copyright 2010 by Nando Vieira.
# Copyright 2010 by Nando Vieira. This work is licensed under MIT License.
# This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
# This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
# This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
#
copyright: "Copyright (C) 2010 Rails Documentation Team."

# Who's publishing this book.
publisher: "Nando Vieira"

# When this book was published.
published_at: "2010-12-19"

# Some book description.
subject: "These guides are designed to make you immediately productive with Rails, and to help you understand how all of the pieces fit together."

# Some keywords that identify this book.
keywords: "[Your book keywords (comma-separated)]"

# Some unique identification. Works great with your domain
# like `http://yourbook.example.com`.
uid: "b731cad288c08e875982ebc3d30f9b2d"

# Your book identification like ISBN or ISSN.
identifier:
id: "http://yourbook.example.com"
type: "URL" # can be ISBN, ISSN or URL

# This book authors.
authors:
- "Rails Documentation Team"

# The theme that will be used for source
# code syntax highlighting.
theme: idle

# The base URL from your source code.
base_url: http://example.com
Binary file added examples/RailsGuides/images/challenge.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/RailsGuides/images/posts_index.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/RailsGuides/images/rails_welcome.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/RailsGuides/output/RailsGuides.epub
Binary file not shown.

0 comments on commit 52873f7

Please sign in to comment.