webmcp
diff demo-app/app/main/_filter_view/30_topnav.lua @ 0:9fdfb27f8e67
Version 1.0.0
author | jbe/bsw |
---|---|
date | Sun Oct 25 12:00:00 2009 +0100 (2009-10-25) |
parents | |
children | 2f8d8edd1836 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/demo-app/app/main/_filter_view/30_topnav.lua Sun Oct 25 12:00:00 2009 +0100 1.3 @@ -0,0 +1,83 @@ 1.4 +-- display navigation only, if user is logged in 1.5 +if app.session.user_id == nil then 1.6 + execute.inner() 1.7 + return 1.8 +end 1.9 + 1.10 +slot.select("topnav", function() 1.11 + ui.link{ 1.12 + attr = { class = "nav" }, 1.13 + text = _"Home", 1.14 + module = "index", 1.15 + view = "index" 1.16 + } 1.17 + ui.link{ 1.18 + attr = { class = "nav" }, 1.19 + text = _"Media", 1.20 + module = "medium" 1.21 + } 1.22 + ui.link{ 1.23 + attr = { class = "nav" }, 1.24 + text = _"Media types", 1.25 + module = "media_type" 1.26 + } 1.27 + ui.link{ 1.28 + attr = { class = "nav" }, 1.29 + text = _"Genres", 1.30 + module = "genre" 1.31 + } 1.32 + if app.session.user.admin then 1.33 + ui.link{ 1.34 + attr = { class = "nav" }, 1.35 + text = _"Users", 1.36 + module = "user" 1.37 + } 1.38 + end 1.39 + ui.container{ 1.40 + attr = { class = "nav lang_chooser" }, 1.41 + content = function() 1.42 + for i, lang in ipairs{"en", "de", "es"} do 1.43 + ui.container{ 1.44 + content = function() 1.45 + ui.link{ 1.46 + content = function() 1.47 + ui.image{ 1.48 + static = "lang/" .. lang .. ".png", 1.49 + attr = { alt = lang } 1.50 + } 1.51 + slot.put(lang) 1.52 + end, 1.53 + module = "index", 1.54 + action = "set_lang", 1.55 + params = { lang = lang }, 1.56 + routing = { 1.57 + default = { 1.58 + mode = "redirect", 1.59 + module = request.get_module(), 1.60 + view = request.get_view(), 1.61 + id = param.get_id_cgi(), 1.62 + params = param.get_all_cgi() 1.63 + } 1.64 + } 1.65 + } 1.66 + end 1.67 + } 1.68 + end 1.69 + end 1.70 + } 1.71 + 1.72 + ui.link{ 1.73 + attr = { class = "nav" }, 1.74 + text = _"Logout", 1.75 + module = "index", 1.76 + action = "logout", 1.77 + redirect_to = { 1.78 + ok = { 1.79 + module = "index", 1.80 + view = "login" 1.81 + } 1.82 + } 1.83 + } 1.84 +end) 1.85 + 1.86 +execute.inner()