61 lines
1.8 KiB
Ruby
61 lines
1.8 KiB
Ruby
# This webgen plugin extends the available tags with tags that can retrieve
|
|
# stat(2) information.
|
|
#
|
|
# Copyright (2006) Paul van Tilburg <paulvt@debian.org>
|
|
|
|
# This plugin is free software; you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by the
|
|
# Free Software Foundation; either version 2 of the License, or (at your
|
|
# option) any later version.
|
|
|
|
class FileADateTag < Tags::DefaultTag
|
|
|
|
infos( :name => 'Custom/FileADate', :author => "Paul van Tilburg",
|
|
:summary => "Puts the access time and date of the file on the page" )
|
|
|
|
param 'format', '%A, %B %d %H:%M:%S %Z %Y',
|
|
'The format of the date (same options as Time#strftime).'
|
|
|
|
register_tag 'fileatime'
|
|
|
|
def process_tag(tag, chain)
|
|
atime = File.atime(chain.last.node_info[:src])
|
|
return atime.strftime(param('format'))
|
|
end
|
|
|
|
end # class FileADateTag
|
|
|
|
class FileCDateTag < Tags::DefaultTag
|
|
|
|
infos( :name => 'Custom/FileCDate', :author => "Paul van Tilburg",
|
|
:summary => "Puts the create time and date of the file on the page" )
|
|
|
|
param 'format', '%A, %B %d %H:%M:%S %Z %Y',
|
|
'The format of the date (same options as Time#strftime).'
|
|
|
|
register_tag 'filcatime'
|
|
|
|
def process_tag(tag, chain)
|
|
ctime = File.ctime(chain.last.node_info[:src])
|
|
return ctime.strftime(param('format'))
|
|
end
|
|
|
|
end # class FileCDateTag
|
|
|
|
class FileMDateTag < Tags::DefaultTag
|
|
|
|
infos( :name => 'Custom/FileMDate', :author => "Paul van Tilburg",
|
|
:summary => "Puts the modification time and date of the file on the page")
|
|
|
|
param 'format', '%A, %B %d %H:%M:%S %Z %Y',
|
|
'The format of the date (same options as Time#strftime).'
|
|
|
|
register_tag 'filemtime'
|
|
|
|
def process_tag(tag, chain)
|
|
mtime = File.mtime(chain.last.node_info[:src])
|
|
return mtime.strftime(param('format'))
|
|
end
|
|
|
|
end # class FileMDateTag
|