-
Notifications
You must be signed in to change notification settings - Fork 0
/
directory_index.erb
63 lines (60 loc) · 1.41 KB
/
directory_index.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
<%
require 'pathname'
require 'cgi'
include ERB::Util
cur_dir = Pathname.new(File.expand_path(Dir.pwd)).cleanpath.to_s
script_dir = Pathname.new(File.expand_path(__dir__)).cleanpath.to_s
a_c = cur_dir.split(File::Separator)
a_s = script_dir.split(File::Separator)
a_r = a_c.slice((a_s.size)..(-1))
dir = a_r.join('/')
case a_r[0]
when 'archive', 'contrib'
# nothing to do
else
raise "unknown target directory: #{dir}"
end
%><html>
<head>
<title>bioruby.org/<%= dir %></title>
<style type="text/css">
<!--
td { padding-right: 1em; padding-left: 1em; }
-->
</style>
</head>
<body>
<table>
<%
child_dirs = [ ".." ]
files = []
Dir.glob('*').sort.each do |fn|
if File.directory?(fn) then
child_dirs.push fn
elsif File.file?(fn) then
case fn
when 'index.html',
'index.html.erb',
'Rakefile',
/\~/, /\s/, /\A[^a-zA-Z0-9]/
# files which should be excluded
# do nothing
else
files.push fn
end
end
end
%>
<tr><th>filename</th><th>sha256sum</th></tr>
<% child_dirs.each do |fn|
%><tr><td><a href="<%= h(fn) %>/"><%= h(fn) %>/</td><td><br></td></tr>
<% end %>
<% files.each do |fn|
line = `sha256sum #{fn}`
a = line.chomp.split(/\s+/, 2)
sha256 = a[0].to_s
%><tr><td><a href="<%= h(fn) %>"><%= h(fn) %></td><td><%= h(sha256) %></td></tr>
<% end %>
</table>
</body>
</html>