applications: add freifunk widgets app to customize the index page
[project/luci.git] / applications / luci-freifunk-widgets / luasrc / controller / freifunk / widgets.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2012 Manuel Munz <freifunk at somakoma de>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 ]]--
13 local require = require
14 module "luci.controller.freifunk.widgets"
15
16
17 function index()
18
19 local page = node("admin", "freifunk", "widgets")
20 page.target = cbi("freifunk/widgets/widgets_overview")
21 page.title = _("Widgets")
22 page.i18n = "widgets"
23 page.order = 30
24
25 local page = node("admin", "freifunk", "widgets", "widget")
26 page.target = cbi("freifunk/widgets/widget")
27 page.leaf = true
28
29 local page = node("freifunk", "search_redirect")
30 page.target = call("search_redirect")
31 page.leaf = true
32 end
33
34 function search_redirect()
35 local dsp = require "luci.dispatcher"
36 local http = require "luci.http"
37 local engine = http.formvalue("engine")
38 local searchterms = http.formvalue("searchterms") or ""
39 if engine then
40 http.redirect(engine .. searchterms)
41 else
42 http.redirect(dsp.build_url())
43 end
44 end