Changeset 1485 for trunk


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

More improvements to collector

Location:
trunk/gsdl
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/build

    r1461 r1485  
    140140        # we assume anything not beginning with http:// or ftp://
    141141        # is a file or directory on the local file system.
    142         $download_dir =~ s/^file:\/\///;
     142        $download_dir =~ s/^file:(\/\/)?//;
    143143       
    144144        if (-e $download_dir) {
  • trunk/gsdl/bin/script/filecopy.pl

    r1454 r1485  
    5454    my $full_importname
    5555    = &util::filename_cat($collectdir, $dirname, "import");
    56 
    57     print $out "full_importname: $full_importname\n";
    5856
    5957    # split argv into 2 lists: files and directories
  • trunk/gsdl/lib/fileutil.cpp

    r1476 r1485  
    280280}
    281281
    282 // returns the last line (or last 256 characters)
    283 // of filename file
     282
     283text_t file_tail (const text_t &filename, int numlines) {
     284  if (numlines < 1) numlines = 1;
     285  int numchars = 256*numlines;
     286
     287  text_tarray lines;
     288  text_t ret;
     289
     290  char *filenamec = filename.getcstr();
     291  char linec[256];
     292  ifstream file_in (filenamec);
     293  delete filenamec;
     294  if (file_in) {
     295
     296    // this should be here to keep things reasonably fast
     297    // when there's a long file to tail but I can't work out
     298    // how to tell when it's rewound past the beginning of the file
     299    // (which causes some problems)
     300
     301    //    file_in.seekg (-numchars, ios::end);
     302
     303    while (!file_in.eof()) {
     304      file_in.getline (linec, 256);
     305      ret.setcstr(linec);
     306      text_t::const_iterator here = ret.begin();
     307      text_t::const_iterator end = ret.end();
     308      // make sure line has content
     309      while (here != end) {
     310    if (*here != '\n' && *here != ' ') {
     311      lines.push_back (ret);
     312      break;
     313    }
     314    here ++;
     315      }
     316    }
     317    file_in.close();
     318  }
     319
     320  ret.clear();
     321  int numlinesgot = lines.size();
     322  int sindex = 0;
     323  if (numlinesgot > numlines) sindex = numlinesgot - numlines;
     324  for (int i = sindex; i < numlinesgot; i++) {
     325    ret += lines[i] + "\n";
     326  }
     327
     328  return ret;
     329}
     330
     331// returns the last numlines lines (or last numlines*256
     332// characters) of file
     333/*
    284334text_t file_tail (const text_t &filename) {
     335
    285336
    286337  text_t return_str, tmpstr;
    287338  char *filenamec = filename.getcstr();
    288339  char linec[256];
    289 
    290340
    291341  ifstream file_in (filenamec);
     
    313363  return return_str;
    314364}
    315 
     365*/
    316366#ifdef __WIN32__
    317367
     
    343393
    344394#endif
     395
     396// read in file from filename and load into content
     397bool read_file (const text_t &filename, text_t &content) {
     398
     399  content.clear();
     400
     401  char *filenamec = filename.getcstr();
     402#ifdef GSDL_USE_IOS_H
     403  ifstream file_in (filenamec, ios::in | ios::nocreate);
     404#else
     405  ifstream file_in (filenamec, ios::in);
     406#endif
     407  delete filenamec;
     408
     409  if (file_in) {
     410    char c;
     411    file_in.get(c);
     412    while (!file_in.eof ()) {
     413      content.push_back(c);
     414      file_in.get(c);
     415    }
     416    file_in.close();
     417  } else {
     418    return false;
     419  }
     420  return true;
     421}
  • trunk/gsdl/lib/fileutil.h

    r1456 r1485  
    5353bool file_copy (const text_t &fromfile, const text_t &tofile);
    5454
    55 text_t file_tail (const text_t &filename);
     55text_t file_tail (const text_t &filename, int numlines);
    5656
    5757// returns true if directory created successfully
    5858bool mk_dir (const text_t &dirname);
    5959
     60bool read_file (const text_t &filename, text_t &content);
     61
    6062#endif
  • trunk/gsdl/macros/collect.dm

    r1476 r1485  
    1919_gstimage_ [v=1] {<a href="_1_" target="\_top">_5_</a><br>}
    2020
    21 
    22 
    2321# a plain header for those pages that need it (the _pagebanner_ macro
    2422# will be set to this by the server for those pages.
    2523_plainbanner_ {}
     24
     25# dont want links to "help" or "preferences" pages from within
     26# collector
     27_javalinks_ {_imagehome_}
     28_javalinks_ [v=1] {
     29_imagehome_<br>
     30}
     31
    2632
    2733#######################################################################
     
    7985_httpconf_ {_gwcgi_?e=_compressedoptions_&cp=conf}
    8086_httpbild_ {_gwcgi_?e=_compressedoptions_&cp=bild}
    81 _httpview_ {_gwcgi_?e=_compressedoptions_&a=p&p=about&c=_cgiargbc1dirname_}
     87_httpview_ {_gwcgi_?a=p&p=about&c=_cgiargbc1dirname_}
    8288_httpdel_  {javascript:do_delete();}
    8389
     
    429435function check\_submit (gotopage) \{
    430436  var form = document.collectorform;
    431   if (form.bc1inputdir1.value.match(/^\\s*$/) &&
    432       form.bc1inputdir2.value.match(/^\\s*$/) &&
    433       form.bc1inputdir3.value.match(/^\\s*$/) &&
    434       form.bc1inputdir4.value.match(/^\\s*$/))
     437  var found = 0;
     438  var i = 0;
     439  if (!form.bc1inputdir1.value.match(/^\\s*$/)) \{
     440    if (!form.bc1inputdir1.value.match(/^\(http|ftp|file\):/)) \{
     441      i = form.sel1.selectedIndex;
     442      form.bc1inputdir1.value = form.sel1.options[i].value + form.bc1inputdir1.value;
     443    \}
     444    found = 1;
     445  \}
     446  if (!form.bc1inputdir2.value.match(/^\\s*$/)) \{
     447    if (!form.bc1inputdir2.value.match(/^\(http|ftp|file\):/)) \{
     448      i = form.sel2.selectedIndex;
     449      form.bc1inputdir2.value = form.sel2.options[i].value + form.bc1inputdir2.value;
     450    \}
     451    found = 1;
     452  \}
     453  if (!form.bc1inputdir3.value.match(/^\\s*$/)) \{
     454    if (!form.bc1inputdir3.value.match(/^\(http|ftp|file\):/)) \{
     455      i = form.sel3.selectedIndex;
     456      form.bc1inputdir3.value = form.sel3.options[i].value + form.bc1inputdir3.value;
     457    \}
     458    found = 1;
     459  \}
     460  if (!form.bc1inputdir4.value.match(/^\\s*$/)) \{
     461    if (!form.bc1inputdir4.value.match(/^\(http|ftp|file\):/)) \{
     462      i = form.sel4.selectedIndex;
     463      form.bc1inputdir4.value = form.sel4.options[i].value + form.bc1inputdir4.value;
     464    \}
     465    found = 1;
     466  \}
     467
     468  if (!found)
    435469  \{
    436470    alert("At least one input source must be specified");
     
    449483  \} else \{
    450484    form.bc1clonechanged.value = 0;
     485  \}
     486  menuchange();
     487\}
     488
     489function menuchange () \{
     490  var form = document.collectorform;
     491  var warnlist = new Array (_warnindex_);
     492
     493  if (warnlist[form.bc1clonecol.selectedIndex] == 1) \{
     494    alert ("The collection you are cloning has a non-standard input file\\n" +
     495           "format, and/or uses metadata specified in auxiliary files.  If your\\n" +
     496       "new input lacks this information, some browsing facilities may not\\n" +
     497           "work properly.");
    451498  \}
    452499\}
     
    499546
    500547<h4>Input source:</h4>
    501 <input type=text name="bc1inputdir1" value="_cgiargbc1inputdir1_" size=72>
     548_typeselect_(1,file)<input type=text name="bc1inputdir1" value="_cgiargbc1inputdir1_" size=60>
    502549<br>
    503 <input type=text name="bc1inputdir2" value="_cgiargbc1inputdir2_" size=72>
     550_typeselect_(2,http)<input type=text name="bc1inputdir2" value="_cgiargbc1inputdir2_" size=60>
    504551<br>
    505 <input type=text name="bc1inputdir3" value="_cgiargbc1inputdir3_" size=72>
     552_typeselect_(3,ftp)<input type=text name="bc1inputdir3" value="_cgiargbc1inputdir3_" size=60>
    506553<br>
    507 <input type=text name="bc1inputdir4" value="_cgiargbc1inputdir4_" size=72>
     554_typeselect_(4,file)<input type=text name="bc1inputdir4" value="_cgiargbc1inputdir4_" size=60>
    508555<br>
    509556<font color="#909090">
     
    525572
    526573<p>_iconblankbar_
    527 <p>Remember, you can always revisit a previous stage by clicking its yellow
    528 button.
     574<p>Click one of the green buttons. If you are an advanced user you may want
     575to adjust the collection configuration. Alternatively, go straight to the
     576building stage. Remember, you can always revisit an earlier stage by
     577clicking its yellow button.
    529578
    530579<p><center>
     
    537586</form>
    538587}
     588
     589_typeselect_ {<select name="sel_1_">
     590<option value="file://" _If_("_2_" eq "file",selected)>file://
     591<option value="http://" _If_("_2_" eq "http",selected)>http://
     592<option value="ftp://" _If_("_2_" eq "ftp",selected)>ftp://
     593</select>}
    539594
    540595_srcemenu_ {<input type=radio name=bc1clone onClick="clone_changed(1);" value=1
     
    622677<frameset rows="*,150" border=0>
    623678  <noframes><body bgcolor="#ffffff">
    624   <p>You must have a frame enabled browser to view this.</p>
     679  <p>You must have a frame enabled browser to obtain feedback
     680  on how the building process is progressing. The collection <i>will</i>
     681  continue to build as normal however.
     682
     683  <table>
     684  <tr valign=center><td>
     685  To stop the building process at any time, click here.
     686  <br>The collection you are working on will remain intact.
     687  </td>
     688  <td><input type="submit" value="stop building"></td>
     689  </table>
     690
    625691  </body>
    626692  </noframes>
     
    681747status line below gives feedback on how the operation is progressing.
    682748<p>
    683 To stop the building process at any time, click here:
    684 <input type="submit" value="stop building">
     749
     750<table>
     751<tr valign=center><td>
     752To stop the building process at any time, click here.
    685753<br>The collection you are working on will remain intact.
     754</td>
     755<td><input type="submit" value="stop building"></td>
     756</table>
     757
    686758<p>
    687759If you leave this page (and have not cancelled the building process with
     
    814886<tr><td>
    815887<p>An error has occurred while attempting to build your collection.
     888<br> The build log contains the following:
     889<p>_faillog_
    816890</td></tr>
    817891</table></center>
  • 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}
  • trunk/gsdl/src/recpt/collectoraction.h

    r1457 r1485  
    7575  text_t get_collectdir (cgiargsclass &args);
    7676
     77  bool collectoraction::uses_weird_plugin (const text_t &collection);
     78
    7779public:
    7880  collectoraction ();
Note: See TracChangeset for help on using the changeset viewer.