liquid_feedback_frontend
view 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
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 |
line source
1 if not config.feature_rss_enabled then
2 error("feature not enabled")
3 end
5 local area_id = param.get("area_id", atom.integer)
6 local issue_id = param.get("issue_id", atom.integer)
7 local order = param.get("order") or "last_created"
9 local initiatives_selector = Initiative:new_selector()
11 local issue
12 local area
14 if issue_id then
15 issue = Issue:by_id(issue_id)
16 initiatives_selector:add_where{ "initiative.issue_id = ?", issue_id }
17 elseif area_id then
18 area = Area:by_id(area_id)
19 initiatives_selector:join("issue", nil, "issue.id = initiative.issue_id")
20 initiatives_selector:add_where{ "issue.area_id = ?", area_id }
21 end
24 if order == "last_created" then
25 initiatives_selector:add_order_by("initiative.created DESC")
26 initiatives_selector:add_field("initiative.created", "created_or_updated")
27 elseif order == "last_updated" then
28 initiatives_selector:add_field("(SELECT MAX(created) FROM draft WHERE initiative_id = initiative.id GROUP BY initiative_id)", "created_or_updated")
29 initiatives_selector:add_order_by("(SELECT MAX(created) FROM draft WHERE initiative_id = initiative.id GROUP BY initiative_id) DESC")
30 else
31 error("Invalid order")
32 end
34 initiatives_selector:add_order_by("id DESC")
36 initiatives_selector:limit(25)
38 local initiatives = initiatives_selector:exec()
40 slot.set_layout("atom")
41 request.force_absolute_baseurl()
43 ui.tag{
44 tag = "author",
45 content = function()
46 ui.tag{
47 tag = "name",
48 content = "LiquidFeedback"
49 }
50 end
51 }
53 local title
55 if issue then
56 title = "#" .. tostring(issue.id) .. " " .. issue.area.name
57 elseif area then
58 title = area.name
59 else
60 title = config.app_title
61 end
63 ui.tag{
64 tag = "title",
65 content = title
66 }
68 local subtitle
69 if order == "last_created" then
70 subtitle = "Initiatives (last created first)"
71 elseif order == "last_updated" then
72 subtitle = "Initiatives (last updated first)"
73 end
75 ui.tag{
76 tag = "subtitle",
77 content = subtitle
78 }
80 ui.tag{
81 tag = "id",
82 content = "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6"
83 }
85 ui.tag{
86 tag = "updated",
87 content = "2003-12-14T10:20:09Z"
88 }
90 for i, initiative in ipairs(initiatives) do
91 ui.tag{
92 tag = "entry",
93 content = function()
94 slot.put("\n")
95 ui.tag{ tag = "category", attr = { term = encode.html(initiative.issue.area.name) } }
96 slot.put("\n")
97 ui.tag{ tag = "author", content = encode.html(initiative.current_draft.author.name) }
98 slot.put("\n")
99 ui.tag{ tag = "title", content = encode.html(initiative.shortened_name) }
100 slot.put("\n")
101 ui.tag{ tag = "link", attr = {
102 href = encode.url{
103 module = "initiative",
104 view = "show",
105 id = initiative.id
106 }
107 } }
108 slot.put("\n")
109 ui.tag{ tag = "id", content = "initiative_" .. tostring(initiative.id) }
110 slot.put("\n")
111 ui.tag{ tag = "updated", content = tostring(initiative.created_or_updated) }
112 slot.put("\n")
113 ui.tag{ tag = "content", content = encode.html(initiative.current_draft.content or "") }
114 slot.put("\n")
115 end
116 }
117 slot.put("\n")
118 end