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
data/config/actions/gitify.rb
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
module EpubForge
|
|
2
|
-
module Action
|
|
3
|
-
class Gitify < ThorAction
|
|
4
|
-
description "create a remote git repository of the project folder"
|
|
5
|
-
keywords :gitify, :git_init
|
|
6
|
-
usage "#{$PROGRAM_NAME} gitify <project_directory>"
|
|
7
|
-
|
|
8
|
-
desc( "do:gitify", "create a git repository to hold backups" )
|
|
9
|
-
def do( project, *args )
|
|
10
|
-
@project = project
|
|
11
|
-
@conf = @project.config
|
|
12
|
-
@gitconf = @conf.git
|
|
13
|
-
@cli_sequence = CliSequence.new
|
|
14
|
-
@cli_sequence.default( :verbose, true )
|
|
15
|
-
@cli_sequence.default( :local_dir, @project.target_dir )
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if project_already_gitted?
|
|
19
|
-
say_error "Already seems to be a git project. delete the .git folder if this is incorrect."
|
|
20
|
-
return false
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
project_name_with_folder = @gitconf["repo_folder"].fwf_filepath.expand
|
|
24
|
-
|
|
25
|
-
if @gitconf["remote_host"]
|
|
26
|
-
remote_host = "#{@gitconf['remote_user']}@#{@gitconf['remote_host']}"
|
|
27
|
-
@cli_sequence.default( :remote, remote_host )
|
|
28
|
-
project_url = "ssh://#{remote_host}#{project_name_with_folder}"
|
|
29
|
-
|
|
30
|
-
@cli_sequence.add_remote_command( "mkdir -p #{project_name_with_folder}", "rm -rf #{project_name_with_folder}" )
|
|
31
|
-
@cli_sequence.add_remote_command( "git --bare init #{project_name_with_folder}" )
|
|
32
|
-
identifier = project_name_with_folder.join( @gitconf["repo_id"] )
|
|
33
|
-
@cli_sequence.add_remote_command( "touch #{identifier}", "rm #{identifier}" ) # undo isn't needed here, since the directory will be wiped out.
|
|
34
|
-
else
|
|
35
|
-
project_url = "file://#{project_name_with_folder}"
|
|
36
|
-
@cli_sequence.add_local_command( "mkdir -p #{project_name_with_folder}", "rm -rf #{project_name_with_folder}" )
|
|
37
|
-
@cli_sequence.add_local_command( "git --bare init #{project_name_with_folder}" )
|
|
38
|
-
identifier = project_name_with_folder.join( @gitconf["repo_id"] )
|
|
39
|
-
@cli_sequence.add_local_command( "touch #{identifier}", "rm #{identifier}" )
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# running locally
|
|
43
|
-
@cli_sequence.add_local_command "git init", "rm -rf .git"
|
|
44
|
-
@cli_sequence.add_local_command "git remote add origin #{project_url}"
|
|
45
|
-
@cli_sequence.add_local_command "git add ."
|
|
46
|
-
@cli_sequence.add_local_command "git commit -a -m \"Initial commit\""
|
|
47
|
-
@cli_sequence.add_local_command "git config branch.master.remote origin"
|
|
48
|
-
@cli_sequence.add_local_command "git config branch.master.merge refs/heads/master"
|
|
49
|
-
@cli_sequence.add_local_command "git push origin master" # need to be explicit about branch the first time
|
|
50
|
-
|
|
51
|
-
if @cli_sequence.execute
|
|
52
|
-
say_all_is_well( "All done. The url for this project is #{project_url}" )
|
|
53
|
-
else
|
|
54
|
-
say_error( "Command sequence failed." )
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
protected
|
|
59
|
-
def git_remote_exec( cmd )
|
|
60
|
-
say_subtly( "attempting to run remotely: #{cmd}" )
|
|
61
|
-
`cd #{@project.target_dir} && ssh #{@gitconf["remote_user"]}@#{@gitconf["remote_host"]} "#{cmd}"`
|
|
62
|
-
say( "Success: #{$?.success?}")
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def git_local_exec( cmd )
|
|
66
|
-
say_subtly( "attempting to run locally: #{cmd}" )
|
|
67
|
-
`cd #{@project.target_dir} && #{cmd}`
|
|
68
|
-
say( "Success: #{$?.success?}")
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
data/config/actions/init.rb
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
module EpubForge
|
|
2
|
-
module Action
|
|
3
|
-
class Init < ThorAction
|
|
4
|
-
include_standard_options
|
|
5
|
-
project_not_required
|
|
6
|
-
|
|
7
|
-
desc("init", "create a new epubforge project")
|
|
8
|
-
def init( *args )
|
|
9
|
-
unless @project.nil?
|
|
10
|
-
say_error "Project already exists. Quitting."
|
|
11
|
-
return false
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
return false unless parse_args( *args )
|
|
15
|
-
|
|
16
|
-
@template_dir = EpubForge.root.join( "templates", @template_to_use )
|
|
17
|
-
src_entries = @template_dir.glob( "**", "*" ).map{ |entry|
|
|
18
|
-
entry.relative_path_from( @template_dir )
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
self.source_paths.push( @template_dir )
|
|
22
|
-
src_dirs = src_entries.select{ |d| @template_dir.join(d).directory? }.uniq
|
|
23
|
-
|
|
24
|
-
for dir in src_dirs
|
|
25
|
-
empty_directory( self.destination_root_filepath.join( dir ) )
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
for entry in src_entries - src_dirs
|
|
29
|
-
case entry.ext
|
|
30
|
-
when "template"
|
|
31
|
-
dst = self.destination_root_filepath.join( entry ).without_ext
|
|
32
|
-
template( entry, dst )
|
|
33
|
-
when "sequence"
|
|
34
|
-
@chapter_count ||= @opts[:answers][:chapter_count] if @opts[:answers]
|
|
35
|
-
@chapter_count ||= ask_prettily("Setting up chapter files.\n How many chapters will your book have (you can add more later)? >>> ").to_i
|
|
36
|
-
|
|
37
|
-
1.upto( @chapter_count ) do |i|
|
|
38
|
-
@i = i
|
|
39
|
-
dst = self.destination_root_filepath.join( entry ).gsub( /%i%/, sprintf( "%04i", @i) ).without_ext
|
|
40
|
-
template( entry, dst )
|
|
41
|
-
end
|
|
42
|
-
when "form"
|
|
43
|
-
configure_configuration( @opts[:answers] || {} )
|
|
44
|
-
dst = self.destination_root_filepath.join( entry ).without_ext
|
|
45
|
-
template( entry, dst, @template_options )
|
|
46
|
-
say_all_is_well( "Your configuration is all set up!" )
|
|
47
|
-
say_instruction( "run 'epubforge gitify' to initialize the backup repository." )
|
|
48
|
-
else
|
|
49
|
-
copy_file( entry, self.destination_root_filepath.join( entry ) )
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
protected
|
|
55
|
-
def configure_configuration(opts = {})
|
|
56
|
-
say_instruction( "Don't think too hard about these next few questions. You can always change your mind by editing settings/config" )
|
|
57
|
-
|
|
58
|
-
opts[:title] ||= ask_prettily("What is the name of your book?")
|
|
59
|
-
opts[:author] ||= ask_prettily( "What is the name of the author?" )
|
|
60
|
-
opts[:license] ||= ask_from_menu "What license do you want your book under?", [ "All Rights Reserved",
|
|
61
|
-
"Creative Commons Non-Commercial, No Derivatives License",
|
|
62
|
-
"Creative Commons Non-Commercial, Share-Alike License",
|
|
63
|
-
"GNU Free Documentation License",
|
|
64
|
-
"Public Domain",
|
|
65
|
-
"Other" ]
|
|
66
|
-
if opts[:license] == "Other"
|
|
67
|
-
opts[:license] = ask_prettily( "Type in the license you wish to use : " )
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
@template_options = opts
|
|
71
|
-
|
|
72
|
-
if git_installed?
|
|
73
|
-
if opts[:use_git] || opts[:use_git].nil? && yes_prettily?( "Do you want to back up your project using git?" )
|
|
74
|
-
configure_git( opts[:git] || {} )
|
|
75
|
-
end
|
|
76
|
-
else
|
|
77
|
-
warn("The program 'git' must be installed and locatable if you want epubforge to back up your project.")
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
def configure_git( opts = {})
|
|
84
|
-
opts[:remote] = "Back up to a remote host."
|
|
85
|
-
opts[:thumb] = "Back up to an external or thumb drive."
|
|
86
|
-
opts[:backup_type] ||= ask_from_menu( "Where would you like to back up your project to?",
|
|
87
|
-
[ opts[:remote],
|
|
88
|
-
opts[:thumb] ] )
|
|
89
|
-
|
|
90
|
-
opts[:repo_id] ||= rand(16**32).to_s(16)
|
|
91
|
-
|
|
92
|
-
if opts[:backup_type] == opts[:remote]
|
|
93
|
-
opts[:host] ||= ask_prettily("Enter the name of the remote host : ")
|
|
94
|
-
opts[:user] ||= ask_prettily("Enter your user name : ")
|
|
95
|
-
opts[:repo] ||= ask_prettily("Enter the name of the folder on the remote host. A folder called #{backup_folder_name} will be created there : ")
|
|
96
|
-
elsif opts[:backup_type] == opts[:thumb]
|
|
97
|
-
opts[:repo] ||= ask_prettily("Enter the full path to the backup folder. A folder called #{backup_folder_name} will be created there: ")
|
|
98
|
-
else
|
|
99
|
-
say_error("I'm confused by the requested backup style <#{opts[:backup_type]}>. Skipping git configuration.")
|
|
100
|
-
opts = nil
|
|
101
|
-
return false
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
# TODO: What if the target file system uses a different file separator?
|
|
105
|
-
opts[:repo] = opts[:repo].fwf_filepath.join( backup_folder_name ) if opts[:repo].is_a?(String)
|
|
106
|
-
@template_options[:git] = opts
|
|
107
|
-
true
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def backup_folder_name
|
|
111
|
-
(@template_options[:title] || "").epf_underscorize + ".epubforge.git"
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
# Expects the following arguments: 1:<project directory (shouldn't exist)>, 2: options hash.
|
|
115
|
-
# Options hash includes:
|
|
116
|
-
def parse_args( *args )
|
|
117
|
-
@opts = args.last.is_a?(Hash) ? args.pop : {}
|
|
118
|
-
root = args.shift
|
|
119
|
-
|
|
120
|
-
if root.nil?
|
|
121
|
-
say_error "No destination directory given."
|
|
122
|
-
return false
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
self.destination_root_filepath = root.fwf_filepath
|
|
126
|
-
|
|
127
|
-
if self.destination_root_filepath.exist? &&
|
|
128
|
-
(!(self.destination_root_filepath.empty?) || !(self.destination_root_filepath.directory?))
|
|
129
|
-
say_error "This action must create a new directory or act upon an empty directory. Quitting."
|
|
130
|
-
return false
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
@template_to_use = "default" # TODO: should turn into an option
|
|
134
|
-
true
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
module EpubForge
|
|
2
|
-
module Action
|
|
3
|
-
class Forge < ThorAction
|
|
4
|
-
include_standard_options
|
|
5
|
-
|
|
6
|
-
desc( "forge:notes", "Wraps your story notes up in a .epub (ebook) file." )
|
|
7
|
-
def notes( *args )
|
|
8
|
-
before_start
|
|
9
|
-
builder = EpubForge::Epub::Builder.new( @project, book_dir: @project.target_dir.join("notes"),
|
|
10
|
-
page_order: @project.config[:pages][:notes] )
|
|
11
|
-
builder.build
|
|
12
|
-
builder.package( @project.filename_for_epub_notes )
|
|
13
|
-
builder.clean
|
|
14
|
-
puts "Done building epub <#{@project.filename_for_epub_notes}>"
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module EpubForge
|
|
2
|
-
module Action
|
|
3
|
-
class NotesToKindle < Kindle
|
|
4
|
-
description "Create a .mobi book from the notes and try to push it to your Kindle"
|
|
5
|
-
keywords :n2k
|
|
6
|
-
usage "#{$PROGRAM_NAME} n2k <project_directory>"
|
|
7
|
-
|
|
8
|
-
def do( project, args )
|
|
9
|
-
@project = project
|
|
10
|
-
@src_epub = @project.filename_for_epub_notes.fwf_filepath
|
|
11
|
-
@dst_mobi = @project.filename_for_mobi_notes.fwf_filepath
|
|
12
|
-
|
|
13
|
-
mobify
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
data/config/htmlizers.rb
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
EpubForge::Utils::Htmlizer.define do |html|
|
|
2
|
-
html.format :xhtml
|
|
3
|
-
html.group :default
|
|
4
|
-
html.executable "false"
|
|
5
|
-
html.cmd "cat {{f}}"
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
EpubForge::Utils::Htmlizer.define do |html|
|
|
10
|
-
html.format :markdown
|
|
11
|
-
html.group :default # the default is :user, so user-defined ones don't have to set it
|
|
12
|
-
html.executable "multimarkdown"
|
|
13
|
-
html.cmd "{{x}} {{o}} {{f}}"
|
|
14
|
-
# html.opts "" # the default
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
EpubForge::Utils::Htmlizer.define do |html|
|
|
18
|
-
html.format :markdown
|
|
19
|
-
html.group :default
|
|
20
|
-
html.executable "pandoc"
|
|
21
|
-
html.cmd "{{x}} {{o}} {{f}}"
|
|
22
|
-
html.opts "--from=markdown --to=html"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
EpubForge::Utils::Htmlizer.define do |html|
|
|
26
|
-
html.format :textile
|
|
27
|
-
html.group :default
|
|
28
|
-
html.executable "pandoc"
|
|
29
|
-
html.cmd "{{x}} {{o}} {{f}}"
|
|
30
|
-
html.opts "--from=textile --to=html"
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
# Emergency backups
|
|
35
|
-
EpubForge::Utils::Htmlizer.define do |html|
|
|
36
|
-
html.format :markdown
|
|
37
|
-
html.group :fallback
|
|
38
|
-
html.executable "false"
|
|
39
|
-
html.cmd "echo \"<pre>\" && cat {{f}} && echo \"</pre>\""
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
EpubForge::Utils::Htmlizer.define do |html|
|
|
43
|
-
html.format :textile
|
|
44
|
-
html.group :fallback
|
|
45
|
-
html.executable "false"
|
|
46
|
-
html.cmd "echo \"<pre>\" && cat {{f}} && echo \"</pre>\""
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
EpubForge::Utils::Htmlizer.define do |html|
|
|
50
|
-
html.format :txt
|
|
51
|
-
html.group :fallback
|
|
52
|
-
html.executable "false"
|
|
53
|
-
html.cmd "echo \"<pre>\" && cat {{f}} && echo \"</pre>\""
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
# Would be nice to detect and strip out the outer tags
|
|
57
|
-
# leaving only the content.
|
|
58
|
-
EpubForge::Utils::Htmlizer.define do |html|
|
|
59
|
-
html.format :html
|
|
60
|
-
html.group :fallback
|
|
61
|
-
html.executable "false"
|
|
62
|
-
html.cmd "cat {{f}}"
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
EpubForge::Utils::Htmlizer.define do |html|
|
|
66
|
-
html.format :unknown
|
|
67
|
-
html.group :fallback
|
|
68
|
-
html.executable "false"
|
|
69
|
-
html.cmd "echo \"<pre>\" && cat {{f}} && echo \"</pre>\""
|
|
70
|
-
end
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
module EpubForge
|
|
2
|
-
module Action
|
|
3
|
-
class ActionsLookup
|
|
4
|
-
attr_accessor :actions, :actions_directories, :keywords
|
|
5
|
-
|
|
6
|
-
def initialize
|
|
7
|
-
clear
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def clear
|
|
11
|
-
@keywords = {}
|
|
12
|
-
@actions = []
|
|
13
|
-
@actions_directories = []
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def add_actions( *args )
|
|
17
|
-
Utils::ActionLoader.load_me( *args )
|
|
18
|
-
|
|
19
|
-
new_actions = Utils::ActionLoader.loaded_classes - @actions
|
|
20
|
-
@actions += new_actions
|
|
21
|
-
new_directories = Utils::ActionLoader.loaded_directories - @actions_directories
|
|
22
|
-
@actions_directories += new_directories
|
|
23
|
-
|
|
24
|
-
for action in new_actions
|
|
25
|
-
for keyword in action.keywords
|
|
26
|
-
@keywords[keyword] = action
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# Find all the actions with keywords that start with the given string.
|
|
32
|
-
# If this results in more than one action being found, the proper
|
|
33
|
-
# response is to panic and flail arms.
|
|
34
|
-
def keyword_to_action( keyword )
|
|
35
|
-
exact_match = @keywords.keys.select{ |k| k == keyword }
|
|
36
|
-
|
|
37
|
-
return [@keywords[exact_match.first]] if exact_match.length == 1
|
|
38
|
-
|
|
39
|
-
# if no exact match can be found, find a partial match, at the beginning
|
|
40
|
-
# of the keywords.
|
|
41
|
-
@keywords.keys.select{ |k| k.match(/^#{keyword}/) }.map{ |k| @keywords[k] }.uniq
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
data/lib/epub/assets/html.rb
DELETED
data/lib/epub/assets/markdown.rb
DELETED
data/lib/epub/assets/textile.rb
DELETED
data/lib/epub/assets/xhtml.rb
DELETED
data/lib/epub/packager.rb
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module EpubForge
|
|
2
|
-
module Epub
|
|
3
|
-
class Packager
|
|
4
|
-
def initialize( src_dir, dst_filename )
|
|
5
|
-
@src_dir = src_dir
|
|
6
|
-
@dst_filename = dst_filename
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def package
|
|
10
|
-
@dst_filename = @dst_filename.expand
|
|
11
|
-
FileUtils.rm( @dst_filename ) if @dst_filename.exist?
|
|
12
|
-
`cd #{@src_dir} && zip -Xr #{@dst_filename.to_s.epf_backhashed_filename} mimetype META-INF OEBPS`
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|