[Libreoffice-commits] online.git: 2 commits - loleaflet/dist loolwsd/configure.ac loolwsd/FileServer.hpp loolwsd/Makefile.am loolwsd/test
Jan Holesovsky
kendy at collabora.com
Wed Apr 13 16:43:22 UTC 2016
loleaflet/dist/loleaflet.html | 34 ++++++++++++++++++++++++----------
loolwsd/FileServer.hpp | 13 +++----------
loolwsd/Makefile.am | 4 +++-
loolwsd/configure.ac | 2 ++
loolwsd/test/data/hello.odt |binary
5 files changed, 32 insertions(+), 21 deletions(-)
New commits:
commit efb67d68fd0ee08bf25b91e1a03489f54d2fdf8b
Author: Jan Holesovsky <kendy at collabora.com>
Date: Wed Apr 13 18:31:10 2016 +0200
The host= parameter for loleaflet.html does not exist any more.
Now loolwsd fills that in directly.
Also show http:// or https:// in 'make run' according to the configuration.
diff --git a/loolwsd/Makefile.am b/loolwsd/Makefile.am
index 41d58c8..ccd729b 100644
--- a/loolwsd/Makefile.am
+++ b/loolwsd/Makefile.am
@@ -105,7 +105,9 @@ clean-local:
run: @JAILS_PATH@ @SYSTEMPLATE_PATH@/system_stamp
@echo "Launching loolwsd - launch this in your browser:"
- @echo " https://localhost:9980/loleaflet/dist/loleaflet.html?file_path=file://$(abs_top_srcdir)/test/data/hello.odt&host=wss://localhost:9980"
+ @PROTOCOL="http" ; if test "z at ENABLE_SSL@" != "z"; then PROTOCOL="https" ; fi ; \
+ echo " $$PROTOCOL://localhost:9980/loleaflet/dist/loleaflet.html?file_path=file://$(abs_top_srcdir)/test/data/hello.odt"
+ @echo
./loolwsd --systemplate="@SYSTEMPLATE_PATH@" --lotemplate="@LO_PATH@" \
--childroot="@JAILS_PATH@" --allowlocalstorage
else
diff --git a/loolwsd/configure.ac b/loolwsd/configure.ac
index ce4f255..c16e242 100644
--- a/loolwsd/configure.ac
+++ b/loolwsd/configure.ac
@@ -177,6 +177,8 @@ else
ssl_msg="insecure: ssl disabled"
fi
+AC_SUBST(ENABLE_SSL)
+
LIBS="$LIBS -lPocoNet${POCO_DEBUG_SUFFIX} -lPocoUtil${POCO_DEBUG_SUFFIX} -lPocoJSON${POCO_DEBUG_SUFFIX} -lPocoFoundation${POCO_DEBUG_SUFFIX} -lPocoXML${POCO_DEBUG_SUFFIX} -lPocoNetSSL${POCO_DEBUG_SUFFIX} -lPocoCrypto${POCO_DEBUG_SUFFIX}"
AC_CHECK_HEADERS([LibreOfficeKit/LibreOfficeKit.h],
diff --git a/loolwsd/test/data/hello.odt b/loolwsd/test/data/hello.odt
index d6e9c2d..fcd047a 100644
Binary files a/loolwsd/test/data/hello.odt and b/loolwsd/test/data/hello.odt differ
commit b09b6eab891d5f4bcf1a09d03edb9d58f1da649e
Author: Jan Holesovsky <kendy at collabora.com>
Date: Wed Apr 13 18:24:19 2016 +0200
Only the access_token (and _ttl) is supposed to be passed via the form post.
diff --git a/loleaflet/dist/loleaflet.html b/loleaflet/dist/loleaflet.html
index c8f442b..2012fb1 100644
--- a/loleaflet/dist/loleaflet.html
+++ b/loleaflet/dist/loleaflet.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<!-- saved from url=(0054)http://leafletjs.com/examples/quick-start-example.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<title>Document Simple Example</title>
+<title>Online Editor</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -260,22 +260,36 @@
</style>
<script>
- var wopiSrc = 'WOPISRC';
- var filePath = 'FILEPATH';
- var title = 'TITLE';
+ function getParameterByName(name) {
+ name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
+ var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
+ results = regex.exec(location.search);
+ return results === null ? "" : results[1].replace(/\+/g, " ");
+ }
+
+ var wopiSrc = getParameterByName('WOPISrc');
+ var access_token = '%ACCESS_TOKEN%';
+ if (wopiSrc !== '' && access_token !== '') {
+ wopiSrc += '?access_token=' + access_token;
+ }
+
+ var filePath = getParameterByName('file_path');
+ var title = getParameterByName('title');
if (title === '') {
title = decodeURIComponent(filePath.substring(filePath.lastIndexOf('/')+1));
}
- var host = 'HOST';
- var permission = 'PERMISSION';
- var timestamp = 'TIMESTAMP';
- var closebutton = 'CLOSEBUTTON';
+
+ var host = '%HOST%';
+ var permission = getParameterByName('permission');
+ var timestamp = getParameterByName('timestamp');
+ var closebutton = getParameterByName('closebutton');
if (wopiSrc === '' && filePath === '') {
- vex.dialog.alert('Wrong WOPISrc, usage: WOPISrc=valid encoded URI, or file_path, usage: file_path=/path/to/doc/');
+ vex.dialog.alert('Wrong WOPISrc, usage: WOPISrc=valid encoded URI, or file_path, usage: file_path=/path/to/doc/');
}
if (host === '') {
- vex.dialog.alert('The host URL is empty, usage: host=wss://localhost:9980');
+ vex.dialog.alert('The host URL is empty. The loolwsd server is probably misconfigured, please contact the administrator.');
}
+
var docURL = wopiSrc !== '' ? wopiSrc : filePath;
document.title = title;
diff --git a/loolwsd/FileServer.hpp b/loolwsd/FileServer.hpp
index 250301b..2941c35 100644
--- a/loolwsd/FileServer.hpp
+++ b/loolwsd/FileServer.hpp
@@ -120,22 +120,15 @@ public:
requestUri.normalize(); // avoid .'s and ..'s
const auto path = Poco::Path(LOOLWSD::FileServerRoot, requestUri.getPath());
- const auto wopi = form.has("WOPISrc") ?
- form.get("WOPISrc") + "?access_token=" + form.get("access_token","") : "";
-
Log::debug("Preprocessing file: " + path.toString());
FileInputStream file(path.toString());
StreamCopier::copyToString(file, preprocess);
file.close();
- Poco::replaceInPlace(preprocess, std::string("WOPISRC"), wopi);
- Poco::replaceInPlace(preprocess, std::string("HOST"), form.get("host", host));
- Poco::replaceInPlace(preprocess, std::string("FILEPATH"), form.get("file_path", ""));
- Poco::replaceInPlace(preprocess, std::string("TITLE"), form.get("title", ""));
- Poco::replaceInPlace(preprocess, std::string("PERMISSION"), form.get("permission", ""));
- Poco::replaceInPlace(preprocess, std::string("TIMESTAMP"), form.get("timestamp", ""));
- Poco::replaceInPlace(preprocess, std::string("CLOSEBUTTON"), form.get("closebutton", ""));
+ Poco::replaceInPlace(preprocess, std::string("%ACCESS_TOKEN%"), form.get("access_token", ""));
+ Poco::replaceInPlace(preprocess, std::string("%ACCESS_TOKEN_TTL%"), form.get("access_token_ttl", ""));
+ Poco::replaceInPlace(preprocess, std::string("%HOST%"), host);
response.setContentType("text/html");
response.setContentLength(preprocess.length());
diff --git a/loolwsd/test/data/hello.odt b/loolwsd/test/data/hello.odt
index 9624a1c..d6e9c2d 100644
Binary files a/loolwsd/test/data/hello.odt and b/loolwsd/test/data/hello.odt differ
More information about the Libreoffice-commits
mailing list