diff options
author | Manuel Munz <freifunk@somakoma.de> | 2012-09-17 14:20:36 +0000 |
---|---|---|
committer | Manuel Munz <freifunk@somakoma.de> | 2012-09-17 14:20:36 +0000 |
commit | 745920eb08b63944ea03cb140dbe4033d7467973 (patch) | |
tree | 0de08781ed3e8350b7aa519b8752b6cd33764183 /applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets | |
parent | 2ad8d7fe61697bdeb9dc9ca421c9149c9ec33917 (diff) |
applications: add freifunk widgets app to customize the index page
Diffstat (limited to 'applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets')
5 files changed, 162 insertions, 0 deletions
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 new file mode 100644 index 0000000000..7669a58f48 --- /dev/null +++ b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/clear/main.htm @@ -0,0 +1 @@ +<div style="clear:both"></div> 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 new file mode 100644 index 0000000000..f59a9302d3 --- /dev/null +++ b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/html/main.htm @@ -0,0 +1,28 @@ +<% +--local utl = require "luci.util" +local fs = require "luci.fs" +local title = data.title +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-freifunk-widgets/luasrc/view/freifunk/widgets/iframe/main.htm b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/iframe/main.htm new file mode 100644 index 0000000000..7d8f087e45 --- /dev/null +++ b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/iframe/main.htm @@ -0,0 +1,31 @@ +<% +local url = data['url'] +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-freifunk-widgets/luasrc/view/freifunk/widgets/rssfeed/main.htm b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/rssfeed/main.htm new file mode 100644 index 0000000000..ad64da5673 --- /dev/null +++ b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/rssfeed/main.htm @@ -0,0 +1,70 @@ +<% +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 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 + local file = io.open(cachefile, "w") + file:write(utl.serialize_data(output)) + file:close() + 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> +</div> +</div> +<%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 new file mode 100644 index 0000000000..97215aa3e9 --- /dev/null +++ b/applications/luci-freifunk-widgets/luasrc/view/freifunk/widgets/search/main.htm @@ -0,0 +1,32 @@ +<% +local utl = require "luci.util" +local title = luci.i18n.translate(data.title or "Search") +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> + <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(data.engine) 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> |