bsw/jbe@52: if not config.feature_rss_enabled then bsw/jbe@52: error("feature not enabled") bsw/jbe@52: end bsw/jbe@52: bsw/jbe@52: local area_id = param.get("area_id", atom.integer) bsw/jbe@52: local issue_id = param.get("issue_id", atom.integer) bsw/jbe@52: local order = param.get("order") or "last_created" bsw/jbe@52: bsw/jbe@52: local initiatives_selector = Initiative:new_selector() bsw/jbe@52: bsw/jbe@52: local issue bsw/jbe@52: local area bsw/jbe@52: bsw/jbe@52: if issue_id then bsw/jbe@52: issue = Issue:by_id(issue_id) bsw/jbe@52: initiatives_selector:add_where{ "initiative.issue_id = ?", issue_id } bsw/jbe@52: elseif area_id then bsw/jbe@52: area = Area:by_id(area_id) bsw/jbe@52: initiatives_selector:join("issue", nil, "issue.id = initiative.issue_id") bsw/jbe@52: initiatives_selector:add_where{ "issue.area_id = ?", area_id } bsw/jbe@52: end bsw/jbe@52: bsw/jbe@52: bsw/jbe@52: if order == "last_created" then bsw/jbe@52: initiatives_selector:add_order_by("initiative.created DESC") bsw/jbe@52: initiatives_selector:add_field("initiative.created", "created_or_updated") bsw/jbe@52: elseif order == "last_updated" then bsw/jbe@52: initiatives_selector:add_field("(SELECT MAX(created) FROM draft WHERE initiative_id = initiative.id GROUP BY initiative_id)", "created_or_updated") bsw/jbe@52: initiatives_selector:add_order_by("(SELECT MAX(created) FROM draft WHERE initiative_id = initiative.id GROUP BY initiative_id) DESC") bsw/jbe@52: else bsw/jbe@52: error("Invalid order") bsw/jbe@52: end bsw/jbe@52: bsw/jbe@52: initiatives_selector:add_order_by("id DESC") bsw/jbe@52: bsw/jbe@52: initiatives_selector:limit(25) bsw/jbe@52: bsw/jbe@52: local initiatives = initiatives_selector:exec() bsw/jbe@52: bsw/jbe@19: slot.set_layout("atom") bsw/jbe@19: request.force_absolute_baseurl() bsw/jbe@19: bsw/jbe@52: ui.tag{ bsw/jbe@52: tag = "author", bsw/jbe@52: content = function() bsw/jbe@52: ui.tag{ bsw/jbe@52: tag = "name", bsw/jbe@52: content = "LiquidFeedback" bsw/jbe@52: } bsw/jbe@52: end bsw/jbe@52: } bsw/jbe@52: bsw/jbe@52: local title bsw/jbe@52: bsw/jbe@52: if issue then bsw/jbe@52: title = "#" .. tostring(issue.id) .. " " .. issue.area.name bsw/jbe@52: elseif area then bsw/jbe@52: title = area.name bsw/jbe@52: else bsw/jbe@52: title = config.app_title bsw/jbe@52: end bsw/jbe@52: bsw/jbe@52: ui.tag{ bsw/jbe@52: tag = "title", bsw/jbe@52: content = title bsw/jbe@52: } bsw/jbe@52: bsw/jbe@52: local subtitle bsw/jbe@52: if order == "last_created" then bsw/jbe@52: subtitle = "Initiatives (last created first)" bsw/jbe@52: elseif order == "last_updated" then bsw/jbe@52: subtitle = "Initiatives (last updated first)" bsw/jbe@52: end bsw/jbe@52: bsw/jbe@52: ui.tag{ bsw/jbe@52: tag = "subtitle", bsw/jbe@52: content = subtitle bsw/jbe@52: } bsw/jbe@52: bsw/jbe@52: ui.tag{ bsw/jbe@52: tag = "id", bsw@75: -- content = "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6" bsw/jbe@52: } bsw/jbe@52: bsw@75: --[[ bsw/jbe@52: ui.tag{ bsw/jbe@52: tag = "updated", bsw/jbe@52: content = "2003-12-14T10:20:09Z" bsw/jbe@52: } bsw@75: --]] bsw/jbe@19: bsw/jbe@19: for i, initiative in ipairs(initiatives) do bsw/jbe@19: ui.tag{ bsw/jbe@19: tag = "entry", bsw/jbe@19: content = function() bsw/jbe@52: slot.put("\n") bsw/jbe@52: ui.tag{ tag = "category", attr = { term = encode.html(initiative.issue.area.name) } } bsw/jbe@52: slot.put("\n") bsw/jbe@52: ui.tag{ tag = "author", content = encode.html(initiative.current_draft.author.name) } bsw/jbe@52: slot.put("\n") bsw/jbe@52: ui.tag{ tag = "title", content = encode.html(initiative.shortened_name) } bsw/jbe@52: slot.put("\n") bsw/jbe@19: ui.tag{ tag = "link", attr = { bsw/jbe@19: href = encode.url{ bsw/jbe@19: module = "initiative", bsw/jbe@19: view = "show", bsw/jbe@19: id = initiative.id bsw/jbe@19: } bsw/jbe@19: } } bsw/jbe@52: slot.put("\n") bsw/jbe@52: ui.tag{ tag = "id", content = "initiative_" .. tostring(initiative.id) } bsw/jbe@52: slot.put("\n") bsw/jbe@52: ui.tag{ tag = "updated", content = tostring(initiative.created_or_updated) } bsw/jbe@52: slot.put("\n") bsw/jbe@52: ui.tag{ tag = "content", content = encode.html(initiative.current_draft.content or "") } bsw/jbe@52: slot.put("\n") bsw/jbe@19: end bsw/jbe@19: } bsw/jbe@52: slot.put("\n") bsw/jbe@52: end