Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
57 lines (40 sloc) 1.4 KB

Shoes Tutorial Note Launcher

Markdown + BlueCloth + Shoes = AWESOME!

Markdown
http://daringfireball.net/projects/markdown/

BlueCloth
http://www.deveiate.org/projects/BlueCloth

# sample44.rb
Shoes.setup do
  gem 'BlueCloth'
end

require 'BlueCloth'
BROWSER = 'C:/Program Files/Mozilla Firefox/firefox.exe'
PROTOCOL = 'file:///'
mfolder = File.dirname(Dir.pwd) + '/mdowns'
hfolder = File.dirname(Dir.pwd) + '/html'

Shoes.app :width => 450, :height => 130, :title => 'Shoes Tutorial Note Launcher' do
  background dimgray..gainsboro, :angle => 90
  @slot = stack{}
  
  Dir.entries(mfolder).each do |mname|
    @slot.append do
      hname = mname.sub(/\.mdown/, '.html')
      mfile = mfolder + '/' + mname
      hfile = hfolder + '/' + hname
      para link(strong(hname), :stroke => white){
        b = BlueCloth.new IO.read(mfile)
        open(hfile, 'w'){|f| f.puts b.to_html}
        system BROWSER, PROTOCOL + hfile
      } if /\.mdown$/ =~ mname
    end
  end
end

Note:
BlueCloth has a bug. It may delete \ in the code falsely. :(
So, please use sample44.rb under src directory instead of above code.

sample44.png

sample44.png

Policeman

The sample44.rb doesn't work with Shoes-0.r1263. Because Shoes.setup doesn't work so far.