-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.html.erb
179 lines (165 loc) · 5.01 KB
/
web.html.erb
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<%
require 'yaml'
require 'active_support/all'
require 'redcarpet'
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
pledges = YAML.load_file('pledges.yml').sort_by { |x| x['date'] }
contracts = Dir['contracts/*.yml'].map { |f| YAML.load_file(f) }
DURATION_PARTS = {
years: 'yr',
months: 'mo',
days: 'dy',
hours: 'hr',
minutes: 'mn'
}
def render_time(time)
return "<time datetime=\"#{ time.strftime('%FT%T%:z') }\">#{ time.utc.strftime('%b %d %Y %H:%M') } UTC</time>"
end
%>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<style>
body {
max-width: 50em;
margin: auto;
}
.agreement {
border: 1px solid black;
margin-bottom: 5px;
padding: 5px;
}
.agreement :last-child {
margin-bottom: 0;
}
.pledge-by {
float: right;
}
.pledge-meta {
display: flex;
justify-content: space-between;
}
h3 {
margin: 0;
}
</style>
</head>
<body>
<h1>Office of the Notary of Agora Nomic</h1>
<p><a href="report.txt">Text Report</a></p>
<p>Last updated <%= render_time(Time.now) %>.</p>
<p>
Display times in:
<label><input type="radio" id="time-utc" name="displayTimes" value="huey"> UTC</label>
<label><input type="radio" id="time-local" name="displayTimes" value="huey" checked> Your Local Time</label>
</p>
<div id="contracts">
<h2>Contracts</h2>
<p>
<% if contracts.length == 1 %>
There is one non-invisible contract.
<% else %>
There are <%= contracts.length %> non-invisible contracts.
<% end %>
</p>
<% contracts.each do |contract| %>
<div class='agreement contract'>
<h3><%= contract['title'] %></h3>
<div id='contract-parties'><%= contract['parties'].join(', ') %></div>
<%= markdown.render(contract['text'].strip) %>
<hr>
<% if contract['assets'] %>
<h4>Asset ownership (self-ratifying if I am the recordkeepor)</h4>
<%= markdown.render(contract['assets']) %>
<% end %>
<% if contract['notes'] %>
<h4>Notes</h4>
<%= markdown.render(contract['notes'] )%>
<% end %>
<% if contract['history'] %>
<h4>History</h4>
<% rev = 0 %>
<ul>
<% contract['history'].each do |event| %>
<%
if event['event'].include? '($)'
rev += 1
event['event'].gsub!('($)', "(#{rev})")
end
%>
<li>
<%= render_time(event['date']) %>:
<%= event['event'] %>
</li>
<% end %>
</ul>
<% end %>
</div>
<% end %>
</div>
<div id="pledges">
<h2>Pledges</h2>
<p>
<% if pledges.length == 1 %>
There is one non-invisible pledge.
<% else %>
There are <%= pledges.length %> non-invisible pledges.
<% end %>
<% pledges.each do |pledge|
window = pledge['window'] ? ActiveSupport::Duration.parse("P" + pledge['window']) : 60.days
window_str = window.parts.map { |type, value| "#{value}#{DURATION_PARTS[type]}" }.join(' ')
expire = pledge['date'].utc + window
if expire < Time.now
puts "pledges.yml contains expired pledge: #{pledge['title']}"
exit 1
end
%>
<div class="agreement pledge">
<h3>
<%= pledge['title'] %>
<span class="pledge-by"><%= pledge['by'] %></span>
</h3>
<div class="pledge-meta">
<span><strong>Made:</strong> <%= render_time(pledge['date']) %></span>
<span><strong>Window:</strong> <%= window_str %></span>
<span><strong>Expires:</strong> <%= render_time(pledge['date'].utc + window) %></span>
<span><strong>N:</strong> <%= pledge['n'] || 2 %></span>
</div>
<%= markdown.render(pledge['text'].strip) %>
</div>
<% end %>
</div>
<p>
The transitional period can end on or after April 27, 2020. At that
point, any invisible contracts or pledges (i.e. those not listed above)
will be destroyed.
</p>
<script>
let utc = false
function updateDates() {
const dates = document.querySelectorAll('time')
dates.forEach(el => {
el.textContent = new Date(el.dateTime).toLocaleString(undefined, {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
timeZoneName: "short",
timeZone: utc ? "UTC" : undefined
})
})
}
updateDates()
document.getElementById('time-local').onclick = () => {
utc = false
updateDates()
}
document.getElementById('time-utc').onclick = () => {
utc = true
updateDates()
}
</script>
</body>
</html>