view · edit · sidebar · attach · print · history

20111011-table-contents-kindle-ebook-htmlgridSo-ruby193-oddbOrg-change-top-address-bbmbCh

<< | Index | >>


  1. Debug table of contents kindle ebook
  2. Top page style oddb.org on Ruby 1.9.3
  3. Change top page address

Goal/Estimate/Evaluation
  • Debug table of contents kindle ebook / 80% / 100%
  • top style oddb.org on Ruby 1.9.3 / 70% / 100%
Milestones
  1. Missing table contents kindle
    1. Add French link
  2. oddb.org on Ruby 1.9.3
    1. top page style
  3. change top page address bbmb
  4. Fi, DDD, !, Pop-Ups without address bar bbmb

Debug table of contents kindle ebook

Experiment

  • Create a kindle book with
    • the first 5,000,000 data
    • the last 5,000,000 data

Result

  • Both have table of contents and no warning comes

Note

  • The data format is not a cause
  • The number of data is the cause
  • (Maybe) the cause is the number of links in the toc.ncx of oddb kindle ebook
  • There are in total 4523 links

Reference

Run on kindle v1.2

Run

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

Log

**************************************************
* 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/d20111011-30268-1dfk99z/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:493:in `block in export'",
 "/home/masa/ywesee/ebps/lib/ebps/conversion/oebps.rb:513:in `call'",
 "/home/masa/ywesee/ebps/lib/ebps/conversion/oebps.rb:513:in `with_tmpdir'",
 "/home/masa/ywesee/ebps/lib/ebps/conversion/oebps.rb:457:in `export'",
 "/home/masa/ywesee/ebps/lib/ebps/conversion/mobi_pocket.rb:29:in `export'",
 "bin/oddb_kindle:72:in `<main>'"]

Experiment

  • lib/ebps/config.rb
 #'kindlegen_args'    => '-c2 -nomin -unicode',
 'kindlegen_args'    => '-c2',

Run (with small test data)

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

Log

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

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

option: -c2: Kindle Huffdic compression
Info(prcgen): Added metadata dc:Title        "Test kindle 1.2"
Info(prcgen): Added metadata dc:Date         "2011-10-11"
Info(prcgen): Added metadata dc:Creator      "ch.oddb.org"
Info(prcgen): Parsing files  0000009
Info(prcgen): Resolving hyperlinks
Info(prcgen): Building table of content     URL: /tmp/d20111011-30497-1aux5vw/toc.ncx
Info(pagemap): No Page map found in the book
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: Basic Greek [370..3FF]
Info(prcgen): Found UNICODE range: Mathematical Operators [2200..22FF]
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  0000154
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):  056.84%
Info(prcgen/compress): Compression dictionary statistics:  000019698 bytes 000001663 entries 
Info(prcgen/compress): Compression pass  0000004
Info(prcgen/compress): Text compressed to (in % of original size):  053.23%
Info(prcgen/compress): Compression dictionary statistics:  000016820 bytes 000001300 entries 
Info(prcgen/compress): Compression pass  0000005
Info(prcgen/compress): Text compressed to (in % of original size):  051.35%
Info(prcgen/compress): Compression dictionary statistics:  000014674 bytes 000001056 entries 
Info(prcgen/compress): Compression pass  0000006
Info(prcgen/compress): Text compressed to (in % of original size):  047.16%
Info(prcgen/compress): Compression dictionary statistics:  000011120 bytes 000000863 entries 
Info(prcgen/compress): Compression pass  0000007
Info(prcgen/compress): Text compressed to (in % of original size):  046.77%
Info(prcgen/compress): Compression dictionary statistics:  000010024 bytes 000000709 entries 
Info(prcgen/compress): Compression pass  0000008
Info(prcgen/compress): Text compressed to (in % of original size):  046.91%
Info(prcgen/compress): Compression dictionary statistics:  000009256 bytes 000000588 entries 
Info(prcgen/compress): Advanced compression successful (decoded and verified).
Info(prcgen): Final stats - text compressed to (in % of original size):  046.91%
Info(prcgen): The document identifier is: "Test_kindle_1.2"
Info(prcgen): The file format version is V6
Info(prcgen): Saving MOBI file
Info(prcgen): MOBI File successfully generated!

Note

  • It looks success

Run (with full data)

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

Result

  • The ebook looks good but the file size is triple bigger than the old one
    • the old file is 17MB
    • the new file is 52MB

Top page style oddb.org on Ruby 1.9.3

Reference

Top page html files

Next

  • Forcus on 'class = 'list center''
  • Some part of TD tag do not have 'class = 'list center' attribute on Ruby 1.9.3

Experiment

  • /usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb
    def css_map
p "ruby 1.8.6 getin css_map"
      @css_map ||= self::class::CSS_MAP.dup
p @css_map
@css_map
    end
  • ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb
    def css_map
p "ruby 1.9.3 getin css_map"
      @css_map ||= self::class::CSS_MAP.dup
p @css_map
@css_map
    end
  • src/view/drugs/centeredsearchform.rb
p "css_map.store([0,4,1,9], 'list center')"
        css_map.store([0,4,1,9], 'list center')

Run

  • ruby18 bin/oddb
...
"css_map.store([0,4,1,9], 'list center')"
"ruby 1.8.6 getin css_map"
{[0, 0, 1, 5]=>"list center"}
"ruby 1.8.6 getin css_map"
{[0, 4, 1, 9]=>"list center", [0, 0, 1, 5]=>"list center"}
...
  • ruby193 -I ../oddb/lib bin/oddb
...
"ruby 1.9.3 getin css_map"
{[0, 0, 1, 5]=>"list center"}
"ruby 1.9.3 getin css_map"
{[0, 0, 1, 5]=>"list center", [0, 4, 1, 9]=>"list center"}
...

Note

  • @css_map keeps data correctly

Note

  • The core part of htmlgrid library is a Ruby extended library (coded with C)

Question

  • Which part of htmlgrid composes html code?

Note

  • flow in htmlgrid
    1. Composite#to_html
    2. Grid#to_html
    3. Row#to_html
    4. Field#to_html

Note

  • htmlgrid/lib/htmlgrid/grid.rb
begin
 require 'htmlgrid.so'
rescue LoadError
  puts "could not find htmlgrid.so, falling back to pure-ruby class"
  module HtmlGrid
    class Grid
...
  • If Ruby cannot load 'htmlgrid.so', grid.rb pure Ruby methods are used
  • Ruby 1.8.6 uses htmlgrid.so
  • Ruby 1.9.3 uses the pure Ruby Grid methods

Experiment

  • /usr/lib64/ruby/site_ruby/1.8/htmlgrid/grid.rb
#begin
# require 'htmlgrid.so'
#rescue LoadError
...
#end

Run

  • ruby18 bin/oddbd

Result

  • The top page style looks same as one of Ruby 1.9.3

Note

  • We should use htmlgrid.so rather than the pure Ruby Grid methods
  • grid.rb methods should be updated in the future

Setup

  • Compile htmlgrid.so with Ruby 1.9.3
masa@masa ~/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/ext/htmlgrid $ ruby193 extconf.rb 
creating Makefile
masa@masa ~/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/ext/htmlgrid $ make
compiling grid.c
grid.c: In Funktion »grid_set_dimensions«:
grid.c:104: Warnung: ISO C90 forbids mixed declarations and code
grid.c:126: Warnung: ISO C90 forbids mixed declarations and code
grid.c: In Funktion »grid_cat_attribute«:
grid.c:297: Warnung: Implizite Deklaration der Funktion »STR2CSTR«
grid.c:297: Warnung: Zuweisung erzeugt Zeiger von Ganzzahl ohne Typkonvertierung
grid.c:298: Warnung: Zuweisung erzeugt Zeiger von Ganzzahl ohne Typkonvertierung
grid.c:299: Warnung: ISO C90 forbids mixed declarations and code
grid.c: In Funktion »grid_store_allowed_attribute«:
grid.c:337: Warnung: Zuweisung erzeugt Zeiger von Ganzzahl ohne Typkonvertierung
grid.c: In Funktion »grid_to_html«:
grid.c:436: Warnung: ISO C90 forbids mixed declarations and code
grid.c: In Funktion »grid_push«:
grid.c:601: Warnung: ISO C90 forbids mixed declarations and code
grid.c: In Funktion »grid_set_colspan«:
grid.c:618: Warnung: ISO C90 forbids mixed declarations and code
grid.c: In Funktion »grid_insert_row«:
grid.c:664: Warnung: ISO C90 forbids mixed declarations and code
grid.c: In Funktion »grid_field_add_tag«:
grid.c:752: Warnung: Übergabe des Arguments 2 von »strcpy« erzeugt Zeiger von Ganzzahl ohne Typkonvertierung
/usr/include/bits/string3.h:104: Anmerkung: expected »const char * __restrict__« but argument is of type »int«
grid.c: In Funktion »grid_row_set_attributes«:
grid.c:781: Warnung: ISO C90 forbids mixed declarations and code
grid.c: In Funktion »grid_add_attribute«:
grid.c:805: Warnung: ISO C90 forbids mixed declarations and code
compiling htmlgrid.c
linking shared-object htmlgrid.so
  • ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb
 #require 'htmlgrid.so'
 require '/home/masa/work/htmlgrid.so'

Run

 masa@masa ~/ywesee/oddb.org $ ruby193 -I ../oddb/lib bin/oddbd

Access

Result

  • Error
Oddb (OddbApp): symbol lookup error: /home/masa/work/htmlgrid.so: undefined symbol: STR2CSTR

Reference

Experiment

  • Replace STR2CSTR by StringValuePtr in grid.c
  • compile
masa@masa ~/work/ext/htmlgrid $ grep -r STR2CSTR grid.c
masa@masa ~/work/ext/htmlgrid $ ruby193 extconf.rb 
creating Makefile
masa@masa ~/work/ext/htmlgrid $ make
compiling grid.c
grid.c: In Funktion »grid_set_dimensions«:
grid.c:104: Warnung: ISO C90 forbids mixed declarations and code
grid.c:126: Warnung: ISO C90 forbids mixed declarations and code
grid.c: In Funktion »grid_cat_attribute«:
grid.c:301: Warnung: ISO C90 forbids mixed declarations and code
grid.c: In Funktion »grid_to_html«:
grid.c:439: Warnung: ISO C90 forbids mixed declarations and code
grid.c: In Funktion »grid_push«:
grid.c:604: Warnung: ISO C90 forbids mixed declarations and code
grid.c: In Funktion »grid_set_colspan«:
grid.c:621: Warnung: ISO C90 forbids mixed declarations and code
grid.c: In Funktion »grid_insert_row«:
grid.c:667: Warnung: ISO C90 forbids mixed declarations and code
grid.c: In Funktion »grid_row_set_attributes«:
grid.c:784: Warnung: ISO C90 forbids mixed declarations and code
grid.c: In Funktion »grid_add_attribute«:
grid.c:808: Warnung: ISO C90 forbids mixed declarations and code
compiling htmlgrid.c
linking shared-object htmlgrid.so

Result

Patch

Experiment

  • ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb
 begin
   VERSION = '1.0.0'
   ext_dir = File.expand_path('../../ext/htmlgrid', File.dirname(__FILE__))
   ext_lib = File.join(ext_dir, 'htmlgrid.so')
   require ext_lib
 rescue

Note

  • grid.rb automatically load the extended library in 'ext' directory without installation of htmlgrid

Change top page address

Refer to http://dev.ywesee.com/wiki.php/Gag/Bbmbchangelog

view · edit · sidebar · attach · print · history
Page last modified on October 12, 2011, at 07:21 AM