view · edit · sidebar · attach · print · history

20110922-filename-bbmb-add-picture-ebook-ebps

<< | Index | >>


  1. Change Bbmb order filename
  2. Add a picture in ebook
  3. Make a font bold

Goal/Estimate/Evaluation:

  • filename bbmb / 100% / 100%
  • add a picture ebook / 80% / 80%
Milestones
  • filename bbmb
  • ebook
    • show picture
    • font bold
    • get picture files from ftp server
ToDo
  • 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

Change Bbmb order filename

Task

  • Add a filename and transaction_id with incremental index in a file content (010, 251 entries)
  • Count file index before FTP process
  • Add the index to prefix (transaction_id, ade_id)

Note

  • idx is added to filename in lib/xmlconv/util/destination.rb#deliver_to_connection
  • transaction_id is set in lib/conversion/bdd_i2.rb#_doc_add_delivery

Experiment

  • lib/conversion/bdd_i2.rb
        def convert(bdd)
          sender_id = 'YWESEE'
          if((bsr = bdd.bsr) && (id = bsr.customer.acc_id))
            sender_id = id
          end
          index = 0
          bdd.deliveries.collect { |delivery|
            doc = I2::Document.new
            index += 1
            _doc_add_delivery(doc, delivery, sender_id, index)
            doc
          }
        end
        def _doc_add_delivery(doc, delivery, sender_id='YWESEE', index=0)
          order = I2::Order.new
          order.sender_id = sender_id
          # customer_id is in reality the delivery_id assigned by the
          # customer - the slight confusion is due to automatic naming
          transaction_id = delivery.customer_id
          order.ade_id = order.delivery_id = transaction_id
          order.ade_id = "%013d%02d" % [transaction_id, index]

Run

masa@masa ~/ywesee/globopharm.xmlconv.bbmb.ch $ bin/xmlconvd config="etc/xmlconv.yml"
masa@masa ~/ywesee/bbmb.ch $ bin/bbmbd

Order

masa@masa ~/ywesee/globopharm.xmlconv.bbmb.ch $ cp input.xml xml_orders/
masa@masa ~/ywesee/globopharm.xmlconv.bbmb.ch $  ls xml_orders/
input.xml

(Wait one minute)

Result

  • Filename (example): CO_000000000528601_201109220739.dat
010:CO_0000000005286_201109220739.dat
251:000000000528602

Note

  • 251 value is different plus one from the filename index
  • 010 value does not change

Experiment

  • lib/conversion/bdd_i2.rb
        def convert(bdd)
          sender_id = 'YWESEE'
          if((bsr = bdd.bsr) && (id = bsr.customer.acc_id))
            sender_id = id
          end
          index = 0
          bdd.deliveries.collect { |delivery|
            doc = I2::Document.new
            _doc_add_delivery(doc, delivery, sender_id, index)
            index += 1
            doc
          }
        end

        def _doc_add_delivery(doc, delivery, sender_id='YWESEE', index=0)
          ..
          transaction_id = delivery.customer_id
          order.ade_id = order.delivery_id = transaction_id
          order.ade_id = "%013d%02d" % [transaction_id, index]
          ...
          prefix = 'CO_' + order.ade_id
  • lib/xmlconv/util/destination.rb
      def deliver_to_connection(connection, delivery, idx=nil)
      ...
          if(idx)
#            target.gsub!(/(CO_\d{13})/, '\1%02d' % idx)
          end

Result

  • Filename: CO_000000000528601_201109220836.dat
...
010:CO_000000000528601_201109220836.dat
...
251:000000000528601
...

Add a picture in ebook

Email

Task

  • Add a picture and link
    1. Add a tag <monid> in _DE.xml under <fi> tag
    2. The monid number is corresponding to the number of Components directory
    3. Add one photo under the subtitles of a page
    4. Add all the photo link and name at the bottom of a page

Note

  • _DE.xml is written in UTF-16
  • iconv -f UTF-16 -t UTF-8 file

Reference

Experiment

  • setup
masa@masa ~/work $ cp /var/ebps/bin/emediat_de_firefox .
masa@masa ~/work $ scp user@server:/etc/ebps/emediat_de_firefox.yml .
  • modify the yaml for local environement target: /home/masa/work/kompendium_de_firefox.epub

Run

masa@masa ~/ywesee/ebps/bin $ unset RUBYOPT
masa@masa ~/work $ ruby1.9 emediat_de_firefox config="emediat_de_firefox.yml"

Result

Input file for conversion: /var/ebps/data/emediat/de/_DE.xml

The Ebook kompendium_de_firefox.epub was generated and stored in /home/masa/work

Question

  • Where is the other libraries used?
    • -> ebps is installed in local PC,
masa@masa ~/ywesee/ebps $ whereis ebps
ebps: /usr/bin/ebps /etc/ebps

Experiment

  • <monid>Number</monid> entry is inserted just before </fi> tag
  • 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|
            # picture name (left)
            @current_target.next_row! if i > 0
            filename = File.basename(file).gsub(/\.jpg/,'').gsub(/^\d+_/,'')
            @current_target << filename

            # picture (right)
            picture = Text::Picture.new
            picture << File.read(file)
            @current_target.rows.last << picture
          end
          @current_chapter.add_paragraph(@current_target)

          @current_target = nil
          @current_chapter = nil
        end
        def start_monid attrs
          @current_chapter = Text::Chapter.new
          @current_document.add_chapter @current_chapter
          @current_target = Text::Paragraph.new
          @current_chapter.heading << 'Fotos'
        end
  • lib/ebps/conversion/oebps.rb
        def format_picture(picture, xml)
          xml.td do
            name = picture.filename
            path = File.join @tmpdir, name
            picture.image.write path
            @builder.p 'class' => 'ebps' do |xml|
              xml.img 'src' => name, 'alt' => ''
            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)
                    else
                      xml.td do format cell end
                    end
                  end
                end
              end
            end
          end
        end

Note (UPDATE)

  • Basically, only a Text::Paragraph instance was available for a cell element of Text::Table
  • Now Text::Picture can be inserted in a cell

Run

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

Result

  • Good

Next

  • font bold

Note

  • decorattors are located in /var/ebps/bin/decorators/
  • decorator is set in a config yml file like
 decorate:
  - - /var/ebps/bin/decorators/just_medical_de.rb

Make a font bold

Key

  • Builder::XmlMarkup
  • lib/ebps/conversion/oebps.rb
view · edit · sidebar · attach · print · history
Page last modified on September 26, 2011, at 08:29 AM