Browse Source

--add-sharks

JSON-95
Roker 4 years ago
parent
commit
97cbb70712
4 changed files with 46 additions and 1 deletions
  1. +24
    -1
      html/interactive.js
  2. +10
    -0
      server/ev_server.cc
  3. +4
    -0
      server/ev_server.hh
  4. +8
    -0
      server/main.cc

+ 24
- 1
html/interactive.js View File

@ -498,7 +498,30 @@ function init_pep_functions()
optionList += '<option' + (f.separator? ' disabled> —— ':'>') + f.name + "</option>\n";
}
document.getElementById("fn_name").innerHTML = optionList;
document.getElementById("spn_version").innerHTML = "version: " + server_version + " “" + server_version_name + "”"
document.getElementById("spn_version").innerHTML = "version: " + server_version + " “" + server_version_name + "”";
if(add_sharks)
{
var h1 = document.getElementsByTagName("h1")[0];
var shark = document.createElement("img");
shark.src = "data:image/png;base64," +
"iVBORw0KGgoAAAANSUhEUgAAAMQAAABYAQMAAACQzMoQAAAABlBMVEUAAAAAAAClZ7nPAA" +
"AAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElN" +
"RQfiBQQJFzochG6lAAAB0UlEQVRIx62WPW7cMBCFH8NCnXUBI8oxXBjRVXyELV1FzClyHQ" +
"IpfA3eIAQCrFUIfCkokjNaMYAXZrWLbzX75s0PBbTzBb0z9InrkdF3SeiSeAdZu2T7OJnS" +
"HYSfS9wdxPeJJclb+2b+JklyuyXlxC5hnxweWhpJ5+SNPGRWHvhFDKpZbCURUIUfC3kD8H" +
"wqLQJ4OPsbukMnmwI2ADCCDCQTSQYAMF4LSM2ZoAVcSa43ZNnJHuZFC7g2x4J24Pqnuhy0" +
"A+/VSqFtyqQU2rpjCQKweD3nzRlDL32zwplxk14PNRhg6BCBKAQUZ2ZvPfBjzzKpxTBiV7" +
"KXs+Rg4yuAeRX1LE799XU4s4DaFlkiXQ1XHbnkX4cSrYkIOcW1eFObOTeBIUt3uMNyJF0W" +
"0II9FpNDFtBqdSmdsWYBzV1fHEtQyWBqLv9UydQ5sHmUmrK6go3ocwCw27HOvoTwJ4MbjR" +
"5rMeyHgZ80WU/m84YM/yWh9NsiF5XlNvnciytmTeLYDNAkjCK0Iv6r+JIkcY9iKBXBk5iW" +
"JFXjmxhxSZLeS4JsvcthPGy5HhnYuyytIJPapkYSfYNIonfz0r7OhzsAPTK1j9+7bxav3Z" +
"eMS5e84IPnH+BiDVEeA5CdAAAAAElFTkSuQmCC";
shark.alt = "Shark. CC_BY Rachel Haley (AU).";
shark.width = 98;
shark.height = 44;
h1.insertBefore(shark, h1.childNodes[0]);
}
}


+ 10
- 0
server/ev_server.cc View File

@ -142,6 +142,9 @@ const FunctionMap functions = {
FP( "shutdown", new Func<void, In<JsonAdapter*, false>>( &JsonAdapter::shutdown_now ) ),
};
bool add_sharks = false;
} // end of anonymous namespace
@ -250,6 +253,7 @@ void ev_server::OnGetFunctions(evhttp_request* req, void*)
"\n"
"var server_version_name = \"" + version.name + "\";\n"
"var server_version = \"" + version.major_minor_patch() + "\";\n"
"var add_sharks = " + (add_sharks?"true":"false") + ";\n"
"var pep_functions = ";
js::Array jsonfunctions;
@ -327,4 +331,10 @@ void ev_server::setLogfile(std::ostream* new_logfile)
}
void ev_server::addSharks()
{
add_sharks = true;
}
std::ostream* ev_server::log_file = &nulllogger;

+ 4
- 0
server/ev_server.hh View File

@ -37,6 +37,10 @@ public:
// if new_logfile is NULL, the logfile is reset to nulllogger.
static
void setLogfile(std::ostream* new_logfile);
// add sharks to the JSON Adapter
static
void addSharks();
protected:
// prints "evserver:" to the log and returns it to allow << chaining


+ 8
- 0
server/main.cc View File

@ -16,6 +16,8 @@ namespace po = boost::program_options;
bool debug_mode = false;
bool do_sync = false;
bool ignore_missing_session = false;
bool add_sharks = false;
uintptr_t status_handle = 0;
std::string address = "127.0.0.1";
@ -56,6 +58,7 @@ try
("html-directory,H", po::value<boost::filesystem::path>(&ev_server::path_to_html)->default_value(ev_server::path_to_html), "Path to the HTML and JavaScript files")
("logfile,l", po::value<std::string>(&logfile)->default_value(logfile), "Name of the logfile. Can be \"stderr\" for log to stderr or empty for no log.")
("ignore-missing-session", po::bool_switch(&ignore_missing_session), "Ignore when no PEP_SESSION can be created.")
("add-sharks", po::bool_switch(&add_sharks), "Add sharks to the JSON Adapter.")
#ifdef _WIN32
((STATUS_HANDLE), po::value<uintptr_t>(&status_handle)->default_value(0), "Status file handle, for internal use.")
#endif
@ -94,6 +97,11 @@ try
my_logfile = real_logfile.get();
}
if(add_sharks)
{
ev_server::addSharks();
}
if( debug_mode == false )
daemonize (!debug_mode, (const uintptr_t) status_handle);


Loading…
Cancel
Save