<commit_before>// webadmin.cpp : Defines the entry point for the DLL application.
//

#include "bzfsAPI.h"
#include "plugin_utils.h"
#include "plugin_HTTP.h"
#include "plugin_HTTPTemplates.h"

class WebAdmin : public BZFSHTTPServer, TemplateCallbackClass
{
public:
  WebAdmin(const char * plugInName);

  void init (std::string &tDir);

  // from BSFSHTTPServer
  virtual bool acceptURL ( const char *url ) { return true; }
  virtual void getURLData ( const char* url, int requestID, const URLParams &paramaters, bool get = true );

  Templateiser templateSystem;

  // from TemplateCallbackClass
  virtual void keyCallback ( std::string &data, const std::string &key );
  virtual bool loopCallback ( const std::string &key );
  virtual bool ifCallback ( const std::string &key );
};

WebAdmin webAdmin("webadmin");

BZ_GET_PLUGIN_VERSION

BZF_PLUGIN_CALL int bz_Load(const char* commandLine)
{
  webAdmin.init(std::string(commandLine ? commandLine : "./"));

  bz_debugMessage(4,"webadmin plugin loaded");
  webAdmin.startupHTTP();
  return 0;
}

BZF_PLUGIN_CALL int bz_Unload(void)
{
  webAdmin.shutdownHTTP();
  bz_debugMessage(4,"webadmin plugin unloaded");
  return 0;
}

WebAdmin::WebAdmin(const char *plugInName)
: BZFSHTTPServer(plugInName)
{
}

void WebAdmin::init(std::string &tDir)
{
  templateSystem.addSearchPath(tDir.c_str());

  /* template symbols go here */

  templateSystem.setPluginName("Web Report", getBaseServerURL());
}

// event hook for [$Something] in templates
void WebAdmin::keyCallback (std::string &data, const std::string &key)
{

}

// condition check for [*START] in templates
bool WebAdmin::loopCallback (const std::string &key)
{<commit_msg>pass the search dir in as a char* so we don't have to make an unnamed temp.<commit_after>// webadmin.cpp : Defines the entry point for the DLL application.
//

#include "bzfsAPI.h"
#include "plugin_utils.h"
#include "plugin_HTTP.h"
#include "plugin_HTTPTemplates.h"

class WebAdmin : public BZFSHTTPServer, TemplateCallbackClass
{
public:
  WebAdmin(const char * plugInName);

  void init (const char *tDir);

  // from BSFSHTTPServer
  virtual bool acceptURL ( const char *url ) { return true; }
  virtual void getURLData ( const char* url, int requestID, const URLParams &paramaters, bool get = true );

  Templateiser templateSystem;

  // from TemplateCallbackClass
  virtual void keyCallback ( std::string &data, const std::string &key );
  virtual bool loopCallback ( const std::string &key );
  virtual bool ifCallback ( const std::string &key );
};

WebAdmin webAdmin("webadmin");

BZ_GET_PLUGIN_VERSION

BZF_PLUGIN_CALL int bz_Load(const char* commandLine)
{
  webAdmin.init(commandLine ? commandLine : "./");

  bz_debugMessage(4,"webadmin plugin loaded");
  webAdmin.startupHTTP();
  return 0;
}

BZF_PLUGIN_CALL int bz_Unload(void)
{
  webAdmin.shutdownHTTP();
  bz_debugMessage(4,"webadmin plugin unloaded");
  return 0;
}

WebAdmin::WebAdmin(const char *plugInName)
: BZFSHTTPServer(plugInName)
{
}

void WebAdmin::init(const  char* tDir)
{
  if (tDir)
    templateSystem.addSearchPath(tDir);

  /* template symbols go here */

  templateSystem.setPluginName("Web Report", getBaseServerURL());
}

// event hook for [$Something] in templates
void WebAdmin::keyCallback (std::string &data, const std::string &key)
{

}

// condition check for [*START] in templates
bool WebAdmin::loopCallback (const std::string &key)
{
{'fraction_non_alphanumeric': 0.11795774647887323, 'fraction_numerical': 0.002347417840375587, 'mean_word_length': 5.065836298932385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2736058', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1100, 'n_words': 306}