liquid_feedback_frontend
changeset 164:49b0da970463
started sitemap.xml for better search engine index
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Sat Oct 09 20:34:23 2010 +0200 (2010-10-09) |
parents | 89c4f2239442 |
children | 6d30e49ad609 |
files | app/main/_filter/21_auth.lua app/main/_filter_view/34_stylesheet.lua app/main/sitemap/show.lua |
line diff
1.1 --- a/app/main/_filter/21_auth.lua Sat Oct 09 15:16:49 2010 +0200 1.2 +++ b/app/main/_filter/21_auth.lua Sat Oct 09 20:34:23 2010 +0200 1.3 @@ -39,7 +39,7 @@ 1.4 1.5 end 1.6 1.7 -if config.api_enabled and request.get_module() == "api" then 1.8 +if config.api_enabled and request.get_module() == "api" or request.get_module() == "sitemap" then 1.9 auth_needed = false 1.10 end 1.11
2.1 --- a/app/main/_filter_view/34_stylesheet.lua Sat Oct 09 15:16:49 2010 +0200 2.2 +++ b/app/main/_filter_view/34_stylesheet.lua Sat Oct 09 20:34:23 2010 +0200 2.3 @@ -41,7 +41,7 @@ 2.4 slot.set_layout("blank") 2.5 end 2.6 2.7 -if request.get_module() ~= "api" and request.get_view() ~= "list_rss" then 2.8 +if request.get_module() ~= "api" and request.get_view() ~= "list_rss" and request.get_module() ~= "sitemap" then 2.9 ui.container{ 2.10 attr = { 2.11 class = web20 and "web20" or "web10"
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/app/main/sitemap/show.lua Sat Oct 09 20:34:23 2010 +0200 3.3 @@ -0,0 +1,80 @@ 3.4 +slot.set_layout("xml", "text/xml") 3.5 + 3.6 +slot.put_into("default", '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">') 3.7 + 3.8 +function url(args) 3.9 + return ui.tag{ 3.10 + tag = "url", 3.11 + content = function() 3.12 + ui.tag{tag = "loc", 3.13 + content = encode.url{ 3.14 + base = request.get_absolute_baseurl(), 3.15 + module = args.module, 3.16 + view = args.view, 3.17 + id = args.id 3.18 + } 3.19 + } 3.20 + if args.lastmod then 3.21 + ui.tag{tag = "lastmod", 3.22 + content = args.lastmod 3.23 + } 3.24 + end 3.25 + ui.tag{tag = "changefreq", 3.26 + content = args.changefreq or "daily", 3.27 + } 3.28 + if args.priority then 3.29 + ui.tag{tag = "priority", 3.30 + content = tostring(args.priority) 3.31 + } 3.32 + end 3.33 + 3.34 + end 3.35 + } 3.36 +end 3.37 + 3.38 +function max(...) 3.39 + trace.debug_table(arg) 3.40 + nargs = {} 3.41 + for i = 1,1,arg.n do 3.42 + if type(arg[i]) == "number" then 3.43 + nargs[#nargs] = arg[i] 3.44 + end 3.45 + end 3.46 + if #nargs > 0 then 3.47 + return math.max(unpack(nargs)) 3.48 + end 3.49 + return nil 3.50 +end 3.51 + 3.52 + 3.53 +areas = Area:new_selector():add_where("active='y'") 3.54 + 3.55 +for i,area in ipairs(areas:exec()) do 3.56 + url{ module = "area", view = "show", id = area.id, priority = 0.9 } 3.57 +end 3.58 + 3.59 +-- FIXME timezone should be added as ...HH24:MI:SS+TZ with NUMERIC like +09:00 3.60 + 3.61 +issues = Issue:new_selector() 3.62 +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") 3.63 + 3.64 +for i,issue in ipairs(issues:exec()) do 3.65 + url{ module = "issue", view = "show", id = issue.id, priority = 0.8, 3.66 + lastmod = tostring(issue.lastmod) 3.67 + } 3.68 +end 3.69 + 3.70 +initiatives = Initiative:new_selector() 3.71 +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") 3.72 + 3.73 +for i,initiative in ipairs(initiatives:exec()) do 3.74 + url{ module = "initiative", view = "show", id = initiative.id, priority = 0.5, 3.75 + lastmod = tostring(initiative.lastmod) 3.76 + } 3.77 +end 3.78 + 3.79 +--trace.render() 3.80 + 3.81 +slot.put_into("default", '</urlset>') 3.82 + 3.83 +return 3.84 \ No newline at end of file