Created
November 13, 2011 22:57
-
-
Save lcapaldo/1362872 to your computer and use it in GitHub Desktop.
My second shoe for two shoes weekend 2: the shoesening
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shoes.app do | |
@log = [] | |
@entries = stack do | |
@entry = edit_line | |
flow do | |
button("Add text") { | |
@log << "TXT #{@entry.text}" | |
@entries.append { title @entry.text } | |
} | |
button("Add image") { | |
@log << "IMG #{@entry.text}" | |
@entries.append { image @entry.text } | |
} | |
button("Save") { | |
File.open("blog.txt", "w") do |f| | |
@log.each { |l| f.puts(l) } | |
end | |
} | |
end | |
filecontents = File.read('blog.txt') rescue nil | |
if filecontents | |
filecontents.each_line do |l| | |
l.chomp! | |
@log << l | |
if l =~ /^TXT (.*)/ | |
title $1 | |
elsif l =~ /^IMG (.*)/ | |
image $1 | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment