Ignore:
Timestamp:
2000-08-31T20:07:53+12:00 (24 years ago)
Author:
sjboddie
Message:

More improvements to collector

File:
1 edited

Legend:

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

    r1474 r1485  
    251251  // note that the "bildstatus" and "bildframe1" pages don't actually do anything
    252252  // functional so we don't need to worry about authenticating them (it's the
    253   // underlying "bild" page that does the building (anc creates the frameset))
     253  // underlying "bild" page that does the building (and creates the frameset))
    254254  // This helps us overcome a bit of a problem we have with multiple pages trying
    255255  // to read from the key.db database at the same time.
     
    324324    // turned on).
    325325    update_cfgfile_clone (args, logout);
     326
     327    // if cloning has just been turned on we'll also copy the rest of the files
     328    // (excluding collect.cfg which we've already done) from the cloned collections
     329    // etc directory to the new collection.
     330    if (args["bc1clone"] == "1") {
     331      text_t clone_etc = filename_cat(gsdlhome, "collect", args["bc1clonecol"], "etc");
     332      text_t new_etc = filename_cat(get_collectdir(args), args["bc1dirname"], "etc");
     333      text_tarray files;
     334
     335      if (read_dir (clone_etc, files)) {
     336    text_tarray::const_iterator here = files.begin();
     337    text_tarray::const_iterator end = files.end();
     338    while (here != end) {
     339      if (*here != "collect.cfg" && *here != "collect.cfg.org") {
     340        file_copy (filename_cat(clone_etc, *here), filename_cat(new_etc, *here));
     341      }
     342      here ++;
     343    }
     344      } else {
     345    outconvertclass text_t2ascii;
     346    logout <<text_t2ascii << "collectoraction::check_cgiargs couldn't read from "
     347           << clone_etc << " directory\n";
     348      }
     349    }
    326350  }
    327351 
     
    578602}
    579603
    580 // set the _fullnamemenu_ macro
     604// set the _fullnamemenu_ macro (and _warnindex_ if we're on the "srce" page)
    581605void collectoraction::set_fullnamemenu (displayclass &disp, cgiargsclass &args,
    582606                    recptprotolistclass *protos, ostream &logout) {
     
    633657        dirnames.push_back(*collist_here);
    634658        fullnames.push_back(collectionname);
    635         // check to see if the "collection" is writable
     659        // check to see if the collection is writable
    636660        if (collection_protected (*collist_here)) write_protected.push_back(true);
    637661        else write_protected.push_back(false);
     662
    638663        if (*collist_here == currentname) selected_index = index;       
    639        
    640664        index ++;
    641665      }
     
    647671  }
    648672
    649   bool have_one = false;
     673  bool first = true;
     674  text_t warnindex;
    650675  text_t fullnamemenu = "<select name=\"bc1dirname\">\n";
    651   if (current_page == "srce") fullnamemenu = "<select name=\"bc1clonecol\">\n";
     676  if (current_page == "srce") fullnamemenu = "<select name=\"bc1clonecol\" onChange=\"menuchange();\">\n";
    652677  for (int i = 0; i < index; i ++) {
    653678    // don't want write protected collections in list on "change existing
    654679    // collection" page
    655680    if (write_protected[i] && current_page == "existing") continue;
    656     have_one = true;
    657681    fullnamemenu += "<option value=\"" + dirnames[i] + "\"";
    658682    if (i == selected_index) fullnamemenu += " selected";
     
    660684    fullnamemenu += fullnames[i];
    661685    if (write_protected[i]) fullnamemenu += " <b>(write protected)</b>";
     686    fullnamemenu.push_back ('\n');
     687   
     688    // add to Warnindex if collection uses any dubious plugins
     689    // (if creating clone collection list)
     690    if (current_page == "srce") {
     691      if (!first) warnindex.push_back(',');
     692      if (uses_weird_plugin (dirnames[i])) {
     693    warnindex += text_t (1);
     694      } else {
     695    warnindex += text_t (0);
     696      }
     697    }
     698    first = false;
    662699  }
    663700  fullnamemenu += "</select>\n";
    664   if (have_one) disp.setmacro ("fullnamemenu", "collector", fullnamemenu);
     701
     702  if (!first) {
     703    disp.setmacro ("fullnamemenu", "collector", fullnamemenu);
     704    if (current_page == "srce")
     705      disp.setmacro ("warnindex", "collector", warnindex);
     706  }
    665707}
    666708
     
    718760  if (file_exists (bld_file + ".download")) {
    719761    statusline = "Downloading files ...<br>\n";
    720     statusline += file_tail (bld_file + ".download");
     762    statusline += file_tail (bld_file + ".download", 1);
    721763  } else if (file_exists (bld_file + ".import")) {
    722764    statusline = "Importing collection ...<br>\n";
    723     statusline += file_tail (bld_file + ".import");
     765    statusline += file_tail (bld_file + ".import", 1);
    724766  } else if (file_exists (bld_file + ".build")) {
    725767    statusline = "Building collection ...<br>\n";
    726     statusline += file_tail (bld_file + ".build");
     768    statusline += file_tail (bld_file + ".build", 1);
    727769  } else {
    728770    statusline += "creating collection ...<br>\n";
    729     statusline += file_tail (bld_file);
     771    statusline += file_tail (bld_file, 1);
    730772  }
    731773
     
    745787  // _statusline_ -- if displaying the bildstatus page
    746788  // _header_ -- may be set for pages that require it
     789  // _faillog_ - set to last 6 lines of .bld file if build failed
    747790
    748791  text_t &collector_page = args["cp"];
     
    797840    collectorbar += get_button (collector_page, "green", "conf", true);
    798841    collectorbar += "<td>_icongreyarrow_</td>\n";
    799     collectorbar += get_button (collector_page, "grey", "bild", false);
     842    collectorbar += get_button (collector_page, "green", "bild", true);
    800843    collectorbar += "<td>_icongreyarrow_</td>\n";
    801844    collectorbar += get_button (collector_page, "grey", "view", false);
     
    857900    collectorbar += "<td>_icongreyarrow_</td>\n";
    858901    collectorbar += get_button (collector_page, "grey", "view", false);
     902  }
     903
     904  if (collector_page == "bildfail") {
     905    text_t bldlog = filename_cat(gsdlhome, "tmp", args["bc1tmp"], args["bc1dirname"] + ".bld");
     906    text_t rawlog = file_tail (bldlog, 6);
     907    // we'll shove in some <br> tags where \n's occur
     908    text_t faillog;
     909    text_t::const_iterator here = rawlog.begin();
     910    text_t::const_iterator end = rawlog.end();
     911    while (here != end) {
     912      if (*here == '\n') faillog += "<br>";
     913      faillog.push_back (*here);
     914      here ++;
     915    }
     916    disp.setmacro ("faillog", "collector", faillog);
    859917  }
    860918
     
    12291287  }
    12301288}
     1289
     1290// checks to see if any of the plugins in pluginset occur in
     1291// collections configuration file
     1292bool collectoraction::uses_weird_plugin (const text_t &collection) {
     1293
     1294  text_tset pluginset;
     1295  pluginset.insert ("HBPlug");
     1296
     1297  text_t cfgfile_content;
     1298  text_t cfgfile_name = filename_cat (gsdlhome, "collect", collection, "etc", "collect.cfg");
     1299  text_t pluginstr, pluginname;
     1300
     1301  if (read_file (cfgfile_name, cfgfile_content)) {
     1302    text_t::const_iterator here = cfgfile_content.begin();
     1303    text_t::const_iterator end = cfgfile_content.end();
     1304    while (here != end) {
     1305      here = findchar (here, end, 'p');
     1306      if (here == end) break;
     1307      if ((here+6 < end) && (substr (here, here+6) == "plugin")) {
     1308    getdelimitstr (here+6, end, '\n', pluginstr);
     1309    text_t::const_iterator hp = pluginstr.begin();
     1310    text_t::const_iterator ep = pluginstr.end();
     1311    bool found = false;
     1312    // remove any leading whitespace, trailing options etc.
     1313    while (hp != ep) {
     1314      if (*hp == '\t' || *hp == ' ' || *hp == '\n') {
     1315        if (found) break;
     1316      } else {
     1317        pluginname.push_back (*hp);
     1318        found = true;
     1319      }
     1320      hp ++;
     1321    }
     1322    text_tset::const_iterator it = pluginset.find (pluginname);
     1323    if (it != pluginset.end()) return true; // found matching plugin
     1324    pluginname.clear();
     1325      }
     1326      here ++;
     1327    }
     1328  }
     1329  return false;
     1330}
Note: See TracChangeset for help on using the changeset viewer.