Changeset 26596 for gs3-extensions/html-to-expeditee
- Timestamp:
- 2013-01-08T14:13:09+13:00 (11 years ago)
- Location:
- gs3-extensions/html-to-expeditee/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/html-to-expeditee/trunk/src/perllib/ExpediteeFrameIO.pm
r26511 r26596 217 217 { 218 218 my $self = shift @_; 219 my ($x, $y, $text, $w,$attr) = @_;220 221 my %attr_copy = %$attr; #make a private copy of 'attr'222 223 224 225 226 227 228 229 230 219 my ($x,$y,$text,$w,$attr) = @_; 220 221 my %attr_copy = %$attr; #make a private copy of 'attr' 222 223 $self->setTextDefaultAttributes(\%attr_copy); 224 my $items = $self->{'items'}; 225 226 $attr_copy{'P'} = "$x $y"; 227 $attr_copy{'T'} = $text; 228 $attr_copy{'w'} = "-$w" if (defined $w); 229 230 return $self->_addItem("T",\%attr_copy); 231 231 } 232 232 … … 422 422 } 423 423 424 sub save Frame425 { 426 my $self = shift @_; 427 my ($file) = @_;424 sub saveZeroFrame 425 { 426 my $self = shift @_; 427 my $file = "0.exp"; 428 428 429 429 my $filename = &util::filename_cat($self->{'output_dir'},$file); 430 430 431 431 my $status = undef; 432 433 my $username = $self->{'username'}; 434 my $fdate = getFormattedDate(); 432 435 433 436 if (open(FOUT,">$filename")) { 434 437 binmode(FOUT,":utf8"); 438 439 print FOUT <<EOT; 440 441 V 1 442 p 4 443 U $username 444 D $fdate 445 M $username 446 d $fdate 447 Z 448 449 Z 450 451 Z 452 453 Z 454 455 EOT 456 457 close(FOUT); 458 $status = 1; 459 } 460 else { 461 print STDERR "ExpediteeFrameIO::saveZeroFrame() Failed to open $filename for output\n"; 462 $status = 0; 463 } 464 465 return $status; 466 } 467 468 sub writeAssocFilePath 469 { 470 my $self = shift @_; 471 my ($assoc) = @_; 472 473 my $x = 318; 474 my $y = 123; 475 my $text = "\@assocfilepath: $assoc"; 476 477 my $attr = {}; 478 479 #add data: gsdl.Metadata: assocfilepath to this piece of text. 480 $attr->{'D'} = "gsdl.Metadata: assocfilepath"; 481 482 $self->addText($x,$y,$text,undef,$attr); 483 } 484 485 sub saveFrame 486 { 487 my $self = shift @_; 488 my ($file,$assoc) = @_; 489 490 if ($file eq "1.exp") { 491 $self->saveZeroFrame(); 492 } 493 494 my $filename = &util::filename_cat($self->{'output_dir'},$file); 495 496 my $status = undef; 497 498 if (open(FOUT,">$filename")) { 499 binmode(FOUT,":utf8"); 500 501 502 $self->writeAssocFilePath($assoc); #write assocfilepath out to frame. 503 435 504 $self->writeHeaderSection(); 436 505 $self->writeItemsSection(); … … 438 507 $self->writeConstraintsSection(); 439 508 $self->writeStatisticsSection(); 440 509 510 511 441 512 close(FOUT); 442 513 $status = 1; … … 486 557 $img_url =~ s/^http:\/\/(.*?)\/greenstone3(.*?)\///; 487 558 if ($img_url =~ m/^interfaces\//) { 488 $img_url = " images/$img_url";559 $img_url = "greenstone3-svn/web/$img_url"; 489 560 } 490 561 elsif ($img_url =~ m/^sites\//) { 491 $img_url =~ s/^sites\/(.*?)\//images\//; 562 # if ($img_url =~ m/^sites\//) { 563 # $img_url =~ s/^sites\/(.*?)\//images\//; 564 $img_url = "greenstone3-svn/web/$img_url"; 492 565 } 493 566 … … 546 619 #writes frameset name concatenated with last frame number in the set to the frame.inf file. 547 620 my $getFramesetName = $self->{'output_dir'}; 548 print FNOUT "$getFramesetName$last_frame_number\n"; 549 621 550 622 551 623 close(FNOUT); -
gs3-extensions/html-to-expeditee/trunk/src/perllib/cgiactions/HtmlToExpediteeAction.pm
r24938 r26596 50 50 { 51 51 "generate-frame" => { 'compulsory-args' => [ "fn", "json" ], 52 'optional-args' => [ ] },52 'optional-args' => ["assoc"] }, 53 53 }; 54 54 … … 78 78 79 79 my $fn = $self->{'fn'}; 80 81 my $assoc = $self->{'assoc'}; 80 82 81 83 # no need to lock collection (??), the operation is read only … … 95 97 $expeditee_frame_io->buildFrame($exp_frame_tree); 96 98 97 if ($expeditee_frame_io->saveFrame("$fn.exp" )) {99 if ($expeditee_frame_io->saveFrame("$fn.exp",$assoc)) { 98 100 99 101 # write out next free frame num -
gs3-extensions/html-to-expeditee/trunk/src/src/cgi-bin/html-to-expeditee.pl.in
r26593 r26596 1 #! @FULL_PERL_EXE@-w1 #!/cygdrive/c/strawberry/perl/bin/perl -w 2 2 3 3 # Need to specify the full path of Perl above, e.g. for Windows something like … … 181 181 } 182 182 183 url += "&p.showExpediteeAttributes=1"; 184 183 //url += "&p.showExpediteeAttributes=1"; 184 185 185 186 /* load iframe with document drawn from Greenstone collection */ 186 187 iframe.src = url; … … 228 229 */ 229 230 231 //get assocfilepath from xml 232 var xmlUrl = iframe.src + "&o=xml"; 233 234 var assoc = getAssocFilePath(xmlUrl); 235 230 236 var expFrameTree = htmlToExpeditee(gsContent); 231 237 … … 239 245 var params = "c=" + collect; 240 246 if (site.match(/\\w/)) { 241 params += "&site=" + site;247 params += "&site=" + site; 242 248 } 249 243 250 params += "&a=generate-frame&fn=" + frameID; 244 251 params += "&json=" + escape(expFrame); 252 253 //add an assocfilepath parameter 254 255 if(assoc !== null && assoc !== undefined){ 256 params += "&assoc=" + assoc; 257 } 245 258 246 259 var clHtml = urlPostSync(url,params); 247 260 248 261 if (!clHtml.match(/html-to-expeditee saved frame/)) { 249 262 alert("Error processing url: " + url); 250 263 } 251 264 … … 274 287 } 275 288 276 url += "&p.showExpediteeAttributes=1";289 //url += "&p.showExpediteeAttributes=1"; 277 290 278 291 iframe.src = url; … … 288 301 289 302 } 303 304 function getAssocFilePath(xmlUrl){ 305 var assoc = ""; 306 307 \$.ajax({ 308 type: "GET", 309 async: false, 310 url: xmlUrl, 311 dataType: "xml", 312 success: function(xml){ 313 314 315 \$(xml).find('metadata').each(function(){ 316 317 var name = \$(this).attr('name'); 318 319 if(name === 'assocfilepath'){ 320 if(assoc === ""){ 321 assoc = \$(this).text(); 322 //console.log(assoc); 323 } 324 325 } 326 }); 327 328 } 329 330 }); 331 332 return assoc; 333 } 290 334 291 335 </script>
Note:
See TracChangeset
for help on using the changeset viewer.