summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRoland Stigge <stigge@antcom.de>2018-01-08 16:57:47 +0100
committerRoland Stigge <stigge@antcom.de>2018-01-08 16:57:47 +0100
commitd8eae5827b2599bb1fb125aed47d73bf82d1ff10 (patch)
tree97c835f8580e4eb102185b2a7cbbe9c2e559db5f
parent34f772d353839b5febcc0cad2a54e29716dcb6c8 (diff)
Debian package, fix list xml
-rw-r--r--Makefile16
-rw-r--r--TODO6
-rw-r--r--apache/localhost.conf2
-rw-r--r--debian/README.Debian100
-rw-r--r--debian/changelog5
-rw-r--r--debian/compat1
-rw-r--r--debian/control16
-rw-r--r--debian/copyright5
-rwxr-xr-xdebian/rules5
-rw-r--r--debian/source/format1
-rw-r--r--html/webbox.js24
-rw-r--r--src/Makefile3
-rw-r--r--src/webbox.cpp41
13 files changed, 210 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index cae9e7c..dd411cf 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,22 @@
+DESTDIR=
+
all:
make -C src
install: all
+ mkdir -p $(DESTDIR)/var/www/webbox
+ cp -r html/* $(DESTDIR)/var/www/webbox/
+ mkdir -p $(DESTDIR)/usr/lib/webbox
+ cp src/query $(DESTDIR)/usr/lib/webbox/
+
+
+deploy: all
sudo service apache2 stop
- sudo cp -r html/* /var/www/webbox/
- sudo mkdir -p /usr/lib/webbox
- sudo cp src/query /usr/lib/webbox/
+ sudo make install
sudo service apache2 start
+deb:
+ dpkg-buildpackage -us -uc -rfakeroot
+
clean:
make -C src clean
diff --git a/TODO b/TODO
index 7d69bdb..13e29e2 100644
--- a/TODO
+++ b/TODO
@@ -1,11 +1,14 @@
Prio 1 (for next version)
======
-debian/
+mobile: font size
+mobile: escape in menu
+
Prio 2 (for future versions)
======
+rename
handle errors from http
gallery
chromecast
@@ -15,3 +18,4 @@ register GET/POST functions
handle too small popup window
sandclock during operations
i18n
+forward/back button
diff --git a/apache/localhost.conf b/apache/localhost.conf
index 160dbe3..e74f680 100644
--- a/apache/localhost.conf
+++ b/apache/localhost.conf
@@ -26,6 +26,8 @@
Require all granted
</Directory>
+ Alias /webbox /var/www/webbox
+
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
diff --git a/debian/README.Debian b/debian/README.Debian
new file mode 100644
index 0000000..65db4e4
--- /dev/null
+++ b/debian/README.Debian
@@ -0,0 +1,100 @@
+webbox for Debian
+=================
+
+This package is implemented as a FastCGI application in Apache.
+
+After installing this package and its dependencies, the following
+directories are relevant:
+
+* Webbox FCGI Application directory: /usr/lib/webbox
+
+* Webbox HTML directory: /var/www/webbox
+
+ This directory is part of the webbox package and contains all static
+ contents to be served by apache as web UI interface of webbox.
+
+ In an Apache configuration, this directory is specified as
+ DocumentRoot or Alias.
+
+* Webbox directory(s): e.g. /home/webbox
+
+ This directory or directories contain the actual contents to be served.
+ It can be specified multiple times in an Apache configuration to
+ implement several webboxes in one server.
+
+ The contained files need to be owned by the www-data user.
+
+ This directory is specified via the WEBBOX_PATH environment variable.
+
+
+File browser
+------------
+
+The file browser can be used via the URL
+
+http://<servername>/<path>
+
+where servername is the host name served as VirtualHost by Apache
+and <path> is the Alias configured in the Apache configuration for
+the actual files (or DocumentRoot if no <path> component is
+required).
+
+All files readable by the user www-data are served, except for
+hidden files (i.e. beginning with a ".").
+
+
+Environment Variables
+---------------------
+
+The following environment variables are supported:
+
+WEBBOX_PATH
+
+ Directory with the payload files to be served by a webbox.
+
+WEBBOX_NAME
+
+ Title of the webbox. Will be written on top of the Web UI.
+
+
+Example configuration for Apache
+--------------------------------
+
+The following configuration can be included (and adjusted) in an Apache
+VirtualHost configuration:
+
+ # Define the URL of the webbox served by the Apache server:
+ # http://<servername>/testbox
+ Alias /testbox /var/www/webbox
+
+ # Actual location of files to be served
+ FcgidInitialEnv WEBBOX_PATH /home/testbox
+
+ # Title of the Webbox
+ FcgidInitialEnv WEBBOX_NAME Testbox
+
+ # Maximum transfer size supported is defined by this Fcgid parameter.
+ # Note that the actual filesize will be smaller due to different
+ # encoding schemes
+ FcgidMaxRequestLen 100000000
+
+ # The following makes the FastCGI application part of Webbox available
+ # to the user. The static HTML pages of webbox always access the
+ # FastCGI part via http://<servername>/bin/
+ ScriptAlias /bin/ /usr/lib/webbox/
+ <Directory "/usr/lib/webbox">
+ SetHandler fcgid-script
+
+ AllowOverride None
+ Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
+ # Order allow,deny
+ # Allow from all
+ Require all granted
+ </Directory>
+
+
+Contact
+-------
+
+Reichwein IT <mail@reichwein.it>
+
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..db2e3e2
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,5 @@
+webbox (1.0) unstable; urgency=medium
+
+ * Initial release
+
+ -- Roland Reichwein <mail@reichwein.it> Mon, 08 Jan 2018 10:31:20 +0100
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..ec63514
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+9
diff --git a/debian/control b/debian/control
index 7725dc4..8c4e16d 100644
--- a/debian/control
+++ b/debian/control
@@ -1 +1,15 @@
-Depends: zip
+Source: webbox
+Section: web
+Priority: extra
+Maintainer: Roland Reichwein <mail@reichwein.it>
+Build-Depends: debhelper (>= 9), qtbase5-dev, libfcgi-dev
+Standards-Version: 4.1.3
+Homepage: http://www.reichwein.it/webbox/
+
+Package: webbox
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, zip, apache2, apache2-bin, libapache2-mod-fcgid
+Homepage: http://www.reichwein.it/webbox/
+Description: Web file manager
+ Webbox is a web file manager using HTML5 with support for desktop and mobile
+ browsers.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..a9838e7
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,5 @@
+This package is Copyright 2018 by Reichwein.IT
+Roland Reichwein <mail@reichwein.it>
+
+Commercial licensing is available.
+
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..abde6ef
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,5 @@
+#!/usr/bin/make -f
+
+%:
+ dh $@
+
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..89ae9db
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (native)
diff --git a/html/webbox.js b/html/webbox.js
index 071137c..dd57966 100644
--- a/html/webbox.js
+++ b/html/webbox.js
@@ -189,6 +189,7 @@ function entryMouseUp(filename) {
} else if (type == "dir") {
if (filename == "..") {
if (!currentDir.includes("/")) {
+ // error: this shouldn't happen
alert("Bad path " + currentDir + " for " + filename);
return;
}
@@ -215,6 +216,7 @@ function entryMouseUp(filename) {
function showDialog() {
document.getElementById("greyout").style.display = 'block';
document.getElementById("dialogwindow").style.display = 'block';
+ document.getElementById("okbutton").focus();
}
function hideDialog() {
@@ -238,7 +240,7 @@ function initMainpage() {
// default action for "Cancel" button: hide dialog window
document.getElementById("cancelbutton").onclick = hideDialog;
- // on Escape, hide dialog window
+ // on Escape, globally hide dialog and menu window
document.onkeydown = function(evt) {
if (evt.key == "Escape") {
hideDialog();
@@ -352,6 +354,7 @@ function createDir() {
document.getElementById("dialog").innerHTML = xhr.responseText;
document.getElementById("okbutton").onclick = hideDialog;
+ document.getElementById("okbutton").focus();
loadContents(currentDir); // load new file list with new dir
}
@@ -368,7 +371,7 @@ function createDir() {
document.getElementById("dialog").innerHTML = document.getElementById("create-dir-dialog").innerHTML;
document.getElementById("newdir").focus();
-
+
document.getElementById("newdir").onkeydown = function(evt) {
if (evt.key == "Enter") {
document.getElementById("okbutton").click();
@@ -382,6 +385,7 @@ function upload() {
uploadfile.click();
}
+// Callback on selected and uploaded file
function onUploadFile() {
var xhr = new XMLHttpRequest();
@@ -390,12 +394,23 @@ function onUploadFile() {
return;
}
+ showDialog();
+ var message = "";
+
if (xhr.responseText == "OK") {
- alert("Upload successful.");
+ message = "Upload successful.";
loadContents(currentDir); // load new file list with uploaded file
} else {
- alert("Error: " + xhr.responseText);
+ message = "Error: " + xhr.responseText;
+ }
+
+ document.getElementById("dialog").innerHTML = message;
+ document.getElementById("cancelbutton").style.display = "none";
+ document.getElementById("okbutton").onclick = function() {
+ hideDialog();
+ document.getElementById("cancelbutton").style.display = "block";
}
+ document.getElementById("okbutton").focus();
}
var uploadfile = document.getElementById("uploadfile");
@@ -490,6 +505,7 @@ function move() {
document.getElementById("dialog").innerHTML = xhr.responseText;
document.getElementById("okbutton").onclick = hideDialog;
+ document.getElementById("okbutton").focus();
loadContents(currentDir); // load new file list with deleted items
}
diff --git a/src/Makefile b/src/Makefile
index e960f67..d7f3847 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,5 +1,6 @@
+ARCH=$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
TARGET=query
-CPPFLAGS=-Wall -O2 -fPIC -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtCore
+CPPFLAGS=-Wall -O2 -fPIC -I/usr/include/$(ARCH)/qt5 -I/usr/include/$(ARCH)/qt5/QtCore
LDFLAGS=-Wall -O2 -fPIC -lstdc++ -lfcgi -lQt5Core
OBJS=webbox.o
diff --git a/src/webbox.cpp b/src/webbox.cpp
index 71f023c..e991266 100644
--- a/src/webbox.cpp
+++ b/src/webbox.cpp
@@ -6,6 +6,7 @@
#include <QDir>
#include <QFileInfo>
#include <QXmlStreamReader>
+#include <QXmlStreamWriter>
#include <QDateTime>
#include <QProcess>
#include <QTemporaryFile>
@@ -13,6 +14,25 @@
#define PROGRAMVERSION "1.0"
#define BUFSIZE 1000000
+// XML special characters:
+// < : &lt;
+// > : &gt;
+// & : &amp;
+// " : &quot;
+// ' : &apos;
+//
+// here:replace &
+QString escapeXML(QString s) {
+ s.replace("&", "&amp;");
+ return s;
+}
+
+// revert escapeXML();
+QString unescapeXML(QString s) {
+ s.replace("&amp;", "&");
+ return s;
+}
+
// supported httpStatusCode:
// 400 Bad Request
// 403 Forbidden
@@ -101,6 +121,8 @@ int main(int argc, char* argv[]) {
QString path = webboxPath + pathInfo;
+#if 0
+ // only for debugging
if (command == "diag") {
FCGX_PutS("Content-Type: text/html\r\n\r\n", request.out);
@@ -119,19 +141,28 @@ int main(int argc, char* argv[]) {
FCGX_PutS("</body></html>\r\n", request.out);
} else
+#endif
if (command == "list") {
FCGX_PutS("Content-Type: text/xml\r\n\r\n", request.out);
- FCGX_PutS("<list>\r\n", request.out);
-
QDir dir(path);
- QFileInfoList dirEntryList = dir.entryInfoList(QDir::NoDot | QDir::AllEntries, QDir::DirsFirst | QDir::Name);
+ QFileInfoList dirEntryList = dir.entryInfoList(QDir::NoDot | QDir::AllEntries, QDir::DirsFirst | QDir::Name | QDir::IgnoreCase);
+
+ QByteArray xmlData;
+ QXmlStreamWriter xmlWriter(&xmlData);
+ xmlWriter.writeStartDocument();
+ xmlWriter.writeStartElement("list");
foreach(QFileInfo i, dirEntryList) {
if (pathInfo != "/" || i.fileName() != "..") { // skip on ".." in "/"
- FCGX_PutS(QString("<listentry type=\"%1\">%2</listentry>\r\n").arg(i.isDir() ? "dir" : "file").arg(i.fileName()).toUtf8().data(), request.out);
+ xmlWriter.writeStartElement("listentry");
+ xmlWriter.writeAttribute("type", i.isDir() ? "dir" : "file");
+ xmlWriter.writeCharacters(i.fileName());
+ xmlWriter.writeEndElement();
}
}
- FCGX_PutS("</list>\r\n", request.out);
+ xmlWriter.writeEndElement(); // list
+ xmlWriter.writeEndDocument();
+ FCGX_PutS(xmlData.data(), request.out);
} else if (command == "title") {
FCGX_PutS("Content-Type: text/plain\r\n\r\n", request.out);
FCGX_PutS(getenv("WEBBOX_NAME"), request.out);