2 # Nick's web site: Generate directory listing.
4 # Copyright © 2021 Nick Bowler
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>
22 @items.find_all(@item[:pattern]).each do |item|
25 item.reps.each do |rep|
30 next unless "#{d}/" == mydir
33 sz = Dir.children(File.dirname(rep.raw_path)).length - 1
36 sz = human_filesize(File.size(rep.raw_path))
41 mtime: if t then t.getutc.strftime "%Y-%m-%d %H:%M UTC" end,
48 if @items["#{File.dirname(mydir)}/index.lst"]
49 files[".."] = { type: "UP" }
52 <table class='filelist'>
54 <tr><th /><th>Name</th><th>Last Modified</th><th>Size</th></tr>
57 <% files.keys.sort.each do |key| %>
60 <% if files[key][:type] %>
63 case files[key][:type]
64 when "DIR"; "/images/folder.svg"
65 when "UP"; "/images/return.svg"
66 else raise "no icon for filetype #{files[key][:type]}"
67 end %>' alt='<%= files[key][:type] %>' width='16' height='16' />
71 <td><a href='<%= key %>'><%=
72 if key == ".." then "[Parent Directory]" else key end
74 <td><%= files[key][:mtime] %></td>
75 <td><%= files[key][:size] %></td>