mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Remove webserver (never used)
This commit is contained in:
parent
0fe4586bab
commit
f8cb1db917
@ -71,7 +71,6 @@ option(USE_SHARED_HARFBUZZ "Use shared HarfBuzz library" off)
|
||||
option(ENABLE_MEMLEAK "Enable memory-leaks detector (only for developers)" off)
|
||||
option(ENABLE_UPDATER "Enable automatic check for updates" on)
|
||||
option(ENABLE_SCRIPTING "Compile with scripting support" on)
|
||||
option(ENABLE_WEBSERVER "Enable support to run a webserver (for HTML5 gamedev)" off)
|
||||
option(ENABLE_TESTS "Compile unit tests" off)
|
||||
option(ENABLE_BENCHMARKS "Compile benchmarks" off)
|
||||
option(ENABLE_TRIAL_MODE "Compile the trial version" off)
|
||||
|
@ -1,17 +0,0 @@
|
||||
body, h2 {
|
||||
font-family: Segoe UI, Arial;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 14pt;
|
||||
font-weight: normal;
|
||||
color: #669;
|
||||
}
|
||||
|
||||
#console {
|
||||
border:8px solid #eee;
|
||||
background-color:#eee;
|
||||
width:80%;
|
||||
height:128px;
|
||||
overflow:auto;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
window.Aseprite = window.Aseprite || {};
|
||||
(function(Aseprite) {
|
||||
'use strict';
|
||||
|
||||
Aseprite.host = 'http://127.0.0.1:10453';
|
||||
|
||||
Aseprite.get = function(uri, callback) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: Aseprite.host + uri,
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
callback(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Aseprite.get_version = function(callback) {
|
||||
Aseprite.get('/version', callback);
|
||||
}
|
||||
})(window.Aseprite);
|
Binary file not shown.
Before Width: | Height: | Size: 1.0 KiB |
@ -1,31 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Aseprite</title>
|
||||
<link href="aseprite.css" rel="stylesheet">
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
||||
<script src="aseprite.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('#run').click(function() {
|
||||
eval($('#code').text());
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<img src="aseprite.png">
|
||||
|
||||
<h2>Console:</h2>
|
||||
<pre id="console"></pre>
|
||||
|
||||
<h2>Test your code:</h2>
|
||||
<textarea id="code" cols="80" rows="10">
|
||||
Aseprite.get_version(function(version){
|
||||
alert(version.package + "/" + version.version + " APIv" + version.api +
|
||||
" (" + version.webserver + " webserver)");
|
||||
});</textarea><br>
|
||||
<input id="run" type="button" value="Run" style="width:200px">
|
||||
|
||||
</body>
|
||||
</html>
|
@ -104,10 +104,6 @@ if(ENABLE_UPDATER)
|
||||
add_subdirectory(updater)
|
||||
endif()
|
||||
|
||||
if(ENABLE_WEBSERVER)
|
||||
add_subdirectory(webserver)
|
||||
endif()
|
||||
|
||||
if(ENABLE_STEAM)
|
||||
add_subdirectory(steam)
|
||||
endif()
|
||||
|
@ -28,7 +28,6 @@ because they don't depend on any other component.
|
||||
* [cfg](cfg/) (base): Library to load/save .ini files.
|
||||
* [gen](gen/) (base): Helper utility to generate C++ files from different XMLs.
|
||||
* [net](net/) (base): Networking library to send HTTP requests.
|
||||
* [webserver](webserver/) (base): HTTP web server
|
||||
|
||||
## Level 2
|
||||
|
||||
@ -48,7 +47,7 @@ because they don't depend on any other component.
|
||||
|
||||
## Level 5
|
||||
|
||||
* [app](app/) (base, doc, dio, filters, fixmath, flic, gfx, pen, render, scripting, os, ui, undo, updater, webserver)
|
||||
* [app](app/) (base, doc, dio, filters, fixmath, flic, gfx, pen, render, scripting, os, ui, undo, updater)
|
||||
|
||||
## Level 6
|
||||
|
||||
|
@ -557,7 +557,6 @@ add_library(app-lib
|
||||
util/range_utils.cpp
|
||||
util/readable_time.cpp
|
||||
util/wrap_point.cpp
|
||||
webserver.cpp
|
||||
xml_document.cpp
|
||||
xml_exception.cpp
|
||||
${ui_app_files}
|
||||
@ -604,10 +603,6 @@ if(ENABLE_UPDATER)
|
||||
target_link_libraries(app-lib updater-lib)
|
||||
endif()
|
||||
|
||||
if(ENABLE_WEBSERVER)
|
||||
target_link_libraries(app-lib webserver-lib)
|
||||
endif()
|
||||
|
||||
if(ENABLE_STEAM)
|
||||
add_definitions(-DENABLE_STEAM)
|
||||
target_link_libraries(app-lib steam-lib)
|
||||
|
@ -51,7 +51,6 @@
|
||||
#include "app/ui/workspace.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "app/util/clipboard.h"
|
||||
#include "app/webserver.h"
|
||||
#include "base/exception.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/scoped_lock.h"
|
||||
@ -334,12 +333,6 @@ void App::run()
|
||||
checkUpdate.launch();
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WEBSERVER
|
||||
// Launch the webserver.
|
||||
app::WebServer webServer;
|
||||
webServer.start();
|
||||
#endif
|
||||
|
||||
app::SendCrash sendCrash;
|
||||
sendCrash.search();
|
||||
|
||||
|
@ -1,83 +0,0 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WEBSERVER
|
||||
|
||||
#include "app/webserver.h"
|
||||
|
||||
#include "base/fs.h"
|
||||
#include "base/path.h"
|
||||
#include "app/resource_finder.h"
|
||||
#include "webserver/webserver.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#define API_VERSION 1
|
||||
|
||||
namespace app {
|
||||
|
||||
WebServer::WebServer()
|
||||
: m_webServer(NULL)
|
||||
{
|
||||
ResourceFinder rf;
|
||||
rf.includeDataDir("www");
|
||||
|
||||
while (rf.next()) {
|
||||
if (base::is_directory(rf.filename())) {
|
||||
m_wwwpath = rf.filename();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebServer::~WebServer()
|
||||
{
|
||||
delete m_webServer;
|
||||
}
|
||||
|
||||
void WebServer::start()
|
||||
{
|
||||
m_webServer = new webserver::WebServer(this);
|
||||
}
|
||||
|
||||
void WebServer::onProcessRequest(webserver::IRequest* request,
|
||||
webserver::IResponse* response)
|
||||
{
|
||||
std::string uri = request->getUri();
|
||||
if (!uri.empty() && uri[uri.size()-1] == '/')
|
||||
uri.erase(uri.size()-1);
|
||||
|
||||
if (uri == "/version") {
|
||||
response->setContentType("text/plain");
|
||||
response->getStream() << "{\"package\":\"" << PACKAGE "\","
|
||||
<< "\"version\":\"" << VERSION << "\","
|
||||
<< "\"webserver\":\"" << m_webServer->getName() << "\","
|
||||
<< "\"api\":\"" << API_VERSION << "\"}";
|
||||
}
|
||||
else {
|
||||
if (uri == "/" || uri.empty())
|
||||
uri = "/index.html";
|
||||
|
||||
std::string fn = base::join_path(m_wwwpath, uri);
|
||||
if (base::is_file(fn)) {
|
||||
response->sendFile(fn.c_str());
|
||||
}
|
||||
else {
|
||||
response->setStatusCode(404);
|
||||
response->getStream() << "Not found\n"
|
||||
<< "URI = " << uri << "\n"
|
||||
<< "Local file = " << fn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // ENABLE_WEBSERVER
|
@ -1,37 +0,0 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifndef APP_WEBSERVER_H_INCLUDED
|
||||
#define APP_WEBSERVER_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#ifdef ENABLE_WEBSERVER
|
||||
|
||||
#include "webserver/webserver.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
class WebServer : public webserver::IDelegate {
|
||||
public:
|
||||
WebServer();
|
||||
~WebServer();
|
||||
|
||||
void start();
|
||||
|
||||
// webserver::IDelegate implementation
|
||||
virtual void onProcessRequest(webserver::IRequest* request,
|
||||
webserver::IResponse* response) override;
|
||||
|
||||
private:
|
||||
webserver::WebServer* m_webServer;
|
||||
std::string m_wwwpath;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
||||
#endif // ENABLE_WEBSERVER
|
||||
|
||||
#endif // APP_WEBSERVER_H_INCLUDED
|
@ -1,5 +0,0 @@
|
||||
# ASEPRITE
|
||||
# Copyright (C) 2001-2013, 2015, 2016 David Capello
|
||||
|
||||
add_library(webserver-lib
|
||||
webserver.cpp)
|
@ -1,247 +0,0 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#error Not implemented
|
||||
|
||||
#include "webserver/webserver.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace webserver {
|
||||
|
||||
static int begin_request_handler(mg_connection* conn);
|
||||
|
||||
class RequestResponseImpl : public IRequest
|
||||
, public IResponse
|
||||
{
|
||||
public:
|
||||
RequestResponseImpl(mg_connection* conn, std::ostream& stream)
|
||||
: m_conn(conn)
|
||||
, m_requestInfo(mg_get_request_info(conn))
|
||||
, m_stream(stream)
|
||||
, m_code(200)
|
||||
, m_done(false)
|
||||
, m_contentType("text/plain")
|
||||
{
|
||||
}
|
||||
|
||||
// IRequest implementation
|
||||
|
||||
virtual const char* getRequestMethod() override {
|
||||
return m_requestInfo->request_method;
|
||||
}
|
||||
|
||||
virtual const char* getUri() override {
|
||||
return m_requestInfo->uri;
|
||||
}
|
||||
|
||||
virtual const char* getHttpVersion() override {
|
||||
return m_requestInfo->http_version;
|
||||
}
|
||||
|
||||
virtual const char* getQueryString() override {
|
||||
return m_requestInfo->query_string;
|
||||
}
|
||||
|
||||
// IResponse implementation
|
||||
|
||||
virtual void setStatusCode(int code) override {
|
||||
m_code = code;
|
||||
}
|
||||
|
||||
virtual void setContentType(const char* contentType) override {
|
||||
m_contentType = contentType;
|
||||
}
|
||||
|
||||
virtual std::ostream& getStream() override {
|
||||
return m_stream;
|
||||
}
|
||||
|
||||
virtual void sendFile(const char* path) override {
|
||||
mg_send_file(m_conn, path);
|
||||
m_done = true;
|
||||
}
|
||||
|
||||
int getStatusCode() const {
|
||||
return m_code;
|
||||
}
|
||||
|
||||
const char* getContentType() const {
|
||||
return m_contentType.c_str();
|
||||
}
|
||||
|
||||
bool done() {
|
||||
return m_done;
|
||||
}
|
||||
|
||||
private:
|
||||
mg_connection* m_conn;
|
||||
const mg_request_info* m_requestInfo;
|
||||
std::ostream& m_stream;
|
||||
int m_code;
|
||||
bool m_done;
|
||||
std::string m_contentType;
|
||||
};
|
||||
|
||||
class WebServer::WebServerImpl
|
||||
{
|
||||
public:
|
||||
WebServerImpl(IDelegate* delegate)
|
||||
: m_delegate(delegate) {
|
||||
const char* options[] = {
|
||||
"listening_ports", "10453",
|
||||
NULL
|
||||
};
|
||||
|
||||
memset(&m_callbacks, 0, sizeof(m_callbacks));
|
||||
m_callbacks.begin_request = &begin_request_handler;
|
||||
|
||||
m_context = mg_start(&m_callbacks, (void*)this, options);
|
||||
}
|
||||
|
||||
~WebServerImpl() {
|
||||
mg_stop(m_context);
|
||||
}
|
||||
|
||||
std::string getName() const {
|
||||
std::string name;
|
||||
name = "mongoose ";
|
||||
name += mg_version();
|
||||
return name;
|
||||
}
|
||||
|
||||
int onBeginRequest(mg_connection* conn) {
|
||||
std::stringstream body;
|
||||
RequestResponseImpl rr(conn, body);
|
||||
m_delegate->onProcessRequest(&rr, &rr);
|
||||
|
||||
if (rr.done())
|
||||
return 1;
|
||||
|
||||
// Send HTTP reply to the client
|
||||
std::string bodyStr = body.str();
|
||||
std::stringstream headers;
|
||||
|
||||
headers << "HTTP/1.1 "
|
||||
<< rr.getStatusCode() << " "
|
||||
<< getStatusCodeString(rr.getStatusCode()) << "\r\n"
|
||||
<< "Server: mongoose/" << mg_version() << "\r\n"
|
||||
<< "Content-Type: " << rr.getContentType() << "\r\n"
|
||||
<< "Content-Length: " << bodyStr.size() << "\r\n"
|
||||
<< "Access-Control-Allow-Origin: *\r\n"
|
||||
<< "\r\n";
|
||||
|
||||
std::string headersStr = headers.str();
|
||||
|
||||
mg_write(conn, (const void*)headersStr.c_str(), headersStr.size());
|
||||
mg_write(conn, (const void*)bodyStr.c_str(), bodyStr.size());
|
||||
|
||||
// Returning non-zero tells mongoose that our function has replied to
|
||||
// the client, and mongoose should not send client any more data.
|
||||
return 1;
|
||||
}
|
||||
|
||||
private:
|
||||
const char* getStatusCodeString(int code) {
|
||||
switch (code) {
|
||||
case 100: return "Continue";
|
||||
case 101: return "Switching Protocols";
|
||||
case 102: return "Processing";
|
||||
case 200: return "OK";
|
||||
case 201: return "Created";
|
||||
case 202: return "Accepted";
|
||||
case 203: return "Non-Authoritative Information";
|
||||
case 204: return "No Content";
|
||||
case 205: return "Reset Content";
|
||||
case 206: return "Partial Content";
|
||||
case 207: return "Multi-Status";
|
||||
case 208: return "Already Reported";
|
||||
case 226: return "IM Used";
|
||||
case 300: return "Multiple Choices";
|
||||
case 301: return "Moved Permanently";
|
||||
case 302: return "Found";
|
||||
case 303: return "See Other";
|
||||
case 304: return "Not Modified";
|
||||
case 305: return "Use Proxy";
|
||||
case 306: return "Reserved";
|
||||
case 307: return "Temporary Redirect";
|
||||
case 308: return "Permanent Redirect";
|
||||
case 400: return "Bad Request";
|
||||
case 401: return "Unauthorized";
|
||||
case 402: return "Payment Required";
|
||||
case 403: return "Forbidden";
|
||||
case 404: return "Not Found";
|
||||
case 405: return "Method Not Allowed";
|
||||
case 406: return "Not Acceptable";
|
||||
case 407: return "Proxy Authentication Required";
|
||||
case 408: return "Request Timeout";
|
||||
case 409: return "Conflict";
|
||||
case 410: return "Gone";
|
||||
case 411: return "Length Required";
|
||||
case 412: return "Precondition Failed";
|
||||
case 413: return "Request Entity Too Large";
|
||||
case 414: return "Request-URI Too Long";
|
||||
case 415: return "Unsupported Media Type";
|
||||
case 416: return "Requested Range Not Satisfiable";
|
||||
case 417: return "Expectation Failed";
|
||||
case 422: return "Unprocessable Entity";
|
||||
case 423: return "Locked";
|
||||
case 424: return "Failed Dependency";
|
||||
case 426: return "Upgrade Required";
|
||||
case 428: return "Precondition Required";
|
||||
case 429: return "Too Many Requests";
|
||||
case 431: return "Request Header Fields Too Large";
|
||||
case 500: return "Internal Server Error";
|
||||
case 501: return "Not Implemented";
|
||||
case 502: return "Bad Gateway";
|
||||
case 503: return "Service Unavailable";
|
||||
case 504: return "Gateway Timeout";
|
||||
case 505: return "HTTP Version Not Supported";
|
||||
case 506: return "Variant Also Negotiates (Experimental)";
|
||||
case 507: return "Insufficient Storage";
|
||||
case 508: return "Loop Detected";
|
||||
case 510: return "Not Extended";
|
||||
case 511: return "Network Authentication Required";
|
||||
default: return "Unassigned";
|
||||
}
|
||||
}
|
||||
|
||||
IDelegate* m_delegate;
|
||||
mg_context* m_context;
|
||||
mg_callbacks m_callbacks;
|
||||
};
|
||||
|
||||
static int begin_request_handler(mg_connection* conn)
|
||||
{
|
||||
const mg_request_info* request_info = mg_get_request_info(conn);
|
||||
WebServer::WebServerImpl* webServer =
|
||||
reinterpret_cast<WebServer::WebServerImpl*>(request_info->user_data);
|
||||
|
||||
return webServer->onBeginRequest(conn);
|
||||
}
|
||||
|
||||
WebServer::WebServer(IDelegate* delegate)
|
||||
: m_impl(new WebServerImpl(delegate))
|
||||
{
|
||||
}
|
||||
|
||||
WebServer::~WebServer()
|
||||
{
|
||||
delete m_impl;
|
||||
}
|
||||
|
||||
std::string WebServer::getName() const
|
||||
{
|
||||
return m_impl->getName();
|
||||
}
|
||||
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
|
||||
#ifndef WEBSERVER_WEBSERVER_H_INCLUDED
|
||||
#define WEBSERVER_WEBSERVER_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "base/disable_copying.h"
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace webserver {
|
||||
|
||||
class IRequest {
|
||||
public:
|
||||
virtual ~IRequest() { }
|
||||
virtual const char* getRequestMethod() = 0;
|
||||
virtual const char* getUri() = 0;
|
||||
virtual const char* getHttpVersion() = 0;
|
||||
virtual const char* getQueryString() = 0;
|
||||
};
|
||||
|
||||
class IResponse {
|
||||
public:
|
||||
virtual ~IResponse() { }
|
||||
virtual void setStatusCode(int code) = 0;
|
||||
virtual void setContentType(const char* contentType) = 0;
|
||||
virtual std::ostream& getStream() = 0;
|
||||
virtual void sendFile(const char* path) = 0;
|
||||
};
|
||||
|
||||
class IDelegate {
|
||||
public:
|
||||
virtual ~IDelegate() { }
|
||||
virtual void onProcessRequest(IRequest* request, IResponse* response) = 0;
|
||||
};
|
||||
|
||||
class WebServer {
|
||||
public:
|
||||
class WebServerImpl;
|
||||
|
||||
WebServer(IDelegate* delegate);
|
||||
~WebServer();
|
||||
|
||||
std::string getName() const;
|
||||
|
||||
private:
|
||||
WebServerImpl* m_impl;
|
||||
|
||||
DISABLE_COPYING(WebServer);
|
||||
};
|
||||
|
||||
} // namespace webserver
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user