liquid_feedback_frontend

annotate app/main/sitemap/show.xml.lua @ 1667:36fb14503a84

Polishing example config
author bsw
date Sun Feb 28 12:22:36 2021 +0100 (2021-02-28)
parents 7d231961a9d2
children
rev   line source
poelzi@164 1 slot.set_layout("xml", "text/xml")
poelzi@164 2
poelzi@164 3 slot.put_into("default", '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">')
poelzi@164 4
poelzi@164 5 function url(args)
poelzi@164 6 return ui.tag{
poelzi@164 7 tag = "url",
poelzi@164 8 content = function()
poelzi@164 9 ui.tag{tag = "loc",
poelzi@164 10 content = encode.url{
poelzi@164 11 base = request.get_absolute_baseurl(),
poelzi@164 12 module = args.module,
poelzi@164 13 view = args.view,
poelzi@164 14 id = args.id
poelzi@164 15 }
poelzi@164 16 }
poelzi@164 17 if args.lastmod then
poelzi@164 18 ui.tag{tag = "lastmod",
poelzi@164 19 content = args.lastmod
poelzi@164 20 }
poelzi@164 21 end
poelzi@164 22 ui.tag{tag = "changefreq",
poelzi@164 23 content = args.changefreq or "daily",
poelzi@164 24 }
poelzi@164 25 if args.priority then
poelzi@164 26 ui.tag{tag = "priority",
poelzi@164 27 content = tostring(args.priority)
poelzi@164 28 }
poelzi@164 29 end
poelzi@164 30
poelzi@164 31 end
poelzi@164 32 }
poelzi@164 33 end
poelzi@164 34
poelzi@164 35 function max(...)
poelzi@164 36 trace.debug_table(arg)
poelzi@164 37 nargs = {}
poelzi@164 38 for i = 1,1,arg.n do
poelzi@164 39 if type(arg[i]) == "number" then
poelzi@164 40 nargs[#nargs] = arg[i]
poelzi@164 41 end
poelzi@164 42 end
poelzi@164 43 if #nargs > 0 then
poelzi@164 44 return math.max(unpack(nargs))
poelzi@164 45 end
poelzi@164 46 return nil
poelzi@164 47 end
poelzi@164 48
poelzi@164 49
poelzi@164 50 areas = Area:new_selector():add_where("active='y'")
poelzi@164 51
poelzi@164 52 for i,area in ipairs(areas:exec()) do
poelzi@164 53 url{ module = "area", view = "show", id = area.id, priority = 0.9 }
poelzi@164 54 end
poelzi@164 55
poelzi@164 56 -- FIXME timezone should be added as ...HH24:MI:SS+TZ with NUMERIC like +09:00
poelzi@164 57
poelzi@164 58 issues = Issue:new_selector()
poelzi@164 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")
poelzi@164 60
poelzi@164 61 for i,issue in ipairs(issues:exec()) do
poelzi@164 62 url{ module = "issue", view = "show", id = issue.id, priority = 0.8,
poelzi@164 63 lastmod = tostring(issue.lastmod)
poelzi@164 64 }
poelzi@164 65 end
poelzi@164 66
poelzi@164 67 initiatives = Initiative:new_selector()
poelzi@164 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")
poelzi@164 69
poelzi@164 70 for i,initiative in ipairs(initiatives:exec()) do
poelzi@164 71 url{ module = "initiative", view = "show", id = initiative.id, priority = 0.5,
poelzi@164 72 lastmod = tostring(initiative.lastmod)
poelzi@164 73 }
poelzi@164 74 end
poelzi@164 75
poelzi@164 76 --trace.render()
poelzi@164 77
poelzi@164 78 slot.put_into("default", '</urlset>')
poelzi@164 79
poelzi@164 80 return

Impressum / About Us