Skip to content

Commit

Permalink
for #5,
Browse files Browse the repository at this point in the history
* rename ebook.rb to be ebook-builder.rb
* add GUI support to (re)order the the sections (aka chapters)
* add GUI support to (re)order the files in display order in a section
* Many things could be better GUI wise - go for it.
* It's TOC that should work well enough to get help_ebook.rb tested
* useless crud in yaml exists - probably
* does not auto parse the nav document and build the TOC automagically
  because that's not a priority. Remember - we still can't render anything
  with acceptable fidelity.
  • Loading branch information
Cecil committed Dec 17, 2016
1 parent 1cdc67b commit a3231e9
Showing 1 changed file with 51 additions and 3 deletions.
54 changes: 51 additions & 3 deletions ebook.rb → ebook-builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,22 @@
@panel.clear do
el_v = []
el_t = []
para "Order the sections starting with 1, 0 means delete."
para "Save will write to #{cfg['doc_home']}/.ebook/ebook.yaml"
para "Important: Save before you move to other options."
flow do
button "cancel" do
Shoes.quit
end
button "save" do
cfg['toc']['section_order'] = []
# TODO: Magic occurs

el_v.each_index do |i|
ord = el_v[i].text.to_i
if ord > 0
cfg['toc']['section_order'][ord-1] = el_t[i].text
end
end
File.open("#{cfg['doc_home']}/.ebook/ebook.yaml", 'w') do |f|
YAML.dump(cfg, f)
end
Expand All @@ -159,8 +167,8 @@
flow do
eln = edit_line width: 30
el_v << eln
t = cfg['sections'][pos][:title]
elt = edit_line text: t, width: 200
t = cfg['sections'][pos][:dir]
elt = edit_line text: t, width: 200, state: "readonly"
el_t << elt
end
end
Expand All @@ -169,6 +177,46 @@
end

button "order sections" do
@panel.clear do
para "Select section to view the documents. Order them from 1. 0 means delete"
para "Important: Save after modifing each section before selecting the next!"
el_v = []
el_t = []
sect = {}
flow do
button "Quit" do
Shoes.quit
end
button "Save" do
sect[:display_order] = []
el_v.each_index do |i|
ord = el_v[i].text.to_i
if ord > 0
sect[:display_order][ord-1] = el_t[i].text
end
end
File.open("#{cfg['doc_home']}/.ebook/ebook.yaml", 'w') do |f|
YAML.dump(cfg, f)
end
end
list_box items: cfg['toc']['section_order'] do |lb|
item = lb.text
@chapter.clear do
sect = cfg['sections'][item]
files = sect[:files]
files.each_index do |i|
flow do
eln = edit_line text: "#{i+1}", width: 30
el_v << eln
elt = edit_line text: files[i], width: 200, state: "readonly"
el_t << elt
end
end
end
end
end
@chapter = stack
end
end

button "render" do
Expand Down

0 comments on commit a3231e9

Please sign in to comment.