From 386fa7a674f077d54d48955cb1bbd969c632c8a8 Mon Sep 17 00:00:00 2001 From: Manuel Munz Date: Wed, 19 Sep 2012 06:27:51 +0000 Subject: applications/freifunk-widgets: remove order variable, fix html in rss view, fix search view --- .../luasrc/view/freifunk/widgets/clear/main.htm | 14 ++++ .../luasrc/view/freifunk/widgets/html/main.htm | 14 ++++ .../luasrc/view/freifunk/widgets/iframe/main.htm | 14 ++++ .../luasrc/view/freifunk/widgets/rssfeed/main.htm | 98 ++++++++++++---------- .../luasrc/view/freifunk/widgets/search/main.htm | 24 +++++- 5 files changed, 121 insertions(+), 43 deletions(-) (limited to 'applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets') diff --git a/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/clear/main.htm b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/clear/main.htm index 7669a58f48..df01839f44 100644 --- a/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/clear/main.htm +++ b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/clear/main.htm @@ -1 +1,15 @@ +<% +--[[ +LuCI - Lua Configuration Interface + +Copyright 2012 Manuel Munz + +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 + +]]-- +%>
diff --git a/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/html/main.htm b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/html/main.htm index f59a9302d3..87ad5b6292 100644 --- a/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/html/main.htm +++ b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/html/main.htm @@ -1,7 +1,21 @@ <% +--[[ +LuCI - Lua Configuration Interface + +Copyright 2012 Manuel Munz + +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%" diff --git a/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/iframe/main.htm b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/iframe/main.htm index 7d8f087e45..f0d89d7425 100644 --- a/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/iframe/main.htm +++ b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/iframe/main.htm @@ -1,5 +1,19 @@ <% +--[[ +LuCI - Lua Configuration Interface + +Copyright 2012 Manuel Munz + +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 diff --git a/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/rssfeed/main.htm b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/rssfeed/main.htm index ad64da5673..08fc550ecd 100644 --- a/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/rssfeed/main.htm +++ b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/rssfeed/main.htm @@ -1,4 +1,17 @@ <% +--[[ +LuCI - Lua Configuration Interface + +Copyright 2012 Manuel Munz + +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" @@ -13,58 +26,59 @@ 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" %>
-
-

<%=title%>

+
+

<%=title%>

-<% 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 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%> <%=url%> - <% - else - local count = 0 - for item in string.gmatch(rss, "(.-)") do - if count < max then - local title = item:match("(.-)") - local link = item:match("(.-)") - local desc = item:match("(.-)") or "" - if title and link then - table.insert(output, { title = utl.pcdata(title), link = utl.pcdata(link) }) + if not fs.access(cachefile) or expire < now then + rss = sys.httpget(url) + if #rss == 0 then + %> + <%:Could not get rss data from%> <%=url%> + <% + else + local count = 0 + for item in string.gmatch(rss, "(.-)") do + if count < max then + local title = item:match("(.-)") + local link = item:match("(.-)") + local desc = item:match("(.-)") or "" + if title and link then + table.insert(output, { title = utl.pcdata(title), link = utl.pcdata(link) }) + end + count = count + 1 end - count = count + 1 + end + if count > 0 then + local file = io.open(cachefile, "w") + file:write(utl.serialize_data(output)) + file:close() end end - local file = io.open(cachefile, "w") - file:write(utl.serialize_data(output)) - file:close() + else + local file = assert(io.open(cachefile)) + output = utl.restore_data(file:read'*a') end - else - local file = assert(io.open(cachefile)) - output = utl.restore_data(file:read'*a') end -end -if #output > 0 then -%> -
    -<% - for k, v in ipairs(output) do -%> -
  • <%=v.title%>
  • -<% end %> -
-
+ if #output > 0 then + %> +
    + <% for k, v in ipairs(output) do %> +
  • <%=v.title%>
  • + <% end %> +
+ <%end%> +
-<%end%> diff --git a/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/search/main.htm b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/search/main.htm index 97215aa3e9..e319f15fbc 100644 --- a/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/search/main.htm +++ b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/search/main.htm @@ -1,11 +1,33 @@ <% +--[[ +LuCI - Lua Configuration Interface + +Copyright 2012 Manuel Munz + +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 %>
@@ -15,7 +37,7 @@ end
<% local checked = " checked" - for k, v in ipairs(data.engine) do + for k, v in ipairs(engines) do local e = utl.split(v, "|") local name = e[1] local url = e[2] -- cgit v1.2.3