liquid_feedback_frontend

annotate app/main/initiative/list_rss.lua @ 57:4f39f0a0d5b5

Listing of updated drafts on start page; Code cleanup; Minor bugfix

MOTD, initiator invite, issues to vote and listing of updated drafts shown as tabs on start page;
Bugfix: Initiator icon only shown when initiatorship has been accepted
author bsw
date Sat Apr 17 21:59:02 2010 +0200 (2010-04-17)
parents 88ac7798b562
children 733f65c0c0a0
rev   line source
bsw/jbe@52 1 if not config.feature_rss_enabled then
bsw/jbe@52 2 error("feature not enabled")
bsw/jbe@52 3 end
bsw/jbe@52 4
bsw/jbe@52 5 local area_id = param.get("area_id", atom.integer)
bsw/jbe@52 6 local issue_id = param.get("issue_id", atom.integer)
bsw/jbe@52 7 local order = param.get("order") or "last_created"
bsw/jbe@52 8
bsw/jbe@52 9 local initiatives_selector = Initiative:new_selector()
bsw/jbe@52 10
bsw/jbe@52 11 local issue
bsw/jbe@52 12 local area
bsw/jbe@52 13
bsw/jbe@52 14 if issue_id then
bsw/jbe@52 15 issue = Issue:by_id(issue_id)
bsw/jbe@52 16 initiatives_selector:add_where{ "initiative.issue_id = ?", issue_id }
bsw/jbe@52 17 elseif area_id then
bsw/jbe@52 18 area = Area:by_id(area_id)
bsw/jbe@52 19 initiatives_selector:join("issue", nil, "issue.id = initiative.issue_id")
bsw/jbe@52 20 initiatives_selector:add_where{ "issue.area_id = ?", area_id }
bsw/jbe@52 21 end
bsw/jbe@52 22
bsw/jbe@52 23
bsw/jbe@52 24 if order == "last_created" then
bsw/jbe@52 25 initiatives_selector:add_order_by("initiative.created DESC")
bsw/jbe@52 26 initiatives_selector:add_field("initiative.created", "created_or_updated")
bsw/jbe@52 27 elseif order == "last_updated" then
bsw/jbe@52 28 initiatives_selector:add_field("(SELECT MAX(created) FROM draft WHERE initiative_id = initiative.id GROUP BY initiative_id)", "created_or_updated")
bsw/jbe@52 29 initiatives_selector:add_order_by("(SELECT MAX(created) FROM draft WHERE initiative_id = initiative.id GROUP BY initiative_id) DESC")
bsw/jbe@52 30 else
bsw/jbe@52 31 error("Invalid order")
bsw/jbe@52 32 end
bsw/jbe@52 33
bsw/jbe@52 34 initiatives_selector:add_order_by("id DESC")
bsw/jbe@52 35
bsw/jbe@52 36 initiatives_selector:limit(25)
bsw/jbe@52 37
bsw/jbe@52 38 local initiatives = initiatives_selector:exec()
bsw/jbe@52 39
bsw/jbe@19 40 slot.set_layout("atom")
bsw/jbe@19 41 request.force_absolute_baseurl()
bsw/jbe@19 42
bsw/jbe@52 43 ui.tag{
bsw/jbe@52 44 tag = "author",
bsw/jbe@52 45 content = function()
bsw/jbe@52 46 ui.tag{
bsw/jbe@52 47 tag = "name",
bsw/jbe@52 48 content = "LiquidFeedback"
bsw/jbe@52 49 }
bsw/jbe@52 50 end
bsw/jbe@52 51 }
bsw/jbe@52 52
bsw/jbe@52 53 local title
bsw/jbe@52 54
bsw/jbe@52 55 if issue then
bsw/jbe@52 56 title = "#" .. tostring(issue.id) .. " " .. issue.area.name
bsw/jbe@52 57 elseif area then
bsw/jbe@52 58 title = area.name
bsw/jbe@52 59 else
bsw/jbe@52 60 title = config.app_title
bsw/jbe@52 61 end
bsw/jbe@52 62
bsw/jbe@52 63 ui.tag{
bsw/jbe@52 64 tag = "title",
bsw/jbe@52 65 content = title
bsw/jbe@52 66 }
bsw/jbe@52 67
bsw/jbe@52 68 local subtitle
bsw/jbe@52 69 if order == "last_created" then
bsw/jbe@52 70 subtitle = "Initiatives (last created first)"
bsw/jbe@52 71 elseif order == "last_updated" then
bsw/jbe@52 72 subtitle = "Initiatives (last updated first)"
bsw/jbe@52 73 end
bsw/jbe@52 74
bsw/jbe@52 75 ui.tag{
bsw/jbe@52 76 tag = "subtitle",
bsw/jbe@52 77 content = subtitle
bsw/jbe@52 78 }
bsw/jbe@52 79
bsw/jbe@52 80 ui.tag{
bsw/jbe@52 81 tag = "id",
bsw/jbe@52 82 content = "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6"
bsw/jbe@52 83 }
bsw/jbe@52 84
bsw/jbe@52 85 ui.tag{
bsw/jbe@52 86 tag = "updated",
bsw/jbe@52 87 content = "2003-12-14T10:20:09Z"
bsw/jbe@52 88 }
bsw/jbe@19 89
bsw/jbe@19 90 for i, initiative in ipairs(initiatives) do
bsw/jbe@19 91 ui.tag{
bsw/jbe@19 92 tag = "entry",
bsw/jbe@19 93 content = function()
bsw/jbe@52 94 slot.put("\n")
bsw/jbe@52 95 ui.tag{ tag = "category", attr = { term = encode.html(initiative.issue.area.name) } }
bsw/jbe@52 96 slot.put("\n")
bsw/jbe@52 97 ui.tag{ tag = "author", content = encode.html(initiative.current_draft.author.name) }
bsw/jbe@52 98 slot.put("\n")
bsw/jbe@52 99 ui.tag{ tag = "title", content = encode.html(initiative.shortened_name) }
bsw/jbe@52 100 slot.put("\n")
bsw/jbe@19 101 ui.tag{ tag = "link", attr = {
bsw/jbe@19 102 href = encode.url{
bsw/jbe@19 103 module = "initiative",
bsw/jbe@19 104 view = "show",
bsw/jbe@19 105 id = initiative.id
bsw/jbe@19 106 }
bsw/jbe@19 107 } }
bsw/jbe@52 108 slot.put("\n")
bsw/jbe@52 109 ui.tag{ tag = "id", content = "initiative_" .. tostring(initiative.id) }
bsw/jbe@52 110 slot.put("\n")
bsw/jbe@52 111 ui.tag{ tag = "updated", content = tostring(initiative.created_or_updated) }
bsw/jbe@52 112 slot.put("\n")
bsw/jbe@52 113 ui.tag{ tag = "content", content = encode.html(initiative.current_draft.content or "") }
bsw/jbe@52 114 slot.put("\n")
bsw/jbe@19 115 end
bsw/jbe@19 116 }
bsw/jbe@52 117 slot.put("\n")
bsw/jbe@52 118 end

Impressum / About Us