diff --git a/.gitignore b/.gitignore index b078b75..182c522 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ Release *.o *.o.d *.mk - +.vscode/** diff --git a/HTTPConnection.h b/HTTPConnection.h index c0f3c5d..7b306e2 100644 --- a/HTTPConnection.h +++ b/HTTPConnection.h @@ -14,7 +14,7 @@ namespace http { void onDataReceived(char *data, int len) override { - coreutils::Log(coreutils::LOG_DEBUG_1) << data; +// coreutils::Log(coreutils::LOG_DEBUG_1) << data; protocol(std::string(data, len)); send(); diff --git a/HTTPPage.h b/HTTPPage.h index dcafa15..da5737c 100644 --- a/HTTPPage.h +++ b/HTTPPage.h @@ -9,11 +9,13 @@ namespace http { class HTTPPage : public core::Object { - - public: + + public: bool check(std::string request) { if(request != "") { - if(name.length() > 0) { + if(request.find("?") != -1) + request = request.substr(0, request.find("?")); + if(name.length() > 0) { if(name == request) return true; } @@ -22,14 +24,14 @@ namespace http { return false; } - virtual int processCommand(std::string request, - core::TCPSession *session, - HTTPSession *httpSession, - HTTPRequest *httpRequest, + virtual int processCommand(std::string request, + core::TCPSession *session, + HTTPSession *httpSession, + HTTPRequest *httpRequest, std::stringstream &data) { return false; } - + }; } diff --git a/HTTPServer b/HTTPServer index 309bd8b..3a37bee 100755 Binary files a/HTTPServer and b/HTTPServer differ diff --git a/__editview.h b/__editview.h index 48c340e..0dd21b6 100644 --- a/__editview.h +++ b/__editview.h @@ -2,6 +2,7 @@ #define ____editview_h__ #include "HTTPPage.h" +#include "File.h" namespace http { @@ -23,7 +24,11 @@ namespace http { data << " " << std::endl; data << "" << std::endl; - data << "
" << std::endl; + coreutils::File workspace("/home/barant/jetserver/views/testview1.view"); + workspace.read(); + data << "
"; + data << workspace.asString(); + data << "
" << std::endl; data << "" << std::endl; data << "
parseFloat(mainpage.style.width)) - dragobject.style.left = (mouseX - mousedownx) + "px"; - } else if(dragHint == "rightbottomresize") { + if((mouseX - mousedownx + parseFloat(dragobject.style.width)) > parseFloat(mainpage.style.width)) + dragobject.style.left = (mouseX - mousedownx) + "px"; + } else if(dragHint == "rightbottomresize") { dragobject.style.width = (mouseX - mouseDownLeft) + "px"; dragobject.style.height = (mouseY - mouseDownTop) + "px"; - } else if(dragHint == "rightresize") { + } else if(dragHint == "rightresize") { if(snapToGrid == false) { - dragobject.style.width = (mouseX - mouseDownLeft) + "px"; + dragobject.style.width = (mouseX - mouseDownLeft) + "px"; } else { - dragobject.style.width = (Math.round((mouseX - mouseDownLeft) / gridSize) * gridSize) + "px"; + dragobject.style.width = (Math.round((mouseX - mouseDownLeft) / gridSize) * gridSize) + "px"; } - } else if(dragHint == "bottomresize") { + } else if(dragHint == "bottomresize") { if(snapToGrid == false) { dragobject.style.height = (mouseY - mouseDownTop) + "px"; } else { dragobject.style.height = (Math.round((mouseY - mouseDownTop) / gridSize) * gridSize) + "px"; } - } else if(dragHint == "leftresize") { + } else if(dragHint == "leftresize") { dragobject.style.left = mouseX + "px"; dragobject.style.width = (mouseDownWidth + (mouseDownLeft - mouseX)) + "px"; - } else if(dragHint == "topresize") { + } else if(dragHint == "topresize") { dragobject.style.top = mouseY + "px"; dragobject.style.height = (mouseDownHeight + (mouseDownTop - mouseY)) + "px"; } - - data.innerHTML = "

" + dragobject.nodeName + "
" + + + data.innerHTML = "

" + dragobject.nodeName + "
" + "Action: " + dragHint + "
" + "MouseLocation: " + mouseX + ":" + mouseY + "
" + - "MouseOver Location: " + (mouseX - dragobject.offsetLeft) + ":" + (mouseY - dragobject.offsetTop) + "
" + - "Location: " + dragobject.style.left + ":" + dragobject.style.top + "
" + - "Size: " + dragobject.style.width + ":" + dragobject.style.height + "
" + + "MouseOver Location: " + (mouseX - dragobject.offsetLeft) + ":" + (mouseY - dragobject.offsetTop) + "
" + + "Location: " + dragobject.style.left + ":" + dragobject.style.top + "
" + + "Size: " + dragobject.style.width + ":" + dragobject.style.height + "
" + "

"; - + } else { var mouseabove = document.elementFromPoint(mouseX + mainpage.offsetLeft, mouseY + mainpage.offsetTop); if((mouseabove.id != "mainpage") && (mouseabove.id != "grid")) { - - data.innerHTML = "

" + mouseabove.nodeName + "
" + + + data.innerHTML = "

" + mouseabove.nodeName + "
" + "Action: " + dragHint + "
" + "MouseLocation: " + mouseX + ":" + mouseY + "
" + - "MouseOver Location: " + (mouseX - mouseabove.offsetLeft) + ":" + (mouseY - mouseabove.offsetTop) + "
" + - "Location: " + mouseabove.style.left + ":" + mouseabove.style.top + "
" + - "Size: " + mouseabove.style.width + ":" + mouseabove.style.height + "
" + + "MouseOver Location: " + (mouseX - mouseabove.offsetLeft) + ":" + (mouseY - mouseabove.offsetTop) + "
" + + "Location: " + mouseabove.style.left + ":" + mouseabove.style.top + "
" + + "Size: " + mouseabove.style.width + ":" + mouseabove.style.height + "
" + "

"; - - if((mouseabove.nodeName == "DIV") || - (mouseabove.nodeName == "IMG") || + + if((mouseabove.nodeName == "DIV") || + (mouseabove.nodeName == "IMG") || (mouseabove.nodeName == "BUTTON") || (mouseabove.nodeName == "INPUT") || (mouseabove.nodeName == "SPAN")) { - - if((parseFloat(mouseabove.style.width) <= (mouseX - mouseabove.offsetLeft)) && + + if((parseFloat(mouseabove.style.width) <= (mouseX - mouseabove.offsetLeft)) && (parseFloat(mouseabove.style.height) <= (mouseY - mouseabove.offsetTop))) { mouseabove.style.cursor = "nwse-resize"; - dragHint = "rightbottomresize"; - } else if((parseFloat(mouseabove.style.left) <= (mouseX - mouseabove.offsetLeft)) && + dragHint = "rightbottomresize"; + } else if((parseFloat(mouseabove.style.left) <= (mouseX - mouseabove.offsetLeft)) && ((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseY - mouseabove.offsetTop))) { mouseabove.style.cursor = "nesw-resize"; - dragHint = "righttopresize"; - } else if(((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseX - mouseabove.offsetLeft)) && + dragHint = "righttopresize"; + } else if(((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseX - mouseabove.offsetLeft)) && (parseFloat(mouseabove.style.height) <= (mouseY - mouseabove.offsetTop))) { mouseabove.style.cursor = "nesw-resize"; - dragHint = "leftbottomresize"; + dragHint = "leftbottomresize"; } else if(parseFloat(mouseabove.style.width) <= (mouseX - mouseabove.offsetLeft)) { mouseabove.style.cursor = "ew-resize"; dragHint = "rightresize"; @@ -189,12 +189,12 @@ } displayParameters(); } - + function displayParameters() { - itemparameters.innerHTML = "

" + selected.nodeName + ": " + selected.id + "
" + - "Location: " + selected.style.left + ":" + selected.style.top + "
" + - "Size: " + selected.style.width + ":" + selected.style.height + "
" + + itemparameters.innerHTML = "

" + selected.nodeName + ": " + selected.id + "
" + + "Location: " + selected.style.left + ":" + selected.style.top + "
" + + "Size: " + selected.style.width + ":" + selected.style.height + "
" + "

"; } @@ -209,19 +209,19 @@ - - +
View Editor -
@@ -229,8 +229,8 @@ - - @@ -248,7 +248,7 @@ style="width: 100px; height: 100px; border: 10px solid red; position: absolute; background: #ffff80;" onmousedown="mousedown(this, event); return true;">
- + This is a text label @@ -263,9 +263,9 @@ OPTIONS -
+
Show Grid
@@ -287,18 +287,18 @@ Toolbar -
-
- -
+ +
diff --git a/__viewlist.h b/__viewlist.h index e14131e..b0069e9 100644 --- a/__viewlist.h +++ b/__viewlist.h @@ -7,42 +7,42 @@ namespace http { class __viewlist : public HTTPPage { - - int processCommand(std::string request, - core::TCPSession *session, - HTTPSession *httpSession, - HTTPRequest *httpRequest, + + int processCommand(std::string request, + core::TCPSession *session, + HTTPSession *httpSession, + HTTPRequest *httpRequest, std::stringstream &data) override { - - coreutils::Directory directory("/home/bradarant/jetserver/views"); - + + coreutils::Directory directory("../../jetserver/views"); + data << "
" << std::endl; - + data << "
" << std::endl; data << " Create new view" << std::endl; data << "
" << std::endl; - + while(!directory.eod()) { - + if(directory.get().getName().substr(0, 1) == ".") { - directory.next(); + directory.next(); continue; } - + data << "
" << std::endl; + data << " onmousedown=\"getPage('/editview?view=testview1','main');\">" << std::endl; data << " " << directory.get().getName() << "" << std::endl; data << "
" << std::endl; directory.next(); } data << "
" << std::endl; - - httpRequest->response.addHeader("Content-Type", "text/html"); + + httpRequest->response.addHeader("Content-Type", "text/html"); return true; - } + } }; } diff --git a/_image.h b/_image.h new file mode 100644 index 0000000..7b8f71e --- /dev/null +++ b/_image.h @@ -0,0 +1,35 @@ +#ifndef ____editview_h__ +#define ____editview_h__ + +#include "HTTPPage.h" +#include "File.h" + +namespace http { + + class _image : public HTTPPage { + + bool test(std::string request) { + if(request.substr(0, 6) == "image/") { + return true; + } + return false; + } + + int processCommand(std::string request, core::TCPSession *session, HTTPSession *httpSession, HTTPRequest *httpRequest, std::stringstream &data) override { + + std::cout << ">>>" << request << std::endl; + + coreutils::File workspace("/home/barant/jetserver/images/barant_web_logo.png"); + workspace.read(); + httpRequest->response.addHeader("Content-Length", workspace.asString().size().toString()); + httpRequest->response.addHeader("Content-Type", "image/png"); + httpRequest->response.body = workspace.asString(); + + return 0; + } + + }; + +} + +#endif diff --git a/launch.json b/launch.json new file mode 100644 index 0000000..322a149 --- /dev/null +++ b/launch.json @@ -0,0 +1,15 @@ +{ + "name": "C++ Launch (Windows)", + "type": "cppvsdbg", + "request": "launch", + "program": "C:\\app1\\Debug\\app1.exe", + "symbolSearchPath": "C:\\Symbols;C:\\SymbolDir2", + "externalConsole": true, + "logging": { + "moduleLoad": false, + "trace": true + }, + "visualizerFile": "${workspaceFolder}/my.natvis", + "showDisplayString": true +} + \ No newline at end of file