File tree Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ module Awestruct
2+ module Extensions
3+ module DirectoryListing
4+
5+ def list_entries ( dir , pattern )
6+ table = Array . new
7+ Dir . glob ( File . join ( dir , pattern ) ) do |file_name |
8+ file_data = Array . new
9+ file_data . push File . basename ( file_name )
10+ file_data . push File . mtime ( file_name ) . asctime
11+ file_size = File . size ( file_name )
12+ if file_size > 1024
13+ file_size = "#{ file_size / 1024 } K"
14+ end
15+ file_data . push file_size
16+ table . push file_data
17+ end
18+ return table
19+ end
20+
21+ end
22+ end
23+ end
Original file line number Diff line number Diff line change 77require 'releases'
88require 'release_file_parser'
99require 'redirect_creator'
10+ require 'directory_listing'
1011
1112# dependencies for asciidoc support
1213require 'tilt'
3940 helper Awestruct ::Extensions ::GoogleAnalytics
4041 helper Awestruct ::Extensions ::Relative
4142 helper Awestruct ::Extensions ::Releases
43+ helper Awestruct ::Extensions ::DirectoryListing
4244
4345 # register extensions and transformers
4446 extension Awestruct ::Extensions ::ReleaseFileParser . new
Original file line number Diff line number Diff line change 1+ ---
2+ layout: project
3+ title: Directory listing /dtd
4+ ---
5+
6+ .content
7+ %h1 Index of /dtd
8+
9+ - @items = list_entries(File.dirname(__FILE__), '*.dtd')
10+
11+ %table {:style=>" border: 10px; width: 80%" }
12+ %tbody
13+ %tr
14+ %th{:align=>'left', :style=>" padding-bottom: 20px;" } Name
15+ %th{:align=>'left', :style=>" padding-bottom: 20px;" } Last modified
16+ %th{:align=>'right', :style=>" padding-bottom: 20px;" } Size
17+ - @items.each_with_index do |row, row_index|
18+ %tr
19+ - row.each_with_index do |column, column_index|
20+ -if column_index == 0
21+ %td
22+ %a(title=column href=" ./#{ column } " ) #{column}
23+ -else
24+ -if column_index < 2
25+ %td= " #{ column } "
26+ -else
27+ %td{:align=>'right'}= " #{ column } "
You can’t perform that action at this time.
0 commit comments