From 1bb4822dca6113f73e3bc89e2acf15935e6f8e92 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 3 Dec 2014 15:17:05 +0100 Subject: 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 --- .../luasrc/view/freifunk/widgets/clear/main.htm | 15 ++++ .../luasrc/view/freifunk/widgets/html/main.htm | 42 +++++++++++ .../luasrc/view/freifunk/widgets/iframe/main.htm | 45 ++++++++++++ .../luasrc/view/freifunk/widgets/rssfeed/main.htm | 84 ++++++++++++++++++++++ .../luasrc/view/freifunk/widgets/search/main.htm | 54 ++++++++++++++ 5 files changed, 240 insertions(+) create mode 100644 applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/clear/main.htm create mode 100644 applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/html/main.htm create mode 100644 applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/iframe/main.htm create mode 100644 applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/rssfeed/main.htm create mode 100644 applications/luci-app-freifunk-widgets/luasrc/view/freifunk/widgets/search/main.htm (limited to 'applications/luci-app-freifunk-widgets/luasrc/view') 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 000000000..df01839f4 --- /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 + +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-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 000000000..87ad5b629 --- /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 + +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 + +%> + +
+
+ <% if title then %> +

<%=title%>

+ <% end %> + <% if text then %> + <%=text%> + <%else%> + <%:Could not load the custom text from%> "<%=file%>!" + <%end%> + + <%=data.text%> +
+
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 000000000..f0d89d742 --- /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 + +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 + +%> + +
+

<%=title%>

+ +<% if not url then %> + +<%:No url set.%> + +<% else %> +
+ + +<%:Sorry, your browser doesn't support the object tag and cannot display this page:%>
+<%=url%> +
+
+
+<%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 000000000..08fc550ec --- /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 + +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" +%> +
+
+

<%=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 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 + 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 + %> +
    + <% for k, v in ipairs(output) do %> +
  • <%=v.title%>
  • + <% end %> +
+ <%end%> +
+
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 000000000..e319f15fb --- /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 + +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 +%> + +
+

<%=title%>

+
+
+
+ <% + 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 + %> + > <%=name%>
+ <% end + checked = "" + end +%> + +
+
+
-- cgit v1.2.3