applications/freifunk-widgets: remove order variable, fix html in rss view, fix search view
This commit is contained in:
parent
be8760679a
commit
386fa7a674
13 changed files with 199 additions and 70 deletions
|
@ -1,10 +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 map, section = ...
|
||||||
|
|
||||||
local width = wdg:option(Value, "width", translate("Width"))
|
local width = wdg:option(Value, "width", translate("Width"))
|
||||||
width.rmempty = true
|
width.rmempty = true
|
||||||
|
|
||||||
|
--[[
|
||||||
local height = wdg:option(Value, "height", translate("Height"))
|
local height = wdg:option(Value, "height", translate("Height"))
|
||||||
height.rmempty = true
|
height.rmempty = true
|
||||||
|
height.optional = true
|
||||||
|
]]--
|
||||||
|
|
||||||
local pr = wdg:option(Value, "paddingright", translate("Padding right"))
|
local pr = wdg:option(Value, "paddingright", translate("Padding right"))
|
||||||
pr.rmempty = true
|
pr.rmempty = true
|
||||||
|
|
|
@ -1,3 +1,16 @@
|
||||||
|
--[[
|
||||||
|
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 map, section = ...
|
||||||
local utl = require "luci.util"
|
local utl = require "luci.util"
|
||||||
local fs = require "nixio.fs"
|
local fs = require "nixio.fs"
|
||||||
|
|
|
@ -1,3 +1,16 @@
|
||||||
|
--[[
|
||||||
|
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 map, section = ...
|
||||||
local utl = require "luci.util"
|
local utl = require "luci.util"
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,16 @@
|
||||||
|
--[[
|
||||||
|
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 map, section = ...
|
||||||
local utl = require "luci.util"
|
local utl = require "luci.util"
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,16 @@
|
||||||
|
--[[
|
||||||
|
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 map, section = ...
|
||||||
local utl = require "luci.util"
|
local utl = require "luci.util"
|
||||||
|
|
||||||
|
|
|
@ -36,12 +36,6 @@ en.rmempty = false
|
||||||
local title = wdg:option(Value, "title", translate("Title"))
|
local title = wdg:option(Value, "title", translate("Title"))
|
||||||
title.rmempty = true
|
title.rmempty = true
|
||||||
|
|
||||||
local order = wdg:option(Value, "order", translate("Order"))
|
|
||||||
order.default = "100"
|
|
||||||
order.placeholder = "100"
|
|
||||||
order.datatype = "integer"
|
|
||||||
|
|
||||||
|
|
||||||
local form = loadfile(
|
local form = loadfile(
|
||||||
utl.libpath() .. "/model/cbi/freifunk/widgets/%s.lua" % widget
|
utl.libpath() .. "/model/cbi/freifunk/widgets/%s.lua" % widget
|
||||||
)
|
)
|
||||||
|
@ -49,5 +43,6 @@ local form = loadfile(
|
||||||
if form then
|
if form then
|
||||||
setfenv(form, getfenv(1))(m, wdg)
|
setfenv(form, getfenv(1))(m, wdg)
|
||||||
end
|
end
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
||||||
|
|
|
@ -44,25 +44,19 @@ for k, v in ipairs(fs.dir('/usr/lib/lua/luci/view/freifunk/widgets/')) do
|
||||||
end
|
end
|
||||||
|
|
||||||
local title = wdg:option(Value, "title", translate("Title"))
|
local title = wdg:option(Value, "title", translate("Title"))
|
||||||
--title.rmempty = true
|
title.rmempty = true
|
||||||
|
|
||||||
|
|
||||||
local order = wdg:option(Value, "order", translate("Order"))
|
|
||||||
order.default = "100"
|
|
||||||
order.placeholder = "100"
|
|
||||||
order.datatype = "integer"
|
|
||||||
|
|
||||||
local width = wdg:option(Value, "width", translate("Width"))
|
local width = wdg:option(Value, "width", translate("Width"))
|
||||||
--width.rmempty = true
|
width.rmempty = true
|
||||||
|
|
||||||
local height = wdg:option(Value, "height", translate("Height"))
|
local height = wdg:option(Value, "height", translate("Height"))
|
||||||
--height.rmempty = true
|
height.rmempty = true
|
||||||
|
|
||||||
local pr = wdg:option(Value, "paddingright", translate("Padding right"))
|
local pr = wdg:option(Value, "paddingright", translate("Padding right"))
|
||||||
pr.rmempty = true
|
pr.rmempty = true
|
||||||
|
|
||||||
function m.on_commit(self)
|
function m.on_commit(self)
|
||||||
-- clean custom text files for elements which may have been deleted
|
-- clean custom text files whose config has been deleted
|
||||||
local dir = "/usr/share/customtext/"
|
local dir = "/usr/share/customtext/"
|
||||||
local active = {}
|
local active = {}
|
||||||
uci:foreach("freifunk-widgets", "widget", function(s)
|
uci:foreach("freifunk-widgets", "widget", function(s)
|
||||||
|
@ -79,4 +73,3 @@ function m.on_commit(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
||||||
|
|
|
@ -1 +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>
|
<div style="clear:both"></div>
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
<%
|
<%
|
||||||
|
--[[
|
||||||
|
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 utl = require "luci.util"
|
||||||
local fs = require "luci.fs"
|
local fs = require "luci.fs"
|
||||||
local title = data.title
|
local title = data.title
|
||||||
|
local name = data['.name']
|
||||||
local file = "/usr/share/customtext/" .. name .. ".html"
|
local file = "/usr/share/customtext/" .. name .. ".html"
|
||||||
local text = fs.readfile(file)
|
local text = fs.readfile(file)
|
||||||
local width = data.width or "100%"
|
local width = data.width or "100%"
|
||||||
|
|
|
@ -1,5 +1,19 @@
|
||||||
<%
|
<%
|
||||||
|
--[[
|
||||||
|
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 url = data['url']
|
||||||
|
local name = data['.name']
|
||||||
local title = data['title'] or "No title set"
|
local title = data['title'] or "No title set"
|
||||||
local height = data['height'] or "400px"
|
local height = data['height'] or "400px"
|
||||||
if type(height) == "number" then
|
if type(height) == "number" then
|
||||||
|
|
|
@ -1,4 +1,17 @@
|
||||||
<%
|
<%
|
||||||
|
--[[
|
||||||
|
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 sys = require "luci.sys"
|
||||||
local utl = require "luci.util"
|
local utl = require "luci.util"
|
||||||
local fs = require "luci.fs"
|
local fs = require "luci.fs"
|
||||||
|
@ -13,6 +26,7 @@ local width = data.width or "100%"
|
||||||
if type(width) == "number" then
|
if type(width) == "number" then
|
||||||
width = width .. "px"
|
width = width .. "px"
|
||||||
end
|
end
|
||||||
|
local name = data['.name']
|
||||||
local cachetime = tonumber(data.cache) or 3600
|
local cachetime = tonumber(data.cache) or 3600
|
||||||
cachefile = "/tmp/" .. name .. ".cache"
|
cachefile = "/tmp/" .. name .. ".cache"
|
||||||
%>
|
%>
|
||||||
|
@ -46,10 +60,12 @@ cachefile = "/tmp/" .. name .. ".cache"
|
||||||
count = count + 1
|
count = count + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if count > 0 then
|
||||||
local file = io.open(cachefile, "w")
|
local file = io.open(cachefile, "w")
|
||||||
file:write(utl.serialize_data(output))
|
file:write(utl.serialize_data(output))
|
||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
local file = assert(io.open(cachefile))
|
local file = assert(io.open(cachefile))
|
||||||
output = utl.restore_data(file:read'*a')
|
output = utl.restore_data(file:read'*a')
|
||||||
|
@ -59,12 +75,10 @@ end
|
||||||
if #output > 0 then
|
if #output > 0 then
|
||||||
%>
|
%>
|
||||||
<ul>
|
<ul>
|
||||||
<%
|
<% for k, v in ipairs(output) do %>
|
||||||
for k, v in ipairs(output) do
|
|
||||||
%>
|
|
||||||
<li><a href="<%=v.link%>"><%=v.title%></a></li>
|
<li><a href="<%=v.link%>"><%=v.title%></a></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<%end%>
|
<%end%>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
|
@ -1,11 +1,33 @@
|
||||||
<%
|
<%
|
||||||
|
--[[
|
||||||
|
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 utl = require "luci.util"
|
||||||
local title = luci.i18n.translate(data.title or "Search")
|
local title = luci.i18n.translate(data.title or "Search")
|
||||||
|
local name = data['.name']
|
||||||
local width = data.width or "100%"
|
local width = data.width or "100%"
|
||||||
|
|
||||||
if type(width) == "number" then
|
if type(width) == "number" then
|
||||||
width = width .. "px"
|
width = width .. "px"
|
||||||
end
|
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">
|
<div id="<%=name%>" style="width:<%=width%>;float:left">
|
||||||
|
@ -15,7 +37,7 @@ end
|
||||||
<input type="text" name="searchterms" style="margin-bottom:15px; width: 90%"><br />
|
<input type="text" name="searchterms" style="margin-bottom:15px; width: 90%"><br />
|
||||||
<%
|
<%
|
||||||
local checked = " checked"
|
local checked = " checked"
|
||||||
for k, v in ipairs(data.engine) do
|
for k, v in ipairs(engines) do
|
||||||
local e = utl.split(v, "|")
|
local e = utl.split(v, "|")
|
||||||
local name = e[1]
|
local name = e[1]
|
||||||
local url = e[2]
|
local url = e[2]
|
||||||
|
|
|
@ -1,38 +1,33 @@
|
||||||
config widget 'iframe_freifunk'
|
config widget 'example_iframe'
|
||||||
option template 'iframe'
|
option template 'iframe'
|
||||||
option order '10'
|
|
||||||
option url 'http://www.freifunk.net'
|
option url 'http://www.freifunk.net'
|
||||||
option title 'Freifunk Homepage'
|
option title 'Freifunk Homepage'
|
||||||
option height '500px'
|
option height '500px'
|
||||||
option width '100%'
|
option width '100%'
|
||||||
option enabled '0'
|
option enabled '0'
|
||||||
|
|
||||||
config widget 'rss_freifunk'
|
config widget 'example_rss'
|
||||||
option template 'rssfeed'
|
option template 'rssfeed'
|
||||||
option order '20'
|
|
||||||
option url 'http://global.freifunk.net/rss/all/rss.xml'
|
option url 'http://global.freifunk.net/rss/all/rss.xml'
|
||||||
option max '10'
|
option max '10'
|
||||||
option cache '3600'
|
option cache '3600'
|
||||||
option enabled '0'
|
option enabled '0'
|
||||||
option title 'Globaler Freifunk RSS Feed'
|
option title 'Globaler Freifunk RSS Feed'
|
||||||
|
|
||||||
config widget 'search'
|
config widget 'example_search'
|
||||||
option template 'search'
|
option template 'search'
|
||||||
option enabled '0'
|
option enabled '0'
|
||||||
option order '30'
|
|
||||||
option title 'Search'
|
option title 'Search'
|
||||||
list engine 'Google|http://www.google.de/search?q='
|
list engine 'Google|http://www.google.de/search?q='
|
||||||
list engine 'Freifunk Wiki|http://wiki.freifunk.net/index.php?search='
|
list engine 'Freifunk Wiki|http://wiki.freifunk.net/index.php?search='
|
||||||
option width '50%'
|
option width '50%'
|
||||||
option paddingright '8%'
|
option paddingright '8%'
|
||||||
|
|
||||||
config widget 'customtext'
|
config widget 'example_customtext'
|
||||||
option template 'html'
|
option template 'html'
|
||||||
option width '50%'
|
option width '50%'
|
||||||
option order '40'
|
|
||||||
option enabled '0'
|
option enabled '0'
|
||||||
|
|
||||||
config widget 'clear'
|
config widget 'example_clear'
|
||||||
option enabled '0'
|
option enabled '0'
|
||||||
option template 'clear'
|
option template 'clear'
|
||||||
option order '50'
|
|
||||||
|
|
Loading…
Reference in a new issue