<%# Copyright 2008 Steven Barth Copyright 2008-2010 Jo-Philipp Wich 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("simple-uci").cursor() local fs = require "nixio.fs" local pretty_hostname = require "pretty_hostname" local hostname = pretty_hostname.get(uci) local release = fs.readfile("/lib/gluon/release") local root = node() local rnode = node(unpack(request)) local category = request[1] local cattree = category and node(category) local function node_visible(node) return ( node.title and node.target and (not node.hidden) ) end local function node_children(node) if not node then return {} end local ret = {} for k, v in pairs(node.nodes) do if node_visible(v) then table.insert(ret, k) end end table.sort(ret, function(a, b) return (node.nodes[a].order or 100) < (node.nodes[b].order or 100) end ) return ret end local categories = node_children(root) local function append(xs, x) local r = {unpack(xs)} r[#r+1] = x return r end local function title(node) return i18n(node.pkg).translate(node.title) end local function subtree(prefix, node, name, ...) if not node then return end local children = node_children(node) if #children == 0 then return end %>
    <% for i, v in ipairs(children) do local child = node.nodes[v] local active = (v == name) %>
  • <%|title(child)%>
  • <% end %>

<% subtree(append(prefix, name), node.nodes[name], ...) %>
<% end local function menutree(path, ...) subtree({path}, root.nodes[category], ...) end http:prepare_content("application/xhtml+xml") -%> <%| hostname .. ((rnode and rnode.title) and ' - ' .. title(rnode) or '') %>
<% if not hidenav then menutree(unpack(request)) end %>
<% ok, err = pcall(renderer.render, content, scope, pkg) if not ok then renderer.render('error/500', {message = err}, 'gluon-web') end %>