Skip to content

Commit

Permalink
hopefully this will solve the .mobi problem. Also, added instructions…
Browse files Browse the repository at this point in the history
… to the email for getting files onto Kindle/Nook.
  • Loading branch information
darthschmoo committed May 22, 2013
1 parent 0bc8bc5 commit e778592
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ gem 'bluecloth'
gem 'liquid'
gem 'haml'
gem 'eeepub'
gem 'epubforge'
gem 'epubforge', "0.0.7"
gem 'pacecar'

# required for publicity tweets
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ GEM
eeepub (0.8.1)
builder
rubyzip
epubforge (0.0.6)
epubforge (0.0.7)
builder
fun_with_configurations
fun_with_files
Expand Down Expand Up @@ -212,7 +212,7 @@ DEPENDENCIES
compass-rails
debugger
eeepub
epubforge
epubforge (= 0.0.7)
factory_girl (~> 3.0)
factory_girl_rails (~> 3.0)
faker
Expand Down
35 changes: 33 additions & 2 deletions app/controllers/books_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,35 @@ def handle_errors( &block )
FileUtils.rm( file ) if file.exist?
end

debugger

sig_html = <<-EOS
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>#{@book.title}, by #{@book.author.name}</title>
<link href="../Styles/style.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body id="sig">
<p class="name">#{@ebook_signature.name},</p>
<div class="message">
#{ ApplicationHelper.markdown( @ebook_signature.message ) }
</div>
<div class="sig">
<img style="float:right" src="../Images/bryce.png" alt="Bryce Anderson signed this"/>
</div>
</body>
</html>
EOS

@book.absolute_project_path.join( "book", "sig.xhtml" ).write( sig_html )

@should_pdf = params[:book_format][:pdf] == "1"
@should_mobi = params[:book_format][:mobi] == "1"
@should_epub = params[:book_format][:epub] == "1"
Expand All @@ -71,8 +100,9 @@ def handle_errors( &block )
@errors = []

[ ["forge", :epub, @should_epub],
["mobify", :mobi, @should_mobi],
["pdfify", :pdf, @should_pdf ] ].each do |forge_command, format, should_be_done|
["mobify", :mobi, @should_mobi] #,
# ["pdfify", :pdf, @should_pdf ]
].each do |forge_command, format, should_be_done|
if should_be_done
handle_errors do
rundesc = EpubForge::Action::Runner.new.exec( forge_command, @book.absolute_project_path )
Expand All @@ -87,6 +117,7 @@ def handle_errors( &block )

unless @files.empty?
handle_errors do
puts "Sending to gmail"
response = BookMailer.send_signed_copy( @book, @files, @ebook_signature ).deliver!
end
end
Expand Down
16 changes: 16 additions & 0 deletions app/views/book_mailer/send_signed_copy.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,21 @@

<p><%= @book.author.name %>,<br/>
Author and Proprietor of <a href="http://bannedsorcery.com">bannedsorcery.com</a></p>

<hr/>

<h2>Instructions for loading onto your e-reader:</h2>

<p>Nook: Plug the Nook into your computer and copy the <strong>.epub</strong> file to its "My Documents" folder.</p>

<p>Kindle: Plug in the Kindle, copy the <strong>.mobi</strong> file to the "Documents" folder. More help can be
found at <a href="http://www.amazon.com/gp/help/customer/display.html?nodeId=200375630">http://www.amazon.com/gp/help/customer/display.html?nodeId=200375630</a>.</p>

<p>Kindle Fire: Same process as Kindle, but I believe the .mobi file goes into the "Books" folder.</p>

<p>You can also use Calibre (a free, open source program) to manage the books on your device, and to
read ebooks on your laptop. Visit <a href="http://calibre-ebook.com">calibre-ebook.com</a> for details.</p>

<p>For other devices... really, I have no advice beyond "consult Google the All-Seer."</p>
</body>
</html>
18 changes: 17 additions & 1 deletion app/views/book_mailer/send_signed_copy.text.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,20 @@ you many hours of enjoyment, and inspires you to be your very best.
Good day and good luck,

<%= @book.author.name %>,
Author and Proprietor of bannedsorcery.com
Author and Proprietor of bannedsorcery.com

---------------------

Instructions for loading onto your e-reader:

Nook: Plug the Nook into your computer and copy the .epub file to its "My Documents" folder.

Kindle: Plug in the Kindle, copy the .mobi file to the "Documents" folder. More help can be
found at http://www.amazon.com/gp/help/customer/display.html?nodeId=200375630 .

Kindle Fire: Same process as Kindle, but I believe the .mobi file goes into the "Books" folder.

You can also use Calibre (a free, open source program) to manage the books on your device, and to
read ebooks on your laptop. Visit calibre-ebook.com for details.

For other devices... really, I have no advice beyond "consult Google the All-Seer."

0 comments on commit e778592

Please sign in to comment.