gluon-web: reorganize layout handling
Also bring back gluon-web-theme's i18n strings.
This commit is contained in:
parent
c3e4ceed28
commit
9648489a01
@ -106,36 +106,27 @@ local function action_upgrade(http, renderer)
|
|||||||
fs.unlink(tmpfile)
|
fs.unlink(tmpfile)
|
||||||
end
|
end
|
||||||
|
|
||||||
renderer.render("layout", {
|
renderer.render_layout('admin/upgrade', {
|
||||||
content = "admin/upgrade",
|
|
||||||
env = {
|
|
||||||
bad_image = has_image and not has_support,
|
bad_image = has_image and not has_support,
|
||||||
},
|
}, 'gluon-web-admin')
|
||||||
pkg = 'gluon-web-admin',
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Step 2: present uploaded file, show checksum, confirmation
|
-- Step 2: present uploaded file, show checksum, confirmation
|
||||||
elseif step == 2 then
|
elseif step == 2 then
|
||||||
renderer.render("layout", {
|
renderer.render_layout('admin/upgrade_confirm', {
|
||||||
content = "admin/upgrade_confirm",
|
|
||||||
env = {
|
|
||||||
checksum = image_checksum(tmpfile),
|
checksum = image_checksum(tmpfile),
|
||||||
filesize = fs.stat(tmpfile).size,
|
filesize = fs.stat(tmpfile).size,
|
||||||
flashsize = storage_size(),
|
flashsize = storage_size(),
|
||||||
keepconfig = (http:formvalue("keepcfg") == "1"),
|
keepconfig = (http:formvalue("keepcfg") == "1"),
|
||||||
},
|
}, 'gluon-web-admin')
|
||||||
pkg = 'gluon-web-admin',
|
|
||||||
})
|
|
||||||
elseif step == 3 then
|
elseif step == 3 then
|
||||||
if http:formvalue("keepcfg") == "1" then
|
if http:formvalue("keepcfg") == "1" then
|
||||||
fork_exec("/sbin/sysupgrade", tmpfile)
|
fork_exec("/sbin/sysupgrade", tmpfile)
|
||||||
else
|
else
|
||||||
fork_exec("/sbin/sysupgrade", "-n", tmpfile)
|
fork_exec("/sbin/sysupgrade", "-n", tmpfile)
|
||||||
end
|
end
|
||||||
renderer.render("layout", {
|
renderer.render_layout('admin/upgrade_reboot', nil, 'gluon-web-admin', {
|
||||||
content = "admin/upgrade_reboot",
|
|
||||||
hidenav = true,
|
hidenav = true,
|
||||||
pkg = 'gluon-web-admin',
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
map:render(renderer)
|
map:render(renderer)
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
<script type="text/javascript" src="<%|resource%>/gluon-web.js"></script>
|
<script type="text/javascript" src="/static/gluon-web-model.js"></script>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
/*
|
/*
|
||||||
Build using:
|
Build using:
|
||||||
|
|
||||||
uglifyjs javascript/gluon-web.js -o files/lib/gluon/web/www/static/resources/gluon-web.js -c -m --support-ie8
|
uglifyjs javascript/gluon-web-model.js -o files/lib/gluon/web/www/static/gluon-web-model.js -c -m --support-ie8
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -58,11 +58,9 @@ return function(config, http, renderer, name, pkg)
|
|||||||
hidenav = hidenav or map.hidenav
|
hidenav = hidenav or map.hidenav
|
||||||
end
|
end
|
||||||
|
|
||||||
renderer.render('layout', {
|
renderer.render_layout('model/wrapper', {
|
||||||
content = 'model/wrapper',
|
|
||||||
env = {
|
|
||||||
maps = maps,
|
maps = maps,
|
||||||
},
|
}, nil, {
|
||||||
hidenav = hidenav,
|
hidenav = hidenav,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -11,26 +11,27 @@ PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
|||||||
|
|
||||||
include ../gluon.mk
|
include ../gluon.mk
|
||||||
|
|
||||||
|
PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG)
|
||||||
|
|
||||||
|
|
||||||
define Package/gluon-web-theme
|
define Package/gluon-web-theme
|
||||||
SECTION:=gluon
|
SECTION:=gluon
|
||||||
CATEGORY:=Gluon
|
CATEGORY:=Gluon
|
||||||
TITLE:=gluon-web theme
|
TITLE:=gluon-web theme
|
||||||
DEPENDS:=+gluon-core +gluon-web-model
|
DEPENDS:=+gluon-core +gluon-web
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Build/Prepare
|
define Build/Prepare
|
||||||
mkdir -p $(PKG_BUILD_DIR)
|
mkdir -p $(PKG_BUILD_DIR)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Build/Configure
|
|
||||||
endef
|
|
||||||
|
|
||||||
define Build/Compile
|
define Build/Compile
|
||||||
|
$(call GluonBuildI18N,gluon-web-theme,i18n)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/gluon-web-theme/install
|
define Package/gluon-web-theme/install
|
||||||
$(CP) ./files/* $(1)/
|
$(CP) ./files/* $(1)/
|
||||||
|
$(call GluonInstallI18N,gluon-web-theme,$(1))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call BuildPackage,gluon-web-theme))
|
$(eval $(call BuildPackage,gluon-web-theme))
|
||||||
|
@ -100,7 +100,7 @@ You may obtain a copy of the License at
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="stylesheet" type="text/css" media="screen" href="<%|media%>/cascade.css" />
|
<link rel="stylesheet" type="text/css" media="screen" href="/static/gluon.css" />
|
||||||
<title><%| hostname .. ((rnode and rnode.title) and ' - ' .. title(rnode) or '') %></title>
|
<title><%| hostname .. ((rnode and rnode.title) and ' - ' .. title(rnode) or '') %></title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -140,7 +140,7 @@ You may obtain a copy of the License at
|
|||||||
</noscript>
|
</noscript>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
ok, err = pcall(renderer.render, content, env, pkg)
|
ok, err = pcall(renderer.render, content, scope, pkg)
|
||||||
if not ok then
|
if not ok then
|
||||||
renderer.render('error/500', {message = err}, 'gluon-web')
|
renderer.render('error/500', {message = err}, 'gluon-web')
|
||||||
end
|
end
|
20
package/gluon-web-theme/i18n/de.po
Normal file
20
package/gluon-web-theme/i18n/de.po
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
|
"PO-Revision-Date: 2013-03-29 12:13+0200\n"
|
||||||
|
"Last-Translator: Matthias Schiffer <mschiffer@universe-factory.net>\n"
|
||||||
|
"Language-Team: German\n"
|
||||||
|
"Language: de\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
|
msgid "JavaScript required!"
|
||||||
|
msgstr "JavaScript benötigt!"
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
"You must enable JavaScript in your browser or the web interface will not "
|
||||||
|
"work properly."
|
||||||
|
msgstr "Bitte aktiviere JavaScript in deinem Browser, damit das Webinterface "
|
||||||
|
"korrekt funktionieren kann."
|
19
package/gluon-web-theme/i18n/fr.po
Normal file
19
package/gluon-web-theme/i18n/fr.po
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
|
"PO-Revision-Date: 2013-12-22 17:11+0200\n"
|
||||||
|
"Last-Translator: goofy <pierre.gaufillet@gmail.com>\n"
|
||||||
|
"Language-Team: French\n"
|
||||||
|
"Language: fr\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
|
|
||||||
|
msgid "JavaScript required!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
"You must enable JavaScript in your browser or the web interface will not "
|
||||||
|
"work properly."
|
||||||
|
msgstr ""
|
10
package/gluon-web-theme/i18n/gluon-web-theme.pot
Normal file
10
package/gluon-web-theme/i18n/gluon-web-theme.pot
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
msgid ""
|
||||||
|
msgstr "Content-Type: text/plain; charset=UTF-8"
|
||||||
|
|
||||||
|
msgid "JavaScript required!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgid ""
|
||||||
|
"You must enable JavaScript in your browser or the web interface will not "
|
||||||
|
"work properly."
|
||||||
|
msgstr ""
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Use sass like this to update it:
|
Use sass like this to update it:
|
||||||
|
|
||||||
sass --sourcemap=none -C -t compressed sass/cascade.scss files/lib/gluon/web/www/static/gluon/cascade.css
|
sass --sourcemap=none -C -t compressed sass/gluon.scss files/lib/gluon/web/www/static/gluon.css
|
||||||
|
|
||||||
When commiting changes to this file make sure to commit the respective
|
When commiting changes to this file make sure to commit the respective
|
||||||
changes to the compilid version within the same commit!
|
changes to the compilid version within the same commit!
|
@ -1,3 +0,0 @@
|
|||||||
<%
|
|
||||||
include("themes/" .. theme .. "/layout")
|
|
||||||
%>
|
|
@ -2,4 +2,7 @@
|
|||||||
|
|
||||||
require 'gluon.web.cgi' {
|
require 'gluon.web.cgi' {
|
||||||
base_path = '/lib/gluon/web',
|
base_path = '/lib/gluon/web',
|
||||||
|
|
||||||
|
layout_package = 'gluon-web-theme',
|
||||||
|
layout_template = 'theme/layout',
|
||||||
}
|
}
|
||||||
|
@ -86,9 +86,6 @@ local function dispatch(config, http, request)
|
|||||||
write = function(...) return http:write(...) end,
|
write = function(...) return http:write(...) end,
|
||||||
pcdata = util.pcdata,
|
pcdata = util.pcdata,
|
||||||
urlencode = proto.urlencode,
|
urlencode = proto.urlencode,
|
||||||
media = '/static/gluon',
|
|
||||||
theme = 'gluon',
|
|
||||||
resource = '/static/resources',
|
|
||||||
attr = attr,
|
attr = attr,
|
||||||
url = function(path) return build_url(http, path) end,
|
url = function(path) return build_url(http, path) end,
|
||||||
}, { __index = _G }))
|
}, { __index = _G }))
|
||||||
@ -136,10 +133,10 @@ local function dispatch(config, http, request)
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
template = function(view)
|
template = function(view, scope)
|
||||||
local pkg = _pkg
|
local pkg = _pkg
|
||||||
return function()
|
return function()
|
||||||
renderer.render("layout", {content = view, pkg = pkg})
|
renderer.render_layout(view, scope, pkg)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -178,15 +175,11 @@ local function dispatch(config, http, request)
|
|||||||
|
|
||||||
if not node or not node.target then
|
if not node or not node.target then
|
||||||
http:status(404, "Not Found")
|
http:status(404, "Not Found")
|
||||||
renderer.render("layout", {
|
renderer.render_layout("error/404", {
|
||||||
content = "error/404",
|
|
||||||
env = {
|
|
||||||
message =
|
message =
|
||||||
"No page is registered at '/" .. table.concat(request, "/") .. "'.\n" ..
|
"No page is registered at '/" .. table.concat(request, "/") .. "'.\n" ..
|
||||||
"If this URL belongs to an extension, make sure it is properly installed.\n",
|
"If this URL belongs to an extension, make sure it is properly installed.\n",
|
||||||
},
|
}, 'gluon-web')
|
||||||
pkg = 'gluon-web',
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -195,15 +188,11 @@ local function dispatch(config, http, request)
|
|||||||
local ok, err = pcall(node.target)
|
local ok, err = pcall(node.target)
|
||||||
if not ok then
|
if not ok then
|
||||||
http:status(500, "Internal Server Error")
|
http:status(500, "Internal Server Error")
|
||||||
renderer.render("layout", {
|
renderer.render_layout("error/500", {
|
||||||
content = "error/500",
|
|
||||||
env = {
|
|
||||||
message =
|
message =
|
||||||
"Failed to execute dispatcher target for entry '/" .. table.concat(request, "/") .. "'.\n" ..
|
"Failed to execute dispatcher target for entry '/" .. table.concat(request, "/") .. "'.\n" ..
|
||||||
"The called action terminated with an exception:\n" .. tostring(err or "(unknown)"),
|
"The called action terminated with an exception:\n" .. tostring(err or "(unknown)"),
|
||||||
},
|
}, 'gluon-web')
|
||||||
pkg = 'gluon-web',
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ return function(config, env)
|
|||||||
--- Render a certain template.
|
--- Render a certain template.
|
||||||
-- @param name Template name
|
-- @param name Template name
|
||||||
-- @param scope Scope to assign to template (optional)
|
-- @param scope Scope to assign to template (optional)
|
||||||
|
-- @param pkg i18n namespace package (optional)
|
||||||
function ctx.render(name, scope, pkg)
|
function ctx.render(name, scope, pkg)
|
||||||
local sourcefile = viewdir .. name .. ".html"
|
local sourcefile = viewdir .. name .. ".html"
|
||||||
local template, _, err = tparser.parse(sourcefile)
|
local template, _, err = tparser.parse(sourcefile)
|
||||||
@ -78,6 +79,7 @@ return function(config, env)
|
|||||||
--- Render a template from a string.
|
--- Render a template from a string.
|
||||||
-- @param template Template string
|
-- @param template Template string
|
||||||
-- @param scope Scope to assign to template (optional)
|
-- @param scope Scope to assign to template (optional)
|
||||||
|
-- @param pkg i18n namespace package (optional)
|
||||||
function ctx.render_string(str, scope, pkg)
|
function ctx.render_string(str, scope, pkg)
|
||||||
local template, _, err = tparser.parse_string(str)
|
local template, _, err = tparser.parse_string(str)
|
||||||
|
|
||||||
@ -87,5 +89,20 @@ return function(config, env)
|
|||||||
render_template('(local)', template, scope, pkg)
|
render_template('(local)', template, scope, pkg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Render a template, wrapped in the configured layout.
|
||||||
|
-- @param name Template name
|
||||||
|
-- @param scope Scope to assign to template (optional)
|
||||||
|
-- @param pkg i18n namespace package (optional)
|
||||||
|
-- @param layout_scope Additional variables to pass to the layout template
|
||||||
|
function ctx.render_layout(name, scope, pkg, layout_scope)
|
||||||
|
ctx.render(config.layout_template, setmetatable({
|
||||||
|
content = name,
|
||||||
|
scope = scope,
|
||||||
|
pkg = pkg,
|
||||||
|
}, {
|
||||||
|
__index = layout_scope
|
||||||
|
}), config.layout_package)
|
||||||
|
end
|
||||||
|
|
||||||
return ctx
|
return ctx
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user