2
# Copyright (c) 2006 http://d.bulkitem.com/
3
# Distributed under the GPL
11
Dir.glob(@conf.data_path + '/????/*.td2') { |data_file|
12
File.open(data_file) { |buffer|
16
if header['visible'] then
17
headers.push(header.clone)
21
if %r|^Date: ([0-9]+)$|i =~ line then
22
header['loc'] = sprintf(@conf['google_sitemaps.uri_format'], $1)
24
if %r|^Last-Modified: ([0-9]+)$|i =~ line then
25
header['lastmod'] = Time.at($1.to_i).iso8601
27
if %r|^Visible: (.+)$|i =~ line then
28
if $1.upcase == "TRUE" then
29
header['visible'] = true
31
header['visible'] = false
38
headers.sort! { |a, b| b['loc'] <=> a['loc']}
40
top_page_uri = File::dirname(@conf['google_sitemaps.uri_format']) + '/'
41
now_datetime = Time.now.iso8601
43
File.open(@conf['google_sitemaps.output_file'], 'w') do |fp|
44
fp.write %Q[<?xml version="1.0" encoding="UTF-8"?>\n]
45
fp.write %Q[<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">\n]
46
fp.write %Q[ <url><loc>#{CGI::escapeHTML(top_page_uri)}</loc><lastmod>#{now_datetime}</lastmod></url>\n]
47
headers.each { |entry|
48
fp.write %Q[ <url><loc>#{CGI::escapeHTML(entry['loc'])}</loc><lastmod>#{entry['lastmod']}</lastmod></url>\n]
50
fp.write %Q[</urlset>\n]
54
def saveconf_google_sitemaps
55
if @mode == 'saveconf' then
56
@conf['google_sitemaps.uri_format'] = @cgi.params['google_sitemaps.uri_format'][0]
57
@conf['google_sitemaps.output_file'] = @cgi.params['google_sitemaps.output_file'][0]