-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstream.rb
76 lines (70 loc) · 1.65 KB
/
stream.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
class Stream < Shoes
url '/', :index
url '/w/(\w+)', :entry
url '/all', :all
DROPS = Hash.new
def index
stack :margin => "5" do
title "Just start writing..."
para "Press enter to add to the stream"
@box = edit_line :width => "100%"
keypress do |k|
if k == "\n"
textlist = @box.text.split(' ')
key = textlist[0]
DROPS.store(key, textlist.drop(1))
visit "/w/#{key}"
end
end
para link("View all entries", :click => "/all")
end
end
def entry(str)
t = DROPS.fetch(str, [])
stack :margin => "5" do
title str
@box = edit_line :width => "100%"
keypress do |k|
if k == "\n"
textlist = @box.text.split(' ')
key = textlist[0]
DROPS.store(key, textlist.drop(1))
visit "/w/#{key}"
end
end
flow do
para strong "#{str} :: "
t.each do |w|
if DROPS.fetch(w, []) == []
para w
else
para link(w, :click => "/w/#{w}")
end
end
end
para link("View all entries", :click => "/all")
end
end
def all
stack :margin => "5" do
title "The whole stream:"
DROPS.each do |k, d|
flow :width => "100%" do
subtitle k
flow do
d.each do |w|
if DROPS.fetch(w, []) == []
para w
else
para link(w, :click => "/w/#{w}")
end
end
end
end
end
para link("return to main", :click => "/")
end
end
end
Stream
Shoes.app :title => "Stream"