Ignore:
Timestamp:
1999-09-03T22:02:31+12:00 (25 years ago)
Author:
rjmcnab
Message:

Made the page parameters configurable. Now the page parameters must
correspond to cgi arguments in name and value (ie language=zh should now
be l=zh) which makes things more consistent anyway. Removed a couple of
specialised NZDL page parameters.

Moved the combining of the cgi arguments so that the receptionist does
all the configuration now.

Made the macro precedence configurable.

Made cgi arguments totally configurable. Now any piece of information about
a cgi argument can be configured meaning that cgi arguments can be declared
from the configuration file.

Removed the argdefault configuration argument. This should now be done
using cgiarg.

File:
1 edited

Legend:

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

    r526 r530  
    1212/*
    1313   $Log$
     14   Revision 1.29  1999/09/03 10:02:30  rjmcnab
     15   Made the page parameters configurable. Now the page parameters must
     16   correspond to cgi arguments in name and value (ie language=zh should now
     17   be l=zh) which makes things more consistent anyway. Removed a couple of
     18   specialised NZDL page parameters.
     19
     20   Moved the combining of the cgi arguments so that the receptionist does
     21   all the configuration now.
     22
     23   Made the macro precedence configurable.
     24
     25   Made cgi arguments totally configurable. Now any piece of information about
     26   a cgi argument can be configured meaning that cgi arguments can be declared
     27   from the configuration file.
     28
     29   Removed the argdefault configuration argument. This should now be done
     30   using cgiarg.
     31
    1432   Revision 1.28  1999/09/03 04:39:46  rjmcnab
    1533   Made cookies and logs optional (they are turned off by default). To
     
    150168  usecookies = false;
    151169  logcgiargs = false;
     170
     171  // these default page parameters can always be overriden
     172  // in the configuration file
     173  pageparams.erase(pageparams.begin(), pageparams.end());
     174  pageparams["c"] = "";
     175  pageparams["l"] = "en";
     176
     177#ifdef MACROPRECEDENCE
     178  macroprecedence = MACROPRECEDENCE;
     179#else
     180  macroprecedence.clear();
     181#endif
    152182}
    153183
     
    199229  ainfo.argdefault = "";
    200230  ainfo.savedarginfo = cgiarginfo::must;
    201   argsinfo.addarginfo (NULL, ainfo);
    202  
    203   // 0=text+graphics, 1=text
    204   ainfo.shortname = "v";
    205   ainfo.longname = "version";
    206   ainfo.multiplechar = false;
    207   ainfo.defaultstatus = cgiarginfo::weak;
    208   ainfo.argdefault = "0";
    209   ainfo.savedarginfo = cgiarginfo::can;
    210   argsinfo.addarginfo (NULL, ainfo);
    211  
    212   // 0=normal, 1=big
    213   ainfo.shortname = "f";
    214   ainfo.longname = "query box size";
    215   ainfo.multiplechar = false;
    216   ainfo.defaultstatus = cgiarginfo::weak;
    217   ainfo.argdefault = "0";
    218   ainfo.savedarginfo = cgiarginfo::can;
    219231  argsinfo.addarginfo (NULL, ainfo);
    220232 
     
    237249  ainfo.savedarginfo = cgiarginfo::mustnot;
    238250  argsinfo.addarginfo (NULL, ainfo);
    239 
     251}
     252
     253
     254void receptionist::add_action (action *theaction) {
     255  // make sure we have an action to add
     256  if (theaction == NULL) return;
     257
     258  // add this action to the list of actions
     259  actions.addaction(theaction);
     260 
     261  // add the cgi arguments from this action
     262  argsinfo.addarginfo (NULL, theaction->getargsinfo());
    240263}
    241264
     
    266289    else if (key == "usecookies") configinfo.usecookies = (cfgline[0] == "true");
    267290    else if (key == "logcgiargs") configinfo.logcgiargs = (cfgline[0] == "true");
    268 
    269     else if ((key == "argdefault") && (cfgline.size() == 2) &&
    270          ((info = argsinfo.getarginfo(cfgline[0])) != NULL)) {
    271       if (info->defaultstatus <= cgiarginfo::config) {
    272     info->defaultstatus = cgiarginfo::config;
    273     info->argdefault = cfgline[1];
     291    else if (key == "pageparam") {
     292      if (cfgline.size() >= 2) configinfo.pageparams[cfgline[0]] = cfgline[1];
     293      else configinfo.pageparams[cfgline[0]] = "";
     294    }
     295    else if (key == "macroprecedence") configinfo.macroprecedence = cfgline[0];
     296
     297   
     298    else if (key == "cgiarg") {
     299      // get shortname
     300      bool seen_defaultstatus = false;
     301      text_t subkey, subvalue;
     302      text_t shortname;
     303      text_t::const_iterator cfglinesub_here;
     304      text_tarray::const_iterator cfgline_here = cfgline.begin();
     305      text_tarray::const_iterator cfgline_end = cfgline.end();
     306      while (cfgline_here != cfgline_end) {
     307    cfglinesub_here = getdelimitstr((*cfgline_here).begin(),
     308                    (*cfgline_here).end(), '=', subkey);
     309    if (subkey == "shortname") {
     310      shortname = substr (cfglinesub_here, (*cfgline_here).end());
     311    }
     312    cfgline_here++;
    274313      }
    275     }
    276   }
    277 
     314
     315      // if we found the shortname process the line again filling in values
     316      if (!shortname.empty()) {
     317    cgiarginfo &chinfo = argsinfo[shortname];
     318    chinfo.shortname = shortname; // in case this is a new argument
     319   
     320    cfgline_here = cfgline.begin();
     321    while (cfgline_here != cfgline_end) {
     322      cfglinesub_here = getdelimitstr((*cfgline_here).begin(),
     323                      (*cfgline_here).end(), '=', subkey);
     324      subvalue = substr (cfglinesub_here, (*cfgline_here).end());
     325
     326      if (subkey == "longname") chinfo.longname = subvalue;
     327      else if (subkey == "multiplechar") chinfo.multiplechar = (subvalue == "true");
     328      else if (subkey == "defaultstatus") {
     329        seen_defaultstatus = true;
     330        if (subvalue == "none") chinfo.defaultstatus = cgiarginfo::none;
     331        else if (subvalue == "weak") chinfo.defaultstatus = cgiarginfo::weak;
     332        else if (subvalue == "good") chinfo.defaultstatus = cgiarginfo::good;
     333        else if (subvalue == "config") chinfo.defaultstatus = cgiarginfo::config;
     334        else if (subvalue == "imperative") chinfo.defaultstatus = cgiarginfo::imperative;
     335      }
     336      else if (subkey == "argdefault") {
     337        chinfo.argdefault = subvalue;
     338        if (!seen_defaultstatus) chinfo.defaultstatus = cgiarginfo::config;
     339      }
     340      else if (subkey == "savedarginfo") {
     341        if (subvalue == "mustnot") chinfo.savedarginfo = cgiarginfo::mustnot;
     342        else if (subvalue == "can") chinfo.savedarginfo = cgiarginfo::can;
     343        else if (subvalue == "must") chinfo.savedarginfo = cgiarginfo::must;
     344      }
     345     
     346      cfgline_here++;
     347    }
     348      }
     349    }
     350  }
     351
     352 
    278353  // configure the actions
    279354  actionptrmap::iterator actionhere = actions.begin ();
     
    346421  }
    347422
    348   // add the cgi arguments from the actions
    349   actionptrmap::iterator here = actions.begin ();
    350   actionptrmap::iterator end = actions.end ();
    351   while (here != end) {
    352     assert ((*here).second.a != NULL);
    353     if ((*here).second.a != NULL) {
    354       if (!argsinfo.addarginfo (&logout, (*here).second.a->getargsinfo()))
    355     return false;
    356     }
    357     here++;
    358   }
    359 
    360423  // create a saveconf string if there isn't one already
    361424  if (configinfo.saveconf.empty())
     
    386449  if (!defaultconvertname.empty()) {
    387450    cgiarginfo *ainfo = argsinfo.getarginfo ("w");
    388     if ((ainfo != NULL) && (ainfo->defaultstatus < cgiarginfo::config)) {
     451    if ((ainfo != NULL) && (converters.get_outconverter(ainfo->argdefault) == NULL)) {
    389452      ainfo->defaultstatus = cgiarginfo::good;
    390453      ainfo->argdefault = defaultconvertname;
     
    907970  // set up page parameters
    908971  text_t pageparams;
    909 
    910972  bool first = true;
    911   if (!args["c"].empty()) {
    912     pageparams +=  "collection=" + args["c"]; first = false;}
    913 
    914 //    if (args.getintarg("u") == 1)
    915 //      if (first) {pageparams += "style=htmlonly"; first = false;}
    916 //      else pageparams += ",style=htmlonly";
    917 //    if (args.getintarg("v") == 1)
    918 //      if (first) {pageparams += "version=text"; first = false;}
    919 //      else pageparams += ",version=text";
    920 //    if (args.getintarg("f") == 1)
    921 //      if (first) {pageparams += ",queryversion=big"; first = false;}
    922 //      else pageparams += ",queryversion=big";
    923   if (args["l"] != "en")
    924     if (first) pageparams += ",language=" + args["l"];
    925     else pageparams += ",language=" + args["l"];
    926 
    927   // this should be in a configuration file
    928   if (args["rl"] != "1")
    929     if (first) pageparams += ",rl=" + args["rl"];
    930     else pageparams += ",rl=" + args["rl"];
    931  
     973
     974  text_tmap::iterator params_here = configinfo.pageparams.begin();
     975  text_tmap::iterator params_end = configinfo.pageparams.end();
     976  while (params_here != params_end) {
     977    if (args[(*params_here).first] != (*params_here).second) {
     978      if (!first) pageparams += ",";
     979      first = false;
     980      pageparams += (*params_here).first;
     981      pageparams += "=";
     982      pageparams += args[(*params_here).first];
     983    }
     984   
     985    params_here++;
     986  }
     987 
     988
    932989  // open the page
    933   disp.openpage(pageparams, MACROPRECEDENCE);
     990  disp.openpage(pageparams, configinfo.macroprecedence);
    934991
    935992
Note: See TracChangeset for help on using the changeset viewer.