Skip to content

Commit

Permalink
for #5 - start reconsruction of show_ebook
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Cecil committed Dec 22, 2016
1 parent f9670d1 commit 335d4e7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
5 changes: 3 additions & 2 deletions ebook-builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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!"
Expand Down
28 changes: 22 additions & 6 deletions show_ebook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 335d4e7

Please sign in to comment.