shoes 4.0.0.pre2 → 4.0.0.pre3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +32 -21
- metadata +18 -337
- data/CHANGELOG +0 -84
- data/Gemfile +0 -24
- data/Guardfile +0 -11
- data/Rakefile +0 -14
- data/app.yaml +0 -60
- data/benchmark/app_clear.rb +0 -21
- data/benchmark/clear.rb +0 -69
- data/benchmark/memory/text_dispose.rb +0 -9
- data/benchmark/para_creator.rb +0 -9
- data/benchmark/paras.rb +0 -52
- data/benchmark/urls.rb +0 -40
- data/bin/ruby-shoes +0 -6
- data/bin/shoes-guard +0 -8
- data/bin/shoes-stub +0 -59
- data/ext/install/Rakefile +0 -29
- data/ext/install/shoes.bat +0 -9
- data/lib/shoes.rb +0 -5
- data/lib/shoes/ui/cli.rb +0 -102
- data/lib/shoes/ui/help.rb +0 -535
- data/lib/shoes/ui/manual.rb +0 -6
- data/lib/shoes/version.rb +0 -3
- data/manifests/common.rb +0 -34
- data/manifests/shoes.rb +0 -44
- data/samples/Gemfile +0 -3
- data/samples/Gemfile.lock +0 -35
- data/samples/README +0 -97
- data/samples/boom.rb +0 -239
- data/samples/class-book-adjusted.rb +0 -45
- data/samples/class-book.rb +0 -43
- data/samples/class-book.yaml +0 -387
- data/samples/clicky.rb +0 -24
- data/samples/cy.png +0 -0
- data/samples/expert-definr.rb +0 -23
- data/samples/expert-funnies.rb +0 -60
- data/samples/expert-game-of-life-adjusted.rb +0 -249
- data/samples/expert-game-of-life.rb +0 -243
- data/samples/expert-irb-adjusted.rb +0 -110
- data/samples/expert-irb.rb +0 -112
- data/samples/expert-minesweeper-adjusted.rb +0 -272
- data/samples/expert-minesweeper.rb +0 -267
- data/samples/expert-othello-adjusted.rb +0 -325
- data/samples/expert-othello.rb +0 -318
- data/samples/expert-pong.rb +0 -62
- data/samples/expert-snake.rb +0 -78
- data/samples/expert-tankspank.rb +0 -385
- data/samples/flow.rb +0 -63
- data/samples/good-arc.rb +0 -45
- data/samples/good-clock.rb +0 -51
- data/samples/good-displace.rb +0 -98
- data/samples/good-follow.rb +0 -26
- data/samples/good-potato-chopping.rb +0 -22
- data/samples/good-reminder.rb +0 -174
- data/samples/good-vjot.rb +0 -58
- data/samples/gray.rb +0 -11
- data/samples/loogink.png +0 -0
- data/samples/nks_booklist.rb +0 -24
- data/samples/nks_breadsticks.rb +0 -7
- data/samples/nks_dancing_circle.rb +0 -13
- data/samples/nks_dictionary.rb +0 -23
- data/samples/nks_edit_box.rb +0 -4
- data/samples/nks_edit_line.rb +0 -6
- data/samples/nks_notes.rb +0 -16
- data/samples/nks_poem.rb +0 -22
- data/samples/nks_self.rb +0 -6
- data/samples/nks_text_sizes.rb +0 -10
- data/samples/nks_trurl.rb +0 -5
- data/samples/original-manual-adjusted.rb +0 -475
- data/samples/original-manual.rb +0 -472
- data/samples/packaging/package_me.rb +0 -6
- data/samples/potato_chopping/1258_s001.gif +0 -0
- data/samples/potato_chopping/1258_s002.gif +0 -0
- data/samples/potato_chopping/1258_s003.gif +0 -0
- data/samples/potato_chopping/1258_s004.gif +0 -0
- data/samples/potato_chopping/1258_s005.gif +0 -0
- data/samples/potato_chopping/1258_s006.gif +0 -0
- data/samples/potato_chopping/1258_s007.gif +0 -0
- data/samples/potato_chopping/1258_s008.gif +0 -0
- data/samples/potato_chopping/1258_s009.gif +0 -0
- data/samples/potato_chopping/1258_s010.gif +0 -0
- data/samples/potato_chopping/1258_s011.gif +0 -0
- data/samples/potato_chopping/1258_s012.gif +0 -0
- data/samples/potato_chopping/1258_s013.gif +0 -0
- data/samples/potato_chopping/1258_s014.gif +0 -0
- data/samples/potato_chopping/1258_s015.gif +0 -0
- data/samples/potato_chopping/1258_s016.gif +0 -0
- data/samples/potato_chopping/1258_s017.gif +0 -0
- data/samples/potato_chopping/1258_s018.gif +0 -0
- data/samples/potato_chopping/1258_s019.gif +0 -0
- data/samples/potato_chopping/1258_s020.gif +0 -0
- data/samples/potato_chopping/1258_s021.gif +0 -0
- data/samples/potato_chopping/1258_s022.gif +0 -0
- data/samples/potato_chopping/1258_s023.gif +0 -0
- data/samples/potato_chopping/1258_s024.gif +0 -0
- data/samples/potato_chopping/1258_s025.gif +0 -0
- data/samples/potato_chopping/1258_s026.gif +0 -0
- data/samples/potato_chopping/1258_s027.gif +0 -0
- data/samples/potato_chopping/1258_s028.gif +0 -0
- data/samples/potato_chopping/1258_s029.gif +0 -0
- data/samples/potato_chopping/1258_s030.gif +0 -0
- data/samples/potato_chopping/1258_s031.gif +0 -0
- data/samples/potato_chopping/1258_s032.gif +0 -0
- data/samples/potato_chopping/1258_s033.gif +0 -0
- data/samples/potato_chopping/1258_s034.gif +0 -0
- data/samples/potato_chopping/1258_s035.gif +0 -0
- data/samples/potato_chopping/1258_s036.gif +0 -0
- data/samples/potato_chopping/1258_s037.gif +0 -0
- data/samples/potato_chopping/1258_s038.gif +0 -0
- data/samples/potato_chopping/1258_s039.gif +0 -0
- data/samples/potato_chopping/1258_s040.gif +0 -0
- data/samples/potato_chopping/1258_s041.gif +0 -0
- data/samples/potato_chopping/1258_s042.gif +0 -0
- data/samples/potato_chopping/1258_s043.gif +0 -0
- data/samples/potato_chopping/1258_s044.gif +0 -0
- data/samples/potato_chopping/1258_s045.gif +0 -0
- data/samples/potato_chopping/1258_s046.gif +0 -0
- data/samples/potato_chopping/1258_s047.gif +0 -0
- data/samples/potato_chopping/1258_s048.gif +0 -0
- data/samples/potato_chopping/1258_s049.gif +0 -0
- data/samples/potato_chopping/1258_s050.gif +0 -0
- data/samples/potato_chopping/1258_s051.gif +0 -0
- data/samples/potato_chopping/1258_s052.gif +0 -0
- data/samples/potato_chopping/1258_s053.gif +0 -0
- data/samples/potato_chopping/1258_s054.gif +0 -0
- data/samples/potato_chopping/1258_s055.gif +0 -0
- data/samples/potato_chopping/1258_s056.gif +0 -0
- data/samples/potato_chopping/1258_s057.gif +0 -0
- data/samples/potato_chopping/1258_s058.gif +0 -0
- data/samples/potato_chopping/1258_s059.gif +0 -0
- data/samples/present.rb +0 -27
- data/samples/progress.rb +0 -10
- data/samples/sample1.rb +0 -30
- data/samples/sample12.rb +0 -21
- data/samples/sample13.rb +0 -13
- data/samples/sample14.rb +0 -64
- data/samples/sample15.rb +0 -18
- data/samples/sample16.rb +0 -10
- data/samples/sample17.rb +0 -10
- data/samples/sample2.rb +0 -14
- data/samples/sample21.rb +0 -5
- data/samples/sample23.rb +0 -8
- data/samples/sample24.rb +0 -21
- data/samples/sample27.rb +0 -18
- data/samples/sample3.rb +0 -14
- data/samples/sample31.rb +0 -22
- data/samples/sample34.rb +0 -27
- data/samples/sample35.rb +0 -32
- data/samples/sample37.rb +0 -8
- data/samples/sample4.rb +0 -7
- data/samples/sample42.rb +0 -14
- data/samples/sample45.rb +0 -11
- data/samples/sample56.rb +0 -10
- data/samples/sample6.rb +0 -9
- data/samples/sample7.rb +0 -3
- data/samples/sample8.rb +0 -7
- data/samples/sample9.rb +0 -10
- data/samples/simple-accordion.rb +0 -75
- data/samples/simple-anim-shapes.rb +0 -17
- data/samples/simple-anim-text.rb +0 -13
- data/samples/simple-animate.rb +0 -12
- data/samples/simple-arc.rb +0 -23
- data/samples/simple-bounce.rb +0 -24
- data/samples/simple-brightness-transitions.rb +0 -8
- data/samples/simple-button-animate.rb +0 -16
- data/samples/simple-calc-2.rb +0 -34
- data/samples/simple-calc.rb +0 -70
- data/samples/simple-color-selector.rb +0 -10
- data/samples/simple-color-transitions.rb +0 -11
- data/samples/simple-control-sizes.rb +0 -24
- data/samples/simple-curve.rb +0 -26
- data/samples/simple-dialogs-outside.rb +0 -12
- data/samples/simple-dialogs.rb +0 -32
- data/samples/simple-displace.rb +0 -15
- data/samples/simple-downloader.rb +0 -27
- data/samples/simple-draw.rb +0 -13
- data/samples/simple-editor.rb +0 -28
- data/samples/simple-face.rb +0 -14
- data/samples/simple-flow-wrap.rb +0 -11
- data/samples/simple-font.rb +0 -17
- data/samples/simple-form.rb +0 -29
- data/samples/simple-form.shy +0 -0
- data/samples/simple-fullscreen.rb +0 -4
- data/samples/simple-guess-game.rb +0 -28
- data/samples/simple-keypress.rb +0 -14
- data/samples/simple-manual.rb +0 -2
- data/samples/simple-mask.rb +0 -21
- data/samples/simple-menu.rb +0 -47
- data/samples/simple-mouse-follow.rb +0 -8
- data/samples/simple-move.rb +0 -13
- data/samples/simple-oval.rb +0 -3
- data/samples/simple-sample-executor.rb +0 -6
- data/samples/simple-shoes-intro.rb +0 -22
- data/samples/simple-slide.rb +0 -56
- data/samples/simple-sound.rb +0 -30
- data/samples/simple-sphere.rb +0 -28
- data/samples/simple-stripes.rb +0 -8
- data/samples/simple-tictactoe.rb +0 -238
- data/samples/simple-timer.rb +0 -15
- data/samples/simple-video.rb +0 -13
- data/samples/simple-visibility.rb +0 -11
- data/samples/simple-widget.rb +0 -9
- data/samples/sounds/102719__sarge4267__explosion.mp3 +0 -0
- data/samples/sounds/145622__andybrannan__train-fog-horn-long-wyomming.aiff +0 -0
- data/samples/sounds/46492__phreaksaccount__shields1.ogg +0 -0
- data/samples/sounds/61847__simon-rue__boink-v3.wav +0 -0
- data/samples/swt-raw.rb +0 -20
- data/samples/troll.rb +0 -22
- data/shoes.gemspec +0 -29
- data/snapshots/sample1.png +0 -0
- data/snapshots/sample10.png +0 -0
- data/snapshots/sample11.png +0 -0
- data/snapshots/sample12.png +0 -0
- data/snapshots/sample13.png +0 -0
- data/snapshots/sample14.png +0 -0
- data/snapshots/sample15.png +0 -0
- data/snapshots/sample16.png +0 -0
- data/snapshots/sample17.png +0 -0
- data/snapshots/sample18.png +0 -0
- data/snapshots/sample19.png +0 -0
- data/snapshots/sample2.png +0 -0
- data/snapshots/sample20.png +0 -0
- data/snapshots/sample21.png +0 -0
- data/snapshots/sample22.png +0 -0
- data/snapshots/sample23.png +0 -0
- data/snapshots/sample24.png +0 -0
- data/snapshots/sample27.png +0 -0
- data/snapshots/sample28.png +0 -0
- data/snapshots/sample29.png +0 -0
- data/snapshots/sample3.png +0 -0
- data/snapshots/sample30.png +0 -0
- data/snapshots/sample31.png +0 -0
- data/snapshots/sample34.png +0 -0
- data/snapshots/sample35.png +0 -0
- data/snapshots/sample36.png +0 -0
- data/snapshots/sample37.png +0 -0
- data/snapshots/sample4.png +0 -0
- data/snapshots/sample42.png +0 -0
- data/snapshots/sample44.png +0 -0
- data/snapshots/sample45.png +0 -0
- data/snapshots/sample46.png +0 -0
- data/snapshots/sample5.png +0 -0
- data/snapshots/sample56.png +0 -0
- data/snapshots/sample6.png +0 -0
- data/snapshots/sample7.png +0 -0
- data/snapshots/sample8.png +0 -0
- data/snapshots/sample9.png +0 -0
- data/snapshots/sample99.png +0 -0
- data/static/PKGBUILD +0 -47
- data/static/Shoes.icns +0 -0
- data/static/avatar.png +0 -0
- data/static/code_highlighter.js +0 -188
- data/static/code_highlighter_ruby.js +0 -26
- data/static/downloading.png +0 -0
- data/static/icon-debug.png +0 -0
- data/static/icon-error.png +0 -0
- data/static/icon-info.png +0 -0
- data/static/icon-warn.png +0 -0
- data/static/listbox_button1.png +0 -0
- data/static/listbox_button2.png +0 -0
- data/static/man-app.png +0 -0
- data/static/man-builds.png +0 -0
- data/static/man-builds1.png +0 -0
- data/static/man-editor-notepad.png +0 -0
- data/static/man-editor-osx.png +0 -0
- data/static/man-ele-background.png +0 -0
- data/static/man-ele-border.png +0 -0
- data/static/man-ele-button.png +0 -0
- data/static/man-ele-check.png +0 -0
- data/static/man-ele-editbox.png +0 -0
- data/static/man-ele-editline.png +0 -0
- data/static/man-ele-image.png +0 -0
- data/static/man-ele-listbox.png +0 -0
- data/static/man-ele-progress.png +0 -0
- data/static/man-ele-radio.png +0 -0
- data/static/man-ele-shape.png +0 -0
- data/static/man-ele-textblock.png +0 -0
- data/static/man-ele-video.png +0 -0
- data/static/man-intro-dmg.png +0 -0
- data/static/man-intro-exe.png +0 -0
- data/static/man-look-tiger.png +0 -0
- data/static/man-look-ubuntu.png +0 -0
- data/static/man-look-vista.png +0 -0
- data/static/man-run-osx.png +0 -0
- data/static/man-run-vista.png +0 -0
- data/static/man-run-xp.png +0 -0
- data/static/man-shot1.png +0 -0
- data/static/manual-en.txt +0 -3531
- data/static/manual-ja.txt +0 -2829
- data/static/manual.css +0 -184
- data/static/menu-corner1.png +0 -0
- data/static/menu-corner2.png +0 -0
- data/static/menu-gray.png +0 -0
- data/static/menu-left.png +0 -0
- data/static/menu-right.png +0 -0
- data/static/menu-top.png +0 -0
- data/static/shoes-dmg.jpg +0 -0
- data/static/shoes-icon-blue.png +0 -0
- data/static/shoes-icon-brown.png +0 -0
- data/static/shoes-icon.png +0 -0
- data/static/shoes-manual-apps.gif +0 -0
- data/static/shoes-manual-apps.png +0 -0
- data/static/shoes_main_window.png +0 -0
- data/static/stripe.png +0 -0
- data/static/tutor-back.png +0 -0
- data/tasks/changelog.rb +0 -92
- data/tasks/gem.rb +0 -38
- data/tasks/rspec.rb +0 -106
- data/tasks/sample.rb +0 -66
- data/tasks/yard.rb +0 -13
data/ext/install/Rakefile
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
require 'rubygems'
|
|
2
|
-
require 'fileutils'
|
|
3
|
-
|
|
4
|
-
# Running JRuby on OS X requires options passed at the start. To pass those
|
|
5
|
-
# options and avoid double JVM startup, we want 'shoes' to be a bash script on
|
|
6
|
-
# Unix systems, but Rubygems only supports installing Ruby to the bin.
|
|
7
|
-
|
|
8
|
-
# We work around this by installing our script as shoes-stub, then acting like
|
|
9
|
-
# a "native extension" via this Rakefile, we manually generate the right script
|
|
10
|
-
# (a copy of shoes-stub) in the Gem.bindir.
|
|
11
|
-
|
|
12
|
-
# Because we don't actually declare shoes as an executable, we also have to
|
|
13
|
-
# copy our shoes.bat into place as well on Windows systems.
|
|
14
|
-
|
|
15
|
-
# We also provide a Rubygems plugin to clean up our manual file on uninstall.
|
|
16
|
-
# Post-install hooks didn't seem to work, though, hence the extension trick.
|
|
17
|
-
|
|
18
|
-
task :default => ['install_script']
|
|
19
|
-
|
|
20
|
-
task :install_script do
|
|
21
|
-
if Gem.win_platform?
|
|
22
|
-
source_path = File.join(File.dirname(__FILE__), "shoes.bat")
|
|
23
|
-
dest_path = File.join(Gem.bindir, "shoes.bat")
|
|
24
|
-
else
|
|
25
|
-
source_path = File.join(File.dirname(__FILE__), "..", "..", "bin", "shoes-stub")
|
|
26
|
-
dest_path = File.join(Gem.bindir, "shoes")
|
|
27
|
-
end
|
|
28
|
-
FileUtils.cp(source_path, dest_path)
|
|
29
|
-
end
|
data/ext/install/shoes.bat
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
@setlocal enableextensions enabledelayedexpansion
|
|
2
|
-
@echo off
|
|
3
|
-
|
|
4
|
-
REM If we're running from source, bin/shoes.bat will have set bin_dir already.
|
|
5
|
-
if not defined bin_dir set bin_dir=%~dp0
|
|
6
|
-
|
|
7
|
-
set command=jruby --1.9 !bin_dir!/ruby-shoes %*
|
|
8
|
-
call !command!
|
|
9
|
-
endlocal
|
data/lib/shoes.rb
DELETED
data/lib/shoes/ui/cli.rb
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
require 'optparse'
|
|
2
|
-
require 'shoes'
|
|
3
|
-
|
|
4
|
-
class Shoes
|
|
5
|
-
class CLI
|
|
6
|
-
def initialize
|
|
7
|
-
@packages = []
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def parse!(args)
|
|
11
|
-
opts = OptionParser.new do |opts|
|
|
12
|
-
opts.program_name = 'shoes'
|
|
13
|
-
opts.banner = <<-EOS
|
|
14
|
-
Usage: #{opts.program_name} [-h] [-p package] file
|
|
15
|
-
EOS
|
|
16
|
-
opts.separator ''
|
|
17
|
-
opts.separator 'Options:'
|
|
18
|
-
|
|
19
|
-
opts.on('-p', '--package PACKAGE_TYPE', 'Package as BACKEND:PACKAGE') do |package|
|
|
20
|
-
unless package =~ /^(swt):(app|jar)$/
|
|
21
|
-
abort("#{opts.program_name}: Can't package as '#{package}'. See '#{opts.program_name} --help'")
|
|
22
|
-
end
|
|
23
|
-
@packages << Package.new(package)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
opts.on('-v', '--version', 'Shoes version') do
|
|
27
|
-
puts "Shoes #{VERSION}"
|
|
28
|
-
exit
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
opts.separator "\nPackage types:"
|
|
32
|
-
opts.separator package_types(opts)
|
|
33
|
-
opts.separator "\nExamples:"
|
|
34
|
-
opts.separator examples(opts)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
opts.parse!(args)
|
|
38
|
-
opts
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def package_types(opts)
|
|
42
|
-
<<-EOS
|
|
43
|
-
swt:app A standalone OS X executable with the Swt backend
|
|
44
|
-
swt:jar An executable JAR with the Swt backend
|
|
45
|
-
EOS
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def examples(opts)
|
|
49
|
-
<<-EOS
|
|
50
|
-
To run a Shoes app:
|
|
51
|
-
#{opts.program_name} path/to/shoes-app.rb
|
|
52
|
-
|
|
53
|
-
Two ways to package a Shoes app as an APP and a JAR, using the Swt backend:
|
|
54
|
-
#{opts.program_name} -p swt:app -p swt:jar path/to/app.yaml
|
|
55
|
-
#{opts.program_name} -p swt:app -p swt:jar path/to/shoes-app.rb
|
|
56
|
-
EOS
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def package(path)
|
|
60
|
-
begin
|
|
61
|
-
require 'furoshiki/shoes'
|
|
62
|
-
config = Furoshiki::Shoes::Configuration.load(path)
|
|
63
|
-
rescue Errno::ENOENT => e
|
|
64
|
-
abort "shoes: #{e.message}"
|
|
65
|
-
end
|
|
66
|
-
@packages.each do |p|
|
|
67
|
-
puts "Packaging #{p.backend}:#{p.wrapper}..."
|
|
68
|
-
packager = Furoshiki::Shoes.new(p.backend, p.wrapper, config)
|
|
69
|
-
packager.package
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
# Execute a shoes app.
|
|
74
|
-
#
|
|
75
|
-
# @param [String] app the location of the app to run
|
|
76
|
-
def execute_app(app)
|
|
77
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
|
78
|
-
require 'shoes/swt'
|
|
79
|
-
load app
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def run(args)
|
|
83
|
-
opts = parse!(args)
|
|
84
|
-
if args.empty?
|
|
85
|
-
puts opts.banner
|
|
86
|
-
puts "Try '#{opts.program_name} --help' for more information"
|
|
87
|
-
exit(0)
|
|
88
|
-
end
|
|
89
|
-
package(args.shift) unless @packages.empty?
|
|
90
|
-
execute_app(args.first) unless args.empty?
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
# Convenience class representing a backend:wrapper pair
|
|
94
|
-
class Package
|
|
95
|
-
def initialize(arg)
|
|
96
|
-
@backend, @wrapper = arg.split(':')
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
attr_reader :backend, :wrapper
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|
data/lib/shoes/ui/help.rb
DELETED
|
@@ -1,535 +0,0 @@
|
|
|
1
|
-
require 'nokogiri'
|
|
2
|
-
require 'nkf'
|
|
3
|
-
require 'ext/highlighter'
|
|
4
|
-
|
|
5
|
-
class Array
|
|
6
|
-
def / len
|
|
7
|
-
a = []
|
|
8
|
-
each_with_index do |x, i|
|
|
9
|
-
a << [] if i % len == 0
|
|
10
|
-
a.last << x
|
|
11
|
-
end
|
|
12
|
-
a
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def dark?
|
|
16
|
-
r, g, b = self
|
|
17
|
-
r + g + b < 0x55 * 3
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def light?
|
|
21
|
-
r, g, b = self
|
|
22
|
-
r + g + b > 0xAA * 3
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
class Manual < Shoes
|
|
27
|
-
url '/', :index
|
|
28
|
-
url '/manual/(\d+)', :index
|
|
29
|
-
|
|
30
|
-
include HH::Markup
|
|
31
|
-
|
|
32
|
-
def index pnum = 0
|
|
33
|
-
#font LANG == 'ja' ? 'MS UI Gothic' : 'Arial'
|
|
34
|
-
#style Link, underline: false, weight: 'bold'
|
|
35
|
-
#style LinkHover, stroke: '#06E'
|
|
36
|
-
self.scroll_top = 0
|
|
37
|
-
TOC.clear; TOC_LIST.clear
|
|
38
|
-
table_of_contents.each{|toc| TOC << toc}
|
|
39
|
-
pnum == '999' ? mk_search_page : manual( *get_title_and_desc(pnum.to_i) )
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def get_title_and_desc pnum
|
|
43
|
-
chapter, section = PNUMS[pnum]
|
|
44
|
-
return nil unless chapter
|
|
45
|
-
if section
|
|
46
|
-
[pnum, DOCS[chapter][1][:sections][section][1][:title],
|
|
47
|
-
DOCS[chapter][1][:sections][section][1][:description],
|
|
48
|
-
DOCS[chapter][1][:sections][section][1][:methods]]
|
|
49
|
-
else
|
|
50
|
-
[pnum, DOCS[chapter][0], DOCS[chapter][1][:description], []]
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def table_of_contents
|
|
55
|
-
PNUMS.map.with_index do |e, pnum|
|
|
56
|
-
chapter, section = e
|
|
57
|
-
title = section ? DOCS[chapter][1][:sections][section][1][:title] : DOCS[chapter][0]
|
|
58
|
-
title = title.sub('The', '').split(' ').first
|
|
59
|
-
TOC_LIST << [title, section]
|
|
60
|
-
section ? [' ', link(title){visit "/manual/#{pnum}"}, "\n"] : [link(fg(title, magenta)){visit "/manual/#{pnum}"}, "\n"]
|
|
61
|
-
end.flatten
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def manual pnum, docs_title, docs_description, docs_methods
|
|
65
|
-
flow do
|
|
66
|
-
show_header docs_title
|
|
67
|
-
show_toc
|
|
68
|
-
paras = mk_paras docs_description
|
|
69
|
-
flow width: 0.75, margin: [20, 0, 20, 0] do
|
|
70
|
-
show_page paras, true
|
|
71
|
-
show_methods docs_methods
|
|
72
|
-
para link('top'){visit "/manual/0"}, " ",
|
|
73
|
-
link('prev'){visit "/manual/#{(pnum-1)%PEND}"}, " ",
|
|
74
|
-
link('next'){visit "/manual/#{(pnum+1)%PEND}"}, " ",
|
|
75
|
-
link('end'){visit "/manual/#{PEND-1}"}
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def show_header docs_title
|
|
81
|
-
background snow..white, angle: 90
|
|
82
|
-
background midnightblue..black, height: 90
|
|
83
|
-
flow width: 500 do
|
|
84
|
-
para fg("The Shoes 4 Manual #{VERSION}", gray), left: 120, top: 10
|
|
85
|
-
title fg(docs_title, white), left: 120, top: 30, font: 'Coolvetica'
|
|
86
|
-
end
|
|
87
|
-
image(File.join(DIR, 'static/shoes-icon.png'), width: 110, height: 110).move 5, -12
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def show_toc
|
|
91
|
-
s = self
|
|
92
|
-
stack height: 30
|
|
93
|
-
flow width: 0.2, margin_left: 10 do
|
|
94
|
-
flow(margin_right: 20) do
|
|
95
|
-
background black(0.7), curve: 5
|
|
96
|
-
inscription "Not findng it?\n", 'Try ', link(fg 'Search', white){visit '/manual/999'}, '!', align: 'center', stroke: lightgray
|
|
97
|
-
end
|
|
98
|
-
stack(height: 10){}
|
|
99
|
-
para *TOC
|
|
100
|
-
para link(fg 'to_html', green){s.html_manual}
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def show_methods docs_methods, term = nil
|
|
105
|
-
docs_methods.each do |m, d|
|
|
106
|
-
flow do
|
|
107
|
-
background rgb(60, 60, 60), curve: 5
|
|
108
|
-
n = m.index("\u00BB")
|
|
109
|
-
if n
|
|
110
|
-
para ' ', fg(strong(m[0...n]), white), fg(strong(m[n..-1]), rgb(160, 160, 160))
|
|
111
|
-
else
|
|
112
|
-
para ' ', fg(strong(m), white)
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
para NL
|
|
116
|
-
show_page mk_paras(d), false, term
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def show_page paras, intro = false, term = nil
|
|
121
|
-
s = self
|
|
122
|
-
paras.each_with_index do |text, i|
|
|
123
|
-
if text =~ CODE_RE
|
|
124
|
-
text.gsub CODE_RE do |lines|
|
|
125
|
-
lines = lines.split NL
|
|
126
|
-
n = lines[1] =~ /\#\!ruby/ ? 2 : 1
|
|
127
|
-
_code = lines[n...-1].join(NL+' ')
|
|
128
|
-
flow do
|
|
129
|
-
background rgb(190, 190, 190), curve: 5
|
|
130
|
-
inscription link(fg('Run this', magenta)){eval s.mk_executable(_code), TOPLEVEL_BINDING}, ' ', align: 'right'
|
|
131
|
-
if _code.include? 'te-su-to'
|
|
132
|
-
para fg(code(' ' + _code), maroon), NL, margin: [-10, 10, 0, 20]
|
|
133
|
-
else
|
|
134
|
-
para *highlight(' ' + _code, nil).map{|e| code e}, NL * 2, margin: [-10, 10, 0, 20]
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
fill_rest_of_line
|
|
138
|
-
para NL
|
|
139
|
-
end
|
|
140
|
-
next
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
if text =~ /\A \* (.+)/m
|
|
144
|
-
$1.split(/^ \* /).each do |txt|
|
|
145
|
-
image File.join(DIR, 'static/shoes-icon.png'), width: 20, height: 20
|
|
146
|
-
flow(width: 510){show_paragraph txt, intro, i, term}
|
|
147
|
-
para NL
|
|
148
|
-
end
|
|
149
|
-
else
|
|
150
|
-
show_paragraph text, intro, i, term
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
def show_paragraph txt, intro, i, term = nil
|
|
156
|
-
txt = txt.gsub("\n", ' ').gsub(/\^(.+?)\^/m, '\1').gsub(/\[\[BR\]\]/i, "\n")
|
|
157
|
-
txts = txt.split(/(\[\[\S+?\]\])/m).map{|s| s.split(/(\[\[\S+? .+?\]\])/m)}.flatten
|
|
158
|
-
case txts[0]
|
|
159
|
-
when /\A==== (.+) ====/; caption *marker($1, term), size: 24
|
|
160
|
-
when /\A=== (.+) ===/; tagline *marker($1, term), size: 12, weight: 'bold'
|
|
161
|
-
when /\A== (.+) ==/; subtitle *marker($1, term)
|
|
162
|
-
when /\A= (.+) =/; title *marker($1, term)
|
|
163
|
-
when /\A\{COLORS\}/; flow{color_page}
|
|
164
|
-
when /\A\{SAMPLES\}/; flow{sample_page}
|
|
165
|
-
else
|
|
166
|
-
para *mk_deco(mk_links(txts, term).flatten), NL, (intro and i.zero?) ? {size: 16} : ''
|
|
167
|
-
txt.gsub IMAGE_RE do
|
|
168
|
-
image File.join(DIR, "static/#{$3}"), eval("{#{$2 or "margin_left: 50"}}")
|
|
169
|
-
fill_rest_of_line
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
def mk_links txts, term = nil
|
|
175
|
-
txts.map{|txt| txt.gsub(IMAGE_RE, '')}.
|
|
176
|
-
map{|txt| txt =~ /\[\[(\S+?)\]\]/m ? (t = $1.split('.'); link(ins *marker(t.last, term)){visit "/manual/#{find_pnum t.first}"}) : txt}.
|
|
177
|
-
map{|txt| txt =~ /\[\[(\S+?) (.+?)\]\]/m ? (url = $1; link(ins *marker($2, term)){visit url =~ /^http/ ? url : "/manual/#{find_pnum url}"}) :
|
|
178
|
-
(txt.is_a?(String) ? marker(txt, term) : txt)}
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
def mk_paras str
|
|
182
|
-
str.split(PARA_RE) - ['']
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
def mk_executable code
|
|
186
|
-
if code =~ /\# Not yet available/
|
|
187
|
-
"Shoes.app{para 'Sorry, not yet available...'}"
|
|
188
|
-
else
|
|
189
|
-
code
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
def color_page
|
|
194
|
-
COLORS.each do |color, v|
|
|
195
|
-
r, g, b = v.red, v.green, v.blue
|
|
196
|
-
c = v.dark? ? white : black
|
|
197
|
-
stack width: 0.33, height: 55, margin_top: 5 do
|
|
198
|
-
clr = send(color)
|
|
199
|
-
background clr
|
|
200
|
-
#para fg(strong(color), c), align: 'center'
|
|
201
|
-
para fg('. ', clr), fg(strong(color), c), fg(' .', clr), align: 'center'
|
|
202
|
-
para fg("rgb(#{r}, #{g}, #{b})", c), align: 'center'
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
para NL
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
def sample_page
|
|
209
|
-
mk_sample_names.each do |file|
|
|
210
|
-
stack width: 80 do
|
|
211
|
-
inscription file[0...-3]
|
|
212
|
-
image File.join(DIR, "snapshots/#{file[0..-3]}png"), width: 50, height: 50 do
|
|
213
|
-
Dir.chdir(File.join DIR, 'samples'){instance_eval(IO.read(file),file,0)}
|
|
214
|
-
end
|
|
215
|
-
para NL
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
def mk_sample_names
|
|
221
|
-
Dir[File.join(DIR, 'samples/sample*.rb')].map do |file|
|
|
222
|
-
orig_name = File.basename file
|
|
223
|
-
dummy_name = orig_name.sub(/sample(.*)\.rb/){
|
|
224
|
-
first, second = $1.split('-')
|
|
225
|
-
"%02d%s%s" % [first.to_i, ('-' if second), second]
|
|
226
|
-
}
|
|
227
|
-
[dummy_name, orig_name]
|
|
228
|
-
end.sort.map &:last
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
def find_pnum page
|
|
232
|
-
return 999 if page == 'Search'
|
|
233
|
-
TOC_LIST.each_with_index do |e, i|
|
|
234
|
-
title, section = e
|
|
235
|
-
return i if title == page
|
|
236
|
-
end
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
def self.load_docs path
|
|
240
|
-
str = IO.read(path).force_encoding("UTF-8")
|
|
241
|
-
(str.split(/^= (.+?) =/)[1..-1]/2).map do |k, v|
|
|
242
|
-
sparts = v.split(/^== (.+?) ==/)
|
|
243
|
-
sections = (sparts[1..-1]/2).map do |k2, v2|
|
|
244
|
-
meth = v2.split(/^=== (.+?) ===/)
|
|
245
|
-
k2t = k2[/^(?:The )?([\-\w]+)/, 1]
|
|
246
|
-
meth_plain = meth[0].gsub(IMAGE_RE, '')
|
|
247
|
-
h = {title: k2, section: k, description: meth[0], methods: (meth[1..-1]/2)}
|
|
248
|
-
[k2t, h]
|
|
249
|
-
end
|
|
250
|
-
h = {description: sparts[0], sections: sections, class: "toc" + k.downcase.gsub(/\W+/, '')}
|
|
251
|
-
[k, h]
|
|
252
|
-
end
|
|
253
|
-
end
|
|
254
|
-
|
|
255
|
-
def self.mk_page_numbers docs
|
|
256
|
-
pnum = []
|
|
257
|
-
docs.length.times do |i|
|
|
258
|
-
pnum << [i, nil]
|
|
259
|
-
docs[i][1][:sections].length.times do |j|
|
|
260
|
-
pnum << [i, j]
|
|
261
|
-
end
|
|
262
|
-
end
|
|
263
|
-
pnum
|
|
264
|
-
end
|
|
265
|
-
|
|
266
|
-
def html_manual
|
|
267
|
-
dir = ask_save_folder
|
|
268
|
-
return unless dir
|
|
269
|
-
FileUtils.mkdir_p File.join(dir, 'static')
|
|
270
|
-
FileUtils.mkdir_p File.join(dir, 'snapshots')
|
|
271
|
-
%w[shoes-icon.png shoes-manual-apps.png manual.css code_highlighter.js code_highlighter_ruby.js].
|
|
272
|
-
each{|x| FileUtils.cp "#{DIR}/static/#{x}", "#{dir}/static"}
|
|
273
|
-
Dir[File.join DIR, 'static/man-*.png'].each{|x| FileUtils.cp x, "#{dir}/static"}
|
|
274
|
-
Dir[File.join DIR, 'snapshots/sample*.png'].each{|x| FileUtils.cp x, "#{dir}/snapshots"}
|
|
275
|
-
|
|
276
|
-
TOC_LIST.length.times do |n|
|
|
277
|
-
num, title, desc, methods = get_title_and_desc n
|
|
278
|
-
open File.join(dir, "#{TOC_LIST[n][0]}.html"), 'wb:utf-8' do |f|
|
|
279
|
-
html = mk_html(title, desc, methods, TOC_LIST[n+1], get_title_and_desc(n+1), mk_sidebar_list(num))
|
|
280
|
-
f.puts html.force_encoding('UTF-8')
|
|
281
|
-
end
|
|
282
|
-
end
|
|
283
|
-
end
|
|
284
|
-
|
|
285
|
-
def mk_html title, desc, methods, next_file, next_title, menu
|
|
286
|
-
man = self
|
|
287
|
-
html = Nokogiri::HTML::Builder.new do |h|
|
|
288
|
-
h.html(:lang => Manual::LANG) do
|
|
289
|
-
h.head do
|
|
290
|
-
h.meta charset: 'utf-8'
|
|
291
|
-
h.title "The Shoes 4 Manual // #{title}"
|
|
292
|
-
h.script type: "text/javascript", src: "static/code_highlighter.js"
|
|
293
|
-
h.script type: "text/javascript", src: "static/code_highlighter_ruby.js"
|
|
294
|
-
h.style type: "text/css" do
|
|
295
|
-
h.text "@import 'static/manual.css';"
|
|
296
|
-
end
|
|
297
|
-
end
|
|
298
|
-
h.body do
|
|
299
|
-
h.div.main! do
|
|
300
|
-
h.div.manual! do
|
|
301
|
-
h.h2 "The Shoes 4 Manual #{VERSION}"
|
|
302
|
-
h.h1 title
|
|
303
|
-
|
|
304
|
-
paras = man.mk_paras desc
|
|
305
|
-
h.div(:class => 'intro') { h << man.manual_p(paras.shift) }
|
|
306
|
-
|
|
307
|
-
html_paragraph = proc do
|
|
308
|
-
paras.each do |str|
|
|
309
|
-
if str =~ CODE_RE
|
|
310
|
-
h.pre{h.code(class: 'rb'){h.text $1.gsub(/^\s*?\n/, '')}}
|
|
311
|
-
else
|
|
312
|
-
cmd, str = case str
|
|
313
|
-
when /\A==== (.+) ====/; [:h4, $1]
|
|
314
|
-
when /\A=== (.+) ===/; [:h3, $1]
|
|
315
|
-
when /\A== (.+) ==/; [:h2, $1]
|
|
316
|
-
when /\A= (.+) =/; [:h1, $1]
|
|
317
|
-
when /\A\{COLORS\}/
|
|
318
|
-
COLORS.each do |color, v|
|
|
319
|
-
f = v.dark? ? "white" : "black"
|
|
320
|
-
h.div(class: 'color', style: "background: #{color}; color: #{f}"){ h.h3 color.to_s; h.p("rgb(%d, %d, %d)" % [v.red, v.green, v.blue])}
|
|
321
|
-
end
|
|
322
|
-
when /\A\{SAMPLES\}/
|
|
323
|
-
man.mk_sample_names.each do |name|
|
|
324
|
-
name = name[0...-3]
|
|
325
|
-
h.div( :class => 'sample') do
|
|
326
|
-
h.h3 name
|
|
327
|
-
h.text '<a href="snapshots/%s.png"><img src="snapshots/%s.png" alt="%s" border=0 width=50 height=50></a>' % [name, name, name]
|
|
328
|
-
end
|
|
329
|
-
end
|
|
330
|
-
when /\A \* (.+)/m
|
|
331
|
-
h.ul {$1.split(/^ \* /).each{|x| h << man.manual_p(x) }} ; nil
|
|
332
|
-
else
|
|
333
|
-
[:p_, str]
|
|
334
|
-
end
|
|
335
|
-
h.send(cmd){ h << man.manual_p(str) } if cmd.is_a?(Symbol)
|
|
336
|
-
end
|
|
337
|
-
end
|
|
338
|
-
end
|
|
339
|
-
|
|
340
|
-
html_paragraph.call
|
|
341
|
-
|
|
342
|
-
methods.each do |m, d|
|
|
343
|
-
n = m.index("\u00BB")
|
|
344
|
-
n ? (sig, val = m[0...n-1], m[n-1..-1]) : (sig, val = m, nil)
|
|
345
|
-
aname = sig[/^[^(=]+=?/].gsub(/\s/, '').downcase
|
|
346
|
-
h.a(name: aname)
|
|
347
|
-
h.div(class: 'divmethod') do
|
|
348
|
-
h.a sig, href: "##{aname}"
|
|
349
|
-
h.text val if val
|
|
350
|
-
end
|
|
351
|
-
h.div(class: 'desc') do
|
|
352
|
-
paras = man.mk_paras d
|
|
353
|
-
html_paragraph.call
|
|
354
|
-
end
|
|
355
|
-
end
|
|
356
|
-
|
|
357
|
-
h.p(class: 'next'){h.text "Next: "; h.a(href: "#{next_file[0]}.html") { h.text next_title[1] }} if next_title
|
|
358
|
-
end
|
|
359
|
-
h.div(class: 'sidebar') do
|
|
360
|
-
h.img src: "static/shoes-icon.png"
|
|
361
|
-
h.ul do
|
|
362
|
-
h.li{h.a(class:'prime', href: "./") { h.text "HELP" }}
|
|
363
|
-
menu.each do |m|
|
|
364
|
-
h.li do
|
|
365
|
-
unless m.is_a?(Array)
|
|
366
|
-
h.a(href: "#{m}.html") {h.text m}
|
|
367
|
-
else
|
|
368
|
-
h.ul(class: 'sub') do
|
|
369
|
-
m.each do |sm|
|
|
370
|
-
h.li{h.a(href: "#{sm}.html") {h.text sm}}
|
|
371
|
-
end
|
|
372
|
-
end
|
|
373
|
-
end
|
|
374
|
-
end
|
|
375
|
-
end
|
|
376
|
-
end
|
|
377
|
-
end
|
|
378
|
-
end
|
|
379
|
-
end
|
|
380
|
-
end
|
|
381
|
-
end.to_html
|
|
382
|
-
|
|
383
|
-
"<!DOCTYPE html>\n#{html}"
|
|
384
|
-
end
|
|
385
|
-
|
|
386
|
-
def mk_sidebar_list num
|
|
387
|
-
toc = []
|
|
388
|
-
[0..3, 4..9, 10..16, 17..32, 33..37].each do |r|
|
|
389
|
-
toc.push TOC_LIST[r.first][0]
|
|
390
|
-
toc.push(TOC_LIST[r.first+1..r.last].to_a.map &:first) if r.include?(num)
|
|
391
|
-
end
|
|
392
|
-
toc
|
|
393
|
-
end
|
|
394
|
-
|
|
395
|
-
def manual_p str
|
|
396
|
-
str.gsub(/\n+\s*/, " ").
|
|
397
|
-
gsub(/&/, '&').gsub(/>/, '>').gsub(/>/, '<').gsub(/"/, '"').
|
|
398
|
-
gsub(/`(.+?)`/m, '<code>\1</code>').gsub(/\[\[BR\]\]/i, "<br />\n").
|
|
399
|
-
gsub(/\^(.+?)\^/m, '\1').
|
|
400
|
-
gsub(/'''(.+?)'''/m, '<strong>\1</strong>').gsub(/''(.+?)''/m, '<em>\1</em>').
|
|
401
|
-
gsub(/\[\[((http|https):\/\/\S+?)\]\]/m, '<a href="\1" target="_new">\1</a>').
|
|
402
|
-
gsub(/\[\[((http|https):\/\/\S+?) (.+?)\]\]/m, '<a href="\1" target="_new">\3</a>').
|
|
403
|
-
gsub(/\[\[(\S+?)\]\]/m) do
|
|
404
|
-
ms, mn = $1.split(".", 2)
|
|
405
|
-
if mn
|
|
406
|
-
'<a href="' + ms + '.html#' + mn + '">' + mn + '</a>'
|
|
407
|
-
else
|
|
408
|
-
'<a href="' + ms + '.html">' + ms + '</a>'
|
|
409
|
-
end
|
|
410
|
-
end.
|
|
411
|
-
gsub(/\[\[(\S+?) (.+?)\]\]/m, '<a href="\1.html">\2</a>').
|
|
412
|
-
gsub(/\!(\{[^}\n]+\})?([^!\n]+\.\w+)\!/) do
|
|
413
|
-
'<img src="' + "static/#$2" + '" />'
|
|
414
|
-
end
|
|
415
|
-
end
|
|
416
|
-
|
|
417
|
-
def mk_search_page
|
|
418
|
-
s = self
|
|
419
|
-
flow do
|
|
420
|
-
show_header 'Search'
|
|
421
|
-
show_toc
|
|
422
|
-
pnum, docs_title, docs_description, docs_methods = get_title_and_desc(25)
|
|
423
|
-
paras = mk_paras docs_description
|
|
424
|
-
|
|
425
|
-
flow width: 0.8, margin: [10, 0, 20, 0] do
|
|
426
|
-
el = edit_line width: 300
|
|
427
|
-
tagline link('search'){
|
|
428
|
-
term = el.text.strip
|
|
429
|
-
unless term.empty?
|
|
430
|
-
descs, methods = s.search term
|
|
431
|
-
@f.clear{s.show_search_result term, descs, methods}
|
|
432
|
-
end
|
|
433
|
-
}
|
|
434
|
-
stack(height: 20){}
|
|
435
|
-
@f = flow{}
|
|
436
|
-
end
|
|
437
|
-
end
|
|
438
|
-
end
|
|
439
|
-
|
|
440
|
-
def search term
|
|
441
|
-
descs, methods = [], []
|
|
442
|
-
PNUMS.each_with_index do |(chapter, section), pnum|
|
|
443
|
-
pnum, docs_title, docs_description, docs_methods = get_title_and_desc(pnum)
|
|
444
|
-
paras = mk_paras(docs_description)
|
|
445
|
-
descs << [chapter, section, docs_title, paras] if paras.map{|txt| txt.gsub(CODE_RE, '').gsub(IMAGE_RE, '')}.join(' ').index(term)
|
|
446
|
-
docs_methods.each do |docs_method|
|
|
447
|
-
m, d = docs_method
|
|
448
|
-
methods << [chapter, section, docs_title, docs_method] if m.index(term) or d.gsub(CODE_RE, '').gsub(IMAGE_RE, '').index(term)
|
|
449
|
-
end
|
|
450
|
-
end
|
|
451
|
-
return descs, methods
|
|
452
|
-
end
|
|
453
|
-
|
|
454
|
-
def show_search_result term, descs, methods
|
|
455
|
-
s = self
|
|
456
|
-
if descs.empty? and methods.empty?
|
|
457
|
-
subtitle 'Not Found'
|
|
458
|
-
else
|
|
459
|
-
methods.each do |(chapter, section, docs_title, docs_method)|
|
|
460
|
-
flow margin: [10, 10, 0, 5] do
|
|
461
|
-
background rgb(200, 200, 200), curve: 5
|
|
462
|
-
para "#{DOCS[chapter][0]}: #{docs_title.sub('The', '').split(' ').first}: ",
|
|
463
|
-
link(docs_method[0]){@f.clear{title docs_title; s.show_methods [docs_method], term}}, NL
|
|
464
|
-
end
|
|
465
|
-
stack(height: 2){}
|
|
466
|
-
end
|
|
467
|
-
descs.each do |(chapter, section, docs_title, paras)|
|
|
468
|
-
flow margin_left: 10 do
|
|
469
|
-
if section
|
|
470
|
-
background gray, curve: 5
|
|
471
|
-
tagline link(fg(docs_title, white)){@f.clear{title docs_title; s.show_page paras, true, term}}, width: 320
|
|
472
|
-
inscription "Sub-Section under #{DOCS[chapter][0]}", stroke: lightgray, width: 180
|
|
473
|
-
else
|
|
474
|
-
background black(0.8), curve: 5
|
|
475
|
-
subtitle link(fg(docs_title, white)){@f.clear{title docs_title; s.show_page paras, true, term}}, width: 320
|
|
476
|
-
inscription 'Section Header', stroke: lightgray, width: 100
|
|
477
|
-
end
|
|
478
|
-
end
|
|
479
|
-
stack(height: 2){}
|
|
480
|
-
end
|
|
481
|
-
para NL
|
|
482
|
-
end
|
|
483
|
-
end
|
|
484
|
-
|
|
485
|
-
def marker txt, term
|
|
486
|
-
if term && txt
|
|
487
|
-
tmp = txt.split(term).map{|s| [s, bg(term, yellow)]}.flatten
|
|
488
|
-
txt =~ /#{term}$/ ? tmp : tmp[0...-1]
|
|
489
|
-
else
|
|
490
|
-
[txt]
|
|
491
|
-
end
|
|
492
|
-
end
|
|
493
|
-
|
|
494
|
-
def mk_deco datas
|
|
495
|
-
datas = decoration(datas, /`(.+?)`/m){|s| fg code(s), rgb(255, 30, 0)}
|
|
496
|
-
datas = decoration(datas, /'''(.+?)'''/m){|s| strong s}
|
|
497
|
-
decoration(datas, /''(.+?)''/m){|s| em s}
|
|
498
|
-
end
|
|
499
|
-
|
|
500
|
-
def decoration datas, re, &blk
|
|
501
|
-
datas.map do |data|
|
|
502
|
-
if data.is_a? String
|
|
503
|
-
txts = [data]
|
|
504
|
-
data.match re do |md|
|
|
505
|
-
n = data.index md[0]
|
|
506
|
-
txts = [data[0...n], blk[md[1]], decoration([data[n+md[0].length..-1]], re, &blk)]
|
|
507
|
-
end
|
|
508
|
-
txts
|
|
509
|
-
else
|
|
510
|
-
data
|
|
511
|
-
end
|
|
512
|
-
end.flatten
|
|
513
|
-
end
|
|
514
|
-
|
|
515
|
-
# Hack to consume remaining space to the right of a flow.
|
|
516
|
-
# Used to rely on NL's, but with new text flowing, that doesn't work anymore.
|
|
517
|
-
def fill_rest_of_line
|
|
518
|
-
flow width:1.0 do
|
|
519
|
-
end
|
|
520
|
-
end
|
|
521
|
-
|
|
522
|
-
IMAGE_RE = /\!(\{([^}\n]+)\})?([^!\n]+\.\w+)\!/
|
|
523
|
-
CODE_RE = /\{{3}(?:\s*\#![^\n]+)?(.+?)\}{3}/m
|
|
524
|
-
PARA_RE = /\s*?(\{{3}(?:.+?)\}{3})|\n\n/m
|
|
525
|
-
NL = "\n"
|
|
526
|
-
LANG = $lang.downcase[0, 2]
|
|
527
|
-
DOCS = load_docs($lang =~ /\.txt$/ ? $lang : File.join(DIR, "static/manual-#{LANG}.txt"))
|
|
528
|
-
PNUMS = mk_page_numbers DOCS
|
|
529
|
-
PEND = PNUMS.length
|
|
530
|
-
TOC, TOC_LIST = [], []
|
|
531
|
-
COLORS = Shoes::COLORS
|
|
532
|
-
VERSION = Shoes::VERSION
|
|
533
|
-
end
|
|
534
|
-
|
|
535
|
-
Shoes.app title: 'The Shoes 4 Manual', width: 720, height: 640
|