// This file is part of Motion Watch. // Motion Watch is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // Motion Watch is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. #include "web.h" void genHTMLul(const string &outputDir, const string &title, shared_t *share) { vector logNames; vector eveNames; vector dirNames; string htmlText = "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "

" + title + "

\n"; if (exists(outputDir + "/live")) { eveNames = lsFilesInDir(outputDir + "/events", ".html"); logNames = lsFilesInDir(outputDir + "/logs", "_log.html"); htmlText += "

Logs

\n"; htmlText += "
    \n"; for (auto &&logName : logNames) { // name.substr(0, name.size() - 9) removes _log.html auto name = logName.substr(0, logName.size() - 9); htmlText += "
  • " + name + "
  • \n"; } htmlText += "
\n"; htmlText += "

Live

\n"; htmlText += "\n"; htmlText += "

Motion Events

\n"; genHTMLstream("stream"); for (auto &&eveName : eveNames) { // regName.substr(0, regName.size() - 5) removes .html auto name = eveName.substr(0, eveName.size() - 5); htmlText += "\n"; } } else { dirNames = lsDirsInDir(outputDir); htmlText += "\n"; } htmlText += "\n"; htmlText += ""; ofstream file(string(cleanDir(outputDir) + "/index.html").c_str()); file << htmlText << endl; file.close(); } void genHTMLstream(const string &name) { string htmlText = "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += " \n"; htmlText += " \n"; htmlText += " \n"; htmlText += "\n"; htmlText += ""; ofstream file(string(name + ".html").c_str()); file << htmlText << endl; file.close(); } void genHTMLvod(const string &name) { string htmlText = "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += "\n"; htmlText += ""; ofstream file(string("events/" + name + ".html").c_str()); file << htmlText << endl; file.close(); } void genCSS(shared_t *share) { string cssText = "body {\n"; cssText += " background-color: " + share->webBg + ";\n"; cssText += " color: " + share->webTxt + ";\n"; cssText += " font-family: " + share->webFont + ";\n"; cssText += "}\n"; cssText += "a {\n"; cssText += " color: " + share->webTxt + ";\n"; cssText += "}\n"; ofstream file(string(cleanDir(share->webRoot) + "/theme.css").c_str()); file << cssText << endl; file.close(); }