epubforge 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +17 -10
- data/VERSION +1 -1
- data/bin/epubforge +1 -1
- data/config/actions/epub.rb +50 -0
- data/config/actions/forge.rb +34 -13
- data/config/actions/git.rb +106 -0
- data/config/actions/help.rb +13 -13
- data/config/actions/html.rb +33 -0
- data/config/actions/mobi.rb +60 -0
- data/config/actions/new.rb +182 -0
- data/config/actions/word_count.rb +26 -24
- data/config/{actions → actions_to_ignore}/generate.rb +1 -1
- data/config/{actions → actions_to_ignore}/generate_chapter.rb +0 -0
- data/config/{actions → actions_to_ignore}/git_backup.rb +2 -2
- data/config/{actions → actions_to_ignore}/globals.rb +1 -1
- data/config/{actions → actions_to_ignore}/kindle.rb +3 -3
- data/config/{actions → actions_to_ignore}/local_action.rb +1 -1
- data/config/{actions → actions_to_ignore}/mobify.rb +3 -3
- data/config/actions_to_ignore/notes_to_epub.rb +19 -0
- data/config/actions_to_ignore/notes_to_kindle.rb +18 -0
- data/config/{actions → actions_to_ignore}/spell.rb +1 -1
- data/config/{actions → actions_to_ignore}/version.rb +3 -3
- data/config/{actions → actions_to_ignore}/wrap_scene_notes_in_hidden_div.rb +1 -1
- data/config/converters/epub_to_mobi.calibre.rb +8 -0
- data/config/converters/epub_to_mobi.kindlegen.rb +11 -0
- data/config/html_translators/default_kramdown.html_translator.rb +9 -0
- data/config/html_translators/default_markdown.html_translator.rb +10 -0
- data/config/html_translators/default_markdown_pandoc.html_translator.rb +10 -0
- data/config/html_translators/default_textile_pandoc.html_translator.rb +8 -0
- data/config/html_translators/default_xhtml.html_translator.rb +7 -0
- data/config/html_translators/fallback_html.html_translator.rb +9 -0
- data/config/html_translators/fallback_markdown.html_translator.rb +8 -0
- data/config/html_translators/fallback_textile.html_translator.rb +7 -0
- data/config/html_translators/fallback_txt.html_translator.rb +8 -0
- data/config/html_translators/fallback_unknown.html_translator.rb +7 -0
- data/lib/epubforge.rb +37 -82
- data/lib/{action/thor_action.rb → epubforge/action/action.rb} +89 -69
- data/lib/epubforge/action/action2.rb +109 -0
- data/lib/epubforge/action/action_definition.rb +62 -0
- data/lib/epubforge/action/actions_lookup.rb +45 -0
- data/lib/epubforge/action/chatterbox.rb +93 -0
- data/lib/{action → epubforge/action}/cli_command.rb +2 -2
- data/lib/{action → epubforge/action}/cli_sequence.rb +0 -0
- data/lib/{action → epubforge/action}/file_transformer.rb +0 -0
- data/lib/{action → epubforge/action}/hooks_interface.rb +2 -2
- data/lib/{action → epubforge/action}/run_description.rb +12 -9
- data/lib/{action → epubforge/action}/runner.rb +23 -24
- data/lib/{epub → epubforge/builder}/assets/asset.rb +1 -1
- data/lib/{epub → epubforge/builder}/assets/font.rb +1 -1
- data/lib/epubforge/builder/assets/html.rb +9 -0
- data/lib/{epub → epubforge/builder}/assets/image.rb +1 -1
- data/lib/epubforge/builder/assets/markdown.rb +9 -0
- data/lib/{epub → epubforge/builder}/assets/page.rb +12 -4
- data/lib/{epub → epubforge/builder}/assets/stylesheet.rb +1 -1
- data/lib/epubforge/builder/assets/textile.rb +9 -0
- data/lib/epubforge/builder/assets/xhtml.rb +9 -0
- data/lib/epubforge/builder/builder.rb +134 -0
- data/lib/{epub/builder.rb → epubforge/builder/epub.rb} +58 -161
- data/lib/epubforge/builder/html.rb +22 -0
- data/lib/epubforge/builder/packager.rb +16 -0
- data/lib/epubforge/core_extensions/array.rb +2 -0
- data/lib/{core_extensions → epubforge/core_extensions}/kernel.rb +0 -0
- data/lib/epubforge/core_extensions/nil_class.rb +2 -0
- data/lib/epubforge/core_extensions/object.rb +24 -0
- data/lib/{core_extensions → epubforge/core_extensions}/string.rb +1 -5
- data/lib/{custom_helpers.rb → epubforge/custom_helpers.rb} +0 -1
- data/lib/{errors.rb → epubforge/exceptions/errors.rb} +0 -0
- data/lib/{project → epubforge/project}/project.rb +23 -17
- data/lib/epubforge/utils/action_loader.rb +8 -0
- data/lib/epubforge/utils/class_loader.rb +102 -0
- data/lib/epubforge/utils/converter.rb +94 -0
- data/lib/{utils → epubforge/utils}/downloader.rb +0 -0
- data/lib/{utils → epubforge/utils}/file_orderer.rb +0 -0
- data/lib/epubforge/utils/file_path.rb +8 -0
- data/lib/epubforge/utils/html_translator.rb +126 -0
- data/lib/epubforge/utils/html_translator_queue.rb +113 -0
- data/lib/epubforge/utils/htmlizer.rb +61 -0
- data/lib/{utils → epubforge/utils}/misc.rb +0 -0
- data/lib/epubforge/utils/root_path.rb +8 -0
- data/lib/epubforge/utils/settings.rb +147 -0
- data/lib/epubforge/utils/template_evaluator.rb +7 -0
- data/templates/{default/book/afterword.markdown.template → project/book/afterword.markdown} +0 -0
- data/templates/project/book/chapter-%0000chapter%.markdown.template +4 -0
- data/templates/{default → project}/book/cover.xhtml.template +2 -2
- data/templates/{default/book/foreword.markdown.template → project/book/foreword.markdown} +0 -0
- data/templates/{default → project}/book/images/cover.png +0 -0
- data/templates/{default/book/stylesheets/stylesheet.css.template → project/book/stylesheets/stylesheet.css} +0 -0
- data/templates/project/book/title_page.markdown.template +5 -0
- data/templates/project/notes/character.%character.name_for_file%.markdown.template +15 -0
- data/templates/{default → project}/notes/images/cover.png +0 -0
- data/templates/{default/notes/stylesheets/stylesheet.css.template → project/notes/stylesheets/stylesheet.css} +0 -0
- data/templates/{default → project}/settings/actions/local_action.rb.example +1 -1
- data/templates/project/settings/config.rb.template +70 -0
- data/templates/project/settings/html_translators/example_translator.rb +29 -0
- data/templates/{default → project}/settings/wordcount.template +1 -1
- data/test/answers01.yml +30 -0
- data/test/helper.rb +62 -39
- data/test/misc/config.rb +5 -7
- data/test/test_epubforge.rb +18 -14
- data/test/{test_htmlizers.rb → test_html_translators.rb} +4 -8
- data/test/test_template_evaluator.rb +42 -0
- data/test/test_utils.rb +0 -11
- metadata +186 -189
- data/config/actions/gitify.rb +0 -72
- data/config/actions/init.rb +0 -138
- data/config/actions/notes_to_epub.rb +0 -18
- data/config/actions/notes_to_kindle.rb +0 -17
- data/config/htmlizers.rb +0 -70
- data/lib/action/actions_lookup.rb +0 -45
- data/lib/core_extensions/array.rb +0 -5
- data/lib/core_extensions/nil_class.rb +0 -5
- data/lib/core_extensions/object.rb +0 -5
- data/lib/epub/assets/html.rb +0 -8
- data/lib/epub/assets/markdown.rb +0 -8
- data/lib/epub/assets/textile.rb +0 -8
- data/lib/epub/assets/xhtml.rb +0 -8
- data/lib/epub/packager.rb +0 -16
- data/lib/utils/action_loader.rb +0 -7
- data/lib/utils/class_loader.rb +0 -102
- data/lib/utils/directory_builder.rb +0 -181
- data/lib/utils/file_path.rb +0 -152
- data/lib/utils/html_translator.rb +0 -100
- data/lib/utils/html_translator_queue.rb +0 -70
- data/lib/utils/htmlizer.rb +0 -92
- data/lib/utils/root_path.rb +0 -20
- data/lib/utils/settings.rb +0 -146
- data/lib/utils/template_evaluator.rb +0 -20
- data/templates/default/book/chapter-%i%.markdown.sequence +0 -4
- data/templates/default/book/title_page.markdown.template +0 -4
- data/templates/default/notes/character.named.markdown.template +0 -4
- data/templates/default/payload.rb +0 -65
- data/templates/default/settings/config.rb.form +0 -55
- data/templates/default/settings/htmlizers.rb +0 -0
- data/test/test_directory_builder.rb +0 -141
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
module EpubForge
|
|
2
|
-
module Utils
|
|
3
|
-
# A priority stack (like a priority queue, but FILO) with a simple job:
|
|
4
|
-
# keep track of the translators (by name and by group), and return them
|
|
5
|
-
# to the object user in the order they should be tried.
|
|
6
|
-
class HtmlTranslatorQueue
|
|
7
|
-
GROUP_NAMES = HtmlTranslator::GROUP_NAMES
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def initialize
|
|
11
|
-
@translators = {}
|
|
12
|
-
@all_translators = []
|
|
13
|
-
@translators_named = {}
|
|
14
|
-
for name in GROUP_NAMES
|
|
15
|
-
@translators[name] = []
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# def translators_handling_format( requested_format )
|
|
20
|
-
# htmlizers = GROUP_NAMES.map{ |group|
|
|
21
|
-
# (@translator_queue.keys - [:all, :named]).map do |format|
|
|
22
|
-
# htmlizers = @translator_queue[format][group]
|
|
23
|
-
# htmlizers ? htmlizers.select{|html| html.handles_format?(requested_format) } : []
|
|
24
|
-
# end
|
|
25
|
-
# }
|
|
26
|
-
#
|
|
27
|
-
# htmlizers.flatten
|
|
28
|
-
# end
|
|
29
|
-
|
|
30
|
-
# last installed, first yielded (within a given group)
|
|
31
|
-
#
|
|
32
|
-
# Returns them in priority order, user-defined ones first.
|
|
33
|
-
# At the moment, it is up to individual translators to accept or
|
|
34
|
-
# reject the translation job based on the file format (by extension, which is lame).
|
|
35
|
-
def each( &block )
|
|
36
|
-
ordered_translators = []
|
|
37
|
-
for group in GROUP_NAMES.map{|g| @translators[g].reverse }
|
|
38
|
-
ordered_translators += group
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
if block_given?
|
|
42
|
-
for translator in ordered_translators
|
|
43
|
-
yield translator
|
|
44
|
-
end
|
|
45
|
-
else
|
|
46
|
-
ordered_translators.to_enum
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def length
|
|
51
|
-
@all_translators.length
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def categorize( htmlizer )
|
|
55
|
-
unless GROUP_NAMES.include?( htmlizer.group )
|
|
56
|
-
puts "No group specified for htmlizer #{htmlizer}. Group must be one of the following symbols: #{GROUP_NAMES.map(&:inspect).inspect}"
|
|
57
|
-
return false
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
@all_translators << htmlizer
|
|
61
|
-
@translators_named[htmlizer.name] = htmlizer if htmlizer.name
|
|
62
|
-
@translators[htmlizer.group] << htmlizer
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def named( sym )
|
|
66
|
-
@translators_named[sym]
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
data/lib/utils/htmlizer.rb
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
module EpubForge
|
|
2
|
-
module Utils
|
|
3
|
-
|
|
4
|
-
# Htmlizer coordinates the discovery, selection, and running of HtmlTranslators.
|
|
5
|
-
# It can be handed basically any supported filetype (markdown, textile, txt), and
|
|
6
|
-
# hand back an HTML translation of the file.
|
|
7
|
-
class Htmlizer
|
|
8
|
-
include Singleton
|
|
9
|
-
|
|
10
|
-
def setup_once
|
|
11
|
-
return false if @already_set_up
|
|
12
|
-
@already_set_up = true
|
|
13
|
-
@exec_location = {}
|
|
14
|
-
|
|
15
|
-
@translator_queue = HtmlTranslatorQueue.new
|
|
16
|
-
|
|
17
|
-
add_htmlizers( EpubForge.root( 'config', 'htmlizers.rb' ) )
|
|
18
|
-
add_htmlizers( EpubForge::USER_SETTINGS.join( 'htmlizers.rb' ) )
|
|
19
|
-
|
|
20
|
-
@already_set_up
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
public
|
|
24
|
-
def location( name, path = nil )
|
|
25
|
-
@exec_location[name] = path if path
|
|
26
|
-
@exec_location[name]
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Commenting out for the moment. Philosophically, maybe it shouldn't provide access to individual translators.
|
|
30
|
-
# def translators_named( name )
|
|
31
|
-
# @translator_queue[:named][name]
|
|
32
|
-
# end
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def self.define( &block )
|
|
36
|
-
htmlizer = HtmlTranslator.new
|
|
37
|
-
yield htmlizer
|
|
38
|
-
self.instance.categorize( htmlizer )
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def categorize( htmlizer )
|
|
42
|
-
@translator_queue.categorize( htmlizer )
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def add_htmlizers( htmlizers_file )
|
|
46
|
-
if htmlizers_file.exist?
|
|
47
|
-
begin
|
|
48
|
-
require htmlizers_file.to_s
|
|
49
|
-
rescue Exception => e
|
|
50
|
-
puts e.message
|
|
51
|
-
puts e.backtrace.map{|line| "\t#{line}" }
|
|
52
|
-
puts "Failed to load htmlizers from project file #{htmlizers_file} Soldiering onward."
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
# available options
|
|
59
|
-
# :htmlizer => the sym for the requested htmlizer.
|
|
60
|
-
# :opts => a string representing options to execute cmd with
|
|
61
|
-
def translate( filename, opts = {} )
|
|
62
|
-
translator = opts[:translator]
|
|
63
|
-
translator = @translator_queue.named( translator ) if translator.is_a?( Symbol )
|
|
64
|
-
opts = opts[:opts] || ""
|
|
65
|
-
|
|
66
|
-
if translator
|
|
67
|
-
if result = translator.translate( filename, {opts: opts } )
|
|
68
|
-
return result
|
|
69
|
-
else
|
|
70
|
-
puts "Named Htmlizer #{htmlizer} did not return html. Falling back on other htmlizers"
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
for translator in @translator_queue
|
|
75
|
-
if result = translator.translate( filename, opts )
|
|
76
|
-
return result
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
"<!-- COULD NOT FIND HTMLIZER FOR #{filename} -->"
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def self.format_from_filename( filename )
|
|
84
|
-
ext = filename.fwf_filepath.ext
|
|
85
|
-
ext.epf_blank? ? :unknown : ext.to_sym
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
Htmlizer.instance.setup_once
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
data/lib/utils/root_path.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module EpubForge
|
|
2
|
-
module Utils
|
|
3
|
-
module RootPath
|
|
4
|
-
def root( *args )
|
|
5
|
-
if args.length > 0
|
|
6
|
-
args.unshift( @root_path )
|
|
7
|
-
FilePath.new( *args )
|
|
8
|
-
else
|
|
9
|
-
FilePath.new( @root_path )
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def set_root_path( path )
|
|
14
|
-
@root_path = FilePath.new( path )
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
EpubForge.extend EpubForge::Utils::RootPath
|
data/lib/utils/settings.rb
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
# have to make a tweak to configurator to allow it to work with project class instances
|
|
2
|
-
module Configurator
|
|
3
|
-
def self.extended(base)
|
|
4
|
-
if base.respond_to?(:class_eval)
|
|
5
|
-
base.class_eval { remove_instance_variable(:@configuration) if defined? @configuration }
|
|
6
|
-
else
|
|
7
|
-
puts "EXTENDING #{base} AS WE SPEAK"
|
|
8
|
-
base.instance_variable_set( :@got_extended, true )
|
|
9
|
-
# base.instance_variable_set( :@configuration, nil )
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
module EpubForge
|
|
15
|
-
module Utils
|
|
16
|
-
class Settings
|
|
17
|
-
def self.thing_to_configure( *args )
|
|
18
|
-
if( args.length >= 1 )
|
|
19
|
-
@thing_to_configure = args.first
|
|
20
|
-
end
|
|
21
|
-
@thing_to_configure
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Takes a configurator object and (optionally) a settings file to write it out to.
|
|
25
|
-
def initialize( configable, file = nil )
|
|
26
|
-
@configable = configable
|
|
27
|
-
@file = file.fwf_filepath.expand if file
|
|
28
|
-
install_configuration
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def act_on_string( keqv, set = :set )
|
|
32
|
-
k,v = parse_kv( keqv )
|
|
33
|
-
if set == :unset
|
|
34
|
-
unset( k )
|
|
35
|
-
elsif set == :set
|
|
36
|
-
set( k, v )
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def set( key, val )
|
|
41
|
-
setting, last_key = descend_key( key )
|
|
42
|
-
setting[last_key] = val
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def unset( key )
|
|
46
|
-
setting, last_key = descend_key( key )
|
|
47
|
-
setting.delete( last_key )
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def write_settings_file( settings_file = nil )
|
|
51
|
-
settings_file ||= @file
|
|
52
|
-
settings_file = settings_file.fwf_filepath
|
|
53
|
-
@depth = 0
|
|
54
|
-
str = indented_line("EpubForge::Utils::Settings.thing_to_configure.config do")
|
|
55
|
-
str += write_config( @configable.config.to_hash )
|
|
56
|
-
str += indented_line("end")
|
|
57
|
-
settings_file.write( str )
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
protected
|
|
61
|
-
def install_configuration
|
|
62
|
-
self.class.thing_to_configure( @configable )
|
|
63
|
-
self.class.thing_to_configure.extend( Configurator )
|
|
64
|
-
require @file
|
|
65
|
-
self.class.thing_to_configure( nil )
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def indented_line( str )
|
|
69
|
-
puts " " * @depth + str + "\n"
|
|
70
|
-
" " * @depth + str + "\n"
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def write_config( h )
|
|
74
|
-
str = ""
|
|
75
|
-
@depth += 2
|
|
76
|
-
for k, v in h
|
|
77
|
-
if v.is_a?(Hash)
|
|
78
|
-
str += indented_line( "#{k} do" )
|
|
79
|
-
str += write_config( v )
|
|
80
|
-
str += indented_line( "end" )
|
|
81
|
-
else
|
|
82
|
-
str += indented_line( "#{k} #{stringify_value( v )}" )
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
@depth -= 2
|
|
86
|
-
|
|
87
|
-
str
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def stringify_value( v )
|
|
91
|
-
case v
|
|
92
|
-
when Regexp
|
|
93
|
-
"/#{v.source}/"
|
|
94
|
-
when Numeric
|
|
95
|
-
"#{v}"
|
|
96
|
-
when String
|
|
97
|
-
escape_string( v )
|
|
98
|
-
when FunWith::Files::FilePath
|
|
99
|
-
escape_string( v ) + ".fwf_filepath"
|
|
100
|
-
when Array # TODO: Is there a way to enter arrays?
|
|
101
|
-
"[ #{ v.map{ |item| stringify_value(item) }.join(', ') } ]"
|
|
102
|
-
when NilClass
|
|
103
|
-
"nil"
|
|
104
|
-
when TrueClass
|
|
105
|
-
"true"
|
|
106
|
-
when FalseClass
|
|
107
|
-
"false"
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
def escape_string( s )
|
|
112
|
-
s.inspect
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
# If given a hierarchical setting key like git:host:url,
|
|
116
|
-
# returns the hash attached to config[:git][:host], so the caller can say
|
|
117
|
-
# rval[:url] = "bannedsorcery.com". Creates empty hashes as it descends,
|
|
118
|
-
# if neccessary.
|
|
119
|
-
def descend_key( k )
|
|
120
|
-
keychain = k.split(":").map{ |key| :"#{key}" }
|
|
121
|
-
|
|
122
|
-
s = @configable.config
|
|
123
|
-
|
|
124
|
-
for key in keychain[0..-2]
|
|
125
|
-
s[key] ||= {}
|
|
126
|
-
s = s[key]
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
[s, keychain.last]
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
def parse_kv( str )
|
|
133
|
-
if m = str.match( /^([a-z0-9_:]+)=(.*)$/ )
|
|
134
|
-
discard, k, v = m.to_a
|
|
135
|
-
elsif m = str.match( /^([a-z0-9_:]+)$/ )
|
|
136
|
-
discard, k = m.to_a
|
|
137
|
-
v = nil
|
|
138
|
-
else
|
|
139
|
-
k = v = nil
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
[k, v]
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module EpubForge
|
|
2
|
-
module Utils
|
|
3
|
-
class TemplateEvaluator
|
|
4
|
-
attr_reader :content, :vars, :result
|
|
5
|
-
def initialize( content, vars = {} )
|
|
6
|
-
if content.is_a?(Pathname) && content.file?
|
|
7
|
-
@content = @content.read
|
|
8
|
-
else
|
|
9
|
-
@content = content.to_s
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
@vars = vars
|
|
13
|
-
|
|
14
|
-
@result = with_locals(@vars) do
|
|
15
|
-
ERB.new( @content ).result( binding )
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
dir '/'
|
|
2
|
-
dir 'book'
|
|
3
|
-
template 'title_page.markdown'
|
|
4
|
-
template 'foreword.markdown'
|
|
5
|
-
template 'afterword.markdown'
|
|
6
|
-
sequence 'scene-{04i}.markdown'
|
|
7
|
-
dir 'images'
|
|
8
|
-
file 'cover.png'
|
|
9
|
-
dir 'stylesheets'
|
|
10
|
-
template 'stylesheet.css'
|
|
11
|
-
dir 'notes'
|
|
12
|
-
sequence 'character.{name}.markdown'
|
|
13
|
-
dir 'settings'
|
|
14
|
-
template 'config'
|
|
15
|
-
file 'htmlizers.rb'
|
|
16
|
-
template 'wordcount'
|
|
17
|
-
dir 'actions'
|
|
18
|
-
file 'local_action.rb.example'
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class Munition
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
class FileSequence < Munition
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
class DirectorySequence < Munition
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
class TemplateFile < Munition
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
class Payload
|
|
36
|
-
def initialize( src, &block )
|
|
37
|
-
@munitions = []
|
|
38
|
-
yield self if block_given?
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def dir( name, &block )
|
|
42
|
-
|
|
43
|
-
yield if block_given?
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def root( dir = nil )
|
|
47
|
-
@root = dir.fwf_filepath if dir
|
|
48
|
-
@root
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def sequence( name, count )
|
|
52
|
-
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def deploy( dst )
|
|
56
|
-
@munitions.each do |munition|
|
|
57
|
-
munition.deploy( dst )
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
Template::Payload.new do |t|
|
|
63
|
-
dir.template
|
|
64
|
-
|
|
65
|
-
end
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# Used by epubforge.
|
|
2
|
-
FunWith::Configurations::Config.new do
|
|
3
|
-
metadata do
|
|
4
|
-
name "<%= config[:title] || "My Book" %>" # The title of the book
|
|
5
|
-
author "<%= config[:author] || "Author" %>" # Your moniker. Your Nom de Plume. The thing people say to get your attention.
|
|
6
|
-
license "<%= config[:license] || "All Rights Reserved" %>"
|
|
7
|
-
publisher "<%= config[:publisher] || 'My Publisher' %>"
|
|
8
|
-
original_publication "<%= config[:original_publication] || Time.now.strftime('%Y-%m-%d') %>" # The year this work was first published
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
filename "<%= config[:title].epf_underscorize %>" # The default filename for your ebook (no extension).
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<% if config[:git] -%>
|
|
15
|
-
############### GOT GIT? #####################################
|
|
16
|
-
git do
|
|
17
|
-
repo_folder "<%= config[:git][:repo] %>"
|
|
18
|
-
remote_host "<%= config[:git][:host] %>"
|
|
19
|
-
remote_user "<%= config[:git][:user] %>"
|
|
20
|
-
repo_id "<%= config[:git][:repo_id] %>"
|
|
21
|
-
end
|
|
22
|
-
############### /GOT GIT? #####################################
|
|
23
|
-
<% end -%>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
# Any pages not listed here will be added
|
|
27
|
-
# to the ebook after the listed pages, in alphabetical order of
|
|
28
|
-
# filename. In this example, the title_page.markdown file goes first,
|
|
29
|
-
# then the foreword.markdown page, then chapters 1 and 2 (in alphanumeric order)
|
|
30
|
-
# and finally the afterword. Any pages not matched will be put after the
|
|
31
|
-
# set of matched pages.
|
|
32
|
-
|
|
33
|
-
pages do
|
|
34
|
-
book [
|
|
35
|
-
# matches title_page.markdown, title_page.textile, or
|
|
36
|
-
# title_page.(any other valid extension). This will be the first
|
|
37
|
-
# scene/chapter/division in the book.
|
|
38
|
-
"title_page",
|
|
39
|
-
"foreword",
|
|
40
|
-
|
|
41
|
-
# filename matches chapter, followed by anything. If you have a page called
|
|
42
|
-
# chapter_summary that comes after, you might want to define the matcher more
|
|
43
|
-
# specifically, for example 'chapter-\d+' (chapter followed by dash followed by any number of numbers).
|
|
44
|
-
#
|
|
45
|
-
"chapter-.*",
|
|
46
|
-
"afterword"
|
|
47
|
-
]
|
|
48
|
-
|
|
49
|
-
notes [
|
|
50
|
-
# You can set the order that the notes entries appear in below.
|
|
51
|
-
"example89823786",
|
|
52
|
-
"example89723987"
|
|
53
|
-
]
|
|
54
|
-
end
|
|
55
|
-
end
|