D
David B.
Hi everybody,
I have write a short script that display each article of a folder:
require 'find'
result = []
@pattern = '*.html'
Find.find('public/2008/') do |p|
next unless File.file?(p)
name = File.basename(p)
result << p if File.fnmatch(@pattern, name)
end
a = ''
result.length.times do |i|
content = File.read(result)
a += '<div class="article">'
a += content
a += '<address>' + File.ctime(result).to_s + '</address>'
a += '</div>'
end
a
As you can see, it display some articles in a webpage. However, but I
would like to order them by time (with File.ctime(result) for
instance) such as in blogs. If you see a sexy way to do so, that would
be very helpful for me.
Thanks,
Dendicus
I have write a short script that display each article of a folder:
require 'find'
result = []
@pattern = '*.html'
Find.find('public/2008/') do |p|
next unless File.file?(p)
name = File.basename(p)
result << p if File.fnmatch(@pattern, name)
end
a = ''
result.length.times do |i|
content = File.read(result)
a += '<div class="article">'
a += content
a += '<address>' + File.ctime(result).to_s + '</address>'
a += '</div>'
end
a
As you can see, it display some articles in a webpage. However, but I
would like to order them by time (with File.ctime(result) for
instance) such as in blogs. If you see a sexy way to do so, that would
be very helpful for me.
Thanks,
Dendicus