view · edit · sidebar · attach · print · history

20110923-photo_link-ftp-ebook-ebps

<< | Index | >>


  1. Make a link to picture
  2. Get picture files from FTP server
  3. Prepare 3 bins and ymls for firefox, stanza, kindle
  4. Install Kindle desktop reader, Mobi-Pocket reader on windows7 on virtualbox
  5. Testcases ebps

Goal/Estimate/Evaluation:

  • link ebps ebook / 100% /
Milestones
  • ebook
    1. photo link
    2. get picture files from ftp server
    3. confirm to create a ebook for stanza and kindle
    4. update specs
Summary
ToDo
  • rcov ebps
  • Bug fix for kindlegen 1.2
  • Testcase ebps
  • Testcase bbmb
  • Testcase migel (report, mail, compress processes)
  • require 'migel/util/m10l_document' problem in multilingual.rb
  • require 'oddb/util/m10l_document' problem in model_super.rb

Make a link to picture

Task

Review

masa@masa ~/ywesee/ebps $ ruby1.9 -I lib bin/emediat_de_firefox config="emediat_de_firefox.yml"

Result

  • good

Experiment

  • lib/ebps/conversion/oebps.rb
        def format_linked_paragraph(paragraph, xml)
          xml.td do
            xml.a 'href' => paragraph.url do format paragraph end
          end
        end
        def format_table table
          @builder.table 'class' => 'ebps' do |xml|
            xml.tbody do
              table.each_normalized do |row|
                xml.tr do
                  row.each do |cell|
                    #xml.td do format cell end
                    if cell.is_a? EBPS::Text::Picture
                      format_picture(cell, xml)
                    elsif cell.is_a? EBPS::Text::LinkedParagraph
                      format_linked_paragraph(cell, xml)
                    else
                      xml.td do format cell end
                    end
                  end
                end
              end
            end
          end
        end
  • lib/ebps/conversion/fachinfo_xml.rb
        def end_monid
          dir = File.join(EBPS.config.component_dir, @current_target.to_s)
          file_list = Dir.glob(File.join(dir, "*.jpg")).to_a.sort
          @current_target = Text::Table.new
          file_list.each_with_index do |file, i|
            @current_target.next_row! if i > 0

            # picture (right)
            picture = Text::Picture.new
            picture << File.read(file)
            #@current_target.rows.last << picture
            @current_target.rows[i][0] = picture

            # picture name (left)
            @current_target.next_cell!
            filename = File.basename(file).gsub(/\.jpg/,).gsub(/^\d+_/,)
            pic_number = if match = File.basename(file).match(/^(\d+)_/)
                           match[1]
                         end
            url = "https://pictures.e-mediat.net/WV_GetPictures/#{pic_number}_PIF_F.jpg"
            link = Text::LinkedParagraph.new(url, filename)
            @current_target.rows[i][1] = link
            #@current_target << filename
          end
          @current_chapter.add_paragraph(@current_target)

          @current_target = nil
          @current_chapter = nil
        end

Result

  • good

Next

  • Table border should be deleted

Experiment

  • /var/ebps/data/css/emediat.css
.ebps {
  display: block;
  text-indent: 0;
}
h3 {
  font-size: larger;
}
h4 {
  font-weight: normal;
  font-style: italic;
}
table.ebps {
  border-collapse: collapse;
}
/*
table.ebps td {
  border: 1px solid #999;
}
*/
  • emediat_de_firefox.yml
#stylesheet: /var/ebps/data/css/oddb.css
stylesheet: /var/ebps/data/css/emediat.css

Result

  • Table border is gone

Get picture files from FTP server

Note

  • The file is downloaded by cron on the server (unzip too)
  • see: the following server files
    1. /etc/crontab
    2. /var/ebps/bin/run_emediat_ebooks

Question

  • Where is the script to rename the downloaded file?
    • -> wget automatically backup an existing file with incremental number

Note

  • I cannot find log lotation configuration (ex. /etc/logrotate.d/)
  • There is no preprocess setting in yaml files

Experiment

  • emediat_de_firefox.yml
preprocess:
   copy:
     targets:
       - - "ftp://ywesee:xxx@xxx/sample_DE.xml"
         - "/home/masa/work/hogehoge.xml"

Setup

  • send sample_DE.xml to the server

Run

masa@masa ~/ywesee/ebps $ ruby1.9 -I lib bin/emediat_de_firefox config="emediat_de_firefox.yml"

Note

  • bin/ebps should not be used though it is linked from bin/emediat_de_firefox is linked
  • because somewhere the executable file name is used in the scripts

Result

  • ftp download works

Reference

  • lib/ebps/preprocess/copy.rb

Next

  • Unzip file

stop

  • We do not use 'preprocess' but 'cron job' to get Components.zip file

Prepare 3 bins and ymls for firefox, stanza, kindle

Change the following 3 settings

  • source: /home/masa/ywesee/ebps/sample_DE.xml
  • photos: /home/masa/ywesee/ebps/Components
  • target: /home/masa/work/sample_de_xxx.xxx
  • stylesheet: /var/ebps/data/css/emediat.css

Run

masa@masa ~/ywesee/ebps $ ruby1.9 -I lib bin/emediat_de_firefox config="etc/emediat_de_firefox.yml"
masa@masa ~/ywesee/ebps $ ruby1.9 -I lib bin/emediat_de_stanza config="etc/emediat_de_stanza.yml"
masa@masa ~/ywesee/ebps $ ruby1.9 -I lib bin/emediat_de_kindle config="etc/emediat_de_kindle.yml"

Result

  • stanza succeeds
  • kindle fails
Input file for conversion: /home/masa/ywesee/ebps/sample_DE.xml

Errno::ENOENT: No such file or directory - /tmp/d20110923-5997-w8h0bt/mobipocket.azw
/usr/lib64/ruby/1.9.1/fileutils.rb:1407:in `stat'
/usr/lib64/ruby/1.9.1/fileutils.rb:1407:in `block in fu_each_src_dest'
/usr/lib64/ruby/1.9.1/fileutils.rb:1423:in `fu_each_src_dest0'
/usr/lib64/ruby/1.9.1/fileutils.rb:1405:in `fu_each_src_dest'
/usr/lib64/ruby/1.9.1/fileutils.rb:391:in `cp'
/home/masa/ywesee/ebps/lib/ebps/conversion/mobi_pocket.rb:17:in `compile_azw'
/home/masa/ywesee/ebps/lib/ebps/conversion/mobi_pocket.rb:25:in `block in export'
/home/masa/ywesee/ebps/lib/ebps/conversion/oebps.rb:489:in `block in export'
/home/masa/ywesee/ebps/lib/ebps/conversion/oebps.rb:506:in `call'
/home/masa/ywesee/ebps/lib/ebps/conversion/oebps.rb:506:in `with_tmpdir'
/home/masa/ywesee/ebps/lib/ebps/conversion/oebps.rb:453:in `export'
/home/masa/ywesee/ebps/lib/ebps/conversion/mobi_pocket.rb:24:in `export'
bin/emediat_de_kindle:72:in `<main>'

Note

  • Probably 'kindlegen' command should be installed

Install kindlegen

Run

masa@masa ~/ywesee/ebps $ ruby1.9 -I lib bin/emediat_de_kindle config="etc/emediat_de_kindle.yml"

Log

"kindlegen /tmp/d20110923-6753-dugxp2/ArzneimittelKompendium_der_Schweiz.opf -c2 -nomin -unicode -o mobipocket.azw"

**************************************************
* Amazon.com kindlegen(Linux)   V1.2 build 33307 *
* A command line e-book compiler                 *
* Copyright Amazon.com 2011                      *
**************************************************

option: -c2: Kindle Huffdic compression
Error(kindlegen): Unsupported argument  -nomin
"No such file or directory - /tmp/d20110923-6753-dugxp2/mobipocket.azw"
["/usr/lib64/ruby/1.9.1/fileutils.rb:1407:in `stat'",
 "/usr/lib64/ruby/1.9.1/fileutils.rb:1407:in `block in fu_each_src_dest'",
 "/usr/lib64/ruby/1.9.1/fileutils.rb:1423:in `fu_each_src_dest0'",
 "/usr/lib64/ruby/1.9.1/fileutils.rb:1405:in `fu_each_src_dest'",
 "/usr/lib64/ruby/1.9.1/fileutils.rb:391:in `cp'",
 "/home/masa/ywesee/ebps/lib/ebps/conversion/mobi_pocket.rb:18:in `compile_azw'",
 "/home/masa/ywesee/ebps/lib/ebps/conversion/mobi_pocket.rb:30:in `block in export'",
 "/home/masa/ywesee/ebps/lib/ebps/conversion/oebps.rb:489:in `block in export'",
 "/home/masa/ywesee/ebps/lib/ebps/conversion/oebps.rb:506:in `call'",
 "/home/masa/ywesee/ebps/lib/ebps/conversion/oebps.rb:506:in `with_tmpdir'",
 "/home/masa/ywesee/ebps/lib/ebps/conversion/oebps.rb:453:in `export'",
 "/home/masa/ywesee/ebps/lib/ebps/conversion/mobi_pocket.rb:29:in `export'",
 "bin/emediat_de_kindle:72:in `<main>'"]

Copy kindlegen from the server

masa@masa ~/bin $ kindlegen

***********************************************
* Amazon.com kindlegen(Linux)   V1.0 build 85 *
* A command line e-book compiler              *
* Copyright Amazon.com 2009                   *
***********************************************

Note

  • The new version is 1.2

Run

masa@masa ~/ywesee/ebps $ ruby1.9 -I lib bin/emediat_de_kindle config="etc/emediat_de_kindle.yml"

Log

"kindlegen /tmp/d20110923-6850-1ckcvnt/ArzneimittelKompendium_der_Schweiz.opf -c2 -nomin -unicode -o mobipocket.azw"

***********************************************
* Amazon.com kindlegen(Linux)   V1.0 build 85 *
* A command line e-book compiler              *
* Copyright Amazon.com 2009                   *
***********************************************

opt compression: Kindle Huffdic compression
opt version: not minimizing
opt unicode: forces UTF8 output
opt -o:  output file name
Info(prcgen): Added metadata dc:Title        "Arzneimittel-Kompendium der Schweiz"
Info(prcgen): Added metadata dc:Date         "2011-09-23"
Info(prcgen): Added metadata dc:Creator      "Documed"
Info(prcgen): Parsing files  0000005
Info(prcgen): Resolving hyperlinks
Info(prcgen): Building table of content     URL: /tmp/d20110923-6850-1ckcvnt/toc.ncx
Warning(prcgen): Cover is too small :   /tmp/d20110923-6850-1ckcvnt/TitelseiteD.jpg
Info(prcgen): Computing UNICODE ranges used in the book
Info(prcgen): Found UNICODE range: Basic Latin [20..7E]
Info(prcgen): Found UNICODE range: Latin-1 Supplement [A0..FF]
Info(prcgen): Found UNICODE range: General Punctuation - Windows 1252 [2013..2014]
Info(prcgen): Found UNICODE range: Mathematical Operators [2200..22FF]
Info(prcgen): Found UNICODE range: Basic Greek [370..3FF]
Info(prcgen/compress): Compiling source text for compression (4096 passes max). Pass  0000001
Info(prcgen/compress): Compiling source text for compression (4096 passes max). Pass  0000002
Info(prcgen/compress): Compiling source text for compression (4096 passes max). Pass  0000004
Info(prcgen/compress): Compiling source text for compression (4096 passes max). Pass  0000008
Info(prcgen/compress): Compiling source text for compression (4096 passes max). Pass  0000016
Info(prcgen/compress): Compiling source text for compression (4096 passes max). Pass  0000032
Info(prcgen/compress): Compiling source text for compression (4096 passes max). Pass  0000064
Info(prcgen/compress): Compiling source text for compression (4096 passes max). Pass  0000128
Info(prcgen/compress): Compiling source text for compression (4096 passes max). Pass  0000256
Info(prcgen/compress): Compiling source text for compression (4096 passes max). Pass  0000512
Info(prcgen/compress): Compiling source text for compression (4096 passes max). Pass  0001024
Info(prcgen/compress): Compiling source text for compression (4096 passes max). Pass  0002048
Info(prcgen/compress): Compiling source text for compression (4096 passes max). Pass  0002860
Info(prcgen/compress): Compression pass  0000001
Info(prcgen/compress): Compression pass  0000002
Info(prcgen/compress): Compression pass  0000003
Info(prcgen/compress): Text compressed to (in % of original size):  038.33%
Info(prcgen/compress): Compression dictionary statistics:  000027352 bytes 000001603 entries 
Info(prcgen/compress): Compression pass  0000004
Info(prcgen/compress): Text compressed to (in % of original size):  036.64%
Info(prcgen/compress): Compression dictionary statistics:  000023410 bytes 000001270 entries 
Info(prcgen/compress): Compression pass  0000005
Info(prcgen/compress): Text compressed to (in % of original size):  036.17%
Info(prcgen/compress): Compression dictionary statistics:  000021842 bytes 000001030 entries 
Info(prcgen/compress): Compression pass  0000006
Info(prcgen/compress): Text compressed to (in % of original size):  034.04%
Info(prcgen/compress): Compression dictionary statistics:  000018754 bytes 000000838 entries 
Info(prcgen/compress): Compression pass  0000007
Info(prcgen/compress): Text compressed to (in % of original size):  034.45%
Info(prcgen/compress): Compression dictionary statistics:  000017946 bytes 000000685 entries 
Info(prcgen/compress): Advanced compression successful (decoded and verified).
Info(prcgen): Final stats - text compressed to (in % of original size):  034.45%
Info(prcgen): The document identifier is: "Arzneimittel-um_der_Schweiz"
Info(prcgen): The file format version is V7
Info(prcgen): Saving MOBI file
Info(prcgen): MOBI File generated with WARNINGS!

Result

  • works

Note

  • Some warning is outputed (they should be fixed)
  • the error should be fixed in the latest version of kindlegen

Install Kindle desktop reader, Mobi-Pocket reader on windows7 on virtualbox

  • Amazon Kindle Desktop Reader 1.7.1
  • Mobi-Pocket Reader 6.2

Result

  • Works

Testcases ebps

Rspec

masa@masa ~/ywesee/ebps $ rspec spec/suite.rb
...
52 examples, 17 failures

Note

  • I have to use ruby1.9 for specs

Run

masa@masa ~/ywesee/ebps $ ruby1.9 /usr/bin/rspec -c -fs spec/suite.rb 
...
52 examples, 0 failures

Rcov

masa@masa ~/ywesee/ebps $ ruby1.9 -rrspec /usr/bin/rcov spec/suite.rb

Note

  • The coverage is not calculated correctly

Next

  • Make a testcase for the updated methods

Updates

  • spec/conversion/fachinfo_xml_spec.rb (coverage: 93.36%)

Run

masa@masa ~/ywesee/ebps $ rspec /usr/bin/rcov spec/conversion/fachinfo_xml_spec.rb 

Note

  • But this rspec runs on Ruby 1.8
  • Some specs other than these above failed in this way -> Ruby 1.9 is required for some specs to run

Next

  • lib/ebps/conversion/oebps.rb

Note

  • spec/conversion/epub_spec.rb requires Ruby 1.9 to run
view · edit · sidebar · attach · print · history
Page last modified on September 26, 2011, at 08:29 AM