summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-freifunk-widgets
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2014-12-03 15:17:05 +0100
committerJo-Philipp Wich <jow@openwrt.org>2015-01-08 16:26:20 +0100
commit1bb4822dca6113f73e3bc89e2acf15935e6f8e92 (patch)
tree35e16f100466e4e00657199b38bb3d87d52bf73f /applications/luci-app-freifunk-widgets
parent9edd0e46c3f880727738ce8ca6ff1c8b85f99ef4 (diff)
Rework LuCI build system
* Rename subdirectories to their repective OpenWrt package names * Make each LuCI module its own standalone package * Deploy a shared luci.mk which is used by each module Makefile Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'applications/luci-app-freifunk-widgets')
-rw-r--r--applications/luci-app-freifunk-widgets/Makefile14
-rw-r--r--applications/luci-app-freifunk-widgets/luasrc/controller/freifunk/widgets.lua44
-rw-r--r--applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/heightwidth.lua26
-rw-r--r--applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/html.lua41
-rw-r--r--applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/iframe.lua23
-rw-r--r--applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/rssfeed.lua35
-rw-r--r--applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/search.lua25
-rw-r--r--applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/widget.lua48
-rw-r--r--applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/widgets_overview.lua75
-rw-r--r--applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/clear/main.htm15
-rw-r--r--applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/html/main.htm42
-rw-r--r--applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/iframe/main.htm45
-rw-r--r--applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/rssfeed/main.htm84
-rw-r--r--applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/search/main.htm54
-rw-r--r--applications/luci-app-freifunk-widgets/root/etc/config/freifunk-widgets33
-rw-r--r--applications/luci-app-freifunk-widgets/root/lib/upgrade/keep.d/freifunk-widgets1
16 files changed, 605 insertions, 0 deletions
diff --git a/applications/luci-app-freifunk-widgets/Makefile b/applications/luci-app-freifunk-widgets/Makefile
new file mode 100644
index 0000000000..d748827ba3
--- /dev/null
+++ b/applications/luci-app-freifunk-widgets/Makefile
@@ -0,0 +1,14 @@
+#
+# Copyright (C) 2008-2014 The LuCI Team <luci@lists.subsignal.org>
+#
+# This is free software, licensed under the Apache License, Version 2.0 .
+#
+
+include $(TOPDIR)/rules.mk
+
+LUCI_TITLE:=Widgets for the Freifunk index page
+LUCI_DEPENDS:=+luci-mod-freifunk
+
+include ../../luci.mk
+
+# call BuildPackage - OpenWrt buildroot signature
diff --git a/applications/luci-app-freifunk-widgets/luasrc/controller/freifunk/widgets.lua b/applications/luci-app-freifunk-widgets/luasrc/controller/freifunk/widgets.lua
new file mode 100644
index 0000000000..5bbd53f57d
--- /dev/null
+++ b/applications/luci-app-freifunk-widgets/luasrc/controller/freifunk/widgets.lua
@@ -0,0 +1,44 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2012 Manuel Munz <freifunk at somakoma de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+]]--
+local require = require
+module "luci.controller.freifunk.widgets"
+
+
+function index()
+
+ local page = node("admin", "freifunk", "widgets")
+ page.target = cbi("freifunk/widgets/widgets_overview")
+ page.title = _("Widgets")
+ page.i18n = "widgets"
+ page.order = 30
+
+ local page = node("admin", "freifunk", "widgets", "widget")
+ page.target = cbi("freifunk/widgets/widget")
+ page.leaf = true
+
+ local page = node("freifunk", "search_redirect")
+ page.target = call("search_redirect")
+ page.leaf = true
+end
+
+function search_redirect()
+ local dsp = require "luci.dispatcher"
+ local http = require "luci.http"
+ local engine = http.formvalue("engine")
+ local searchterms = http.formvalue("searchterms") or ""
+ if engine then
+ http.redirect(engine .. searchterms)
+ else
+ http.redirect(dsp.build_url())
+ end
+end
diff --git a/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/heightwidth.lua b/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/heightwidth.lua
new file mode 100644
index 0000000000..b572187bdd
--- /dev/null
+++ b/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/heightwidth.lua
@@ -0,0 +1,26 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2012 Manuel Munz <freifunk at somakoma dot de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+]]--
+
+local map, section = ...
+
+local width = wdg:option(Value, "width", translate("Width"))
+width.rmempty = true
+
+--[[
+local height = wdg:option(Value, "height", translate("Height"))
+height.rmempty = true
+height.optional = true
+]]--
+
+local pr = wdg:option(Value, "paddingright", translate("Padding right"))
+pr.rmempty = true
diff --git a/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/html.lua b/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/html.lua
new file mode 100644
index 0000000000..367e8a269e
--- /dev/null
+++ b/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/html.lua
@@ -0,0 +1,41 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2012 Manuel Munz <freifunk at somakoma dot de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+]]--
+
+local map, section = ...
+local utl = require "luci.util"
+local fs = require "nixio.fs"
+local file = "/usr/share/customtext/" .. arg[1] .. ".html"
+
+local form, ferr = loadfile(utl.libpath() .. "/model/cbi/freifunk/widgets/heightwidth.lua")
+if form then
+ setfenv(form, getfenv(1))(m, wdg)
+end
+
+t = wdg:option(TextValue, "_text")
+t.rmempty = true
+t.rows = 20
+
+
+function t.cfgvalue()
+ return fs.readfile(file) or ""
+end
+
+function t.write(self, section, value)
+ return fs.writefile(file, value)
+end
+
+function t.remove(self, section)
+ return fs.unlink(file)
+end
+
+
diff --git a/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/iframe.lua b/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/iframe.lua
new file mode 100644
index 0000000000..b9cbcaee56
--- /dev/null
+++ b/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/iframe.lua
@@ -0,0 +1,23 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2012 Manuel Munz <freifunk at somakoma dot de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+]]--
+
+local map, section = ...
+local utl = require "luci.util"
+
+local form, ferr = loadfile(utl.libpath() .. "/model/cbi/freifunk/widgets/heightwidth.lua")
+if form then
+ setfenv(form, getfenv(1))(m, wdg)
+end
+
+local url = wdg:option(Value, "url", translate("URL"))
+url.default = "http://www.freifunk.net"
diff --git a/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/rssfeed.lua b/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/rssfeed.lua
new file mode 100644
index 0000000000..5df5a346fe
--- /dev/null
+++ b/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/rssfeed.lua
@@ -0,0 +1,35 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2012 Manuel Munz <freifunk at somakoma dot de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+]]--
+
+local map, section = ...
+local utl = require "luci.util"
+
+local form, ferr = loadfile(utl.libpath() .. "/model/cbi/freifunk/widgets/heightwidth.lua")
+if form then
+ setfenv(form, getfenv(1))(m, wdg)
+end
+
+local url = wdg:option(Value, "url", translate("URL"))
+url.default = "http://global.freifunk.net/rss/all/rss.xml"
+
+local max = wdg:option(Value, "max", translate("Maximal entries to show"))
+max.rmempty = true
+max.default = "10"
+max.datatype = "integer"
+
+local cache = wdg:option(Value, "cache", translate("Cache Time"), translate("Cache downloaded feed for that many seconds."))
+cache.rmempty = true
+cache.default = "3600"
+cache.datatype = "integer"
+
+
diff --git a/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/search.lua b/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/search.lua
new file mode 100644
index 0000000000..735dc7cdff
--- /dev/null
+++ b/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/search.lua
@@ -0,0 +1,25 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2012 Manuel Munz <freifunk at somakoma dot de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+]]--
+
+local map, section = ...
+local utl = require "luci.util"
+
+local form, ferr = loadfile(utl.libpath() .. "/model/cbi/freifunk/widgets/heightwidth.lua")
+if form then
+ setfenv(form, getfenv(1))(m, wdg)
+end
+
+local engine = wdg:option(DynamicList, "engine", translate("Search Engine"),
+ translate("Use the form Name|URL, where URL must be a full URL to the search engine " ..
+ "including the query GET parameter, e.g. 'Google|http://www.google.de/search?q='")
+ )
diff --git a/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/widget.lua b/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/widget.lua
new file mode 100644
index 0000000000..5adfc8f850
--- /dev/null
+++ b/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/widget.lua
@@ -0,0 +1,48 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2012 Manuel Munz <freifunk at somakoma dot de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+]]--
+
+
+local uci = require "luci.model.uci".cursor()
+local dsp = require "luci.dispatcher"
+local utl = require "luci.util"
+local widget = uci:get("freifunk-widgets", arg[1], "template")
+local title = uci:get("freifunk-widgets", arg[1], "title") or ""
+
+m = Map("freifunk-widgets", translate("Widget"))
+m.redirect = luci.dispatcher.build_url("admin/freifunk/widgets")
+
+if not arg[1] or m.uci:get("freifunk-widgets", arg[1]) ~= "widget" then
+ luci.http.redirect(m.redirect)
+ return
+end
+
+wdg = m:section(NamedSection, arg[1], "widget", translate("Widget") .. " " .. title)
+wdg.anonymous = true
+wdg.addremove = false
+
+local en = wdg:option(Flag, "enabled", translate("Enable"))
+en.rmempty = false
+
+local title = wdg:option(Value, "title", translate("Title"))
+title.rmempty = true
+
+local form = loadfile(
+ utl.libpath() .. "/model/cbi/freifunk/widgets/%s.lua" % widget
+)
+
+if form then
+ setfenv(form, getfenv(1))(m, wdg)
+end
+
+return m
+
diff --git a/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/widgets_overview.lua b/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/widgets_overview.lua
new file mode 100644
index 0000000000..50771d7e0d
--- /dev/null
+++ b/applications/luci-app-freifunk-widgets/luasrc/model/cbi/freifunk/widgets/widgets_overview.lua
@@ -0,0 +1,75 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2012 Manuel Munz <freifunk at somakoma dot de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+]]--
+
+local uci = require "luci.model.uci".cursor()
+local fs = require "luci.fs"
+local utl = require "luci.util"
+m = Map("freifunk-widgets", translate("Widgets"),
+ translate("Configure installed widgets."))
+
+wdg = m:section(TypedSection, "widget", translate("Widgets"))
+wdg.addremove = true
+wdg.extedit = luci.dispatcher.build_url("admin/freifunk/widgets/widget/%s")
+wdg.template = "cbi/tblsection"
+wdg.sortable = true
+
+--[[
+function wdg.create(...)
+ local sid = TypedSection.create(...)
+ luci.http.redirect(wdg.extedit % sid)
+end
+]]--
+
+local en = wdg:option(Flag, "enabled", translate("Enable"))
+en.rmempty = false
+--en.default = "0"
+function en.cfgvalue(self, section)
+ return Flag.cfgvalue(self, section) or "0"
+end
+
+local tmpl = wdg:option(ListValue, "template", translate("Template"))
+for k, v in ipairs(fs.dir('/usr/lib/lua/luci/view/freifunk/widgets/')) do
+ if v ~= "." and v ~= ".." then
+ tmpl:value(v)
+ end
+end
+
+local title = wdg:option(Value, "title", translate("Title"))
+title.rmempty = true
+
+local width = wdg:option(Value, "width", translate("Width"))
+width.rmempty = true
+
+local height = wdg:option(Value, "height", translate("Height"))
+height.rmempty = true
+
+local pr = wdg:option(Value, "paddingright", translate("Padding right"))
+pr.rmempty = true
+
+function m.on_commit(self)
+ -- clean custom text files whose config has been deleted
+ local dir = "/usr/share/customtext/"
+ local active = {}
+ uci:foreach("freifunk-widgets", "widget", function(s)
+ if s["template"] == "html" then
+ table.insert(active, s[".name"])
+ end
+ end )
+ for k, v in ipairs(fs.dir(dir)) do
+ filename = string.gsub(v, ".html", "")
+ if not utl.contains(active, filename) then
+ fs.unlink(dir .. v)
+ end
+ end
+end
+
+return m
diff --git a/applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/clear/main.htm b/applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/clear/main.htm
new file mode 100644
index 0000000000..df01839f44
--- /dev/null
+++ b/applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/clear/main.htm
@@ -0,0 +1,15 @@
+<%
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2012 Manuel Munz <freifunk at somakoma dot de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+]]--
+%>
+<div style="clear:both"></div>
diff --git a/applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/html/main.htm b/applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/html/main.htm
new file mode 100644
index 0000000000..87ad5b6292
--- /dev/null
+++ b/applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/html/main.htm
@@ -0,0 +1,42 @@
+<%
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2012 Manuel Munz <freifunk at somakoma dot de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+]]--
+
+--local utl = require "luci.util"
+local fs = require "luci.fs"
+local title = data.title
+local name = data['.name']
+local file = "/usr/share/customtext/" .. name .. ".html"
+local text = fs.readfile(file)
+local width = data.width or "100%"
+local pr = data.paddingright or "0"
+if type(width) == "number" then
+ width = width .. "px"
+end
+
+%>
+
+<div id="<%=name%>" style="width:<%=width%>;float:left">
+ <div style="padding-right: <%=pr%>">
+ <% if title then %>
+ <h2><%=title%></h2>
+ <% end %>
+ <% if text then %>
+ <%=text%>
+ <%else%>
+ <%:Could not load the custom text from%> "<%=file%>!"
+ <%end%>
+
+ <%=data.text%>
+ </div>
+</div>
diff --git a/applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/iframe/main.htm b/applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/iframe/main.htm
new file mode 100644
index 0000000000..f0d89d7425
--- /dev/null
+++ b/applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/iframe/main.htm
@@ -0,0 +1,45 @@
+<%
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2012 Manuel Munz <freifunk at somakoma dot de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+]]--
+
+local url = data['url']
+local name = data['.name']
+local title = data['title'] or "No title set"
+local height = data['height'] or "400px"
+if type(height) == "number" then
+ height = height .. "px"
+end
+local width = data['width'] or "100%"
+if type(width) == "number" then
+ width = width .. "px"
+end
+
+%>
+
+<div id="<%=name%>" style="width:<%=width%>;float:left;">
+<h2><%=title%></h2>
+
+<% if not url then %>
+
+<%:No url set.%>
+
+<% else %>
+<div style="height:<%=height%>;min-height:<%=height%>">
+<object type="text/html" data="<%=url%>" width="100%" height="<%=height%>" name="widget_<%=name%>" id="widget_<%=name%>">
+<param name="src" value="<%=url%>" />
+<%:Sorry, your browser doesn't support the object tag and cannot display this page:%><br />
+<a href="<%=url%>"><%=url%></a>
+</object>
+</div>
+</div>
+<%end%>
diff --git a/applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/rssfeed/main.htm b/applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/rssfeed/main.htm
new file mode 100644
index 0000000000..08fc550ecd
--- /dev/null
+++ b/applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/rssfeed/main.htm
@@ -0,0 +1,84 @@
+<%
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2012 Manuel Munz <freifunk at somakoma dot de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+]]--
+
+local sys = require "luci.sys"
+local utl = require "luci.util"
+local fs = require "luci.fs"
+local i18n = require "luci.i18n"
+local url = data.url
+local title = data.title or i18n.translate("RSS")
+local max = tonumber(data.max) or 10
+local rss
+local pr = data.paddingright or "0"
+local output = {}
+local width = data.width or "100%"
+if type(width) == "number" then
+ width = width .. "px"
+end
+local name = data['.name']
+local cachetime = tonumber(data.cache) or 3600
+cachefile = "/tmp/" .. name .. ".cache"
+%>
+<div id="<%=name%>" style="width:<%=width%>;float:left">
+ <div style="padding-right: <%=pr%>">
+ <h2><%=title%></h2>
+
+ <% if not url then %>
+ <%:No url found in config%>
+ <% else
+ local mtime = luci.fs.mtime(cachefile) or 0
+ local now = os.time()
+ expire = mtime + cachetime
+
+ if not fs.access(cachefile) or expire < now then
+ rss = sys.httpget(url)
+ if #rss == 0 then
+ %>
+ <%:Could not get rss data from%> <a href="<%=url%>"><%=url%></a>
+ <%
+ else
+ local count = 0
+ for item in string.gmatch(rss, "<item>(.-)</item>") do
+ if count < max then
+ local title = item:match("<title>(.-)</title>")
+ local link = item:match("<link>(.-)</link>")
+ local desc = item:match("<description>(.-)</description>") or ""
+ if title and link then
+ table.insert(output, { title = utl.pcdata(title), link = utl.pcdata(link) })
+ end
+ count = count + 1
+ end
+ end
+ if count > 0 then
+ local file = io.open(cachefile, "w")
+ file:write(utl.serialize_data(output))
+ file:close()
+ end
+ end
+ else
+ local file = assert(io.open(cachefile))
+ output = utl.restore_data(file:read'*a')
+ end
+ end
+
+ if #output > 0 then
+ %>
+ <ul>
+ <% for k, v in ipairs(output) do %>
+ <li><a href="<%=v.link%>"><%=v.title%></a></li>
+ <% end %>
+ </ul>
+ <%end%>
+ </div>
+</div>
diff --git a/applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/search/main.htm b/applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/search/main.htm
new file mode 100644
index 0000000000..e319f15fbc
--- /dev/null
+++ b/applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/search/main.htm
@@ -0,0 +1,54 @@
+<%
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2012 Manuel Munz <freifunk at somakoma dot de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+]]--
+local utl = require "luci.util"
+local title = luci.i18n.translate(data.title or "Search")
+local name = data['.name']
+local width = data.width or "100%"
+
+if type(width) == "number" then
+ width = width .. "px"
+end
+
+local engines = {}
+if type(data.engine) == "table" then
+ engines = data.engine
+else
+ for k, v in ipairs(string.split(data.engine, " ")) do
+ table.insert(engines, v)
+ end
+end
+%>
+
+<div id="<%=name%>" style="width:<%=width%>;float:left">
+ <h2><%=title%></h2>
+ <div id="form_<%=name%>">
+ <form name="searchform" id="search_<%=name%>" action="<%=luci.dispatcher.build_url('freifunk', 'search_redirect')%>">
+ <input type="text" name="searchterms" style="margin-bottom:15px; width: 90%"><br />
+ <%
+ local checked = " checked"
+ for k, v in ipairs(engines) do
+ local e = utl.split(v, "|")
+ local name = e[1]
+ local url = e[2]
+ if name and url then
+ %>
+ <input name="engine" type="radio" value="<%=url%>"<%=checked%>> <%=name%><br />
+ <% end
+ checked = ""
+ end
+%>
+ <input type="submit" name="SearchSubmit" value="Search" style="margin-top: 15px">
+ </form>
+ </div>
+</div>
diff --git a/applications/luci-app-freifunk-widgets/root/etc/config/freifunk-widgets b/applications/luci-app-freifunk-widgets/root/etc/config/freifunk-widgets
new file mode 100644
index 0000000000..5a9f3254fa
--- /dev/null
+++ b/applications/luci-app-freifunk-widgets/root/etc/config/freifunk-widgets
@@ -0,0 +1,33 @@
+config widget 'example_iframe'
+ option template 'iframe'
+ option url 'http://www.freifunk.net'
+ option title 'Freifunk Homepage'
+ option height '500px'
+ option width '100%'
+ option enabled '0'
+
+config widget 'example_rss'
+ option template 'rssfeed'
+ option url 'http://global.freifunk.net/rss/all/rss.xml'
+ option max '10'
+ option cache '3600'
+ option enabled '0'
+ option title 'Globaler Freifunk RSS Feed'
+
+config widget 'example_search'
+ option template 'search'
+ option enabled '0'
+ option title 'Search'
+ list engine 'Google|http://www.google.de/search?q='
+ list engine 'Freifunk&#160;Wiki|http://wiki.freifunk.net/index.php?search='
+ option width '50%'
+ option paddingright '8%'
+
+config widget 'example_customtext'
+ option template 'html'
+ option width '50%'
+ option enabled '0'
+
+config widget 'example_clear'
+ option enabled '0'
+ option template 'clear'
diff --git a/applications/luci-app-freifunk-widgets/root/lib/upgrade/keep.d/freifunk-widgets b/applications/luci-app-freifunk-widgets/root/lib/upgrade/keep.d/freifunk-widgets
new file mode 100644
index 0000000000..ce5537ac20
--- /dev/null
+++ b/applications/luci-app-freifunk-widgets/root/lib/upgrade/keep.d/freifunk-widgets
@@ -0,0 +1 @@
+/usr/share/customtext