-
Notifications
You must be signed in to change notification settings - Fork 0
/
invoke.rb
138 lines (97 loc) · 3.35 KB
/
invoke.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
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
#!/bin/env ruby
# encoding: utf-8
$nataniev.require("corpse","http")
$nataniev.vessels[:hundredrabbits].path = File.expand_path(File.join(File.dirname(__FILE__), "/"))
$nataniev.vessels[:hundredrabbits].install(:custom,:serve,CorpseHttp.new)
corpse = $nataniev.vessels[:hundredrabbits].corpse
def corpse.build
@host = $nataniev.vessels[:hundredrabbits]
add_meta("description","A design studio on a sailboat")
add_meta("keywords","sailing, patreon, indie games, design, liveaboard")
add_meta("viewport","width=device-width, initial-scale=1, maximum-scale=1")
add_meta("apple-mobile-web-app-capable","yes")
add_link("reset.css",:lobby)
add_link("font.input_mono.css",:lobby)
add_link("font.alte_haas.css",:lobby)
add_link("style.main.css")
add_script("drool.js")
add_footer("<script>var logo = new Logo(false);logo.install(document.getElementById('logo'),120);</script>")
@title = "Hundred Rabbits"
end
def corpse.query q = nil
load_folder("#{@host.path}/objects/*")
@timeline = Memory_Hash.new("timeline",@host.path)
@events = @timeline.to_h("event")
end
def corpse.body
distance = 0
expenses = 0
@events.each do |date,event|
if event.type == "sail" then distance += event.value.to_f end
if event.type == "expense" then expenses += event.value.to_f end
end
html = ""
timeline_html = ""
count = 0
@events.sort_by{|k,to_i,v| k}.reverse.each do |date,event|
if event.type == "hidden" then next end
event.addClass( (count % 2 == 0) ? "odd" : "even" )
timeline_html += event.template
count += 1
end
timeline_html = " <c class='timeline'><center></center>#{timeline_html}</c>"
html += Google_Map.new(@events).to_s
html += "
<overlay>
<canvas id='logo' style='margin:10vh auto; display:block; width:300px; height:300px' width='600' height='600'></canvas>
<c class='menu'>
<a href='#map'>View Map</a>
<a href='https://hundredrabbits.itch.io' target='_blank'>Games</a>
<a href='https://www.youtube.com/channel/UCzdg4pZb-viC3EdA1zxRl4A' target='_blank'>Videos</a>
<a href='https://patreon.com/100' target='_blank'>Support Us</a>
</c>
<c class='status'>
<w>
<h2>Sailed #{distance.to_i}nm</h2>
<h2>Spent #{format_money(expenses.to_i * -1)}</h2>
<hr/>
</w>
</c>
#{timeline_html}
</overlay>"
return html
end
def corpse.format_money int
int = "#{int}"
return "#{int[0,int.length-3]}'#{int[-3,3]}$"
end
class Media
def path; return "#{$nataniev.path}/public/public.hundredrabbits/media" ; end
end
# Extras
class ActionGet_location
include Action
def act q = "Home"
load_folder("#{@host.path}/objects/*")
Memory_Hash.new("timeline",@host.path).to_h("event").each do |date,event|
if !event.type then next end
if !event.type.like("sail") then next end
return event.title
end
return "Unknown Location"
end
end
class ActionGet_position
include Action
def act q = "Home"
load_folder("#{@host.path}/objects/*")
Memory_Hash.new("timeline",@host.path).to_h("event").each do |date,event|
if !event.type then next end
if !event.type.like("sail") then next end
return event.geolocation.last
end
return "Unknown Location"
end
end
$nataniev.vessels[:hundredrabbits].install(:custom,:get_location)
$nataniev.vessels[:hundredrabbits].install(:custom,:get_position)