Ignore:
Timestamp:
1999-07-15T18:02:05+12:00 (25 years ago)
Author:
rjmcnab
Message:

Moved the setting of argsinfo into the constructor. Added the configuration
command argdefault (as used by the actions). Added code to output the
correct charset based on the page encoding so that the user does not need
to specify the encoding used for a particular page.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/receptionist.cpp

    r366 r388  
    1212/*
    1313   $Log$
     14   Revision 1.19  1999/07/15 06:02:05  rjmcnab
     15   Moved the setting of argsinfo into the constructor. Added the configuration
     16   command argdefault (as used by the actions). Added code to output the
     17   correct charset based on the page encoding so that the user does not need
     18   to specify the encoding used for a particular page.
     19
    1420   Revision 1.18  1999/07/11 01:05:20  rjmcnab
    1521   Stored origin of cgiarg with argument.
     
    9399
    94100
     101receptionist::receptionist () {
     102  // create a list of cgi arguments
     103  // this must be done before the configuration
     104
     105  cgiarginfo ainfo;
     106
     107  ainfo.shortname = "e";
     108  ainfo.longname = "compressed arguments";
     109  ainfo.multiplechar = true;
     110  ainfo.defaultstatus = cgiarginfo::good;
     111  ainfo.argdefault = "";
     112  ainfo.savedarginfo = cgiarginfo::mustnot;
     113  argsinfo.addarginfo (NULL, ainfo);
     114
     115  ainfo.shortname = "a";
     116  ainfo.longname = "action";
     117  ainfo.multiplechar = true;
     118  ainfo.defaultstatus = cgiarginfo::none;
     119  ainfo.argdefault = "";
     120  ainfo.savedarginfo = cgiarginfo::must;
     121  argsinfo.addarginfo (NULL, ainfo);
     122
     123  // w=western
     124  ainfo.shortname = "w";
     125  ainfo.longname = "encoding";
     126  ainfo.multiplechar = true;
     127  ainfo.defaultstatus = cgiarginfo::weak;
     128  ainfo.argdefault = "w";
     129  ainfo.savedarginfo = cgiarginfo::must;
     130  argsinfo.addarginfo (NULL, ainfo);
     131 
     132  ainfo.shortname = "nw";
     133  ainfo.longname = "new encoding";
     134  ainfo.multiplechar = true;
     135  ainfo.defaultstatus = cgiarginfo::none;
     136  ainfo.argdefault = "";
     137  ainfo.savedarginfo = cgiarginfo::mustnot;
     138  argsinfo.addarginfo (NULL, ainfo);
     139 
     140  ainfo.shortname = "c";
     141  ainfo.longname = "collection";
     142  ainfo.multiplechar = true;
     143  ainfo.defaultstatus = cgiarginfo::none;
     144  ainfo.argdefault = "";
     145  ainfo.savedarginfo = cgiarginfo::must;
     146  argsinfo.addarginfo (NULL, ainfo);
     147 
     148  // 0=text+graphics, 1=text
     149  ainfo.shortname = "v";
     150  ainfo.longname = "version";
     151  ainfo.multiplechar = false;
     152  ainfo.defaultstatus = cgiarginfo::weak;
     153  ainfo.argdefault = "0";
     154  ainfo.savedarginfo = cgiarginfo::can;
     155  argsinfo.addarginfo (NULL, ainfo);
     156 
     157  // 0=normal, 1=big
     158  ainfo.shortname = "f";
     159  ainfo.longname = "query box size";
     160  ainfo.multiplechar = false;
     161  ainfo.defaultstatus = cgiarginfo::weak;
     162  ainfo.argdefault = "0";
     163  ainfo.savedarginfo = cgiarginfo::can;
     164  argsinfo.addarginfo (NULL, ainfo);
     165 
     166  // the interface language name should use the ISO 639
     167  // standard
     168  ainfo.shortname = "l";
     169  ainfo.longname = "interface language";
     170  ainfo.multiplechar = true;
     171  ainfo.defaultstatus = cgiarginfo::weak;
     172  ainfo.argdefault = "en";
     173  ainfo.savedarginfo = cgiarginfo::must;
     174  argsinfo.addarginfo (NULL, ainfo);
     175}
     176
     177
    95178// configure should be called for each line in the
    96179// configuration files to configure the receptionist and everything
     
    100183  // configure the receptionist
    101184  if (cfgline.size() >= 1) {
     185    cgiarginfo *info = NULL;
    102186    if (key == "gsdlhome") configinfo.gsdlhome = cfgline[0];
    103     else if (key == "collection") configinfo.collection = cfgline[0];
    104     else if (key == "collectdir") configinfo.collectdir = cfgline[0];
     187    else if (key == "collection") {
     188      configinfo.collection = cfgline[0];
     189      // also need to set the default arg to this collection
     190      if ((info = argsinfo.getarginfo("c")) != NULL) {
     191    info->defaultstatus = cgiarginfo::good;
     192    info->argdefault = cfgline[0];
     193      }
     194     
     195    } else if (key == "collectdir") configinfo.collectdir = cfgline[0];
    105196    else if (key == "httpprefix") configinfo.httpprefix = cfgline[0];
    106197    else if (key == "httpimg") configinfo.httpimg = cfgline[0];
     
    108199    else if (key == "macrofiles") configinfo.macrofiles = cfgline;
    109200    else if (key == "saveconf") configinfo.saveconf = cfgline[0];
     201
     202    else if ((key == "argdefault") && (cfgline.size() == 2) &&
     203         ((info = argsinfo.getarginfo(cfgline[0])) != NULL)) {
     204      if (info->defaultstatus <= cgiarginfo::config) {
     205    info->defaultstatus = cgiarginfo::config;
     206    info->argdefault = cfgline[1];
     207      }
     208    }
    110209  }
    111210
     
    173272  if (!read_macrofiles (logout)) return false;
    174273
    175   // defined the main cgi arguments
    176   if (!define_mainargs (logout)) return false;
    177 
    178274  // there must be at least one action defined
    179275  if (actions.empty()) {
     
    222318  if (!defaultconvertname.empty()) {
    223319    cgiarginfo *ainfo = argsinfo.getarginfo ("w");
    224     if ((ainfo != NULL) && (ainfo->defaultstatus < cgiarginfo::good)) {
     320    if ((ainfo != NULL) && (ainfo->defaultstatus < cgiarginfo::config)) {
    225321      ainfo->defaultstatus = cgiarginfo::good;
    226322      ainfo->argdefault = defaultconvertname;
     
    377473    response = content;
    378474    response_data = "text/html";
     475  }
     476
     477  // add the encoding information
     478  if (response == content) {
     479    if (args["w"] == "u") {
     480      response_data += "; charset=UTF-8";
     481    } else {
     482      response_data += "; charset=ISO-8859-1";     
     483    }
    379484  }
    380485}
     
    510615
    511616
    512 // Will define the main general arguments used by the receptionist.
    513 // If an error occurs a message will be written to logout and the
    514 // method will return false.
    515 bool receptionist::define_mainargs (ostream &logout) {
    516   // create a list of cgi arguments
    517   cgiarginfo ainfo;
    518 
    519   ainfo.shortname = "e";
    520   ainfo.longname = "compressed arguments";
    521   ainfo.multiplechar = true;
    522   ainfo.defaultstatus = cgiarginfo::good;
    523   ainfo.argdefault = "";
    524   ainfo.savedarginfo = cgiarginfo::mustnot;
    525   if (!argsinfo.addarginfo (&logout, ainfo)) return false;
    526 
    527   ainfo.shortname = "a";
    528   ainfo.longname = "action";
    529   ainfo.multiplechar = true;
    530   ainfo.defaultstatus = cgiarginfo::none;
    531   ainfo.argdefault = "";
    532   ainfo.savedarginfo = cgiarginfo::must;
    533   if (!argsinfo.addarginfo (&logout, ainfo)) return false;
    534 
    535   // w=western
    536   ainfo.shortname = "w";
    537   ainfo.longname = "encoding";
    538   ainfo.multiplechar = true;
    539   ainfo.defaultstatus = cgiarginfo::weak;
    540   ainfo.argdefault = "w";
    541   ainfo.savedarginfo = cgiarginfo::must;
    542   if (!argsinfo.addarginfo (&logout, ainfo)) return false;
    543  
    544   ainfo.shortname = "nw";
    545   ainfo.longname = "new encoding";
    546   ainfo.multiplechar = true;
    547   ainfo.defaultstatus = cgiarginfo::none;
    548   ainfo.argdefault = "";
    549   ainfo.savedarginfo = cgiarginfo::mustnot;
    550   if (!argsinfo.addarginfo (&logout, ainfo)) return false;
    551  
    552   ainfo.shortname = "c";
    553   ainfo.longname = "collection";
    554   ainfo.multiplechar = true;
    555   if (configinfo.collection.empty()) {
    556     ainfo.defaultstatus = cgiarginfo::none;
    557     ainfo.argdefault = "";
    558     ainfo.savedarginfo = cgiarginfo::must;
    559   } else {
    560     ainfo.defaultstatus = cgiarginfo::good;
    561     ainfo.argdefault = configinfo.collection;
    562     ainfo.savedarginfo = cgiarginfo::can;
    563   }
    564   if (!argsinfo.addarginfo (&logout, ainfo)) return false;
    565  
    566   // 0=text+graphics, 1=text
    567   ainfo.shortname = "v";
    568   ainfo.longname = "version";
    569   ainfo.multiplechar = false;
    570   ainfo.defaultstatus = cgiarginfo::weak;
    571   ainfo.argdefault = "0";
    572   ainfo.savedarginfo = cgiarginfo::can;
    573   if (!argsinfo.addarginfo (&logout, ainfo)) return false;
    574  
    575   // 0=normal, 1=big
    576   ainfo.shortname = "f";
    577   ainfo.longname = "query box size";
    578   ainfo.multiplechar = false;
    579   ainfo.defaultstatus = cgiarginfo::weak;
    580   ainfo.argdefault = "0";
    581   ainfo.savedarginfo = cgiarginfo::can;
    582   if (!argsinfo.addarginfo (&logout, ainfo)) return false;
    583  
    584   // the interface language name should use the ISO 639
    585   // standard
    586   ainfo.shortname = "l";
    587   ainfo.longname = "interface language";
    588   ainfo.multiplechar = true;
    589   ainfo.defaultstatus = cgiarginfo::weak;
    590   ainfo.argdefault = "en";
    591   ainfo.savedarginfo = cgiarginfo::must;
    592   if (!argsinfo.addarginfo (&logout, ainfo)) return false;
    593 
    594   return true;
    595 }
    596  
    597  
    598617// check_mainargs will check all the main arguments. If a major
    599618// error is found it will return false and no cgi page should
Note: See TracChangeset for help on using the changeset viewer.