git-scribe 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
1
  example/output
2
2
  output
3
+ .DS_Store
4
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ git-scribe (0.0.9)
5
+ liquid
6
+ nokogiri
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ liquid (2.2.2)
12
+ nokogiri (1.5.0)
13
+ rake (0.9.2)
14
+ test-unit (2.3.2)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ git-scribe!
21
+ rake
22
+ test-unit
@@ -55,6 +55,11 @@ Check if you have everything installed properly for local generation with `check
55
55
  highlighting - ok
56
56
  fop - ok
57
57
 
58
+ If you are on OSX and using Homebrew http://mxcl.github.com/homebrew/ you can install dependencies easily:
59
+
60
+ $ brew install asciidoc source-highlight fop
61
+ $ brew install https://raw.github.com/adamv/homebrew-alt/master/non-free/kindlegen.rb
62
+
58
63
  Initialize a new book with `init`:
59
64
 
60
65
  $ git scribe init
data/Rakefile CHANGED
@@ -1,31 +1,9 @@
1
- def command?(command)
2
- system("type #{command} > /dev/null 2>&1")
3
- end
4
-
5
- #
6
- # Tests
7
- #
1
+ require 'rake/testtask'
8
2
 
9
3
  task :default => :test
10
4
 
11
- desc "Run the test suite"
12
- task :test do
13
- sh('turn test/**/*_test.rb')
14
- end
15
-
16
-
17
- #
18
- # Publishing
19
- #
20
-
21
- desc "Push a new version to Gemcutter"
22
- task :publish do
23
- require 'git-scribe/version'
24
-
25
- sh "gem build git-scribe.gemspec"
26
- sh "gem push git-scribe-#{GitScribe::Version}.gem"
27
- sh "git tag v#{GitScribe::Version}"
28
- sh "git push origin v#{GitScribe::Version}"
29
- sh "git push origin master"
5
+ Rake::TestTask.new do |t|
6
+ t.libs << "test"
7
+ t.test_files = FileList['test/*_test.rb']
8
+ t.verbose = true
30
9
  end
31
-
data/TODO.txt CHANGED
@@ -1,17 +1,7 @@
1
1
  To-Do List
2
2
  =============
3
3
 
4
- * git-init after git scribe init
5
-
6
- * custom site layouts
7
- * custom/alternate themes (stylesheets)
8
- * cover page for site (author, about, etc)
9
- * book cover (w/template)
10
- * generate hashes for generated assets and do not regenerate them unneccesarily
11
-
12
- * book search
13
- * math formula
14
- * generate different languages from branches/tags (site, epub, mobi)
4
+ * move to GLI?
15
5
 
16
6
  * workflow
17
7
  - review / copy editing
@@ -19,10 +9,9 @@ To-Do List
19
9
  - edition release
20
10
  - maint branches (pegging to software revs)
21
11
 
22
- * amazon/ibooks/lulu integration
23
-
12
+ * book search
24
13
  * site comments
25
14
  * github-side generation
26
- * external auto-publishing / monetization (?)
27
15
  * docbook import / direct from docbook
28
-
16
+ * external auto-publishing / monetization (?)
17
+ - amazon/ibooks/lulu integration
@@ -16,6 +16,10 @@
16
16
  <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"/>
17
17
  <xsl:import href="common.xsl"/>
18
18
 
19
+ <xsl:import href="fo/verbatim.xsl"/>
20
+ <xsl:param name="highlight.source" select="1"></xsl:param>
21
+ <xsl:param name="highlight.xslthl.config">file:///usr/local/Cellar/docbook/5.0/docbook/xsl/1.76.1/highlighting/xslthl-config.xml</xsl:param>
22
+
19
23
  <xsl:param name="fop1.extensions" select="1" />
20
24
  <xsl:param name="variablelist.as.blocks" select="1" />
21
25
 
@@ -15,18 +15,10 @@
15
15
 
16
16
  ******************************************************************** -->
17
17
 
18
- <xsl:template match='xslthl:keyword' mode="xslthl">
19
- <fo:inline font-weight="bold"><xsl:apply-templates mode="xslthl"/></fo:inline>
20
- </xsl:template>
21
-
22
18
  <xsl:template match='xslthl:string' mode="xslthl">
23
19
  <fo:inline font-weight="bold" font-style="italic"><xsl:apply-templates mode="xslthl"/></fo:inline>
24
20
  </xsl:template>
25
21
 
26
- <xsl:template match='xslthl:comment' mode="xslthl">
27
- <fo:inline font-style="italic"><xsl:apply-templates mode="xslthl"/></fo:inline>
28
- </xsl:template>
29
-
30
22
  <xsl:template match='xslthl:tag' mode="xslthl">
31
23
  <fo:inline font-weight="bold"><xsl:apply-templates mode="xslthl"/></fo:inline>
32
24
  </xsl:template>
@@ -39,6 +31,14 @@
39
31
  <fo:inline font-weight="bold"><xsl:apply-templates mode="xslthl"/></fo:inline>
40
32
  </xsl:template>
41
33
 
34
+ <xsl:template match='xslthl:keyword' mode="xslthl">
35
+ <fo:inline font-weight="bold" color="blue"><xsl:apply-templates mode="xslthl"/></fo:inline>
36
+ </xsl:template>
37
+
38
+ <xsl:template match='xslthl:comment' mode="xslthl">
39
+ <fo:inline font-style="italic" color="grey"><xsl:apply-templates mode="xslthl"/></fo:inline>
40
+ </xsl:template>
41
+
42
42
  <!--
43
43
  <xsl:template match='xslthl:html'>
44
44
  <span style='background:#AFF'><font color='blue'><xsl:apply-templates/></font></span>
@@ -191,8 +191,8 @@ set toc,title
191
191
  <xsl:param name="graphicsize.use.img.src.path" select="0"/>
192
192
  <xsl:param name="header.rule" select="1"/>
193
193
  <xsl:param name="highlight.default.language"/>
194
- <xsl:param name="highlight.source" select="0"/>
195
- <xsl:param name="highlight.xslthl.config"/>
194
+ <xsl:param name="highlight.source" select="1"/>
195
+ <xsl:param name="highlight.xslthl.config">file:///usr/local/Cellar/docbook/5.0/docbook/xsl/1.76.1/highlighting/xslthl-config.xml</xsl:param>
196
196
  <xsl:param name="html.append"/>
197
197
  <xsl:param name="html.base"/>
198
198
  <xsl:param name="html.cellpadding"/>
@@ -22,6 +22,8 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_dependency('nokogiri')
24
24
  s.add_dependency('liquid')
25
+ s.add_development_dependency("rake")
26
+ s.add_development_dependency("test-unit")
25
27
 
26
28
  s.executables = %w( git-scribe )
27
29
 
@@ -42,7 +42,7 @@ class GitScribe
42
42
 
43
43
 
44
44
  # check for fop
45
- if !check_can_run('fop -version')
45
+ if !check_can_run('fop -v -out list')
46
46
  info "fop is not present, please install for PDF generation"
47
47
  status[:fop] = false
48
48
  else
@@ -65,7 +65,7 @@ class GitScribe
65
65
 
66
66
  def check_can_run(command)
67
67
  `#{command} 2>&1`
68
- $?.exitstatus == 0
68
+ $?.success?
69
69
  end
70
70
  end
71
71
  end
@@ -42,7 +42,7 @@ class GitScribe
42
42
  end
43
43
 
44
44
  def a2x_wss(type)
45
- a2x(type) + " --stylesheet=stylesheets/handbookish.css"
45
+ a2x(type) + " --stylesheet=stylesheets/scribe.css"
46
46
  end
47
47
 
48
48
  def do_docbook
@@ -57,17 +57,17 @@ class GitScribe
57
57
  def do_pdf
58
58
  info "GENERATING PDF"
59
59
  do_docbook
60
- # TODO: syntax highlighting (fop?)
61
- strparams = {'callout.graphics' => 0,
62
- 'navig.graphics' => 0,
63
- 'admon.textlabel' => 1,
64
- 'admon.graphics' => 0}
65
- param = strparams.map { |k, v| "--stringparam #{k} #{v}" }.join(' ')
66
- cmd = "xsltproc --nonet #{param} --output #{local('book.fo')} #{base('docbook-xsl/fo.xsl')} #{local('book.xml')}"
67
- ex(cmd)
68
- cmd = "fop -fo #{local('book.fo')} -pdf #{local('book.pdf')}"
69
- ex(cmd)
70
- if $?.exitstatus == 0
60
+
61
+ java_options = {
62
+ 'callout.graphics' => 0,
63
+ 'navig.graphics' => 0,
64
+ 'admon.textlabel' => 1,
65
+ 'admon.graphics' => 0,
66
+ }
67
+ run_xslt "-o #{local('book.fo')} #{local('book.xml')} #{base('docbook-xsl/fo.xsl')}", java_options
68
+ ex "fop -fo #{local('book.fo')} -pdf #{local('book.pdf')}"
69
+
70
+ if $?.success?
71
71
  'book.pdf'
72
72
  end
73
73
  end
@@ -97,7 +97,7 @@ class GitScribe
97
97
  info "GENERATING HTML"
98
98
  # TODO: look for custom stylesheets
99
99
  styledir = local('stylesheets')
100
- cmd = "asciidoc -a stylesdir=#{styledir} -a theme=handbookish #{BOOK_FILE}"
100
+ cmd = "asciidoc -a stylesdir=#{styledir} -a theme=scribe #{BOOK_FILE}"
101
101
  if ex(cmd)
102
102
  @done['html'] == true
103
103
  'book.html'
@@ -107,9 +107,9 @@ class GitScribe
107
107
  def do_site
108
108
  info "GENERATING SITE"
109
109
  # TODO: check if html was already done
110
- ex("asciidoc -b docbook #{BOOK_FILE}")
111
- xsldir = base('docbook-xsl/xhtml')
112
- ex("xsltproc --stringparam html.stylesheet stylesheets/handbookish.css --nonet #{xsldir}/chunk.xsl book.xml")
110
+
111
+ ex "asciidoc -b docbook #{BOOK_FILE}"
112
+ run_xslt "book.xml #{base('docbook-xsl/xhtml/chunk.xsl')}", "html.stylesheet" => 1
113
113
 
114
114
  source = File.read('index.html')
115
115
  html = Nokogiri::HTML.parse(source, nil, 'utf-8')
@@ -336,8 +336,18 @@ class GitScribe
336
336
  def ex(command)
337
337
  out = `#{command} 2>&1`
338
338
  info out
339
- $?.exitstatus == 0
339
+ $?.success?
340
340
  end
341
341
 
342
+ private
343
+
344
+ def run_xslt(jar_arguments, java_options)
345
+ ex <<-SH
346
+ java -cp "#{base('vendor/saxon.jar')}:#{base('vendor/xslthl-2.0.2.jar')}" \
347
+ #{java_options.map { |k, v| "-D#{k}=#{v}" }.join(' ')} \
348
+ com.icl.saxon.StyleSheet \
349
+ #{jar_arguments}
350
+ SH
351
+ end
342
352
  end
343
353
  end
@@ -1,3 +1,3 @@
1
1
  class GitScribe
2
- VERSION = '0.0.9'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -1,4 +1,3 @@
1
- /* BEG */
2
1
  /* ---------------------------------------------------------------------------
3
2
  Bare AsciiDoc styles
4
3
  Ryan Tomayko <r@tomayko.com>
@@ -8,7 +7,7 @@ body {
8
7
  font-family:verdana,helvetica,arial,sans-serif;
9
8
  font-size:81.25%; /* 13px */
10
9
  line-height:1.538; /* 20px */
11
- margin:40px 50px;
10
+ margin:40px auto 50px auto;
12
11
  max-width:53.8461538462em; /* 790px */
13
12
  color:#333;
14
13
  }
@@ -32,7 +31,9 @@ p, ul, ol, dl {
32
31
  margin:10px 0
33
32
  }
34
33
 
35
- dl { }
34
+ dl {
35
+ margin-left:40px
36
+ }
36
37
 
37
38
  dt {
38
39
  font-weight:normal;
@@ -46,39 +47,35 @@ h1, h2, h3, h4, h5 {
46
47
  }
47
48
 
48
49
  h1 {
49
- font-size:30px;
50
+ font-size:40px;
50
51
  line-height:1.428;
51
52
  margin:20px 0;
52
53
  }
53
54
 
54
55
  h2 {
55
- font-size:23px;
56
+ font-size:30px;
56
57
  line-height:1.36363636; /* repeating, of course */
57
- margin:20px 0;
58
+ margin:60px 0 20px 0;
58
59
  }
59
60
 
60
61
  h2 + .sectionbody {}
61
62
 
62
63
  h3 {
63
- font-size:18px;
64
+ font-size:24px;
64
65
  line-height:1.1;
65
66
  margin:30px 0 10px 0;
66
67
  }
67
68
 
68
69
  h4 {
69
- font-size:13px;
70
- font-weight:bold;
71
- line-height:1.538;
70
+ font-size:18px;
71
+ line-height:1.1;
72
+ margin:20px 0 5px 0;
72
73
  }
73
74
 
74
75
  h5 {
75
76
  font-size:13px;
76
77
  font-style:italic;
77
- line-height:1.538;
78
- }
79
-
80
- pre {
81
- font-size:larger;
78
+ line-height:1.1;
82
79
  }
83
80
 
84
81
  #header {
@@ -88,9 +85,9 @@ pre {
88
85
 
89
86
  #header h1 { margin-bottom:0 }
90
87
 
91
-
92
88
  .title, .sidebar-title {
93
89
  font-weight:normal;
90
+ color:#000;
94
91
  margin-bottom:0;
95
92
  }
96
93
 
@@ -112,6 +109,10 @@ pre {
112
109
  color:#888;
113
110
  }
114
111
 
112
+ .listingblock {
113
+ margin: 13px 0;
114
+ }
115
+
115
116
  .listingblock .content {
116
117
  border:1px solid silver;
117
118
  background:#eee;
@@ -173,59 +174,4 @@ pre {
173
174
  #author {
174
175
  color:#000;
175
176
  text-transform:uppercase
176
- }
177
-
178
- /* vim: set ft=css ts=4 sw=4 noexpandtab: */
179
-
180
- /* END @import url(bare.css); */
181
-
182
- /* ---------------------------------------------------------------------------
183
- FreeBSD AsciiDoc Theme
184
- Ryan Tomayko <r@tomayko.com>
185
-
186
- Based on The FreeBSD Handbook and various other FreeBSD documenration.
187
- --------------------------------------------------------------------------- */
188
-
189
- body {
190
- font-family:verdana,helvetica,arial,sans-serif;
191
- font-size:100%;
192
- color:#000;
193
- }
194
-
195
- tt { color:#007A00 }
196
- pre tt { color:#000 }
197
-
198
- dt { color:#000 }
199
-
200
- h1, h2, h3, h4, h5 {
201
- font-family:'lucida grande',helvetica,verdana,sans-serif;
202
- color:#900;
203
- font-weight:bold;
204
- }
205
-
206
- #header {
207
- text-align:left;
208
- }
209
- #header h1 { margin-bottom:40px }
210
-
211
- h1 {
212
- font-size:36px;
213
- line-height:1;
214
- margin:40px 0;
215
- }
216
-
217
- h2 {
218
- font-size:28px;
219
- line-height:1;
220
- margin:30px 0 20px 0;
221
- }
222
-
223
- .sectionbody {
224
- margin-left:30px;
225
- }
226
-
227
- pre {
228
- background:#EEE;
229
- }
230
-
231
- /* vim: set ft=css ts=4 sw=4 noexpandtab: */
177
+ }
@@ -9,4 +9,15 @@ context "scribe check tests" do
9
9
  status = @scribe.check
10
10
  assert_equal status.size, 6
11
11
  end
12
+
13
+ # there no option '-failboat' for apache fop cli
14
+ # it accepts only '-v' option but doesn't exit immediately.
15
+ # it should be additional no-op flag provided (like '-out list')
16
+ #
17
+ # see http://svn.apache.org/repos/asf/xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/CommandLineOptions.java
18
+ test "scribe should correctly check fop availability" do
19
+ assert_equal @scribe.check_can_run('fop -v -out list'), true
20
+ assert_equal @scribe.check_can_run('fop -v'), false
21
+ assert_equal @scribe.check_can_run('fop -failboat'), false
22
+ end
12
23
  end
@@ -20,7 +20,7 @@ context "scribe gen tests" do
20
20
  out = Dir.glob('output/**/*')
21
21
  assert out.include? 'output/book.html'
22
22
  assert out.include? 'output/image'
23
- assert out.include? 'output/stylesheets/handbookish.css'
23
+ assert out.include? 'output/stylesheets/scribe.css'
24
24
  end
25
25
  end
26
26
  end
@@ -29,22 +29,34 @@ context "scribe gen tests" do
29
29
  in_temp_dir do
30
30
  @scribe.init('t')
31
31
  Dir.chdir('t') do
32
- data = @scribe.gen('site')
32
+ data = @scribe.gen('site')
33
33
  out = Dir.glob('output/**/*')
34
34
  assert out.include? 'output/index.html'
35
35
  assert out.include? 'output/the_first_chapter.html'
36
36
  assert out.include? 'output/the_second_chapter.html'
37
37
  assert out.include? 'output/image'
38
- assert out.include? 'output/stylesheets/handbookish.css'
38
+ assert out.include? 'output/stylesheets/scribe.css'
39
39
  end
40
40
  end
41
41
  end
42
42
 
43
+ test "scribe can generate site with syntax highlighting" do
44
+ in_temp_dir do
45
+ @scribe.init('t')
46
+ Dir.chdir('t') do
47
+ @scribe.gen('site')
48
+ html = Nokogiri::HTML(File.read('output/the_first_chapter.html'))
49
+ assert html.at_css "b:contains('char')"
50
+ end
51
+ end
52
+ end
53
+
54
+
43
55
  test "scribe can generate a pdf" do
44
56
  in_temp_dir do
45
57
  @scribe.init('t')
46
58
  Dir.chdir('t') do
47
- data = @scribe.gen('pdf')
59
+ data = @scribe.gen('pdf')
48
60
  assert_equal data, 'book.pdf'
49
61
  out = Dir.glob('output/**/*')
50
62
  assert out.include? 'output/book.pdf'
@@ -52,12 +64,24 @@ context "scribe gen tests" do
52
64
  end
53
65
  end
54
66
 
67
+ test "scribe can generate a pdf with syntax highlighting" do
68
+ in_temp_dir do
69
+ @scribe.init('t')
70
+ Dir.chdir('t') do
71
+ @scribe.gen('pdf')
72
+ fo = Nokogiri::XML(File.read('output/book.fo'))
73
+ fo.remove_namespaces!
74
+ assert fo.at_css "inline[font-weight=bold][color=blue]:contains('char')"
75
+ end
76
+ end
77
+ end
78
+
55
79
  test "scribe can generate a epub" do
56
80
  in_temp_dir do
57
81
  @scribe.init('t')
58
82
  Dir.chdir('t') do
59
83
  data = @scribe.gen('epub')
60
- assert_equal data, 'book.epub'
84
+ assert_equal 'book.epub', data
61
85
  out = Dir.glob('output/**/*')
62
86
  assert out.include? 'output/book.epub'
63
87
  end
@@ -2,17 +2,15 @@ dir = File.dirname(File.expand_path(__FILE__))
2
2
  $LOAD_PATH.unshift dir + '/../lib'
3
3
  $TESTING = true
4
4
 
5
- require 'test/unit'
5
+ # Necessary to override stdlib: http://www.ruby-forum.com/topic/212974
6
6
  require 'rubygems'
7
+ gem 'test-unit'
8
+ require 'test/unit'
9
+
7
10
  require 'git-scribe'
8
11
  require 'pp'
9
12
  require 'tempfile'
10
13
 
11
- begin
12
- require 'leftright'
13
- rescue LoadError
14
- end
15
-
16
14
  ##
17
15
  # test/spec/mini 3
18
16
  # http://gist.github.com/25455
Binary file
Binary file
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-scribe
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
5
- prerelease: false
4
+ hash: 27
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 9
10
- version: 0.0.9
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Scott Chacon
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-28 00:00:00 -08:00
19
- default_executable:
18
+ date: 2011-09-16 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: nokogiri
@@ -46,6 +45,34 @@ dependencies:
46
45
  version: "0"
47
46
  type: :runtime
48
47
  version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: rake
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: test-unit
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ type: :development
75
+ version_requirements: *id004
49
76
  description: " git-scribe is a workflow tool for starting, writing, reviewing and publishing\n multiple forms of a book. it allows you to use asciidoc plain text markup to\n write, review and translate a work and provides a simple toolkit for generating\n common digital outputs for publishing - epub, mobi, pdf and html. it is also\n integrated into github functionality, letting you automate the publishing and\n collaboration process.\n"
50
77
  email: schacon@gmail.com
51
78
  executables:
@@ -56,6 +83,8 @@ extra_rdoc_files: []
56
83
 
57
84
  files:
58
85
  - .gitignore
86
+ - Gemfile
87
+ - Gemfile.lock
59
88
  - LICENSE
60
89
  - README.asciidoc
61
90
  - Rakefile
@@ -1187,8 +1216,8 @@ files:
1187
1216
  - site/default/index.html
1188
1217
  - site/default/master.css
1189
1218
  - site/default/page.html
1190
- - stylesheets/handbookish-quirks.css
1191
- - stylesheets/handbookish.css
1219
+ - stylesheets/scribe-quirks.css
1220
+ - stylesheets/scribe.css
1192
1221
  - template/.gitignore
1193
1222
  - template/.gitscribe
1194
1223
  - template/LICENSE
@@ -1202,7 +1231,8 @@ files:
1202
1231
  - test/gen_test.rb
1203
1232
  - test/init_test.rb
1204
1233
  - test/test_helper.rb
1205
- has_rdoc: true
1234
+ - vendor/saxon.jar
1235
+ - vendor/xslthl-2.0.2.jar
1206
1236
  homepage: http://github.com/schacon/git-scribe
1207
1237
  licenses: []
1208
1238
 
@@ -1232,7 +1262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1232
1262
  requirements: []
1233
1263
 
1234
1264
  rubyforge_project:
1235
- rubygems_version: 1.3.7
1265
+ rubygems_version: 1.8.10
1236
1266
  signing_key:
1237
1267
  specification_version: 3
1238
1268
  summary: git-scribe is an authors toolkit for writing and publishing books