Roxen.git / server / config_interface / logutil.pike

version» Context lines:

Roxen.git/server/config_interface/logutil.pike:1: + #include <config_interface.h>   #include <config.h>   #include <roxen.h>      //<locale-token project="roxen_config">LOCALE</locale-token> - #define LOCALE(X,Y) _STR_LOCALE("roxen_config",X,Y) - #define CALL(X,Y) _LOCALE_FUN("roxen_config",X,Y) + #define LOCALE(X,Y) _STR_LOCALE("roxen_config",X,Y) + #define CALL(X,Y) _LOCALE_FUN("roxen_config",X,Y)      int __lt;   string describe_time(int t)   {    int full;    if(localtime(__lt)->yday != localtime(t)->yday)    {    __lt = t;    full=1;    }
Roxen.git/server/config_interface/logutil.pike:71:   string fix_err(string s)   {    sscanf(reverse(s), "%*[ \t\n]%s", s);    s=reverse(s);    if(s=="")    return s;    if(!(<'.','!','?'>)[s[-1]]) s+=".";    return Roxen.html_encode_string(capitalize(s));   }    +  + constant logitem_tmpl = #" +  <ul class='logitem'> +  <li class='err-{{ code }}' title='{{ code_text }}'> +  {{ &links }} +  {{ #times }}<span class='times'>{{ times }}</span><br>{{ /times }} +  {{ &message }} +  </li> +  </ul>"; +    int last_time;   string describe_error(string err, array (int) times,    string lang, int|void no_links)   {    int code, nt;    string links = "", reference, server;    array(string) codetext=({ LOCALE(209, "Notice"),    LOCALE(210, "Warning"),    LOCALE(211, "Error") });       if(sizeof(times)==1 && times[0]/60==last_time) nt=1;    last_time=times[0]/60;    sscanf(err, "%d,%[^,],%s", code, reference, err); -  +     switch(no_links)    {    Configuration conf;    RoxenModule module;    case 2:    sscanf(reference, "%[^/]", server);    if(conf = roxen->find_configuration( server ))    links += sprintf("<a href=\"%s\">%s</a> : ",    @get_conf_url_to_virtual_server( conf, lang ));    case 1: // find_configuration(configinterface)->query_name() == realname    if(module = Roxen.get_module( reference ))    links += sprintf("<a href=\"%s\">%s</a> : ",    @get_conf_url_to_module( module, lang ));    }    -  return "<table class='logitems'><tr><td><img src=&usr.err-"+code+"; \n" -  "alt=\"" + codetext[code-1] + "\" />" -  "</td><td>" + links + (nt?"":describe_times(times)+"<br />") + -  replace(fix_err(err), "\n", "<br />\n") + "</table>"; +  mapping mctx = ([ +  "code" : code, +  "code_text" : codetext[code-1], +  "links" : links, +  "times" : nt ? 0 : describe_times(times), +  "message" : replace(fix_err(err), "\n", "<br />\n") +  ]); +  +  Mustache stache = Mustache(); +  string out = stache->render(logitem_tmpl, mctx); +  +  destruct(stache); +  +  return out; +  +  // return "<table class='logitems'><tr><td><img src=&usr.err-"+code+"; \n" +  // "alt=\"" + codetext[code-1] + "\" />" +  // "</td><td>" + links + (nt?"":describe_times(times)+"<br />") + +  // replace(fix_err(err), "\n", "<br />\n") + "</table>";   }         // Returns ({ URL to module config page, human-readable (full) module name })   array(string) get_conf_url_to_module(string|RoxenModule m, string|void lang)   {    // module is either a RoxenModule object or a string as returned by    // get_modname(some RoxenModule), eg "ConfigInterface/piketag#0"    RoxenModule module = stringp(m) ? Roxen.get_module(m) : m;    Configuration conf = module->my_configuration();