Top Level Namespace
- Includes:
- FileUtils
Defined Under Namespace
Modules: Byebug, ChipMunk, DiyProf, Exerb, Gem, Kernel, OpenURI, Override, PackShoes, TimeHelpers, Vlc, Vlc_path, Winject Classes: Array, Bignum, CallInfo, Class, Encoding, FalseClass, File, Fixnum, Float, Hash, MethodInfo, MimickIRB, Module, NilClass, NodeWidget, NotSupportedByShoes, Numeric, Proc, ProfilerDB, RadioLabel, Range, Regexp, Reporter, Search, Shoes, Shy, String, Symbol, Time, Tracer, TrueClass
Constant Summary collapse
- DATABASE =
SDBM.new(data_file)
- LIB_DIR =
lib_dir || File.join(Dir::tmpdir, "shoes")
- SITE_LIB_DIR =
require ‘rbconfig’
File.join(LIB_DIR, '+lib')
- GEM_DIR =
File.join(LIB_DIR, '+gem')
- CACHE_DIR =
File.join(LIB_DIR, '+cache')
- SHOES_RUBY_ARCH =
- GEM_CENTRAL_DIR =
debug “Trying to use #gp and #ip”
GEM_DIR = gp
- ShoesGemJailBreak =
Loose Shoes
true
- TITLES =
{ title: :h1, subtitle: :h2, tagline: :h3, caption: :h4 }
- CURSOR =
">>"
Class Method Summary collapse
- .manual_as(format, *args) ⇒ Object
-
.manual_p(str, path) ⇒ Object
old manual -> html processor.
Instance Method Summary collapse
-
#audio(path, attr = nil) ⇒ Object
convenience method, hiding away the widget.
- #upraise(message) ⇒ Object
- #video(path, attr = nil) ⇒ Object
- #window(*a, &b) ⇒ Object
Class Method Details
.manual_as(format, *args) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/shoes/manhtml.rb', line 31 def self.manual_as(format, *args) require 'shoes/search' require 'shoes/help' case format when :shoes Shoes.app(width: 720, height: 640, &Shoes::Help) else extend Shoes::Manual man = self dir, = args FileUtils.mkdir_p File.join(dir, 'static') FileUtils.cp "#{DIR}/static/shoes-icon.png", "#{dir}/static" %w(manual.css code_highlighter.js code_highlighter_ruby.js) .each { |x| FileUtils.cp "#{DIR}/static/#{x}", "#{dir}/static" } html_bits = proc do proc do |sym, text| case sym when :intro div.intro { p { self << man.manual_p(text, dir) } } when :code pre { code.rb text.gsub(/^\s*?\n/, '') } when :colors color_names = (Shoes::COLORS.keys * "\n").split("\n").sort color_names.each do |color| c = Shoes::COLORS[color.intern] f = c.dark? ? 'white' : 'black' div.color(style: "background: #{c}; color: #{f}") { h3 color; p c } end when :index tree = man.class_tree shown = [] i = 0 index_p = proc do |k, subs| unless shown.include? k i += 1 p "▸ #{k}", style: "margin-left: #{20 * i}px" subs.uniq.sort.each do |s| index_p[s, tree[s]] end if subs i -= 1 shown << k end end tree.sort.each &index_p # index_page when :list ul { text.each { |x| li { self << man.manual_p(x, dir) } } } when :samples folder = File.join DIR, 'samples' h = {} Dir.glob(File.join folder, '*').each do |file| if File.extname(file) == '.rb' key = File.basename(file).split('-')[0] h[key] ? h[key].push(file) : h[key] = [file] end end h.each do |k, v| p "<h4>#{k}</h4>" samples = [] v.each do |file| sample = File.basename(file).split('-')[1..-1].join('-')[0..-4] samples << "<a href=\"http://github.com/shoes/shoes/raw/master/manual-snapshots/#{k}-#{sample}.png\">#{sample}</a>" end p samples.join ' ' end else send(TITLES[sym] || :p) { self << man.manual_p(text, dir) } end end end docs = load_docs(Shoes::Manual.path) sections = docs.map { |x,| x } docn = 1 docs.each do |title1, opt1| subsect = opt1['sections'].map { |x,| x } = sections.map do |x| [x, (subsect if x == title1)] end path1 = File.join(dir, title1.gsub(/\W/, '')) make_html("#{path1}.html", title1, ) do h2 'The Shoes Manual' h1 title1 man.wiki_tokens opt1['description'], true, &instance_eval(&html_bits) p.next do text 'Next: ' a opt1['sections'].first[1]['title'], href: "#{opt1['sections'].first[0]}.html" end end optn = 1 opt1['sections'].each do |title2, opt2| path2 = File.join(dir, title2) make_html("#{path2}.html", opt2['title'], ) do h2 'The Shoes Manual' h1 opt2['title'] man.wiki_tokens opt2['description'], true, &instance_eval(&html_bits) opt2['methods'].each do |title3, desc3| sig, val = title3.split(/\s+»\s+/, 2) aname = sig[/^[^(=]+=?/].gsub(/\s/, '').downcase a name: aname div.method do a sig, href: "##{aname}" text " » #{val}" if val end div.sample do man.wiki_tokens desc3, &instance_eval(&html_bits) end end if opt1['sections'][optn] p.next do text 'Next: ' a opt1['sections'][optn][1]['title'], href: "#{opt1['sections'][optn][0]}.html" end elsif docs[docn] p.next do text 'Next: ' a docs[docn][0], href: "#{docs[docn][0].gsub(/\W/, '')}.html" end end optn += 1 end end docn += 1 end end end |
.manual_p(str, path) ⇒ Object
old manual -> html processor. needs lots of fixing if it’s ever used again
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/shoes/manhtml.rb', line 4 def self.manual_p(str, path) str.gsub(/\n+\s*/, ' ') .gsub(/&/, '&').gsub(/>/, '>').gsub(/>/, '<').gsub(/"/, '"') .gsub(/`(.+?)`/m, '<code>\1</code>').gsub(/\[\[BR\]\]/i, "<br />\n") .gsub(/\^(.+?)\^/m, '\1') .gsub(/'''(.+?)'''/m, '<strong>\1</strong>').gsub(/''(.+?)''/m, '<em>\1</em>') .gsub(/\[\[(http:\/\/\S+?)\]\]/m, '<a href="\1" target="_new">\1</a>') .gsub(/\[\[(http:\/\/\S+?) (.+?)\]\]/m, '<a href="\1" target="_new">\2</a>') .gsub(/\[\[(\S+?)\]\]/m) do ms, mn = Regexp.last_match(1).split('.', 2) if mn '<a href="' + ms + '.html#' + mn + '">' + mn + '</a>' else '<a href="' + ms + '.html">' + ms + '</a>' end end .gsub(/\[\[(\S+?) (.+?)\]\]/m, '<a href="\1.html">\2</a>') .gsub(/\!(\{[^}\n]+\})?([^!\n]+\.\w+)\!/) do x = "static/#{Regexp.last_match(2)}" FileUtils.cp("#{DIR}/#{x}", "#{path}/#{x}") if File.exist? "#{DIR}/#{x}" '<img src="' + x + '" />' end end |
Instance Method Details
#audio(path, attr = nil) ⇒ Object
convenience method, hiding away the widget
524 525 526 527 528 |
# File 'lib/shoes/videoffi.rb', line 524 def audio(path, attr=nil) attr ||= {} attr.merge!( {width: 0, height: 0, hidden: true} ) video(path, attr) end |
#upraise(message) ⇒ Object
222 223 224 225 |
# File 'lib/shoes/videoffi.rb', line 222 def upraise() Shoes.show_log raise end |
#video(path, attr = nil) ⇒ Object
514 515 516 517 518 519 520 521 |
# File 'lib/shoes/videoffi.rb', line 514 def video(path, attr=nil) if path.nil? || (not path.kind_of? String) upraise "You must, at least, provide an empty path as first agument ! :\n "\ "video(\"\", optional_attriutes) or audio(\"\", optional_attriutes)\n" end # self is the calling app Shoes::VideoVlc.new(self, path, attr) end |
#window(*a, &b) ⇒ Object
438 439 440 |
# File 'lib/package/min-shoes.rb', line 438 def window(*a, &b) Shoes.app(*a, &b) end |