# HG changeset patch # User Daniel Poelzleithner # Date 1286649263 -7200 # Node ID 49b0da970463a6a95a58104f6691401495f94457 # Parent 89c4f22394428ab6a995cc1c4c0d20a91b272c02 started sitemap.xml for better search engine index diff -r 89c4f2239442 -r 49b0da970463 app/main/_filter/21_auth.lua --- a/app/main/_filter/21_auth.lua Sat Oct 09 15:16:49 2010 +0200 +++ b/app/main/_filter/21_auth.lua Sat Oct 09 20:34:23 2010 +0200 @@ -39,7 +39,7 @@ end -if config.api_enabled and request.get_module() == "api" then +if config.api_enabled and request.get_module() == "api" or request.get_module() == "sitemap" then auth_needed = false end diff -r 89c4f2239442 -r 49b0da970463 app/main/_filter_view/34_stylesheet.lua --- a/app/main/_filter_view/34_stylesheet.lua Sat Oct 09 15:16:49 2010 +0200 +++ b/app/main/_filter_view/34_stylesheet.lua Sat Oct 09 20:34:23 2010 +0200 @@ -41,7 +41,7 @@ slot.set_layout("blank") end -if request.get_module() ~= "api" and request.get_view() ~= "list_rss" then +if request.get_module() ~= "api" and request.get_view() ~= "list_rss" and request.get_module() ~= "sitemap" then ui.container{ attr = { class = web20 and "web20" or "web10" diff -r 89c4f2239442 -r 49b0da970463 app/main/sitemap/show.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/sitemap/show.lua Sat Oct 09 20:34:23 2010 +0200 @@ -0,0 +1,80 @@ +slot.set_layout("xml", "text/xml") + +slot.put_into("default", '') + +function url(args) + return ui.tag{ + tag = "url", + content = function() + ui.tag{tag = "loc", + content = encode.url{ + base = request.get_absolute_baseurl(), + module = args.module, + view = args.view, + id = args.id + } + } + if args.lastmod then + ui.tag{tag = "lastmod", + content = args.lastmod + } + end + ui.tag{tag = "changefreq", + content = args.changefreq or "daily", + } + if args.priority then + ui.tag{tag = "priority", + content = tostring(args.priority) + } + end + + end + } +end + +function max(...) + trace.debug_table(arg) + nargs = {} + for i = 1,1,arg.n do + if type(arg[i]) == "number" then + nargs[#nargs] = arg[i] + end + end + if #nargs > 0 then + return math.max(unpack(nargs)) + end + return nil +end + + +areas = Area:new_selector():add_where("active='y'") + +for i,area in ipairs(areas:exec()) do + url{ module = "area", view = "show", id = area.id, priority = 0.9 } +end + +-- FIXME timezone should be added as ...HH24:MI:SS+TZ with NUMERIC like +09:00 + +issues = Issue:new_selector() +issues:add_field("to_char(GREATEST(issue.created, issue.accepted, issue.half_frozen, issue.fully_frozen, issue.closed, issue.cleaned), 'YYYY-MM-DD\"T\"HH24:MI:SS')", "lastmod") + +for i,issue in ipairs(issues:exec()) do + url{ module = "issue", view = "show", id = issue.id, priority = 0.8, + lastmod = tostring(issue.lastmod) + } +end + +initiatives = Initiative:new_selector() +initiatives:add_field("to_char(GREATEST(initiative.created, initiative.revoked, (select draft.created from draft where draft.initiative_id = initiative.id ORDER BY draft.created DESC LIMIT 1)), 'YYYY-MM-DD\"T\"HH24:MI:SS')", "lastmod") + +for i,initiative in ipairs(initiatives:exec()) do + url{ module = "initiative", view = "show", id = initiative.id, priority = 0.5, + lastmod = tostring(initiative.lastmod) + } +end + +--trace.render() + +slot.put_into("default", '') + +return \ No newline at end of file