Update LuCI to master branch

This commit is contained in:
Matthias Schiffer 2017-01-17 22:04:58 +01:00
parent 2dd8a700ca
commit 7736f53dc4
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
26 changed files with 63 additions and 372 deletions

View File

@ -15,5 +15,4 @@ PACKAGES_ROUTING_REPO=git://github.com/openwrt-routing/packages.git
PACKAGES_ROUTING_COMMIT=d848d49d2443448b147c564c2dd8f64433b5fb9c PACKAGES_ROUTING_COMMIT=d848d49d2443448b147c564c2dd8f64433b5fb9c
PACKAGES_LUCI_REPO=git://github.com/openwrt/luci.git PACKAGES_LUCI_REPO=git://github.com/openwrt/luci.git
PACKAGES_LUCI_COMMIT=70a4d43cc895b7d728b4fc201f2b6fd9f4b8aaec PACKAGES_LUCI_COMMIT=d7328360632d7fbf5fd4006b4172a9fe9861d838
PACKAGES_LUCI_BRANCH=for-15.05

View File

@ -19,6 +19,7 @@
<form method="post" enctype="multipart/form-data" action="<%=REQUEST_URI%>"> <form method="post" enctype="multipart/form-data" action="<%=REQUEST_URI%>">
<div> <div>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script> <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<input type="hidden" name="token" value="<%=token%>" />
<input type="hidden" name="cbi.submit" value="1" /> <input type="hidden" name="cbi.submit" value="1" />
</div> </div>
<% end %> <% end %>

View File

@ -32,11 +32,11 @@ function index()
page.title = _("Wizard") page.title = _("Wizard")
page.target = alias("gluon-config-mode", "wizard") page.target = alias("gluon-config-mode", "wizard")
page.order = 5 page.order = 5
page.setuser = "root" page.sysauth = "root"
page.setgroup = "root" page.sysauth_authenticator = function() return "root" end
page.index = true page.index = true
entry({"gluon-config-mode", "wizard"}, form("gluon-config-mode/wizard")).index = true entry({"gluon-config-mode", "wizard"}, cbi("gluon-config-mode/wizard")).index = true
entry({"gluon-config-mode", "reboot"}, call("action_reboot")) entry({"gluon-config-mode", "reboot"}, call("action_reboot"))
end end
end end

View File

@ -1,56 +0,0 @@
<% if not self.embedded then %>
<form method="post" enctype="multipart/form-data" action="<%=REQUEST_URI%>">
<div>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<input type="hidden" name="cbi.submit" value="1" />
</div>
<% end %>
<div class="cbi-map" id="cbi-<%=self.config%>">
<% if self.title and #self.title > 0 then %><h2><a id="content" name="content"><%=self.title%></a></h2><% end %>
<%- if self.message then %>
<p class="message success"><%=self.message%></p>
<%- end %>
<%- if self.errmessage then %>
<p class="message error"><%=self.errmessage%></p>
<%- end %>
<% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
<% self:render_children() %>
</div>
<% if not self.embedded then %>
<div class="cbi-page-actions">
<%-
if type(self.hidden) == "table" then
for k, v in pairs(self.hidden) do
-%>
<input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
<%-
end
end
%>
<% if redirect then %>
<div style="float:left">
<input class="cbi-button cbi-button-link" type="button" value="<%:Back to Overview%>" onclick="location.href='<%=pcdata(redirect)%>'" />
</div>
<% end %>
<%- if self.flow and self.flow.skip then %>
<input class="cbi-button cbi-button-skip" type="submit" name="cbi.skip" value="<%:Skip%>" />
<% end %>
<%- if self.submit ~= false then %>
<input class="cbi-button cbi-button-save" type="submit" name="cbi.apply" value="
<%- if not self.submit then -%><%-:Submit-%><%-else-%><%=self.submit%><%end-%>
" />
<% end %>
<%- if self.reset ~= false then %>
<input class="cbi-button cbi-button-reset" type="reset" value="
<%- if not self.reset then -%><%-:Reset-%><%-else-%><%=self.reset%><%end-%>
" />
<% end %>
<%- if self.cancel ~= false and self.on_cancel then %>
<input class="cbi-button cbi-button-reset" type="submit" name="cbi.cancel" value="
<%- if not self.cancel then -%><%-:Cancel-%><%-else-%><%=self.cancel%><%end-%>
" />
<% end %>
<script type="text/javascript">cbi_d_update();</script>
</div>
</form>
<% end %>

View File

@ -48,8 +48,8 @@ $Id$
<div class="cbi-page-actions right"> <div class="cbi-page-actions right">
<input type="hidden" name="step" value="2" /> <input type="hidden" name="step" value="2" />
<input type="hidden" name="token" value="<%=token%>" />
<input class="cbi-button cbi-button-apply" type="submit" value="<%:Upload image%>" /> <input class="cbi-button cbi-button-apply" type="submit" value="<%:Upload image%>" />
</div> </div>
</form> </form>
<%+footer%> <%+footer%>

View File

@ -52,16 +52,17 @@ $Id$
</ul> </ul>
</p> </p>
<div class="cbi-page-actions"> <div class="cbi-page-actions">
<form style="display:inline"> <form method="post" action="<%=REQUEST_URI%>" style="display:inline">
<input type="hidden" name="step" value="3" /> <input type="hidden" name="step" value="3" />
<input type="hidden" name="keepcfg" value="<%=keepconfig and "1" or "0"%>" /> <input type="hidden" name="keepcfg" value="<%=keepconfig and "1" or "0"%>" />
<input type="hidden" name="token" value="<%=token%>" />
<input class="cbi-button cbi-button-apply" type="submit" value="<%:Continue%>" /> <input class="cbi-button cbi-button-apply" type="submit" value="<%:Continue%>" />
</form> </form>
<form style="display:inline"> <form method="post" action="<%=REQUEST_URI%>" style="display:inline">
<input type="hidden" name="step" value="1" /> <input type="hidden" name="step" value="1" />
<input type="hidden" name="keepcfg" value="<%=keepconfig and "1" or "0"%>" /> <input type="hidden" name="keepcfg" value="<%=keepconfig and "1" or "0"%>" />
<input type="hidden" name="token" value="<%=token%>" />
<input class="cbi-button cbi-button-reset" type="submit" value="<%:Cancel%>" /> <input class="cbi-button cbi-button-reset" type="submit" value="<%:Cancel%>" />
</form> </form>
</div> </div>
<%+footer%> <%+footer%>

View File

@ -44,6 +44,12 @@ function action_upgrade()
-- Determine state -- Determine state
local step = tonumber(luci.http.formvalue("step") or 1) local step = tonumber(luci.http.formvalue("step") or 1)
if step ~= 1 and not luci.dispatcher.test_post_security() then
nixio.fs.unlink(tmpfile)
return
end
local has_image = nixio.fs.access(tmpfile) local has_image = nixio.fs.access(tmpfile)
local has_support = image_supported(tmpfile) local has_support = image_supported(tmpfile)

View File

@ -18,7 +18,7 @@ local fs = require "nixio.fs"
local m = Map("system", translate("SSH keys")) local m = Map("system", translate("SSH keys"))
m.pageaction = false m.pageaction = false
m.template = "admin/expertmode" m.template = "cbi/simpleform"
if fs.access("/etc/config/dropbear") then if fs.access("/etc/config/dropbear") then
local s = m:section(TypedSection, "_dummy1", nil, local s = m:section(TypedSection, "_dummy1", nil,
@ -58,7 +58,7 @@ end
local m2 = Map("system", translate("Password")) local m2 = Map("system", translate("Password"))
m2.reset = false m2.reset = false
m2.pageaction = false m2.pageaction = false
m2.template = "admin/expertmode" m2.template = "cbi/simpleform"
local s = m2:section(TypedSection, "_dummy2", nil, translate( local s = m2:section(TypedSection, "_dummy2", nil, translate(
"Alternatively, you can set a password to access you node. Please choose a secure password you don't use anywhere else.<br /><br />" "Alternatively, you can set a password to access you node. Please choose a secure password you don't use anywhere else.<br /><br />"

View File

@ -14,7 +14,7 @@ $Id$
m = Map("autoupdater", translate("Automatic updates")) m = Map("autoupdater", translate("Automatic updates"))
m.pageaction = false m.pageaction = false
m.template = "admin/expertmode" m.template = "cbi/simpleform"
s = m:section(TypedSection, "autoupdater", nil) s = m:section(TypedSection, "autoupdater", nil)
s.addremove = false s.addremove = false

View File

@ -2,7 +2,6 @@ local uci = luci.model.uci.cursor()
local util = luci.util local util = luci.util
local f = SimpleForm('mesh_vpn', translate('Mesh VPN')) local f = SimpleForm('mesh_vpn', translate('Mesh VPN'))
f.template = "admin/expertmode"
local s = f:section(SimpleSection) local s = f:section(SimpleSection)

View File

@ -8,7 +8,6 @@ local config = 'gluon-node-info'
local role = uci:get(config, uci:get_first(config, "system"), "role") local role = uci:get(config, uci:get_first(config, "system"), "role")
f = SimpleForm("role", i18n.translate("Node role")) f = SimpleForm("role", i18n.translate("Node role"))
f.template = "admin/expertmode"
s = f:section(SimpleSection, nil, i18n.translate( s = f:section(SimpleSection, nil, i18n.translate(
"If this node has a special role within the freifunk network you can specify this role here. " "If this node has a special role within the freifunk network you can specify this role here. "

View File

@ -21,7 +21,6 @@ local wan6 = uci:get_all("network", "wan6")
local dns = uci:get_first("gluon-wan-dnsmasq", "static") local dns = uci:get_first("gluon-wan-dnsmasq", "static")
local f = SimpleForm("portconfig", translate("WAN connection")) local f = SimpleForm("portconfig", translate("WAN connection"))
f.template = "admin/expertmode"
local s local s
local o local o

View File

@ -8,7 +8,6 @@ local primary_iface = 'wan_radio0'
local ssid = uci:get('wireless', primary_iface, "ssid") local ssid = uci:get('wireless', primary_iface, "ssid")
f = SimpleForm("wifi", translate("Private WLAN")) f = SimpleForm("wifi", translate("Private WLAN"))
f.template = "admin/expertmode"
s = f:section(SimpleSection, nil, translate( s = f:section(SimpleSection, nil, translate(
'Your node can additionally extend your private network by bridging the WAN interface ' 'Your node can additionally extend your private network by bridging the WAN interface '

View File

@ -41,7 +41,6 @@ end
local f = SimpleForm("wifi", translate("WLAN")) local f = SimpleForm("wifi", translate("WLAN"))
f.template = "admin/expertmode"
local s = f:section(SimpleSection, nil, translate( local s = f:section(SimpleSection, nil, translate(
"You can enable or disable your node's client and mesh network " "You can enable or disable your node's client and mesh network "

View File

@ -0,0 +1,5 @@
#!/bin/sh /etc/rc.common
if [ -x /etc/init.d/rpcd ]; then
. /etc/init.d/rpcd
fi

View File

@ -11,3 +11,5 @@ uci -q batch <<-EOF
set uhttpd.main.max_requests=32 set uhttpd.main.max_requests=32
EOF EOF
/etc/init.d/rpcd disable

View File

@ -11,7 +11,7 @@ END__GLUON__CHECK__SITE
endef endef
# Languages supported by LuCi # Languages supported by LuCi
GLUON_SUPPORTED_LANGS := ca zh_cn en fr de el he hu it ja ms no pl pt_br pt ro ru es sv uk vi GLUON_SUPPORTED_LANGS := ca cs de el en es fr he hu it ja ms no pl pt-br pt ro ru sk sv tr uk vi zh-cn zh-tw
GLUON_I18N_PACKAGES := $(foreach lang,$(GLUON_SUPPORTED_LANGS),+LUCI_LANG_$(lang):luci-i18n-base-$(lang)) GLUON_I18N_PACKAGES := $(foreach lang,$(GLUON_SUPPORTED_LANGS),+LUCI_LANG_$(lang):luci-i18n-base-$(lang))
GLUON_I18N_CONFIG := $(foreach lang,$(GLUON_SUPPORTED_LANGS),CONFIG_LUCI_LANG_$(lang)) GLUON_I18N_CONFIG := $(foreach lang,$(GLUON_SUPPORTED_LANGS),CONFIG_LUCI_LANG_$(lang))

View File

@ -0,0 +1,32 @@
From: Felix Fietkau <nbd@nbd.name>
Date: Tue, 23 Aug 2016 10:58:00 +0200
Subject: build: pass $(STAGING_DIR_HOST) to Host/Install
makes it more consistent with package builds
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Backport of LEDE 4170267f5a794eb3fa6bb1718a665e3395077434
diff --git a/include/host-build.mk b/include/host-build.mk
index 44401b866a4d637648bb093470a5e66b4a3e38fc..82d5361e30e897e18f5c9f9c57334c07bb74c490 100644
--- a/include/host-build.mk
+++ b/include/host-build.mk
@@ -110,7 +110,7 @@ define Host/Install/Default
endef
define Host/Install
- $(call Host/Install/Default)
+ $(call Host/Install/Default,$(STAGING_DIR_HOST))
endef
@@ -171,7 +171,7 @@ ifndef DUMP
touch $$@
$(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT) $(if $(FORCE_HOST_INSTALL),FORCE)
- $(call Host/Install)
+ $(call Host/Install,$(STAGING_DIR_HOST))
$(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep))
mkdir -p $$(shell dirname $$@)
touch $(HOST_STAMP_BUILT)

View File

@ -1,14 +0,0 @@
From: Nils Schneider <nils@nilsschneider.net>
Date: Sat, 9 Aug 2014 09:33:21 +0200
Subject: fvalue.html: add label that can be styled
diff --git a/modules/luci-base/luasrc/view/cbi/fvalue.htm b/modules/luci-base/luasrc/view/cbi/fvalue.htm
index a1e0808e8d3e8bf1845d4838b244ed6bb0b605f2..a324ab258a86b080f9bf285aa62ee4db43468a81 100644
--- a/modules/luci-base/luasrc/view/cbi/fvalue.htm
+++ b/modules/luci-base/luasrc/view/cbi/fvalue.htm
@@ -6,4 +6,5 @@
attr("id", cbid) .. attr("name", cbid) .. attr("value", self.enabled or 1) ..
ifattr((self:cfgvalue(section) or self.default) == self.enabled, "checked", "checked")
%> />
+ <label<%= attr("for", cbid)%>></label>
<%+cbi/valuefooter%>

View File

@ -13,7 +13,7 @@ i.e. duplicated values will be removed. Also, order is not preserved.
Signed-off-by: Nils Schneider <nils@nilsschneider.net> Signed-off-by: Nils Schneider <nils@nilsschneider.net>
diff --git a/modules/luci-base/luasrc/model/uci.lua b/modules/luci-base/luasrc/model/uci.lua diff --git a/modules/luci-base/luasrc/model/uci.lua b/modules/luci-base/luasrc/model/uci.lua
index 1659137742940ea0621e2b57e98232f393dc7efa..d35b9d70e27913c9da302c6975a97888774de535 100644 index 577c6cde08eaa6e10887c97b26fed000f3289070..e77cacec5dfeb447085b13d6275edfe873beb3c4 100644
--- a/modules/luci-base/luasrc/model/uci.lua --- a/modules/luci-base/luasrc/model/uci.lua
+++ b/modules/luci-base/luasrc/model/uci.lua +++ b/modules/luci-base/luasrc/model/uci.lua
@@ -9,7 +9,7 @@ local table = require "table" @@ -9,7 +9,7 @@ local table = require "table"
@ -25,7 +25,7 @@ index 1659137742940ea0621e2b57e98232f393dc7efa..d35b9d70e27913c9da302c6975a97888
local type, tostring, tonumber, unpack = type, tostring, tonumber, unpack local type, tostring, tonumber, unpack = type, tostring, tonumber, unpack
-- The typical workflow for UCI is: Get a cursor instance from the -- The typical workflow for UCI is: Get a cursor instance from the
@@ -147,6 +147,40 @@ function Cursor.set_list(self, config, section, option, value) @@ -150,6 +150,40 @@ function Cursor.set_list(self, config, section, option, value)
return false return false
end end
@ -67,10 +67,10 @@ index 1659137742940ea0621e2b57e98232f393dc7efa..d35b9d70e27913c9da302c6975a97888
function Cursor._affected(self, configlist) function Cursor._affected(self, configlist)
configlist = type(configlist) == "table" and configlist or {configlist} configlist = type(configlist) == "table" and configlist or {configlist}
diff --git a/modules/luci-base/luasrc/model/uci.luadoc b/modules/luci-base/luasrc/model/uci.luadoc diff --git a/modules/luci-base/luasrc/model/uci.luadoc b/modules/luci-base/luasrc/model/uci.luadoc
index 1c208669d17f24d2d1de99bbbf1cefe878649014..281bdb2953ee1888ee41d8d0fb1cc40e9345b3e0 100644 index 49093c7930128f1e6de6f739662b96adcc43fe74..cfec9eea7922da551cb8d2a4f2c540d479b8ccbe 100644
--- a/modules/luci-base/luasrc/model/uci.luadoc --- a/modules/luci-base/luasrc/model/uci.luadoc
+++ b/modules/luci-base/luasrc/model/uci.luadoc +++ b/modules/luci-base/luasrc/model/uci.luadoc
@@ -116,6 +116,30 @@ Set given values as list. @@ -118,6 +118,30 @@ has the same effect as deleting the option.
]] ]]
---[[ ---[[

View File

@ -1,28 +0,0 @@
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Thu, 19 Mar 2015 18:44:52 +0100
Subject: modules/base: dispatcher: set default language if none provided by the browser matches
diff --git a/modules/luci-base/luasrc/dispatcher.lua b/modules/luci-base/luasrc/dispatcher.lua
index 25269501068dd26efe5b85706b555996d63b0f6d..be2fc3453f528853519649e4b64ecb3fd14d80be 100644
--- a/modules/luci-base/luasrc/dispatcher.lua
+++ b/modules/luci-base/luasrc/dispatcher.lua
@@ -182,6 +182,7 @@ function dispatch(request)
assert(conf.main,
"/etc/config/luci seems to be corrupt, unable to find section 'main'")
+ local i18n = require "luci.i18n"
local lang = conf.main.lang or "auto"
if lang == "auto" then
local aclang = http.getenv("HTTP_ACCEPT_LANGUAGE") or ""
@@ -193,7 +194,10 @@ function dispatch(request)
end
end
end
- require "luci.i18n".setlanguage(lang)
+ if lang == "auto" then
+ lang = i18n.default
+ end
+ i18n.setlanguage(lang)
local c = ctx.tree
local stat

View File

@ -1,32 +0,0 @@
From: Jan-Philipp Litza <janphilipp@litza.de>
Date: Sun, 30 Aug 2015 15:42:52 +0200
Subject: luci-lib-jsonc: Ignore non-string-or-number keys in tables
Previously, the following caused a segmentation fault:
json.stringify({[{}] = true})
This was caused by lua_tostring() returning NULL for anything but
strings and numbers, letting json_object_object_add crash.
This patch makes jsonc ignore all keys which have no string
representation altogether.
Signed-off-by: Jan-Philipp Litza <janphilipp@litza.de>
diff --git a/libs/luci-lib-jsonc/src/jsonc.c b/libs/luci-lib-jsonc/src/jsonc.c
index 49cb21f5bcb2817792d0eef8dc5cd567bc6d86bc..827fde8843082e956b0c89b5855feeabd790e880 100644
--- a/libs/luci-lib-jsonc/src/jsonc.c
+++ b/libs/luci-lib-jsonc/src/jsonc.c
@@ -286,8 +286,9 @@ static struct json_object * _lua_to_json(lua_State *L, int index)
lua_pushvalue(L, -2);
key = lua_tostring(L, -1);
- json_object_object_add(obj, key,
- _lua_to_json(L, lua_gettop(L) - 1));
+ if (key)
+ json_object_object_add(obj, key,
+ _lua_to_json(L, lua_gettop(L) - 1));
lua_pop(L, 2);
}

View File

@ -1,38 +0,0 @@
From: Jan-Philipp Litza <janphilipp@litza.de>
Date: Sun, 30 Aug 2015 15:45:49 +0200
Subject: luci-lib-jsonc: allow encoding empty lists
To be consistent with the behavior of luci-lib-json, an empty Lua table
should be encoded to an empty JSON list, not an empty JSON object.
To still allow encoding empty JSON objects, the usage of anything other
than a number or a string as a key (for example an empty table or a
function) can be used to force encoding as an object:
json.stringify({}) -- "[]"
json.stringify({[{}] = true}) -- "{}"
Signed-off-by: Jan-Philipp Litza <janphilipp@litza.de>
diff --git a/libs/luci-lib-jsonc/src/jsonc.c b/libs/luci-lib-jsonc/src/jsonc.c
index 827fde8843082e956b0c89b5855feeabd790e880..971fb122f7655b379e717ef78a5417032ead9a57 100644
--- a/libs/luci-lib-jsonc/src/jsonc.c
+++ b/libs/luci-lib-jsonc/src/jsonc.c
@@ -222,7 +222,7 @@ static int _lua_test_array(lua_State *L, int index)
out:
lua_pop(L, 2);
- return 0;
+ return -1;
}
/* check for holes */
@@ -254,7 +254,7 @@ static struct json_object * _lua_to_json(lua_State *L, int index)
case LUA_TTABLE:
max = _lua_test_array(L, index);
- if (max > 0)
+ if (max >= 0)
{
obj = json_object_new_array();

View File

@ -1,16 +0,0 @@
From: Jan-Philipp Litza <janphilipp@litza.de>
Date: Mon, 31 Aug 2015 19:52:36 +0200
Subject: luci-lib-jsonc: Fix memory leak in stringify()
diff --git a/libs/luci-lib-jsonc/src/jsonc.c b/libs/luci-lib-jsonc/src/jsonc.c
index 971fb122f7655b379e717ef78a5417032ead9a57..b857c979e93bec395bca164a4f144c7c69005bec 100644
--- a/libs/luci-lib-jsonc/src/jsonc.c
+++ b/libs/luci-lib-jsonc/src/jsonc.c
@@ -106,6 +106,7 @@ static int json_stringify(lua_State *L)
flags |= JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED;
lua_pushstring(L, json_object_to_json_string_ext(obj, flags));
+ json_object_put(obj);
return 1;
}

View File

@ -1,133 +0,0 @@
From: Jan-Philipp Litza <janphilipp@litza.de>
Date: Tue, 1 Sep 2015 16:17:23 +0200
Subject: luci-lib-jsonc: Add ltn12-compatible sink factory
To use the luci-lib-jsonc parser as sink for an ltn12 pump (for example
from stdin), the following code will now do:
require 'luci.ltn12'
require 'luci.jsonc'
local parser = luci.jsonc.new()
luci.ltn12.pump.all(luci.ltn12.source.file(io.input()), parser:sink())
print(parser:get())
Signed-off-by: Jan-Philipp Litza <janphilipp@litza.de>
diff --git a/libs/luci-lib-jsonc/src/jsonc.c b/libs/luci-lib-jsonc/src/jsonc.c
index b857c979e93bec395bca164a4f144c7c69005bec..ef1110166055a78bf32cf1a6fbbd3e356b2bce3f 100644
--- a/libs/luci-lib-jsonc/src/jsonc.c
+++ b/libs/luci-lib-jsonc/src/jsonc.c
@@ -328,6 +328,76 @@ static int json_parse_set(lua_State *L)
return 0;
}
+static int json_parse_sink_closure(lua_State *L)
+{
+ bool finished = lua_toboolean(L, lua_upvalueindex(2));
+ if (lua_isnil(L, 1))
+ {
+ // no more data available
+ if (finished)
+ {
+ // we were finished parsing
+ lua_pushboolean(L, true);
+ return 1;
+ }
+ else
+ {
+ lua_pushnil(L);
+ lua_pushstring(L, "Incomplete JSON data");
+ return 2;
+ }
+ }
+ else
+ {
+ if (finished)
+ {
+ lua_pushnil(L);
+ lua_pushstring(L, "Unexpected data after complete JSON object");
+ return 2;
+ }
+ else
+ {
+ // luci.jsonc.parser.chunk()
+ lua_pushcfunction(L, json_parse_chunk);
+ // parser object from closure
+ lua_pushvalue(L, lua_upvalueindex(1));
+ // chunk
+ lua_pushvalue(L, 1);
+ lua_call(L, 2, 2);
+
+ if (lua_isnil(L, -2))
+ {
+ // an error occurred, leave (nil, errmsg) on the stack and return it
+ return 2;
+ }
+ else if (lua_toboolean(L, -2))
+ {
+ // finished reading, set finished=true and return nil to prevent further input
+ lua_pop(L, 2);
+ lua_pushboolean(L, true);
+ lua_replace(L, lua_upvalueindex(2));
+ lua_pushnil(L);
+ return 1;
+ }
+ else
+ {
+ // not finished reading, return true
+ lua_pop(L, 2);
+ lua_pushboolean(L, true);
+ return 1;
+ }
+ }
+ }
+}
+
+static int json_parse_sink(lua_State *L)
+{
+ luaL_checkudata(L, 1, LUCI_JSONC_PARSER);
+ lua_pushboolean(L, false);
+ lua_pushcclosure(L, json_parse_sink_closure, 2);
+ return 1;
+}
+
static int json_tostring(lua_State *L)
{
struct json_state *s = luaL_checkudata(L, 1, LUCI_JSONC_PARSER);
@@ -367,6 +437,7 @@ static const luaL_reg jsonc_parser_methods[] = {
{ "parse", json_parse_chunk },
{ "get", json_parse_get },
{ "set", json_parse_set },
+ { "sink", json_parse_sink },
{ "stringify", json_tostring },
{ "__gc", json_gc },
diff --git a/libs/luci-lib-jsonc/src/jsonc.luadoc b/libs/luci-lib-jsonc/src/jsonc.luadoc
index 2ee9cebdc889242595f5281228783df15b9b8dcd..720b17d1eb76d8eb9a8b47939ac724891cfb3886 100644
--- a/libs/luci-lib-jsonc/src/jsonc.luadoc
+++ b/libs/luci-lib-jsonc/src/jsonc.luadoc
@@ -121,10 +121,22 @@ parser:set({ "some", "data" })`
]]
---[[
-Serialize current parser state as JSON.
+Generate an ltn12-compatible sink.
@class function
@sort 4
+@name parser.sink
+@return Returns a function that can be used as an ltn12 sink.
+@usage `parser = luci.jsonc.new()
+ltn12.pump.all(ltn12.source.file(io.input()), parser:sink())
+print(parser:get())`
+]]
+
+---[[
+Serialize current parser state as JSON.
+
+@class function
+@sort 5
@name parser.stringify
@param pretty A boolean value indicating whether the resulting JSON should be pretty printed.
@return Returns the serialized JSON data of this parser instance.

View File

@ -1,33 +0,0 @@
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Sun, 6 Sep 2015 01:27:06 +0200
Subject: Move rpcd dependency from luci-base to luci-mode-rpc
LuCI's authentication won't work without rpcd, but we aren't using the
authentication anyways. Users who need it can just install rpcd explicitly.
diff --git a/modules/luci-base/Makefile b/modules/luci-base/Makefile
index 54506b023a728e071b8fb4983ef614897363c0ec..4457034ada02972908a68f7c9c54352e7ac3c054 100644
--- a/modules/luci-base/Makefile
+++ b/modules/luci-base/Makefile
@@ -12,7 +12,7 @@ LUCI_TYPE:=mod
LUCI_BASENAME:=base
LUCI_TITLE:=LuCI core libraries
-LUCI_DEPENDS:=+lua +libuci-lua +luci-lib-nixio +luci-lib-ip +rpcd +libubus-lua
+LUCI_DEPENDS:=+lua +libuci-lua +luci-lib-nixio +luci-lib-ip +libubus-lua
PKG_SOURCE:=LuaSrcDiet-0.12.1.tar.bz2
PKG_SOURCE_URL:=https://luasrcdiet.googlecode.com/files
diff --git a/modules/luci-mod-rpc/Makefile b/modules/luci-mod-rpc/Makefile
index e64c86c6283a5a7d1181816e9f148d78d15c7dd8..5f64a14d48ef1f74435e151bc03a2377239be1f8 100644
--- a/modules/luci-mod-rpc/Makefile
+++ b/modules/luci-mod-rpc/Makefile
@@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI RPC - JSON-RPC API
-LUCI_DEPENDS:=+luci-lib-json
+LUCI_DEPENDS:=+luci-lib-json +rpcd
include ../../luci.mk