publishr 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in publishr.gemspec
4
4
  gemspec
5
+
6
+ gem 'sanitize'
7
+ gem 'kramdown'
data/bin/publishr CHANGED
@@ -45,7 +45,7 @@ if ARGV[0].nil?
45
45
  Process.exit
46
46
  end
47
47
 
48
- project = Publishr::Project.new(ARGV[0], ARGV[1], ARGV[3])
48
+ project = Publishr::Project.new(ARGV[0], File.join(Dir.pwd,ARGV[1]), File.join(Dir.pwd,ARGV[3]))
49
49
 
50
50
  case ARGV[2]
51
51
  when 'kindle' then project.make_kindle
@@ -89,13 +89,13 @@ h3 {
89
89
  text-indent: 0;
90
90
  }
91
91
 
92
- .diff_correction {
92
+ .diff_correction, .DIFF_CORRECTION {
93
93
  color: red;
94
94
  background-color: #FFEEEE;
95
95
  text-decoration: line-through;
96
96
  }
97
97
 
98
- .diff_insertation {
98
+ .diff_insertation, .DIFF_INSERTATION {
99
99
  color: green;
100
100
  background-color: #EEFFEE;
101
101
  }
@@ -37,7 +37,6 @@ module Publishr
37
37
  def make_epub_directory_structure
38
38
  FileUtils.rm_rf @outpath
39
39
  FileUtils.cp_r File.join(@gempath,'lib','epub_skeleton'), @outpath
40
- FileUtils.cp Dir[File.join(@inpath,'..','images','*.jpg')], @outpath
41
40
  FileUtils.cp Dir[File.join(@inpath,'images','*.jpg')], @outpath
42
41
  FileUtils.cp File.join(@inpath,'cover.jpg'), @outpath
43
42
  @image_files = Dir[File.join(@outpath,'*.jpg')]
@@ -10,7 +10,6 @@ module Publishr
10
10
  @rails_resources_url = rails_resources_url
11
11
 
12
12
  @custom_fixes = File.open(File.join(@inpath,'html_postprocessing.rb'), 'r').read if File.exists?(File.join(@inpath,'html_postprocessing.rb'))
13
- @global_fixes = File.open(File.join(@inpath,'..','html_postprocessing.rb'), 'r').read if File.exists?(File.join(@inpath,'..','html_postprocessing.rb'))
14
13
 
15
14
  @depth = 0
16
15
  @quotetype = nil
@@ -21,7 +20,7 @@ module Publishr
21
20
  end
22
21
 
23
22
  def self.sanitize(html)
24
- Sanitize.clean(html, Sanitize::Config::BASIC)
23
+ Sanitize.clean(html, :elements => ['b','i','code'])
25
24
  end
26
25
 
27
26
  def degrade
@@ -40,7 +39,6 @@ module Publishr
40
39
  @add_footnote = true and @footnote_number += 1 if @line.include?('<li id="fn')
41
40
 
42
41
  eval(@custom_fixes, binding) if @custom_fixes
43
- eval(@global_fixes, binding) if @global_fixes
44
42
 
45
43
  annotate_blockquote
46
44
  improve_typography
@@ -25,7 +25,6 @@ module Publishr
25
25
  @inpath = inpath
26
26
 
27
27
  @custom_fixes = File.open(File.join(@inpath,'latex_postprocessing.rb'), 'r').read if File.exists?(File.join(@inpath,'latex_postprocessing.rb'))
28
- @global_fixes = File.open(File.join(@inpath,'..','latex_postprocessing.rb'), 'r').read if File.exists?(File.join(@inpath,'..','latex_postprocessing.rb'))
29
28
  end
30
29
 
31
30
  def fix
@@ -72,7 +71,6 @@ module Publishr
72
71
  @line.gsub! '°', '\\textdegree'
73
72
 
74
73
  eval(@custom_fixes, binding) if @custom_fixes
75
- eval(@global_fixes, binding) if @global_fixes
76
74
 
77
75
  # use correct hyphen code for better automatic hyphenation
78
76
  @line.gsub! /(\w)-(\w)/, '\1\\hyp{}\2'
@@ -31,9 +31,9 @@ module Publishr
31
31
 
32
32
  def make_tex_directory_structure
33
33
  FileUtils.mkdir_p @outpath
34
- FileUtils.cp Dir[File.join(@inpath,'..','images','*.jpg')], @outpath
35
34
  FileUtils.cp Dir[File.join(@inpath,'images','*.jpg')], @outpath
36
35
  FileUtils.cp_r File.join(@gempath,'lib','tex_templates','book.tex'), @outpath
36
+ FileUtils.cp_r File.join(@inpath,'book.tex'), @outpath if File.exists?(File.join(@inpath,'book.tex'))
37
37
  FileUtils.cp_r File.join(@inpath,'preamble.tex'), @outpath
38
38
  end
39
39
 
@@ -21,10 +21,10 @@ module Publishr
21
21
  @@gempath = File.expand_path('../../../', __FILE__)
22
22
 
23
23
  class Project
24
- def initialize(name,relativepath,converterspath)
24
+ def initialize(name,absolutepath,absoluteconverterspath)
25
25
  @name = name
26
- @inpath = File.join(Dir.pwd,relativepath)
27
- @converterspath = File.join(Dir.pwd,converterspath)
26
+ @inpath = absolutepath
27
+ @converterspath = absoluteconverterspath
28
28
 
29
29
  @metadata = YAML::load(File.open(File.join(@inpath,'metadata.yml'), 'r').read)
30
30
  end
@@ -35,13 +35,16 @@ module Publishr
35
35
  epub.render
36
36
  binaryfile = File.join(@converterspath,'kindlegen')
37
37
  epubfile = File.join(@inpath,"#{ @name }.epub")
38
+ lines = []
38
39
  IO.popen("#{ binaryfile } -verbose #{ epubfile }") do |io|
39
40
  while (line = io.gets) do
40
41
  puts line
42
+ lines << line
41
43
  end
42
44
  end
43
45
  FileUtils.rm_r outpath
44
- FileUtils.cp File.join(@inpath,"#{ @name }.mobi"), '/media/Kindle/documents'
46
+ #FileUtils.cp File.join(@inpath,"#{ @name }.mobi"), '/media/Kindle/documents'
47
+ lines.join('<br />')
45
48
  end
46
49
 
47
50
  def make_pdf
@@ -49,21 +52,23 @@ module Publishr
49
52
  pdf.render
50
53
 
51
54
  outpath = File.join(@inpath,'latex')
52
- binaryfile = File.join(@converterspath,'jpeg2ps')
55
+ binaryfile = File.join(@converterspath,'jpeg2ps 2>&1')
53
56
  Dir[File.join(outpath,'*.jpg')].each do |infilepath|
54
57
  outfilepath = File.join(outpath, File.basename(infilepath).gsub(/(.*).jpg/, '\1.eps'))
55
58
  `#{ binaryfile } -r 0 -o #{ outfilepath } #{ infilepath }`
56
59
  end
57
60
 
58
61
  Dir.chdir outpath
59
- IO.popen('pdflatex preamble.tex') do |io|
62
+ lines = []
63
+ IO.popen('pdflatex preamble.tex 2>&1') do |io|
60
64
  while (line = io.gets) do
61
65
  puts line
66
+ lines << line
62
67
  end
63
68
  end
64
69
 
65
70
  FileUtils.mv File.join(outpath,'preamble.pdf'), File.join(@inpath,"#{ @name }.pdf")
66
- #FileUtils.rm_r outpath
71
+ lines.join('<br />')
67
72
  end
68
73
 
69
74
  end
@@ -1,3 +1,3 @@
1
1
  module Publishr
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -0,0 +1,65 @@
1
+ \documentclass[11pt,a5paper,dvips,pdflatex,DIV25,BCOR13mm,headinclude,footinclude,chapterprefix=false]{scrbook}
2
+
3
+ \pagenumbering{arabic}
4
+
5
+ % ------- PAGE HEADER SETTINGS -----------
6
+ \usepackage{scrpage2}
7
+ \pagestyle{scrheadings}
8
+ \manualmark
9
+ \clearscrheadfoot
10
+ \ofoot[]{} %Seitenzahl unten außen erst spaeter einschalten
11
+ % ----------------------------------------
12
+
13
+
14
+ % -------------- PACKAGES ----------------
15
+ \usepackage[ngerman]{babel}
16
+ \usepackage[utf8]{inputenc}
17
+ \usepackage[T1]{fontenc}
18
+ \usepackage{times} %try also charter, cm, helvet, bookman, venturis, [sc]{mathpazo}, cmr, [adobe-utopia]{mathdesign}, gfsdidot
19
+ \usepackage[force,almostfull]{textcomp}
20
+ \usepackage{xspace}
21
+ \usepackage{longtable}
22
+ \usepackage{graphicx}
23
+ \usepackage{hyphenat}
24
+ \usepackage[margin=0pt,font={small,sf},labelfont={bf,sf,small},labelformat=empty,justification=centering]{caption}
25
+ \usepackage[spacing=true,protrusion=true,expansion=true]{microtype}
26
+ \usepackage{makeidx}
27
+ \makeindex
28
+ %\usepackage[german,portrait]{draftcopy}
29
+ %\draftcopySetGrey 0
30
+
31
+ % ----------------------------------------
32
+
33
+
34
+ % -------------- CUSTOMIZATIONS ----------------
35
+ \renewcommand{\sfdefault}{cmbr} % use prettier sans serif font
36
+ \renewcommand{\ttdefault}{lmtt} % use prettier typewriter font
37
+ \renewcommand{\emph}[1]{\textbf{#1}}
38
+
39
+ \newenvironment{quotenormal}{ \begin{quote}\small}{ \end{quote} }
40
+ \newenvironment{quotationnormal}{ \begin{quotation}\small}{ \end{quotation} }
41
+
42
+ \newenvironment{quoteemail}{ \begin{flushleft}\begin{quote} \footnotesize\sffamily}{ \end{quote}\end{flushleft} }
43
+ \newenvironment{quotationemail}{ \begin{flushleft}\begin{quote} \footnotesize\sffamily}{ \end{quote}\end{flushleft} }
44
+
45
+ \newenvironment{quotetranscript}{ \begin{quote}\small\normalfont }{ \end{quote} }
46
+ \newenvironment{quotationtranscript}{ \begin{quote}\small\normalfont }{ \end{quote} }
47
+
48
+ \newenvironment{quotelyrics}{ \begin{quote}\small\normalfont }{ \end{quote} }
49
+ \newenvironment{quotationlyrics}{ \begin{quote}\small\normalfont }{ \end{quote} }
50
+
51
+ \newcommand{\zB}{\mbox{z.\,B.}\xspace}
52
+ \newcommand{\dH}{\mbox{d.\,h.}\xspace}
53
+ \newcommand{\ua}{\mbox{u.\,a.}\xspace}
54
+ \newcommand{\omission}{\mbox{[\dots\hspace{-1,5pt}]}}
55
+ \newcommand{\sessiondate}[1]{\hspace{-5mm}\textit{\scriptsize{#1}}\nopagebreak[4]}
56
+ \newcommand{\object}[1]{\textit{#1}}
57
+ \newcommand{\book}[1]{\textsf{#1}}
58
+ \newcommand{\name}[1]{\textsc{#1}}
59
+ \newcommand{\iron}[1]{\glq#1\grq{}}
60
+ % ----------------------------------------
61
+
62
+ % -------------- OTHER GENERAL SETTINGS ----------------
63
+ \makeindex
64
+ \makeglossary
65
+
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/publishr/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in publishr.gemspec
4
+ gemspec
data/publishr/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ require "publishr/version"
2
+
3
+ module Publishr
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module Publishr
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "publishr/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "publishr"
7
+ s.version = Publishr::VERSION
8
+ s.authors = ["Michael Franzl"]
9
+ s.email = ["michael@billgastro.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{TODO: Write a gem summary}
12
+ s.description = %q{TODO: Write a gem description}
13
+
14
+ s.rubyforge_project = "publishr"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: publishr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-06 00:00:00.000000000Z
12
+ date: 2012-01-08 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: kramdown
16
- requirement: &20535880 !ruby/object:Gem::Requirement
16
+ requirement: &23549760 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *20535880
24
+ version_requirements: *23549760
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: kramdown
27
- requirement: &20533660 !ruby/object:Gem::Requirement
27
+ requirement: &23549120 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *20533660
35
+ version_requirements: *23549120
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sanitize
38
- requirement: &20532720 !ruby/object:Gem::Requirement
38
+ requirement: &23546200 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *20532720
46
+ version_requirements: *23546200
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sanitize
49
- requirement: &20530100 !ruby/object:Gem::Requirement
49
+ requirement: &23545780 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *20530100
57
+ version_requirements: *23545780
58
58
  description: Fast publishing for ebooks and paper
59
59
  email:
60
60
  - michael@billgastro.com
@@ -90,7 +90,14 @@ files:
90
90
  - lib/publishr/latex_renderer.rb
91
91
  - lib/publishr/project.rb
92
92
  - lib/publishr/version.rb
93
+ - lib/tex_templates/book.tex
93
94
  - publishr.gemspec
95
+ - publishr/.gitignore
96
+ - publishr/Gemfile
97
+ - publishr/Rakefile
98
+ - publishr/lib/publishr.rb
99
+ - publishr/lib/publishr/version.rb
100
+ - publishr/publishr.gemspec
94
101
  homepage: ''
95
102
  licenses: []
96
103
  post_install_message: