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
|
@@ -2,33 +2,36 @@ require 'time' # for Time.parse
|
|
|
2
2
|
|
|
3
3
|
module EpubForge
|
|
4
4
|
module Action
|
|
5
|
-
class WordCount <
|
|
6
|
-
include_standard_options
|
|
5
|
+
class WordCount < Action2
|
|
6
|
+
# include_standard_options
|
|
7
7
|
|
|
8
8
|
WORD_COUNT_FILE = "wordcount"
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
define_action( "wc" ) do |action|
|
|
11
|
+
action.help( "Manage your word counts for book chapters and notes. wc (standalone) is main command" )
|
|
12
|
+
|
|
13
|
+
# keywords :wc
|
|
14
|
+
# usage "#{$PROGRAM_NAME} count <project_directory>"
|
|
15
|
+
#
|
|
16
|
+
# desc( "wc", "Countify words.")
|
|
17
|
+
action.execute do
|
|
18
|
+
debugger unless @project
|
|
19
|
+
@report = { "Notes" => wc_one_folder( @project.notes_dir ),
|
|
20
|
+
"Book" => wc_one_folder( @project.book_dir ) }
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
load_word_count_history
|
|
23
|
+
calculate_todays_word_count
|
|
24
|
+
append_word_count_history( @report )
|
|
25
|
+
print_report
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
say_all_is_well( "Done" )
|
|
28
|
+
@report
|
|
29
|
+
end
|
|
27
30
|
end
|
|
28
31
|
|
|
29
32
|
protected
|
|
30
33
|
def wc_one_folder( foldername )
|
|
31
|
-
foldername.glob( ext: EpubForge::
|
|
34
|
+
foldername.glob( ext: EpubForge::Builder::PAGE_FILE_EXTENSIONS ).inject(0) do |count, file|
|
|
32
35
|
count += wc_one_file( file )
|
|
33
36
|
end
|
|
34
37
|
end
|
|
@@ -116,12 +119,11 @@ module EpubForge
|
|
|
116
119
|
end
|
|
117
120
|
|
|
118
121
|
def print_report
|
|
119
|
-
say "",
|
|
120
|
-
say "
|
|
121
|
-
say "
|
|
122
|
-
say "
|
|
123
|
-
say "
|
|
124
|
-
say "Today: #{@report["Today"]}", BLUE
|
|
122
|
+
say( "\nWordcount", :blue )
|
|
123
|
+
say( "---------", :blue )
|
|
124
|
+
say( "Notes: #{@report["Notes"]}", :blue )
|
|
125
|
+
say( "Book: #{@report["Book"]}", :blue )
|
|
126
|
+
say( "Today: #{@report["Today"]}", :blue )
|
|
125
127
|
end
|
|
126
128
|
end
|
|
127
129
|
end
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module EpubForge
|
|
2
2
|
module Action
|
|
3
|
-
class GitBackup <
|
|
3
|
+
class GitBackup < Action
|
|
4
4
|
description "commit your project to the git repo and back it up"
|
|
5
5
|
keywords :backup, :save, :commit
|
|
6
6
|
usage "#{$PROGRAM_NAME} commit <project directory (optional if current dir)> \"optional message\""
|
|
@@ -16,7 +16,7 @@ module EpubForge
|
|
|
16
16
|
return false
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
`cd #{@project.
|
|
19
|
+
`cd #{@project.root_dir} && git commit -a -m "#{@message}" && git push`
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module EpubForge
|
|
2
2
|
module Action
|
|
3
|
-
class Globals <
|
|
3
|
+
class Globals < Action
|
|
4
4
|
description "Set up global defaults for things like author name, publisher, etc."
|
|
5
5
|
keywords :global
|
|
6
6
|
usage "#{$PROGRAM_NAME} global <key>=\"<val>\" or global -i <asks you for defaults>"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module EpubForge
|
|
2
2
|
module Action
|
|
3
|
-
class Kindle <
|
|
3
|
+
class Kindle < Action
|
|
4
4
|
description "Create a .mobi book and try to push it to your Kindle (conversion requires Calibre)"
|
|
5
5
|
keywords :kindle, :push, :b2k
|
|
6
6
|
usage "#{$PROGRAM_NAME} b2k <project_directory>"
|
|
@@ -11,8 +11,8 @@ module EpubForge
|
|
|
11
11
|
desc( "do:kindle", "<<OBSOLETE>> Turn your .epub file into a .mobi file. Check to see if your Kindle is connected, then pushes it." )
|
|
12
12
|
def do( project, *args )
|
|
13
13
|
@project = project
|
|
14
|
-
@src_epub = @project.
|
|
15
|
-
@dst_mobi = @project.
|
|
14
|
+
@src_epub = @project.filename_for_book.ext("epub")
|
|
15
|
+
@dst_mobi = @project.filename_for_book.ext("mobi")
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
protected
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module EpubForge
|
|
2
2
|
module Action
|
|
3
|
-
class LocalAction <
|
|
3
|
+
class LocalAction < Action
|
|
4
4
|
TEMPLATE = EpubForge.root( "templates", "default", "settings", "actions", "local_action.rb.example" )
|
|
5
5
|
|
|
6
6
|
method_option :desc, :type => :string, :default => "Describe this module"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module EpubForge
|
|
2
2
|
module Action
|
|
3
|
-
class Forge <
|
|
3
|
+
class Forge < Action
|
|
4
4
|
# TODO: These should be user-specific settings
|
|
5
5
|
KINDLE_DEVICE_DIR = "/".fwf_filepath.join( "Volumes", "Kindle" )
|
|
6
6
|
KINDLE_PUSH_DIR = KINDLE_DEVICE_DIR.join( "documents", "fic-mine" )
|
|
@@ -14,8 +14,8 @@ module EpubForge
|
|
|
14
14
|
|
|
15
15
|
@args = args
|
|
16
16
|
@push, @push_to = self.push?
|
|
17
|
-
@src_epub = @project.
|
|
18
|
-
@dst_mobi = @project.
|
|
17
|
+
@src_epub = @project.filename_for_book.ext("epub")
|
|
18
|
+
@dst_mobi = @project.filename_for_book.ext("mobi")
|
|
19
19
|
|
|
20
20
|
@regenerate_epub = !!( @args.include?( "--no-cache" ) )
|
|
21
21
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Should be obsolete
|
|
2
|
+
# module EpubForge
|
|
3
|
+
# module Action
|
|
4
|
+
# class Forge < Action
|
|
5
|
+
# include_standard_options
|
|
6
|
+
#
|
|
7
|
+
# desc( "forge:notes", "Wraps your story notes up in a .epub (ebook) file." )
|
|
8
|
+
# def notes( *args )
|
|
9
|
+
# before_start
|
|
10
|
+
# builder = EpubForge::Builder::Epub.new( @project, book_dir: @project.root_dir.join("notes"),
|
|
11
|
+
# page_order: @project.config[:pages][:notes] )
|
|
12
|
+
# builder.build
|
|
13
|
+
# builder.package( @project.filename_for_notes.ext("epub") )
|
|
14
|
+
# builder.clean
|
|
15
|
+
# puts "Done building epub <#{@project.filename_for_notes.ext("epub")}>"
|
|
16
|
+
# end
|
|
17
|
+
# end
|
|
18
|
+
# end
|
|
19
|
+
# end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Should be obsolete
|
|
2
|
+
# module EpubForge
|
|
3
|
+
# module Action
|
|
4
|
+
# class NotesToKindle < Kindle
|
|
5
|
+
# description "Create a .mobi book from the notes and try to push it to your Kindle"
|
|
6
|
+
# keywords :n2k
|
|
7
|
+
# usage "#{$PROGRAM_NAME} n2k <project_directory>"
|
|
8
|
+
#
|
|
9
|
+
# def do( project, args )
|
|
10
|
+
# @project = project
|
|
11
|
+
# @src_epub = @project.filename_for_notes.ext("epub")
|
|
12
|
+
# @dst_mobi = @project.filename_for_notes.ext("mobi")
|
|
13
|
+
#
|
|
14
|
+
# mobify
|
|
15
|
+
# end
|
|
16
|
+
# end
|
|
17
|
+
# end
|
|
18
|
+
# end
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
module EpubForge
|
|
2
2
|
module Action
|
|
3
|
-
class Version <
|
|
4
|
-
description "Print version (v.#{EpubForge
|
|
3
|
+
class Version < Action
|
|
4
|
+
description "Print version (v.#{EpubForge.version}, to save you the trouble)"
|
|
5
5
|
keywords :version, :"--version"
|
|
6
6
|
usage "#{$PROGRAM_NAME} -v"
|
|
7
7
|
project_not_required
|
|
8
8
|
|
|
9
9
|
desc( "do:version", "print out help for the various actions.")
|
|
10
10
|
def do( project, *args )
|
|
11
|
-
puts "epubforge v. #{EpubForge
|
|
11
|
+
puts "epubforge v. #{EpubForge.version}, Copyright Bryce Anderson. MIT License."
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module EpubForge
|
|
2
2
|
module Action
|
|
3
|
-
class WrapSceneNotesInHiddenDiv <
|
|
3
|
+
class WrapSceneNotesInHiddenDiv < Action
|
|
4
4
|
description "Assumes scenes are in book/scene-XXXX.markdown, and that the scene description is above the first horizontal row (a.k.a. ***** in Markdown)."
|
|
5
5
|
keywords :wrap_scene_notes
|
|
6
6
|
usage "#{$PROGRAM_NAME} wrap_scene_notes<project_directory (optional if current directory)>\n\tfollow with 'undo' to reverse transformation."
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
EpubForge::Utils::Converter.new do
|
|
2
|
+
label :epub_to_mobi_calibre
|
|
3
|
+
input_format :epub
|
|
4
|
+
output_format :mobi
|
|
5
|
+
executable "ebook-convert"
|
|
6
|
+
|
|
7
|
+
help "To use #{label}, download the latest version of Calibre at http://calibre-ebook.com/download, then make sure 'ebook-convert' is in your command line's search path."
|
|
8
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# My thinking is that, once the direct-from-source files are generated, further file formats can
|
|
2
|
+
# be handled by "converters" that take generated file X and convert to output file Y.
|
|
3
|
+
|
|
4
|
+
EpubForge::Utils::Converter.new do
|
|
5
|
+
label :epub_to_mobi_kindlegen
|
|
6
|
+
input_format :epub
|
|
7
|
+
output_format :mobi
|
|
8
|
+
executable "kindlegen"
|
|
9
|
+
command "{{x}} {{src}} -o {{dst}}"
|
|
10
|
+
help "Kindlegen is a command-line tool by Amazon, which can be downloaded at http://www.amazon.com/gp/feature.html?docId=1000765211"
|
|
11
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
EpubForge::Utils::HtmlTranslator.new do
|
|
2
|
+
name :epubforge_markdown
|
|
3
|
+
format :markdown
|
|
4
|
+
group :default # the default is :user, so user-defined ones don't have to set it
|
|
5
|
+
|
|
6
|
+
custom_proc do |filepath, *args|
|
|
7
|
+
Kramdown::Document.new( filepath.read ).to_html
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# # Uncomment if you'd rather use the multimarkdown executable
|
|
2
|
+
#
|
|
3
|
+
# EpubForge::Utils::HtmlTranslator.new do
|
|
4
|
+
# name :epubforge_multimarkdown
|
|
5
|
+
# format :markdown
|
|
6
|
+
# group :default # the default is :user, so user-defined ones don't have to set it
|
|
7
|
+
# executable "multimarkdown"
|
|
8
|
+
# cmd "{{x}} {{o}} {{f}}"
|
|
9
|
+
# # opts "" # the default
|
|
10
|
+
# end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# # Uncomment if you'd rather use the pandoc executable
|
|
2
|
+
#
|
|
3
|
+
# EpubForge::Utils::HtmlTranslator.new do
|
|
4
|
+
# name :epubforge_pandoc_markdown
|
|
5
|
+
# format :markdown
|
|
6
|
+
# group :default
|
|
7
|
+
# executable "pandoc"
|
|
8
|
+
# cmd "{{x}} {{o}} {{f}}"
|
|
9
|
+
# opts "--from=markdown --to=html"
|
|
10
|
+
# end
|
data/lib/epubforge.rb
CHANGED
|
@@ -1,63 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
require
|
|
7
|
-
require
|
|
8
|
-
require
|
|
9
|
-
require
|
|
10
|
-
require
|
|
11
|
-
require
|
|
12
|
-
require
|
|
13
|
-
require
|
|
14
|
-
require
|
|
15
|
-
require
|
|
16
|
-
require
|
|
17
|
-
require
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
EpubForge
|
|
24
|
-
EpubForge::DEBUG = false
|
|
25
|
-
# EpubForge.root responds with the gem directory
|
|
26
|
-
FunWith::Files::RootPath.rootify( EpubForge, __FILE__.fwf_filepath.dirname.up )
|
|
27
|
-
EpubForge::VERSION = EpubForge.root("VERSION").read
|
|
28
|
-
|
|
29
|
-
def debugger?
|
|
30
|
-
debugger if debugging?
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def debugging?
|
|
34
|
-
EpubForge::DEBUG
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
require_relative 'core_extensions/array'
|
|
39
|
-
require_relative 'core_extensions/kernel'
|
|
40
|
-
require_relative 'core_extensions/nil_class'
|
|
41
|
-
require_relative 'core_extensions/object'
|
|
42
|
-
require_relative 'core_extensions/string'
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
require_relative 'utils/directory_builder'
|
|
46
|
-
require_relative 'utils/downloader'
|
|
47
|
-
require_relative 'utils/file_orderer'
|
|
48
|
-
require_relative 'utils/misc'
|
|
49
|
-
require_relative 'utils/class_loader'
|
|
50
|
-
require_relative 'utils/action_loader'
|
|
51
|
-
require_relative 'utils/template_evaluator'
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
require "thor"
|
|
2
|
+
require "optparse"
|
|
3
|
+
require "nokogiri"
|
|
4
|
+
require "xdg"
|
|
5
|
+
require "debugger"
|
|
6
|
+
require "erb"
|
|
7
|
+
require "singleton"
|
|
8
|
+
require "builder" # XML Builder, not our builder
|
|
9
|
+
require "pathname"
|
|
10
|
+
require "tmpdir"
|
|
11
|
+
require "rbconfig"
|
|
12
|
+
require "kramdown"
|
|
13
|
+
require "fun_with_gems"
|
|
14
|
+
require "fun_with_templates"
|
|
15
|
+
require "fun_with_configurations"
|
|
16
|
+
require "fun_with_string_colors"
|
|
17
|
+
require "fun_with_patterns"
|
|
18
|
+
|
|
19
|
+
FunWith::StringColors.activate
|
|
20
|
+
String.colorize( true )
|
|
21
|
+
FunWith::Patterns::GetAndSet.activate
|
|
22
|
+
|
|
23
|
+
FunWith::Gems.make_gem_fun( "EpubForge" )
|
|
54
24
|
|
|
55
25
|
module EpubForge
|
|
26
|
+
USER_SETTINGS = XDG['CONFIG_HOME'].fwf_filepath( "epubforge" )
|
|
27
|
+
DEBUG = false
|
|
28
|
+
|
|
56
29
|
ACTIONS_DIR = EpubForge.root.join( "config", "actions" )
|
|
30
|
+
USER_ACTIONS_DIR = USER_SETTINGS.join( "actions" )
|
|
31
|
+
CONVERTERS_DIR = EpubForge.root.join( "config", "converters" )
|
|
32
|
+
USER_CONVERTERS_DIR = USER_SETTINGS.join( "converters" )
|
|
33
|
+
|
|
34
|
+
HTML_TRANSLATORS_DIR = EpubForge.root.join( "config", "html_translators" )
|
|
35
|
+
USER_HTML_TRANSLATORS_DIR = USER_SETTINGS.join( "html_translators" )
|
|
36
|
+
|
|
57
37
|
TEMPLATES_DIR = EpubForge.root.join( "templates" )
|
|
58
|
-
USER_SETTINGS = XDG['CONFIG_HOME'].to_s.fwf_filepath.join( "epubforge" )
|
|
59
38
|
USER_GLOBALS_FILE = USER_SETTINGS.join( "globals.rb" )
|
|
60
|
-
USER_ACTIONS_DIR = USER_SETTINGS.join( "actions" )
|
|
61
39
|
|
|
62
40
|
puts "Warning: Cannot create user settings folder." unless USER_ACTIONS_DIR.touch_dir
|
|
63
41
|
puts "Warning: Cannot create globals file." unless USER_GLOBALS_FILE.touch
|
|
@@ -65,32 +43,9 @@ end
|
|
|
65
43
|
|
|
66
44
|
EpubForge.install_fwc_config_from_file( EpubForge::USER_GLOBALS_FILE )
|
|
67
45
|
|
|
68
|
-
EpubForge.
|
|
69
|
-
|
|
70
|
-
require_relative 'utils/html_translator'
|
|
71
|
-
require_relative 'utils/html_translator_queue'
|
|
72
|
-
require_relative 'utils/htmlizer'
|
|
73
|
-
|
|
74
|
-
require_relative 'action/file_transformer'
|
|
75
|
-
require_relative 'action/run_description'
|
|
76
|
-
require_relative 'action/thor_action'
|
|
77
|
-
require_relative 'action/actions_lookup'
|
|
78
|
-
require_relative 'action/runner'
|
|
79
|
-
require_relative 'action/cli_command'
|
|
80
|
-
require_relative 'action/cli_sequence'
|
|
81
|
-
require_relative 'custom_helpers'
|
|
82
|
-
require_relative 'epub/builder'
|
|
83
|
-
require_relative 'epub/packager'
|
|
84
|
-
require_relative 'epub/assets/asset'
|
|
85
|
-
require_relative 'epub/assets/page'
|
|
86
|
-
require_relative 'epub/assets/html'
|
|
87
|
-
require_relative 'epub/assets/markdown'
|
|
88
|
-
require_relative 'epub/assets/textile'
|
|
89
|
-
require_relative 'epub/assets/image'
|
|
90
|
-
require_relative 'epub/assets/stylesheet'
|
|
91
|
-
require_relative 'epub/assets/xhtml'
|
|
92
|
-
require_relative 'project/project'
|
|
46
|
+
EpubForge.extend( EpubForge::CustomHelpers )
|
|
93
47
|
|
|
94
|
-
|
|
48
|
+
EpubForge::Action::Action2.loader_pattern_load_from_dir( EpubForge::ACTIONS_DIR, EpubForge::USER_ACTIONS_DIR )
|
|
49
|
+
EpubForge::Utils::Converter.loader_pattern_load_from_dir( EpubForge::CONVERTERS_DIR, EpubForge::USER_CONVERTERS_DIR )
|
|
50
|
+
EpubForge::Utils::HtmlTranslator.loader_pattern_load_from_dir( EpubForge::HTML_TRANSLATORS_DIR, EpubForge::USER_HTML_TRANSLATORS_DIR )
|
|
95
51
|
|
|
96
|
-
puts "Done with tests inside epubforge.rb" if debugging?
|