Changeset 1437 for trunk


Ignore:
Timestamp:
2000-08-21T16:47:48+12:00 (24 years ago)
Author:
sjboddie
Message:

* empty log message *

Location:
trunk/gsdl
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/lib/fileutil.cpp

    r1434 r1437  
    253253#endif
    254254}
     255
     256// returns the last line (or last 256 characters)
     257// of filename file
     258text_t file_tail (const text_t &filename) {
     259
     260  text_t return_str;
     261  char *filenamec = filename.getcstr();
     262
     263  ifstream file_in (filenamec);
     264  if (file_in) {
     265    file_in.seekg (256, ios::end);
     266    char c;
     267    file_in.get(c);
     268    while (!file_in.eof()) {
     269      if (c == '\n') return_str.clear();
     270      else return_str.push_back (c);
     271      file_in.get(c);
     272    }
     273    file_in.close();
     274  }
     275  delete filenamec;
     276  return return_str;
     277}
  • trunk/gsdl/lib/fileutil.h

    r1426 r1437  
    5151void file_copy (const text_t &fromfile, const text_t &tofile);
    5252
     53text_t file_tail (const text_t &filename);
     54
    5355#endif
  • trunk/gsdl/macros/collect.dm

    r1433 r1437  
    1414_gsjimage_ [v=1] {<a href="#" onClick="check\_submit(_4_);">_5_</a><br>}
    1515
     16
     17# a plain header for those pages that need it (the _pagebanner_ macro
     18# will be set to this by the server for those pages.
     19_plainbanner_ {}
    1620
    1721#######################################################################
     
    598602# Build page
    599603
    600 _bildscriptextra_ {
    601 var changed = 0;
    602 
    603 function check\_submit (gotopage) \{
    604   var form = document.collectorform;
    605   form.bc1cfgchanged.value = changed;
    606   form.cp.value = gotopage;
    607   form.submit();
    608 \}
    609 }
    610 
    611604_bildcontent_ {
    612 <form name="collectorform" method=post action="_gwcgi_">
    613 <input type=hidden name="e" value="_decodedcompressedoptions_">
    614 <input type=hidden name="cp" value="_cgiargcp_">
    615 
     605<frameset rows="*,150" border=0>
     606  <noframes><body bgcolor="#ffffff">
     607  <p>You must have a frame enabled browser to view this.</p>
     608  </body>
     609  </noframes>
     610  <frame src="_gwcgi_?e=_compressedoptions_&cp=bildframe1">
     611  <frame src="_gwcgi_?e=_compressedoptions_&cp=bildstatus">
     612</frameset>
     613}
     614
     615_bildframe1scriptextra_ {}
     616_bildframe1content_ {
    616617<center>
    617618<table width=_pagewidth_>
     
    622623</center>
    623624<p>_iconblankbar_
    624 
    625 <p><center>
    626 _collectorbar_
    627 </center>
    628 
    629 </td></tr>
    630 </table></center>
    631 
    632 </form>
    633 }
    634 
    635 
    636 
     625<p>
     626The collection is now being built: this might take some time. The building
     627status line below gives feedback on how the operation is progressing.
     628</td></tr>
     629</table></center>
     630}
     631
     632_bildstatusscriptextra_ {}
     633_bildstatuscontent_ {
     634<center>
     635<table width=_pagewidth_>
     636<tr><td>
     637_statusline_
     638</td></tr>
     639</table></center>
     640}
    637641
    638642#######################################################################
     
    643647<form name="collectorform" method=post action="_gwcgi_">
    644648<input type=hidden name="e" value="_decodedcompressedoptions_">
     649
     650<center>
     651<table width=_pagewidth_>
     652<tr><td>
    645653_iconblankbar_
    646654}
     
    649657<p>
    650658<a href="javascript:document.collectorform.submit();">Return to the collector</a>
     659<p>_iconblankbar_
     660</td></tr>
     661</table></center>
    651662</form>
    652 _iconblankbar_
    653663}
    654664
  • trunk/gsdl/src/recpt/collectoraction.cpp

    r1432 r1437  
    511511  while (rprotolist_here != rprotolist_end) {
    512512    if ((*rprotolist_here).p != NULL) {
     513
     514      // don't include z39.50 collection
     515      if ((*rprotolist_here).p->get_protocol_name () == "z3950proto") {
     516    rprotolist_here ++;
     517    continue;
     518      }
     519
    513520      text_tarray collist;
    514521      comerror_t err;
     
    601608}
    602609
     610// set the _statusline_ macro
     611void collectoraction::set_statusline (displayclass &disp, const text_t &collection, ostream &logout) {
     612
     613  // the build command creates .bld.download, .bld.import, and .bld.build files (in that
     614  // order) and deletes them (also in that order) when each stage is complete. the .bld
     615  // file is the concatenation of all these files.
     616  text_t bld_file = filename_cat (gsdlhome, "tmp", collection + ".bld");
     617  text_t statusline;
     618
     619  if (file_exists (bld_file + ".download")) {
     620    statusline = "Downloading files ...<br>";
     621    statusline += file_tail (bld_file + ".download");
     622  } else if (file_exists (bld_file + ".import")) {
     623    statusline = "Importing collection ...<br>";
     624    statusline += file_tail (bld_file + ".import");
     625  } else if (file_exists (bld_file + ".build")) {
     626    statusline = "Building collection ...";
     627    statusline += file_tail (bld_file + ".build");
     628  } else {
     629    statusline += file_tail (bld_file);
     630  }
     631
     632  disp.setmacro ("statusline", "collector", statusline);
     633
     634}
     635
    603636void collectoraction::define_internal_macros (displayclass &disp, cgiargsclass &args,
    604637                          recptprotolistclass *protos, ostream &logout) {
     
    610643  //                   collection" page
    611644  // _cfgfile_ -- if displaying the "configure collection" page
     645  // _statusline_ -- if displaying the bildstatus page
     646  // _pagebanner_ -- may be set to _collector:plainbanner_ for some pages
    612647
    613648  text_t &collector_page = args["cp"];
     
    617652  // set _pagescriptextra_ macro to _cpagescriptextra_
    618653  disp.setmacro ("pagescriptextra", "collector", "_" + collector_page + "scriptextra_");
     654
     655  // set _pagebanner_ for those pages that don't want a fancy header (e.g. those
     656  // displayed in frames
     657  if (collector_page == "bildstatus") {
     658    disp.setmacro ("pagebanner", "collector", "_plainbanner_");
     659  }
    619660
    620661  // set the collectorbar macro
     
    696737  if (collector_page == "conf")
    697738    set_cfgfile (disp, args["bc1dirname"], logout);
     739  if (collector_page == "bildstatus")
     740    set_statusline (disp, args["bc1dirname"], logout);
    698741}
    699742
     
    705748  text_t &collector_page = args["cp"];
    706749  text_t &collection = args["bc1dirname"];
    707   text_t message;
    708 
    709   if (do_mkcol) {
    710     // execute mkcol.pl (do_mkcol is set from within check_cgiargs)
    711     text_t mkcol_cmd = "perl ";
    712     mkcol_cmd += filename_cat (gsdlhome, "bin", "script", "mkcol.pl");
    713     mkcol_cmd += " -creator \"" + args["bc1contactemail"] + "\"";
    714     mkcol_cmd += " -title \"" + args["bc1fullname"] + "\"";
    715     mkcol_cmd += " -about \"" + carriage_replace (args["bc1aboutdesc"], 0) + "\" ";
    716     mkcol_cmd += collection;
    717     char *mkcol_cmdc = mkcol_cmd.getcstr();
    718     system (mkcol_cmdc);
    719     delete mkcol_cmdc;
    720    
    721     // make sure it went ok
    722     text_t cfgfile = filename_cat (gsdlhome, "collect", collection,
    723                    "etc", "collect.cfg");
    724     if (!file_writable (cfgfile)) message = "mkcolfail";
    725     do_mkcol = false; // reset for fast-cgi
    726   }
    727750
    728751  if (collector_page == "bild") {
     
    759782#endif
    760783    delete build_cmdc;
    761   }
    762 
    763   if (args["bc1dodelete"] == "1") {
    764     // delete bcidirname collection
    765     if (collection_protected (collection)) {
    766       message = "delinvalid";
    767 
     784
     785    // don't want header and stuff for build page as it uses frames
     786    textout << outconvert << disp << ("_collector:bildcontent_\n");
     787
     788  } else {
     789
     790    // not bild page
     791
     792    text_t message;
     793
     794    if (do_mkcol) {
     795      // execute mkcol.pl (do_mkcol is set from within check_cgiargs)
     796      text_t mkcol_cmd = "perl ";
     797      mkcol_cmd += filename_cat (gsdlhome, "bin", "script", "mkcol.pl");
     798      mkcol_cmd += " -creator \"" + args["bc1contactemail"] + "\"";
     799      mkcol_cmd += " -title \"" + args["bc1fullname"] + "\"";
     800      mkcol_cmd += " -about \"" + carriage_replace (args["bc1aboutdesc"], 0) + "\" ";
     801      mkcol_cmd += collection;
     802      char *mkcol_cmdc = mkcol_cmd.getcstr();
     803      system (mkcol_cmdc);
     804      delete mkcol_cmdc;
     805     
     806      // make sure it went ok
     807      text_t cfgfile = filename_cat (gsdlhome, "collect", collection,
     808                     "etc", "collect.cfg");
     809      if (!file_writable (cfgfile)) message = "mkcolfail";
     810      do_mkcol = false; // reset for fast-cgi
     811    }
     812
     813    if (args["bc1dodelete"] == "1") {
     814      // delete bcidirname collection
     815      if (collection_protected (collection)) {
     816    message = "delinvalid";
     817   
     818      } else {
     819   
     820    text_t delete_cmd = "perl " + filename_cat (gsdlhome, "bin", "script", "delcol.pl");
     821    delete_cmd += " -f " + collection;
     822    char *delete_cmdc = delete_cmd.getcstr();
     823    int rv = system (delete_cmdc);
     824    delete delete_cmdc;
     825    if (rv != 0) {
     826      // deletion failed -- permissions?
     827      message = "delpermission";
     828    } else {
     829      message = "delsuccess";
     830    }
     831      }
     832    }
     833   
     834    if (clone_failed) {
     835      // clone_failed is set from check_cgiargs if an attempt was made
     836      // to clone an invalid collection
     837      message = "clonefail";
     838      clone_failed = false;
     839    }
     840   
     841    if (message.empty()) {
     842      textout << outconvert << disp << ("_collector:header_\n")
     843          << ("_collector:" + collector_page + "content_\n")
     844          << ("_collector:footer_\n");
    768845    } else {
    769 
    770       text_t delete_cmd = "perl " + filename_cat (gsdlhome, "bin", "script", "delcol.pl");
    771       delete_cmd += " -f " + collection;
    772       char *delete_cmdc = delete_cmd.getcstr();
    773       int rv = system (delete_cmdc);
    774       delete delete_cmdc;
    775       if (rv != 0) {
    776     // deletion failed -- permissions?
    777     message = "delpermission";
    778       } else {
    779     message = "delsuccess";
    780       }
    781     }
    782   }
    783 
    784   if (clone_failed) {
    785     // clone_failed is set from check_cgiargs if an attempt was made
    786     // to clone an invalid collection
    787     message = "clonefail";
    788     clone_failed = false;
    789   }
    790  
    791   if (message.empty()) {
    792     textout << outconvert << disp << ("_collector:header_\n")
    793         << ("_collector:" + collector_page + "content_\n")
    794         << ("_collector:footer_\n");
    795   } else {
    796     textout << outconvert << disp << ("_collector:header_\n")
    797         << ("_collector:" + message + "content_\n")
    798         << ("_collector:footer_\n");
    799   }
    800 
     846      textout << outconvert << disp << ("_collector:header_\n")
     847          << ("_collector:" + message + "content_\n")
     848          << ("_collector:footer_\n");
     849    }
     850  }
    801851  return true;
    802852}
  • trunk/gsdl/src/recpt/collectoraction.h

    r1432 r1437  
    5050  void set_cfgfile (displayclass &disp, const text_t &dirname, ostream &logout);
    5151
     52  void set_statusline (displayclass &disp, const text_t &collection, ostream &logout);
     53
    5254  void update_cfgfile_clone (cgiargsclass &args, ostream &logout);
    5355
Note: See TracChangeset for help on using the changeset viewer.