view · edit · sidebar · attach · print · history

20111007-remove-title-mymedi-update-run_emediat_ebooks-create-ebook-link-decorator-ebps-ruby193-oddb

<< | Index | >>


  1. Remove title medi flavor
  2. Debug Ebook with photo on the server
  3. Decorate Ebook oddb_kindle
  4. Add ebook download link on the top page oddb.org
  5. Setup oddb.org on Ruby 1.9.3

Goal/Estimate/Evaluation
  • mymedi migel_home title / 100% / 100%
  • Debug Ebook photo / 100% / 100%
  • Ebook download link oddb.org / 100% / 100%
  • Oddb.org on Ruby 1.9.3 / 70% /
Milestones
  1. Remove title mymedi
  2. Ebook photo
  3. Ebook free download link
  4. oddb.org on Ruby 1.9.3
    1. Encoding error
    2. Resolve rockit problem (calc pointer, calc size)
    3. ODBA Date._load error
    4. SBSM#import_cookie error
    5. CSV::Cell error
    6. src/stte/drug/init.rb error
    7. Warnings on the boot message
    8. Summary
Summary
Commit

Remove title medi flavor

Remove the title 'Medikamente A-Z' from

Note

  • This title is written in src/custom/lookandfeelwrapper.rb
  class LookandfeelMyMedi < SBSM::LookandfeelWrapper
...
    DICTIONARIES = {
      'de'  =>  {
...
        :sequences                =>  'Medikamente A-Z',
  • The top page is related to src/view/migel/init.rb

Note (trace)

  1. src/state/migel/init.rb
  2. src/view/migel/search.rb
  3. src/view/publictemplate.rb
  4. src/view/migel/centeredsearchform.rb
  5. src/view/centeredsearchform.rb
  6. src/view/tab_navigation.rb

Experiment

  • src/view/tab_navigation.rb
      def build_custom_navigation
        @lookandfeel.zones.each_with_index { |zone, idx|
          if(zone.is_a?(Class))
            zone = zone.direct_event
            symbol_map.store(zone, View::NavigationLink)
          else
            symbol_map.store(zone, View::TabNavigationLink)
          end
          pos = [idx*2,0]
          components.store(pos, zone)
          component_css_map.store(pos, 'tabnavigation')
          if(idx > 0)
            components.store([idx*2-1,0], :tabnavigation_divider)
          end
require 'pp'
pp components
        }
      end

Access

Result

{[0, 0]=>:sequences}

Note

  • the 'sequences' component is set here

Experiment

  • src/view/tab_navigation.rb
      def build_custom_navigation
        @lookandfeel.zones.each_with_index { |zone, idx|
          if(zone.is_a?(Class))
            zone = zone.direct_event
            symbol_map.store(zone, View::NavigationLink)
          else
            symbol_map.store(zone, View::TabNavigationLink)
          end
          pos = [idx*2,0]
          components.store(pos, zone)
          component_css_map.store(pos, 'tabnavigation')
          if(idx > 0)
            components.store([idx*2-1,0], :tabnavigation_divider)
          end
          components.clear
        }
      end

Access

Result

  • The title is gone

Experiment

  • src/custom/lookandfeelwrapper.rb
    def zones
      #[ State::Drugs::Sequences ]
      []
    end

Access

Result

  • The title is gone

Note

Commit

Debug Ebook with photo on the server

Problem

  • Ebook with photo does not run correctly on the server
  • It runs locally

Note

Summary

  • The cron job script (run_emediat_books) has a mistake
  • The setting up was correct
  • wget without option is used for the downloading of _DE.zip, _FR.zip from the ftp server
  • wget DOES NOT overwrite the original file but copy the file with '.xx' (xx is an incremental number)
  • Then the downloaded latest file is never unzipped in the script (/var/ebps/bin/run_emediat_books)
  • The updated script as follows

run_emediat_books

rm _DE.zip
rm _DE.xml
wget ftp://server/_DE.zip
unzip _DE.zip
  • ('wget -nc' can overwrite an existing file)

Decorate Ebook oddb_kindle

Task

  • Add a decorator to oddb_kindle script as well as just-medical
  • /var/ebps/bin/decorators/ch_oddb_de.rb
    module EBPS
    module Decorator
      module ChOddb
        def self.decorate model
          if codes = model.metadata['article_codes']
            ean13s = codes.collect do |hash| hash[:article_ean13] end.compact
            unless ean13s.empty?
              chapter = Text::Chapter.new
              chapter.heading << 'Preisvergleich'
              ean13s.each do |ean13|
                href = "http://ch.oddb.org/de/gcc/compare/ean13/#{ean13}"
                #chapter.add_paragraph Text::LinkedParagraph.new(href, ean13)
                chapter.add_paragraph Text::LinkedParagraph.new(href, model.title + " " + ean13)
              end
              model.add_chapter chapter
            end
          end
        end
      end
    end
end
  • /etc/ebps/oddb_kindle.yml
...
decorate:
 - - /var/ebps/bin/decorators/ch_oddb_de.rb
   - ChOddb

Add ebook download link on the top page oddb.org

Task

  • Add a link to download a ebook file on the top page in oddb.org
  • Add a function to log a downloaded file and the address where the file is accessed

Experiment

  • src/custom/lookandfeelbase.rb
        :download_ebook           =>  'Download ebook',
  • src/view/centeredsearchform.rb
      def download_ebook(model, session)
        link = HtmlGrid::Link.new(:download_ebook,
                                  model, session, self)
=begin
        args = {
          'download[compendium_ch.oddb.org.firefox.epub]' => 1,
          'download[compendium_ch.oddb.org.htc.prc]'      => 1,
          'download[compendium_ch.oddb.org.kindle.mobi]'  => 1,
          'download[compendium_ch.oddb.org.stanza.epub]'  => 1,
        }
        link.href = @lookandfeel._event_url(:download_export, args)
        link.set_attribute('class', 'list')
=end
        link.href = "http://hogehoge"
        link
      end

Access

Result

  • The link and name is rewritten

Create a download link by bin/admin command, grant_download

ch.oddb> grant_download 'free_kindle_ebook@ywesee.com', 'compendium_ch.oddb.org.kindle.mobi', 0, Time.local(2011,12,31) 
-> http://ch.oddb.org/de/gcc/download/invoice/27397543/email/free_kindle_ebook@ywesee.com/filename/compendium_ch.oddb.org.kindle.mobi

Reference

Note

  • Use this link to the link above

Result

Commit

Setup oddb.org on Ruby 1.9.3

Review

  • oddbd works but the view is not shown because of encoding error

Encoding::CompatibilityError incompatible character encodings: ASCII-8BIT and UTF-8

error in SBSM::Session#to_html: /
Encoding::CompatibilityError
incompatible character encodings: ASCII-8BIT and UTF-8
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:152:in `block in field_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:144:in `each'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:144:in `field_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:135:in `block in to_html'
(eval):1256:in `tr'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:134:in `to_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:284:in `block (2 levels) in to_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:284:in `collect'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:284:in `block in to_html'
(eval):769:in `table'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:283:in `to_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:263:in `to_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:93:in `block in component_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:91:in `each'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:91:in `component_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:110:in `block in to_html'
(eval):1290:in `td'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:109:in `to_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:152:in `block in field_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:144:in `each'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:144:in `field_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:135:in `block in to_html'
(eval):1256:in `tr'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:134:in `to_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:284:in `block (2 levels) in to_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:284:in `collect'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:284:in `block in to_html'
(eval):769:in `table'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb:283:in `to_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:263:in `to_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/template.rb:123:in `block in to_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/template.rb:116:in `call'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/template.rb:116:in `template_tags'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/template.rb:111:in `block (2 levels) in template_html'
(eval):1086:in `body'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/template.rb:110:in `block in template_html'
/home/masa/bin/ruby193rc1/lib/ruby/1.9.1/cgi/html.rb:432:in `block in html'
(eval):1069:in `html'
/home/masa/bin/ruby193rc1/lib/ruby/1.9.1/cgi/html.rb:432:in `html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/template.rb:109:in `template_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/template.rb:122:in `to_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/sbsm-1.0.0/lib/sbsm/state.rb:180:in `to_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/sbsm-1.0.0/lib/sbsm/session.rb:446:in `to_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/sbsm-1.0.0/lib/sbsm/session.rb:170:in `block in drb_process'
<internal:prelude>:10:in `synchronize'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/sbsm-1.0.0/lib/sbsm/session.rb:168:in `drb_process'
/home/masa/bin/ruby193rc1/lib/ruby/1.9.1/drb/drb.rb:1548:in `perform_without_block'
/home/masa/bin/ruby193rc1/lib/ruby/1.9.1/drb/drb.rb:1508:in `perform'
/home/masa/bin/ruby193rc1/lib/ruby/1.9.1/drb/drb.rb:1586:in `block (2 levels) in main_loop'
/home/masa/bin/ruby193rc1/lib/ruby/1.9.1/drb/drb.rb:1582:in `loop'
/home/masa/bin/ruby193rc1/lib/ruby/1.9.1/drb/drb.rb:1582:in `block in main_loop'

Trace

  1. SBSM::session.rb#to_html(@@cgi) (The error comes from here)
  2. SBSM::state.rb#to_html(context)
  3. HtmlGrid::TempleteMethods#to_html(context)
  4. HtmlGrid::Composite#to_html(context)

Experiment

  • ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb
    def to_html(context)
      @grid.set_attributes(@attributes)
p      super.encoding
      #super << @grid.to_html(context)
#      super
    end

Access

Result

#<Encoding:US-ASCII>

Experiment

  • ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/grid.rb
        def field_html(cgi)
          html = ""
          span = 1
          @fields.each { |field|
            if(span < 2)
#p field.to_html(cgi).encoding
             html << field.to_html(cgi).force_encoding('utf-8')
              span = field.colspan
            else
              span.step(-1)
            end
          }
          html
        end
  • ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/component.rb
    def to_html(context)
      #_to_html(context, @value).to_s
      _to_html(context, @value).to_s.force_encoding('utf-8')
    end

Access

Result

  • Success to show the top page
  • But the style is not good

Note

  • String#each method is gone in Ruby 1.9.3
view · edit · sidebar · attach · print · history
Page last modified on October 07, 2011, at 04:56 PM