liquid_feedback_frontend
view app/main/index/index.lua @ 20:0a23f39b3e21
Esperanto translation strings added
| author | Dinu Gherman | 
|---|---|
| date | Sat Feb 20 22:14:38 2010 +0100 (2010-02-20) | 
| parents | 00d1004545f1 | 
| children | 53a45356c107 | 
 line source
     1 slot.select("title", function()
     2   if app.session.member then
     3     execute.view{
     4       module = "member_image",
     5       view = "_show",
     6       params = {
     7         member = app.session.member,
     8         image_type = "avatar"
     9       }
    10     }
    11   end
    12 end)
    14 slot.select("title", function()
    15   ui.container{
    16     attr = { class = "lang_chooser" },
    17     content = function()
    18       for i, lang in ipairs{"en", "de", "eo"} do
    19         ui.link{
    20           content = function()
    21             ui.image{
    22               static = "lang/" .. lang .. ".png",
    23               attr = { style = "margin-left: 0.5em;", alt = lang }
    24             }
    25           end,
    26           text = _('Select language "#{langcode}"', { langcode = lang }),
    27           module = "index",
    28           action = "set_lang",
    29           params = { lang = lang },
    30           routing = {
    31             default = {
    32               mode = "redirect",
    33               module = request.get_module(),
    34               view = request.get_view(),
    35               id = param.get_id_cgi(),
    36               params = param.get_all_cgi()
    37             }
    38           }
    39         }
    40       end
    41     end
    42   }
    43 end)
    45 slot.put_into("title", encode.html(config.app_title))
    47 slot.select("actions", function()
    49   if app.session.member then
    50     ui.link{
    51       content = function()
    52           ui.image{ static = "icons/16/application_form.png" }
    53           slot.put(_"Edit my profile")
    54       end,
    55       module = "member",
    56       view = "edit"
    57     }
    59     ui.link{
    60       content = function()
    61           ui.image{ static = "icons/16/user_gray.png" }
    62           slot.put(_"Upload images")
    63       end,
    64       module = "member",
    65       view = "edit_images"
    66     }
    68     execute.view{
    69       module = "delegation",
    70       view = "_show_box"
    71     }
    73     ui.link{
    74       content = function()
    75           ui.image{ static = "icons/16/wrench.png" }
    76           slot.put(_"Settings")
    77       end,
    78       module = "member",
    79       view = "settings"
    80     }
    82     if config.download_dir then
    83       ui.link{
    84         content = function()
    85             ui.image{ static = "icons/16/database_save.png" }
    86             slot.put(_"Download")
    87         end,
    88         module = "index",
    89         view = "download"
    90       }
    91     end 
    92   end
    93 end)
    95 local lang = locale.get("lang")
    96 local basepath = request.get_app_basepath() 
    97 local file_name = basepath .. "/locale/motd/" .. lang .. ".txt"
    98 local file = io.open(file_name)
    99 if file ~= nil then
   100   local help_text = file:read("*a")
   101   if #help_text > 0 then
   102     ui.container{
   103       attr = { class = "motd wiki" },
   104       content = function()
   105         slot.put(format.wiki_text(help_text))
   106       end
   107     }
   108   end
   109 end
   112 util.help("index.index", _"Home")
   114 local areas = {}
   115 if app.session.member then
   116   local selector = Area:new_selector()
   117     :reset_fields()
   118     :add_field("area.id", nil, { "grouped" })
   119     :add_field("area.name", nil, { "grouped" })
   120     :add_field("membership.member_id NOTNULL", "is_member", { "grouped" })
   121     :add_field("count(issue.id)", "issues_to_vote_count")
   122     :add_field("count(interest.member_id)", "interested_issues_to_vote_count")
   123     :join("issue", nil, "issue.area_id = area.id AND issue.fully_frozen NOTNULL AND issue.closed ISNULL")
   124     :left_join("direct_voter", nil, { "direct_voter.issue_id = issue.id AND direct_voter.member_id = ?", app.session.member.id })
   125     :add_where{ "direct_voter.member_id ISNULL" }
   126     :left_join("interest", nil, { "interest.issue_id = issue.id AND interest.member_id = ?", app.session.member.id })
   127     :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ? ", app.session.member.id })
   129   for i, area in ipairs(selector:exec()) do
   130     if area.is_member or area.interested_issues_to_vote_count > 0 then
   131       areas[#areas+1] = area
   132     end
   133   end
   134 end
   136 if #areas > 0 then
   137   ui.container{
   138     attr = { style = "font-weight: bold;" },
   139     content = _"Current votings in areas you are member of and issues you are interested in:"
   140   }
   142   ui.list{
   143     records = areas,
   144     columns = {
   145       {
   146         name = "name"
   147       },
   148       {
   149         content = function(record)
   150           if record.is_member and record.issues_to_vote_count > 0 then
   151             ui.link{
   152               content = function()
   153                 if record.issues_to_vote_count > 1 then
   154                   slot.put(_("#{issues_to_vote_count} issue(s)", { issues_to_vote_count = record.issues_to_vote_count }))
   155                 else
   156                   slot.put(_("One issue"))
   157                 end
   158               end,
   159               module = "area",
   160               view = "show",
   161               id = record.id,
   162               params = { 
   163                 filter = "frozen",
   164                 filter_voting = "not_voted"
   165               }
   166             }
   167           else
   168             slot.put(_"Not a member")
   169           end
   170         end
   171       },
   172       {
   173         content = function(record)
   174           if record.interested_issues_to_vote_count > 0 then
   175             ui.link{
   176               content = function()
   177                 if record.interested_issues_to_vote_count > 1 then
   178                   slot.put(_("#{interested_issues_to_vote_count} issue(s) you are interested in", { interested_issues_to_vote_count = record.interested_issues_to_vote_count }))
   179                 else
   180                   slot.put(_"One issue you are interested in")
   181                 end
   182               end,
   183               module = "area",
   184               view = "show",
   185               id = record.id,
   186               params = { 
   187                 filter = "frozen",
   188                 filter_interest = "my",
   189                 filter_voting = "not_voted"
   190               }
   191             }
   192           end
   193         end
   194       },
   195     }
   196   }
   197 end
   199 local initiatives_selector = Initiative:new_selector()
   200   :join("initiator", nil, { "initiator.initiative_id = initiative.id AND initiator.member_id = ? AND initiator.accepted ISNULL", app.session.member.id })
   202 if initiatives_selector:count() > 0 then
   203   ui.container{
   204     attr = { style = "font-weight: bold;" },
   205     content = _"Initiatives that invited you to become initiator:"
   206   }
   208   execute.view{
   209     module = "initiative",
   210     view = "_list",
   211     params = { initiatives_selector = initiatives_selector }
   212   }
   213 end
   216 if app.session.member then
   217   execute.view{
   218     module = "member",
   219     view = "_show",
   220     params = { member = app.session.member }
   221   }
   222 end
