liquid_feedback_frontend
view app/main/sitemap/show.xml.lua @ 172:165f4bd02cf3
don't show the first draft of a new initiative as a new draft event in the timeline
new draft should only show changes of drafts drafts of new initiatives as they are handled by the new initiative event
new draft should only show changes of drafts drafts of new initiatives as they are handled by the new initiative event
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Sun Oct 10 19:40:32 2010 +0200 (2010-10-10) |
parents | 7d231961a9d2 |
children |
line source
1 slot.set_layout("xml", "text/xml")
3 slot.put_into("default", '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">')
5 function url(args)
6 return ui.tag{
7 tag = "url",
8 content = function()
9 ui.tag{tag = "loc",
10 content = encode.url{
11 base = request.get_absolute_baseurl(),
12 module = args.module,
13 view = args.view,
14 id = args.id
15 }
16 }
17 if args.lastmod then
18 ui.tag{tag = "lastmod",
19 content = args.lastmod
20 }
21 end
22 ui.tag{tag = "changefreq",
23 content = args.changefreq or "daily",
24 }
25 if args.priority then
26 ui.tag{tag = "priority",
27 content = tostring(args.priority)
28 }
29 end
31 end
32 }
33 end
35 function max(...)
36 trace.debug_table(arg)
37 nargs = {}
38 for i = 1,1,arg.n do
39 if type(arg[i]) == "number" then
40 nargs[#nargs] = arg[i]
41 end
42 end
43 if #nargs > 0 then
44 return math.max(unpack(nargs))
45 end
46 return nil
47 end
50 areas = Area:new_selector():add_where("active='y'")
52 for i,area in ipairs(areas:exec()) do
53 url{ module = "area", view = "show", id = area.id, priority = 0.9 }
54 end
56 -- FIXME timezone should be added as ...HH24:MI:SS+TZ with NUMERIC like +09:00
58 issues = Issue:new_selector()
59 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")
61 for i,issue in ipairs(issues:exec()) do
62 url{ module = "issue", view = "show", id = issue.id, priority = 0.8,
63 lastmod = tostring(issue.lastmod)
64 }
65 end
67 initiatives = Initiative:new_selector()
68 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")
70 for i,initiative in ipairs(initiatives:exec()) do
71 url{ module = "initiative", view = "show", id = initiative.id, priority = 0.5,
72 lastmod = tostring(initiative.lastmod)
73 }
74 end
76 --trace.render()
78 slot.put_into("default", '</urlset>')
80 return