diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1a19ddd --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +CMakeCache.txt +CMakeFiles +*~ +*.bak +*.exe +*.so +*.dll +*.cmake +Makefile +oastat_static_web_generator +output/ +nbproject/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9d88ab2 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.9) +project (oastat_static_web_generator) +find_package(Boost COMPONENTS program_options REQUIRED) +add_executable(oastat_static_web_generator src/oastat_static_web_generator.cpp) +TARGET_LINK_LIBRARIES( oastat_static_web_generator ${Boost_LIBRARIES} cppdb ) diff --git a/src/command_arguments.hpp b/src/command_arguments.hpp new file mode 100644 index 0000000..fcd70a8 --- /dev/null +++ b/src/command_arguments.hpp @@ -0,0 +1,12 @@ + + +#ifndef COMMAND_ARGUMENTS_HPP +#define COMMAND_ARGUMENTS_HPP + +struct CommandArguments { + std::string connectstring = "mysql:database=testschema;user=testuser;password=password"; + std::string output_dir = "output"; +}; + +#endif /* COMMAND_ARGUMENTS_HPP */ + diff --git a/src/oastat_static_web_generator.cpp b/src/oastat_static_web_generator.cpp new file mode 100644 index 0000000..76354b9 --- /dev/null +++ b/src/oastat_static_web_generator.cpp @@ -0,0 +1,87 @@ +#include +#include +#include +#include "command_arguments.hpp" +#include + +#ifndef VERSIONNUMBER +#define VERSIONNUMBER "0.1.0" +#endif + +CommandArguments cmdargs; + +const char* const SAGO_CONNECTION_STRING = "SAGO_CONNECTION_STRING"; + + +static void create_dir_recursive(const std::string& path) { + std::string command = std::string("mkdir -p \"")+path+"\""; + int ret = std::system(command.c_str()); + if (ret != 0) { + std::cerr << "Failed to create: " << path << "\n"; + } +} + +static void copy_static_files(const std::string& source, const std::string& destination) { + std::string command = "cp -r \""+source+"\"/* \""+destination+"/\""; + int ret = std::system(command.c_str()); + if (ret != 0) { + std::cerr << "copy with: " << command << "\n"; + } +} + + +void write_html_index(cppdb::session& database) { + std::ofstream myfile; + myfile.open (cmdargs.output_dir+"/index.html"); + myfile << "\n"; + myfile << "\n"; + myfile.close(); +} + +void write_files(cppdb::session& database) { + write_html_index(database); +} + + +void do_dbtest(cppdb::session& database) { + cppdb::statement st = database.prepare("SELECT now()"); + cppdb::result res = st.query(); + if(res.next()) { + std::string value; + res >> value; + std::cout << value << "\n"; + } +} + +int main(int argc, const char* argv[]) { + boost::program_options::options_description desc("Options"); + desc.add_options() + ("version", "Print version information and quit") + ("help,h", "Print basic usage information to stdout and quit") + ("output-dir", boost::program_options::value(), "The directory to write the output to.") + ; + boost::program_options::variables_map vm; + boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm); + boost::program_options::notify(vm); + if (vm.count("help")) { + std::cout << desc << "\n"; + return 0; + } + if (vm.count("version")) { + std::cout << "oastat_static_web_generator " << VERSIONNUMBER << "\n"; + return 0; + } + if (vm.count("output-dir")) { + cmdargs.output_dir = vm["output-dir"].as(); + } + const char* connectstring_env = getenv(SAGO_CONNECTION_STRING); + if (connectstring_env) { + cmdargs.connectstring = connectstring_env; + } + cppdb::session database(cmdargs.connectstring); + do_dbtest(database); + create_dir_recursive(cmdargs.output_dir+"/static"); + copy_static_files("static_content", cmdargs.output_dir+"/static"); + write_files(database); + return 0; +} diff --git a/static_content/css/oastat.css b/static_content/css/oastat.css new file mode 100644 index 0000000..33db3f3 --- /dev/null +++ b/static_content/css/oastat.css @@ -0,0 +1,446 @@ +/* Basic CSS file from pyqscore. GPLv2 only licensed */ +* { +margin-top: 0px; +margin-right: 0px; +margin-bottom: 0px; +margin-left: 0px; +padding-top: 0px; +padding-right: 0px; +padding-bottom: 0px; +padding-left: 0px; +border-width: thin; /* thin | medium | thick | */ +border-color: #000000; /* | transparent | inherit */ +border-style: none; /* none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset */ +border-collapse: collapse; +/* border-top-width, border-right-width, border-bottom-width, border-left-width */ +/* border-top-color, border-right-color, border-bottom-color, border-left-color */ +/* border-top-style, border-right-style, border-bottom-style, border-left-style */ +color: #000000; /* foreground color */ +background-color: transparent; /* | transparent | inherit */ +font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif; /* [ | ] */ +font-style: normal; /* normal | italic | oblique | inherit */ +font-variant: normal; /* normal | small-caps */ +font-weight: normal; /* normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit */ +font-size: 10pt; /* | | | | inherit */ +text-indent: 0px; /* justificación de la primera línea de un párrafo */ +text-align: left; /* left | right | center | justify | inherit */ +text-decoration: none; /* none | [ underline || overline || line-through || blink ] | inherit */ +text-transform: none; /* capitalize | uppercase | lowercase | none | inherit */ +letter-spacing: normal; /* normal | | inherit */ +word-spacing: normal; /* normal | | inherit */ +white-space: normal; /* normal | pre | nowrap | pre-wrap | pre-line | inherit */ +list-style-type: disc; /* disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none | inherit */ +list-style-image: none; /* | none | inherit */ +list-style-position: outside; /* inside | outside | inherit */ +} + +/* cuerpo del html */ +body { +background-color: #CCCCFF; /* | transparent | inherit */ +/* background-image: url("imagenes/fondo.gif");*/ /* | none | inherit */ +/* background-repeat: no-repeat;*/ /* repeat | repeat-x | repeat-y | no-repeat | inherit */ +/* background-attachment: fixed;*/ /* scroll | fixed | inherit */ +/* background-position: 0px 0px;*/ /* [ [ | | left | center | right ] [ | | top | center | bottom ]? ] | [ [ left | center | right ] || [ top | center | bottom ] ] | inherit */ +/* cursor: url("statscursor.cur"), auto;*/ /* [ [ ,]* [ auto | crosshair | default | pointer | move | e-resize | ne-resize | nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | text | wait | help | progress ] ] | inherit */ +} + +/* links genéricos */ +.genericlink:link { +text-decoration: none; +background-color: transparent; +color: #0000AA; +} +.genericlink:visited { +text-decoration: none; +background-color: transparent; +color: #0000AA; +} +.genericlink:hover { +text-decoration: none; +background-color: transparent; +color: #AA0000; +} +.genericlink:active { +text-decoration: none; +background-color: transparent; +color: #0000AA; +} + +/* id del marco de trabajo */ +#marco { +display: inline; /* inline | block | list-item | run-in | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | none | inherit */ +position: absolute; /* static | relative | absolute | fixed | inherit */ +width: auto; /* | | auto | inherit */ +height: auto; /* | | auto | inherit */ +top: 0px; /* | | auto | inherit */ +right: auto; /* | | auto | inherit */ +bottom: auto; /* | | auto | inherit */ +left: 0px; /* | | auto | inherit */ +float: none; /* left | right | none | inherit */ +clear: none; /* none | left | right | both | inherit */ +margin-top: 10px; +margin-right: 20px; +margin-bottom: 20px; +margin-left: 20px; +} + + +/* presentación */ + +.cuadropresentacion { +background-color: #3366CC; +padding-top: 15px; +padding-bottom: 15px; +margin-bottom: 5px; +} + +.intro { +color: #FFFFFF; +padding-left: 80px; +margin-bottom: 15px; +font-family: Verdana, Tahoma, Arial, sans-serif; +font-weight: bold; +font-size: 20pt; +} + +.update { +float: right; +color: #FFFFFF; +margin-right: 70px; +padding-top: 10px; +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 9pt; +font-style: italic; +} + + +.endnote { +float: right; +color: #000000; +margin-right: 10px; +padding-top: 0px; +padding-bottom: 15px; +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 9pt; +font-style: italic; +} + + +/* id del cuerpo */ + +.cuadro { +background-color: #6699FF; +border-color: #3366CC; /* | transparent | inherit */ +border-style: solid; /* none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset */ +margin-top: 0px; +margin-right: 0px; +margin-left: 0px; +margin-bottom: 10px; +padding-top: 5px; +padding-bottom: 15px; +padding-right: 15px; +padding-left: 15px; +} + +.titulocuadro { +color: #003399; +font-size: 12pt; +font-family: Verdana, Tahoma, Arial, sans-serif; +font-weight: bold; +margin-top: 15px; +margin-left: 50px; +} + + +/* tablas */ + +.centrartabla { +text-align: center; +} + +.centrartabla table { +margin-top: 0px; +margin-left: auto; +margin-right: auto; +margin-bottom: 0px; +} + +.centrartabla2 table { +margin-top: 20px; +margin-left: auto; +margin-right: auto; +margin-bottom: 0px; +} + +.tablaserver { +background-color: #FFFFFF; +border-color: #3366CC; +border-style: solid; +border-width: 3px; +} + +.tabladatos { +background-color: #FFFFFF; +border-color: #3366CC; +border-style: solid; +margin-top: 20px; +} + + +/* datos tabla server */ + +.server { +background: #CCCCFF;/*#f0f0f0;*/ +color: #000000; +padding-top: 8px; +padding-right: 20px; +padding-bottom: 8px; +padding-left: 10px; +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +font-weight: bold; +text-align: left; +/* border-bottom-color: #3366CC; */ +/* border-bottom-style: groove; */ +/* border-bottom-width: 4px; */ +} + +.datoserver { +background: #ccccff; /*#f0f0f0;*/ +color: #000000; +padding-top: 8px; +padding-right: 10px; +padding-bottom: 8px; +padding-left: 0px; +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +text-align: left; +/* font-weight: bold; */ +/* border-bottom-color: #3366CC; */ +/* border-bottom-style: groove; */ +/* border-bottom-width: 4px; */ +/* border-right-color: #3366CC; */ +/* border-right-style: groove; */ +/* border-right-width: 4px; */ +} + + + +/* datos tabla de datos */ + +.jugadorquotes { +background: #eeeeff; +color: #000000; +margin-top: 0px; +margin-left: 0px; +margin-right: 0px; +margin-bottom: 0px; +padding-top: 1px; +padding-right: 10px; +padding-left: 6px; +padding-bottom: 1px; +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +text-align: left; +border-top-color: #6699FF; +/* border-top-style: dashed; */ +border-top-width: 1px; +} + +.datoquotes { +min-width: 500px; +background: #eeeeff; +color: #000000; +margin-top: 0px; +margin-left: 0px; +margin-right: 0px; +margin-bottom: 0px; +padding-top: 1px; +padding-left: 10px; +padding-right: 6px; +padding-bottom: 1px; +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +font-style: italic; +text-align: center; +border-top-color: #6699FF; +/* border-top-style: dashed; */ +border-top-width: 1px; +} + + +.tituloup { +color: #000000; +margin-top: 5px; +margin-left: 5px; +margin-right: 5px; +margin-bottom: 0px; +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +font-weight: bold; +text-align: center; +} + +.tituloup2 { +background: #ccccff; +color: #000000; +margin-top: 0px; +margin-left: 0px; +margin-right: 0px; +margin-bottom: 0px; +padding-top: 3px; +padding-bottom: 3px; +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +font-weight: bold; +text-align: center; +} + +.tituloup3 { +color: #000000; +margin-top: 0px; +margin-left: 5px; +margin-right: 5px; +margin-bottom: 3px; +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +font-weight: bold; +text-align: center; +} + + +.tituloup4 { +color: #000000; +margin-top: 8px; +margin-left: 5px; +margin-right: 5px; +margin-bottom: 8px; +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +font-weight: bold; +text-align: center; +} + +.jugador { +background: #CCCCff; +color: #000000; +margin-top: 1px; +margin-left: 0px; +margin-right: 0px; +margin-bottom: 0px; +padding-top: 1px; +padding-right: 0px; +padding-bottom: 1px; +padding-left: 6px; +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +text-align: left; +} + +.jugador2 { +background: #eeeeff; +color: #000000; +margin-top: 1px; +margin-left: 0px; +margin-right: 0px; +margin-bottom: 0px; +padding-top: 1px; +padding-right: 0px; +padding-bottom: 1px; +padding-left: 6px; +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +text-align: left; +} + +.dato { +background: #CCCCff; +color: #000000; +margin-top: 1px; +margin-left: 0px; +margin-right: 0px; +margin-bottom: 0px; +padding-top: 1px; +padding-right: 0px; +padding-bottom: 1px; +padding-left: 0px; +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +text-align: center; +} + +.dato2 { +background: #eeeeff; +color: #000000; +margin-top: 1px; +margin-left: 0px; +margin-right: 0px; +margin-bottom: 0px; +padding-top: 1px; +padding-right: 0px; +padding-bottom: 1px; +padding-left: 0px; +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +text-align: center; +} + + +div.centered +{ +text-align: center; +} +div.centered table +{ +margin: 0 auto; +text-align: left; +} + +/* player name colours */ + +.c0 { +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +color: #000000; +} +.c1 { +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +color: #FF0000; +} +.c2 { +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +color: #00FF00; +} +.c3 { +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +color: #FFFF00; +} +.c4 { +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +color: #0000FF; +} +.c5 { +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +color: #00FFFF; +} +.c6 { +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +color: #FF00FF; +} +.c7 { +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +color: #FFFFFF; +} +.c8 { +font-family: Verdana, Tahoma, Arial, sans-serif; +font-size: 8pt; +color: #FFA500; +} + diff --git a/static_content/icons/bfg.png b/static_content/icons/bfg.png new file mode 100644 index 0000000..bc1a24d Binary files /dev/null and b/static_content/icons/bfg.png differ diff --git a/static_content/icons/chaingun.png b/static_content/icons/chaingun.png new file mode 100644 index 0000000..a13220a Binary files /dev/null and b/static_content/icons/chaingun.png differ diff --git a/static_content/icons/gauntlet.png b/static_content/icons/gauntlet.png new file mode 100644 index 0000000..629cb02 Binary files /dev/null and b/static_content/icons/gauntlet.png differ diff --git a/static_content/icons/grenade.png b/static_content/icons/grenade.png new file mode 100644 index 0000000..ba3e564 Binary files /dev/null and b/static_content/icons/grenade.png differ diff --git a/static_content/icons/lightning.png b/static_content/icons/lightning.png new file mode 100644 index 0000000..7087364 Binary files /dev/null and b/static_content/icons/lightning.png differ diff --git a/static_content/icons/machinegun.png b/static_content/icons/machinegun.png new file mode 100644 index 0000000..906925c Binary files /dev/null and b/static_content/icons/machinegun.png differ diff --git a/static_content/icons/nailgun.png b/static_content/icons/nailgun.png new file mode 100644 index 0000000..4a8ddd1 Binary files /dev/null and b/static_content/icons/nailgun.png differ diff --git a/static_content/icons/plasma.png b/static_content/icons/plasma.png new file mode 100644 index 0000000..c86380a Binary files /dev/null and b/static_content/icons/plasma.png differ diff --git a/static_content/icons/quad.png b/static_content/icons/quad.png new file mode 100644 index 0000000..acbee27 Binary files /dev/null and b/static_content/icons/quad.png differ diff --git a/static_content/icons/railgun.png b/static_content/icons/railgun.png new file mode 100644 index 0000000..687c1c9 Binary files /dev/null and b/static_content/icons/railgun.png differ diff --git a/static_content/icons/red.png b/static_content/icons/red.png new file mode 100644 index 0000000..c6f68bc Binary files /dev/null and b/static_content/icons/red.png differ diff --git a/static_content/icons/rocket.png b/static_content/icons/rocket.png new file mode 100644 index 0000000..5597641 Binary files /dev/null and b/static_content/icons/rocket.png differ diff --git a/static_content/icons/shotgun.png b/static_content/icons/shotgun.png new file mode 100644 index 0000000..0cdd87a Binary files /dev/null and b/static_content/icons/shotgun.png differ diff --git a/static_content/icons/teleporter.png b/static_content/icons/teleporter.png new file mode 100644 index 0000000..5685c73 Binary files /dev/null and b/static_content/icons/teleporter.png differ