From 335d4e78000329e0f202b04ebb80199ea57adf1e Mon Sep 17 00:00:00 2001 From: Cecil Date: Wed, 21 Dec 2016 22:18:44 -0700 Subject: [PATCH] for #5 - start reconsruction of show_ebook * help.rb and help_picky are deepely tied to Shoes manual * Random markdown can't be handled that way, * This commit just gets the title block nearly correct. Lots of works ahead. --- ebook-builder.rb | 5 +++-- show_ebook.rb | 28 ++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/ebook-builder.rb b/ebook-builder.rb index cbf276d..01630b5 100644 --- a/ebook-builder.rb +++ b/ebook-builder.rb @@ -321,8 +321,8 @@ end button "5 - test render" do - # This is used to testing the yaml & rendering. It creates a - # Shoes window which does the rendering using help_ebook.rb (a Shoes module) + # This is used for testing the yaml & rendering. It creates a + # Shoes window which does the rendering using show_ebook.rb (a Shoes module) # copy the current yaml to 'shoes_ebook.yaml' it what ever dir # we're running in. #puts "Render this #{Dir.getwd}/shoes_ebook.yaml" @@ -332,6 +332,7 @@ require 'show_ebook' window(:width => 720, :height => 640, &Shoes.make_ebook(true)) end + button "6 - Create an app" do @panel.clear do para "Create your \"#{cfg['book_title']}\" ebook for #{RUBY_PLATFORM}. May the gods be merciful!" diff --git a/show_ebook.rb b/show_ebook.rb index 34d78c6..7b1ba32 100644 --- a/show_ebook.rb +++ b/show_ebook.rb @@ -51,7 +51,7 @@ def render_section # this will get confusing very quickly. # calls picky to load the indices - # returns an odd structure - IMO + # def load_docs(cfg) puts "load_docs nested #{cfg['nested']}" # first, render the toc[root] document on the opening screen @@ -60,6 +60,20 @@ def load_docs(cfg) return [] end + def get_title(sect_num) + if @@cfg['nested'] + if sect_num == 0 # intro page + return @@cfg['book_title'] + else + sect_nm = @@cfg['toc']['section_order'][section] + return @@cfg['sections'][sect_nm]['title'] + end + else + ka = @@cfg['sections'].keys + return @@cfg['sections'][ka[sect_num]][:title] + end + end + def Shoes.make_ebook(test = false) font "fonts/Coolvetica.ttf" unless Shoes::FONTS.include? "Coolvetica" # load the yaml and see what we have for a TOC and settings @@ -71,7 +85,6 @@ def Shoes.make_ebook(test = false) end #puts "render this #{@cfg['doc_home']}" book_title = @@cfg['book_title'] - #puts "in class #{self.inspect}" proc do extend Shoes::Ebook #docs = load_docs Shoes::Manual.path # creates @docs which might be @@ -121,17 +134,20 @@ def Shoes.make_ebook(test = false) stack :margin_left => 118 do para book_title, :stroke => "#eee", :margin_top => 8, :margin_left => 17, :margin_bottom => 0 - #@title = title docs[0][0], :stroke => white, :margin => 4, :margin_left => 14, - # :margin_top => 0, :font => "Coolvetica" - @title = title book_title, :stroke => white, :margin => 4, :margin_left => 14, - :margin_top => 0, :font => "Coolvetica" end + # @title will change dynamiclly + @title = title get_title(0), :stroke => white, :margin => 4, :margin_left => 14, + :margin_top => 0, :font => "Coolvetica" + end background "rgb(66, 66, 66, 180)".."rgb(0, 0, 0, 0)", :height => 0.7 background "rgb(66, 66, 66, 100)".."rgb(255, 255, 255, 0)", :height => 20, :bottom => 0 end + # @doc is the canvas for drawing content (pre-built Shoes coded (load_docs) @doc = #stack :margin_left => 130, :margin_top => 20, :margin_bottom => 50, :margin_right => 50 + gutter, # &dewikify(docs[0][-1]['description'], true) stack :margin_left => 130, :margin_top => 20, :margin_bottom => 50, :margin_right => 50 + gutter + + # Setup display for the back/forward 'buttons' #add_next_link(0, -1) stack :top => 84, :left => 0, :attach => Shoes::Window do flow :width => 118, :margin_left => 12, :margin_right => 12, :margin_top => 25 do