arthurgeek-kitabu 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/History.txt +59 -0
  2. data/License.txt +20 -0
  3. data/README.markdown +220 -0
  4. data/Rakefile +68 -0
  5. data/TODO.txt +2 -0
  6. data/app_generators/kitabu/USAGE +5 -0
  7. data/app_generators/kitabu/kitabu_generator.rb +68 -0
  8. data/app_generators/kitabu/templates/Rakefile +3 -0
  9. data/app_generators/kitabu/templates/config.yml +8 -0
  10. data/app_generators/kitabu/templates/css/active4d.css +114 -0
  11. data/app_generators/kitabu/templates/css/blackboard.css +88 -0
  12. data/app_generators/kitabu/templates/css/dawn.css +121 -0
  13. data/app_generators/kitabu/templates/css/eiffel.css +121 -0
  14. data/app_generators/kitabu/templates/css/idle.css +62 -0
  15. data/app_generators/kitabu/templates/css/iplastic.css +80 -0
  16. data/app_generators/kitabu/templates/css/lazy.css +73 -0
  17. data/app_generators/kitabu/templates/css/mac_classic.css +123 -0
  18. data/app_generators/kitabu/templates/css/slush_poppies.css +85 -0
  19. data/app_generators/kitabu/templates/css/sunburst.css +180 -0
  20. data/app_generators/kitabu/templates/layouts/boom/layout.css +469 -0
  21. data/app_generators/kitabu/templates/layouts/boom/layout.html +37 -0
  22. data/app_generators/kitabu/templates/user.css +0 -0
  23. data/bin/kitabu +17 -0
  24. data/kitabu.gemspec +79 -0
  25. data/lib/kitabu.rb +18 -0
  26. data/lib/kitabu/base.rb +332 -0
  27. data/lib/kitabu/blackcloth.rb +165 -0
  28. data/lib/kitabu/redcloth.rb +963 -0
  29. data/lib/kitabu/tasks.rb +119 -0
  30. data/themes/active4d.css +114 -0
  31. data/themes/all_hallows_eve.css +72 -0
  32. data/themes/amy.css +147 -0
  33. data/themes/blackboard.css +88 -0
  34. data/themes/brilliance_black.css +605 -0
  35. data/themes/brilliance_dull.css +599 -0
  36. data/themes/cobalt.css +149 -0
  37. data/themes/dawn.css +121 -0
  38. data/themes/eiffel.css +121 -0
  39. data/themes/espresso_libre.css +109 -0
  40. data/themes/idle.css +62 -0
  41. data/themes/iplastic.css +80 -0
  42. data/themes/lazy.css +73 -0
  43. data/themes/mac_classic.css +123 -0
  44. data/themes/magicwb_amiga.css +104 -0
  45. data/themes/pastels_on_dark.css +188 -0
  46. data/themes/slush_poppies.css +85 -0
  47. data/themes/spacecadet.css +51 -0
  48. data/themes/sunburst.css +180 -0
  49. data/themes/twilight.css +137 -0
  50. data/themes/zenburnesque.css +91 -0
  51. metadata +144 -0
@@ -0,0 +1,59 @@
1
+ == 0.0.1 2008-06-06
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
5
+
6
+ == 0.0.2 2008-06-09
7
+ * 1 major enhancement
8
+ * Added textile support
9
+ * Bug fix
10
+ * Wrong require was throwing an error
11
+
12
+ == 0.0.3 2008-06-09
13
+ * Cleaning up the house
14
+ * README converted to Markdown
15
+ * 1 major enhancement
16
+ * Added syntax callback for Textile and Markdown
17
+
18
+ == 0.0.4 2008-06-12
19
+ * 1 major enhancement
20
+ * Added some textile helpers
21
+ * 1 bug fix
22
+ * Textile was escaping code inside <pre> blocks
23
+
24
+ == 0.0.5 2008-06-17
25
+ * 1 minor changes
26
+ * Removed frontcover and backcover jpgs
27
+ * 1 bug fix
28
+ * Line stub (__) now ignores spaces and tabs
29
+
30
+ == 0.0.6 2008-06-20
31
+ * 1 major change
32
+ * All rake tasks moved to namespace 'book'
33
+ * 1 major enhancement
34
+ * Added task book:watch
35
+
36
+ == 0.0.7 2008-06-21
37
+ * 1 major enhancement
38
+ * Added Table of Contents based on h2-h6 tags
39
+ * Added `book:titles` rake task
40
+ * 1 minor enhancement
41
+ * Added new Textile link tag (similar to Markdown)
42
+
43
+ == 0.0.8 2008-06-22
44
+ * 1 minor change
45
+ * Added Hpricot as dependency
46
+ * README updated to document highlight syntax
47
+
48
+ == 0.0.9 2008-07-25
49
+ * 1 bug fix
50
+ * Toc#to_s raised an error if book had no h2-h6 tags (thanks @rferraz)
51
+
52
+ == 0.0.10
53
+ * 2 bug fixes
54
+ * generator was ignoring directories inside chapter
55
+ * repeated titles are now numerated to keep id uniqueness
56
+
57
+ == 0.1.0
58
+ * 1 bug fix
59
+ * RedCloth 3.04 now is bundled with bookmaker until version 4 is supported
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Nando Vieira
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,220 @@
1
+ Kitabu
2
+ ======
3
+
4
+ * [http://github.com/fnando/kitabu](http://github.com/fnando/kitabu)
5
+
6
+ DESCRIPTION:
7
+ ------------
8
+
9
+ A framework for creating e-books from Markdown/Textile text markup using Ruby.
10
+ Using the Prince PDF generator, you'll be able to get high quality PDFs.
11
+ Mac users that have [Textmate](http://macromates.com) installed can have source
12
+ code highlighted with his/her favorite theme.
13
+
14
+ While Prince is too expensive (495USD for a single user license), the
15
+ free version available at [http://www.princexml.com/download/](http://www.princexml.com/download/) generates
16
+ a PDF with a small logo on the first page, which is removed when sent
17
+ to a printer.
18
+
19
+ FEATURES:
20
+ ---------
21
+
22
+ * Write PDF using Markdown or Textile text markup
23
+ * Book layout support
24
+ * Syntax highlight theme based on Textmate
25
+ * Generate a PDF with a single rake task
26
+ * Table of Contents automatically generated from chapter titles
27
+
28
+ SYNOPSIS:
29
+ ---------
30
+
31
+ Create a new book with `kitabu mybook`. Kitabu has support for book
32
+ layout and syntax highlight theme. You can specify other settings:
33
+
34
+ kitabu mybook --theme=mac_classic
35
+ kitabu mybook --layout=boom
36
+
37
+ You can check available layouts and themes with `kitabu --help`
38
+
39
+ The `kitabu` command creates a directory "mybook" with the
40
+ following structure:
41
+
42
+ - book
43
+ - config.yml
44
+ - images
45
+ - output
46
+ - Rakefile
47
+ - templates
48
+ - layout.css
49
+ - layout.html
50
+ - syntax.css
51
+ - user.css
52
+ - text
53
+
54
+ The `config.yml` file holds some information about your book; so you'll always
55
+ change it. This is the default generated file:
56
+
57
+ title: [Your Book Title]
58
+ copyright: Copyright (c) 2008 [Your Name], All Rights Reserved
59
+ authors:
60
+ - [Your Name]
61
+ - [Other Name]
62
+ subject: [Write down what your book is about]
63
+ keywords: [The keywords related to your book]
64
+ theme: eiffel
65
+
66
+ If you're writing on a different language, the `user.css` file can override all
67
+ the messages added by the `layout.css`. Examples on doing this coming soon.
68
+
69
+ Now it's time to write your book. All your book content will be placed on the
70
+ text directory. Kitabu requires you to separate your book into chapters.
71
+ A chapter is nothing but a directory that holds lots of Markdown/Textile files.
72
+ The book will be generated using every folder/file alphabetically. So be sure
73
+ to use a sequential numbering as the name. Here's a sample:
74
+
75
+ - text
76
+ - 01_Introduction
77
+ - 01\_introduction.markdown
78
+ - 02\_What\_is\_Ruby\_on\_Rails
79
+ - 01\_MVC.markdown
80
+ - 02\_DRY.markdown
81
+ - 03\_Convention\_Over\_Configuration.markdown
82
+ - 03\_Installing\_Ruby\_on\_Rails
83
+ - 01\_Installing.textile
84
+ - 02\_Mac\_OS\_X\_instructions.textile
85
+ - 03\_Windows\_instructions.markdown
86
+ - 04\_Ubuntu\_Linux\_instructions.markdown
87
+
88
+ Note that you can use Textile or Markdown at the same time. Just use the
89
+ `.markdown` or `.textile` file extension.
90
+
91
+ You'll want to see your progress eventually; it's time for you to generate
92
+ the book PDF. Just run the command `rake kitabu:pdf` and your book will be
93
+ created on the output directory.
94
+
95
+ There are other rake tasks you can use:
96
+
97
+ * `kitabu:html` - generate a html from your content
98
+ * `kitabu:syntaxes` - list all available syntaxes
99
+ * `kitabu:themes` - list all available themes
100
+ * `kitabu:titles` - list all titles and its permalinks
101
+ * `kitabu:watch` - watch `text` for any change and automatically generate html
102
+
103
+ Kitabu can generate a Table of Contents (TOC) based on your h2-h6 tags. The
104
+ h1 tag is discarded because it's meant to be the book title.
105
+
106
+ If you need to link to a specific chapter, you can use the `kitabu:titles` rake
107
+ task to know what's the permalink that you need. For example, a title
108
+ `Installing Mac OS X` will have a permalink `installing-mac-os-x` and you can
109
+ link to this chapter by writing
110
+ `"See more on Installing Mac OS X":#installing-mac-os-x` when using
111
+ Textile.
112
+
113
+ To generate the TOC, you need to print a variable called `toc`, using the eRb
114
+ tag `<%= toc %>`.
115
+
116
+ Syntax Highlighting (Mac OS X)
117
+ ==============================
118
+
119
+ If you're using Textile, all you need to do is use the tag `syntax.`. For
120
+ example, to highlight a code added right into your text, just do something like
121
+
122
+ syntax(ruby_on_rails). class User < ActiveRecord::Base
123
+ validates_presence_of :login, :password, :email
124
+ __
125
+ validates_uniqueness_of :login, :email
126
+ end
127
+
128
+ To keep multiple line breaks into a single code block, add a line `__`;
129
+ Kitabu will replace it when generating the HTML file.
130
+
131
+ If you want to highlight a file, you need to place it into the `code`
132
+ directory and call it like this:
133
+
134
+ syntax(ruby_on_rails). some_file.rb
135
+
136
+ You can specify the lines you want to highlight; the example below will
137
+ highlight lines 10-17 from some_file.rb.
138
+
139
+ syntax(ruby_on_rails 10,17). some_file.rb
140
+
141
+ You can also specify named blocks to highlight. Named blocks are identified
142
+ by `#begin` and `#end` marks. If some_file.rb has the following code
143
+
144
+ require "rubygems"
145
+ require "hpricot"
146
+ require "open"
147
+
148
+ # begin: get_all_h2_tags
149
+ doc = Hpricot(open('http://simplesideias.com.br'))
150
+ (doc/"h2").each {|h2| puts h2.inner_text }
151
+ # end: get_all_h2_tags
152
+
153
+ you can get the code between `get_all_h2_tags` using
154
+
155
+ syntax(ruby#get_all_h2_tags). some_file.rb
156
+
157
+ *Note:* Makdown uses the same syntax above. You just need to indent your code
158
+ (as usual) and add the `syntax.` thing as the first line.
159
+
160
+ INSTALL:
161
+ --------
162
+
163
+ sudo gem install fnando-kitabu --source http://gems.github.com
164
+
165
+ or, if you have problem
166
+
167
+ git clone git://github.com/fnando/kitabu.git
168
+ cd kitabu
169
+ gem build kitabu.gemspec
170
+ sudo gem install kitabu
171
+
172
+ If you're a Mac user and have Textmate installed, you can
173
+ generate HTML from your source code with syntax highlight,
174
+ the same way you see in Textmate. First, you need to install
175
+ Oniguruma regular expression library that can be found at
176
+ [http://www.geocities.jp/kosako3/oniguruma/](http://www.geocities.jp/kosako3/oniguruma/)
177
+
178
+ Then, you need to install the Ultraviolet gem.
179
+
180
+ sudo gem install ultraviolet
181
+
182
+ REFERENCES:
183
+ -----------
184
+
185
+ - Textile: [http://hobix.com/textile/](http://hobix.com/textile/)
186
+ - Markdown: [http://daringfireball.net/projects/markdown/syntax](http://daringfireball.net/projects/markdown/syntax)
187
+
188
+ MAINTAINER
189
+ ----------
190
+
191
+ * Nando Vieira ([http://simplesideias.com.br](http://simplesideias.com.br))
192
+
193
+ CONTRIBUTORS
194
+ ------------
195
+
196
+ * Arthur Zapparoli ([http://arthurgeek.net](http://arthurgeek.net))
197
+
198
+ LICENSE:
199
+ --------
200
+
201
+ (The MIT License)
202
+
203
+ Permission is hereby granted, free of charge, to any person obtaining
204
+ a copy of this software and associated documentation files (the
205
+ 'Software'), to deal in the Software without restriction, including
206
+ without limitation the rights to use, copy, modify, merge, publish,
207
+ distribute, sublicense, and/or sell copies of the Software, and to
208
+ permit persons to whom the Software is furnished to do so, subject to
209
+ the following conditions:
210
+
211
+ The above copyright notice and this permission notice shall be
212
+ included in all copies or substantial portions of the Software.
213
+
214
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
215
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
216
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
217
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
218
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
219
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
220
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,68 @@
1
+ require 'rake'
2
+
3
+ PKG_FILES = %w( Rakefile kitabu.gemspec History.txt License.txt README.markdown TODO.txt ) + Dir["{app_generators,bin,lib,themes}/**/*"]
4
+
5
+ spec = Gem::Specification.new do |s|
6
+ s.name = "kitabu"
7
+ s.version = "0.2.0"
8
+ s.summary = "A framework for creating e-books from Markdown/Textile text markup using Ruby."
9
+ s.authors = ["Nando Vieira"]
10
+ s.email = ["fnando.vieira@gmail.com"]
11
+ s.homepage = "http://github.com/fnando/kitabu"
12
+ s.description = "A framework for creating e-books from Markdown/Textile text markup using Ruby. Using the Prince PDF generator, you'll be able to get high quality PDFs. Mac users that have Textmate installed can have source code highlighted with his favorite theme."
13
+ s.has_rdoc = false
14
+ s.files = PKG_FILES
15
+ s.bindir = "bin"
16
+ s.executables = "kitabu"
17
+
18
+ # Dependencies
19
+ s.add_dependency "rubigen"
20
+ s.add_dependency "discount"
21
+ s.add_dependency "hpricot"
22
+ s.add_dependency "unicode"
23
+ # Requirements
24
+ s.requirements << "Install the Oniguruma RE library and ultraviolet gem to get Syntax Highlighting (only for TextMate users)"
25
+ end
26
+
27
+ namespace :gem do
28
+ # Thanks to the Merb project for this code.
29
+ desc "Update Github Gemspec"
30
+ task :update_gemspec do
31
+ skip_fields = %w(new_platform original_platform specification_version loaded required_ruby_version rubygems_version platform )
32
+
33
+ result = "# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!\n"
34
+ result << "# RUN : 'rake gem:update_gemspec'\n\n"
35
+ result << "Gem::Specification.new do |s|\n"
36
+
37
+ spec.instance_variables.each do |ivar|
38
+ value = spec.instance_variable_get(ivar)
39
+ name = ivar.split("@").last
40
+ value = Time.now if name == "date"
41
+
42
+ next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
43
+ if name == "dependencies"
44
+ value.each do |d|
45
+ dep, *ver = d.to_s.split(" ")
46
+ result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "").gsub(", runtime", "")}\n"
47
+ end
48
+ else
49
+ case value
50
+ when Array
51
+ value = name != "files" ? value.inspect : value.inspect.split(",").join(",\n")
52
+ when FalseClass
53
+ when TrueClass
54
+ when Fixnum
55
+ when String
56
+ value = value.inspect
57
+ else
58
+ value = value.to_s.inspect
59
+ end
60
+ result << " s.#{name} = #{value}\n"
61
+ end
62
+ end
63
+
64
+ result << "end"
65
+ File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
66
+ end
67
+
68
+ end
@@ -0,0 +1,2 @@
1
+ - Create additional layouts
2
+ - Support Linux and Windows (Linux is probably already supported, but need testing to be sure)
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,68 @@
1
+ require 'kitabu'
2
+
3
+ class KitabuGenerator < RubiGen::Base
4
+
5
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
6
+ Config::CONFIG['ruby_install_name'])
7
+
8
+ default_options :theme => Kitabu::Base.default_theme,
9
+ :layout => Kitabu::Base.default_layout
10
+ attr_reader :theme, :layout
11
+
12
+ def initialize(runtime_args, runtime_options = {})
13
+ super
14
+ usage if args.empty?
15
+ @destination_root = File.expand_path(args.shift)
16
+ @name = base_name
17
+ extract_options
18
+ end
19
+
20
+ def manifest
21
+ record do |m|
22
+ m.directory ''
23
+ BASEDIRS.each { |path| m.directory path }
24
+
25
+ m.template "Rakefile", "Rakefile"
26
+ m.template "user.css", "templates/user.css"
27
+ m.template "layouts/#{@layout}/layout.css", "templates/layout.css"
28
+ m.template "layouts/#{@layout}/layout.html", "templates/layout.html"
29
+ m.template "css/#{@theme}.css", "templates/syntax.css"
30
+ m.template "config.yml", "config.yml", :assigns => {:theme => @theme}
31
+ end
32
+ end
33
+
34
+ protected
35
+ def banner
36
+ <<-EOS
37
+ The 'kitabu' command creates a new book with a default
38
+ directory structure at the path you specify.
39
+
40
+ USAGE: #{spec.name} /path/to/your/book [options]
41
+ EOS
42
+ end
43
+
44
+ def add_options!(opts)
45
+ opts.separator ''
46
+ opts.separator 'Options:'
47
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
48
+ opts.on("--layout=LAYOUT_NAME", String,
49
+ "Define the book layout (#{Kitabu::Base.layouts.join('|')})",
50
+ "Default: #{Kitabu::Base.default_layout}") { |x| options[:layout] = x }
51
+ opts.on("--theme=THEME_NAME", String,
52
+ "Define the syntax highlight theme (#{Kitabu::Base.themes.join('|')})",
53
+ "Default: #{Kitabu::Base.default_theme}") { |x| options[:theme] = x } if RUBY_PLATFORM =~ /darwin/
54
+ end
55
+
56
+ def extract_options
57
+ @theme = options[:theme]
58
+ @layout = options[:layout]
59
+ end
60
+
61
+ BASEDIRS = %w(
62
+ templates
63
+ text
64
+ output
65
+ images
66
+ code
67
+ )
68
+ end