Index: /gs3-extensions/html-to-expeditee/trunk/src/perllib/CssStyleToExpAttr.pm =================================================================== --- /gs3-extensions/html-to-expeditee/trunk/src/perllib/CssStyleToExpAttr.pm (revision 26730) +++ /gs3-extensions/html-to-expeditee/trunk/src/perllib/CssStyleToExpAttr.pm (revision 26731) @@ -352,8 +352,11 @@ my $exp_font_size = undef; - if ($css_font_size =~ m/^(\d+(?:\.\d*))px$/) { $exp_font_size = int($1); - } + }else{ + #FF rounds sizes, e.g. 16.13px will just be 16px. + my $end_index = length($css_font_size) - 2; + $exp_font_size = substr($css_font_size,0,$end_index); + } return $exp_font_size; @@ -365,14 +368,15 @@ my $exp_font_face = undef; - if(lc($css_font_face) eq "bold"){ + #Firefox uses '700' instead of 'bold' for font-weight. + if(lc($css_font_face) eq "bold" || $css_font_face eq "700"){ $exp_font_face = "b"; - }elsif(lc($css_font_face) eq "italic"){ #for now - also need to take into account italic and italic bold. + }elsif(lc($css_font_face) eq "italic"){ $exp_font_face = "i"; - }elsif(lc($css_font_face) eq "bold-italic"){ + }elsif(lc($css_font_face) eq "bold-italic" || $css_font_face eq "700-italic"){ $exp_font_face = "p"; }else{ $exp_font_face = "r"; } - + return $exp_font_face; } Index: /gs3-extensions/html-to-expeditee/trunk/src/perllib/ExpediteeFrameIO.pm =================================================================== --- /gs3-extensions/html-to-expeditee/trunk/src/perllib/ExpediteeFrameIO.pm (revision 26730) +++ /gs3-extensions/html-to-expeditee/trunk/src/perllib/ExpediteeFrameIO.pm (revision 26731) @@ -70,5 +70,5 @@ sub convertStyleToAttr { - my ($css_attr) = @_; + my ($css_attr,$compute_font) = @_; my $exp_attr = {}; @@ -79,47 +79,69 @@ my $exp_font_size = "18"; -# if (defined $css_attr->{'font-family'}) { -# $font_family = $font_family_lookup->[$css_attr->{'font-family'}]; -# } - - if (defined $css_attr->{'font-size'}) { + if(defined $compute_font){ + if($compute_font eq "true"){ + + if (defined $css_attr->{'font-size'}) { - my $css_font_size = $css_attr->{'font-size'}; - $exp_font_size = CssStyleToExpAttr::convert_font_size($css_font_size); - - } - - if(defined $css_attr->{'font-family'}){ - my $obtain_font_family = $css_attr->{'font-family'}; - my $new_exp_font_family = CssStyleToExpAttr::convert_font_family($obtain_font_family); - - if(defined $new_exp_font_family){ - $exp_font_family = $new_exp_font_family; + my $css_font_size = $css_attr->{'font-size'}; + my $new_exp_font_size = CssStyleToExpAttr::convert_font_size($css_font_size); + + if(defined $new_exp_font_size){ + $exp_font_size = $new_exp_font_size; + } + } + + if(defined $css_attr->{'font-family'}){ + my $obtain_font_family = $css_attr->{'font-family'}; + my $new_exp_font_family = CssStyleToExpAttr::convert_font_family($obtain_font_family); + + if(defined $new_exp_font_family){ + $exp_font_family = $new_exp_font_family; + } + } + + #obtain font style/weight - bold, italic or bold-italic. + + if(defined $css_attr->{'font-style'}){ + my $css_font_style = $css_attr->{'font-style'}; + my $new_exp_font_face = CssStyleToExpAttr::convert_font_face($css_font_style); + + if(defined $new_exp_font_face){ + $exp_font_face = $new_exp_font_face; + } + } + + if(defined $css_attr->{'font-weight'}){ + my $css_font_face = $css_attr->{'font-weight'}; + my $new_exp_font_face = CssStyleToExpAttr::convert_font_face($css_font_face); + + if(defined $new_exp_font_face){ + $exp_font_face = $new_exp_font_face; + } + } + + if(defined $css_attr->{'font-style'} && defined $css_attr->{'font-weight'}){ + my $font_face_param = $css_attr->{'font-weight'}.'-'.$css_attr->{'font-style'}; + my $new_exp_font_face = CssStyleToExpAttr::convert_font_face($font_face_param); + + if(defined $new_exp_font_face){ + $exp_font_face = $new_exp_font_face; + } + } + + # color + if(defined $css_attr->{'color'}){ + my $css_color = $css_attr->{'color'}; + + my $exp_color = CssStyleToExpAttr::convert_color($css_color); + + $exp_attr->{'d'} = $exp_color; + } } } - my $css_font_style; - my $css_font_face; - - if(defined $css_attr->{'font-style'}){ - $css_font_style = $css_attr->{'font-style'}; - $exp_font_face = CssStyleToExpAttr::convert_font_face($css_font_style); - } - - if(defined $css_attr->{'font-weight'}){ - $css_font_face = $css_attr->{'font-weight'}; - $exp_font_face = CssStyleToExpAttr::convert_font_face($css_font_face); - } - - if(defined $css_attr->{'font-style'} && defined $css_attr->{'font-weight'}){ - my $font_face_param = $css_attr->{'font-weight'}.'-'.$css_attr->{'font-style'}; - $exp_font_face = CssStyleToExpAttr::convert_font_face($font_face_param); - } - - $exp_attr->{'f'} = $exp_font_family.$exp_font_face.$exp_font_size; + $exp_attr->{'f'} = $exp_font_family.$exp_font_face.$exp_font_size; # background color - - if (defined $css_attr->{'background-color'}) { my $css_color = $css_attr->{'background-color'}; @@ -129,5 +151,7 @@ $exp_attr->{'e'} = $exp_color; } - + + + return $exp_attr; } @@ -251,5 +275,6 @@ $attr_copy{'P'} = "$x $y"; $attr_copy{'T'} = $text; - $attr_copy{'w'} = "-$w" if (defined $w); + #$attr_copy{'w'} = "-$w" if (defined $w); + $attr_copy{'w'} = "$w" if (defined $w); return $self->_addItem("T",\%attr_copy); @@ -534,6 +559,4 @@ $self->writeStatisticsSection(); - - close(FOUT); $status = 1; @@ -550,7 +573,7 @@ { my $self = shift @_; - my ($html_node) = @_; + my ($html_node,$compute_font) = @_; - my $type = $html_node->{'type'}; + my $type = $html_node->{'type'}; if ($type eq "rect") { @@ -561,5 +584,5 @@ my $yt = $rect->{'yt'}; my $yb = $rect->{'yb'}; - + my $attr = convertStyleToAttr($html_node->{'style'}); @@ -606,12 +629,18 @@ } elsif ($type eq "text") { - + my $text = $html_node->{'text'}; my $x = $html_node->{'xl'}; my $y = $html_node->{'yt'}; - my $w = $html_node->{'xr'} - $x +1; - - my $attr = convertStyleToAttr($html_node->{'style'}); + #my $w = $html_node->{'xr'} - $x +1; + + my $w = undef; + + if(defined $html_node->{'width'}){ + $w = $html_node->{'width'} - 5; #take away 5px for extra space. + } + + my $attr = convertStyleToAttr($html_node->{'style'},$compute_font); # fudge factor for now (based on default font size used) @@ -630,5 +659,5 @@ my $childNodes = $html_node->{'childNodes'}; foreach my $child_node (@$childNodes) { - $self->buildFrame($child_node); + $self->buildFrame($child_node,$compute_font); } } Index: /gs3-extensions/html-to-expeditee/trunk/src/perllib/cgiactions/HtmlToExpediteeAction.pm =================================================================== --- /gs3-extensions/html-to-expeditee/trunk/src/perllib/cgiactions/HtmlToExpediteeAction.pm (revision 26730) +++ /gs3-extensions/html-to-expeditee/trunk/src/perllib/cgiactions/HtmlToExpediteeAction.pm (revision 26731) @@ -50,5 +50,5 @@ { "generate-frame" => { 'compulsory-args' => [ "fn", "json" ], - 'optional-args' => ["assoc"] }, + 'optional-args' => ["assoc", "compute-font"] }, }; @@ -80,5 +80,8 @@ my $assoc = $self->{'assoc'}; - + + my $compute_font = $self->{'compute-font'}; + print STDERR "Wil send compute_font... $compute_font\n\n"; + # no need to lock collection (??), the operation is read only @@ -95,5 +98,5 @@ my $expeditee_frame_io = new ExpediteeFrameIO($output_dir); - $expeditee_frame_io->buildFrame($exp_frame_tree); + $expeditee_frame_io->buildFrame($exp_frame_tree,$compute_font); if ($expeditee_frame_io->saveFrame("$fn.exp",$assoc)) { Index: /gs3-extensions/html-to-expeditee/trunk/src/src/cgi-bin/html-to-expeditee.pl.in =================================================================== --- /gs3-extensions/html-to-expeditee/trunk/src/src/cgi-bin/html-to-expeditee.pl.in (revision 26730) +++ /gs3-extensions/html-to-expeditee/trunk/src/src/cgi-bin/html-to-expeditee.pl.in (revision 26731) @@ -62,7 +62,14 @@ - + +
+ Generate Browsing Frameset
+
Extra Expeditee Frame Output Options:
+ Compute Font@@ -70,5 +77,8 @@ var docOIDs = []; var numDocOIDs; - + var compute_font = false; + var compute_width = false; + var generate_browsing = false; //whether to generate a matching browsing frameset + \$(function() { \$('#progress').progressbar(); @@ -89,5 +99,10 @@ cl = "CL" + cl; } - + + compute_font = document.getElementById("checkBoxFont").checked; + compute_width = document.getElementById("checkBoxWidth").checked; + + generate_browsing = document.getElementById("checkBoxBrowsing").checked; + var gs2=$isGSDL2; @@ -102,4 +117,6 @@ url += "&excerptid=gs_content"; } + + console.log("*** CHECKING URL: " + url); /* processing animation */ @@ -227,7 +244,4 @@ if(frameNum === null){ frameNum = iter; - console.log("no frameNum found, use iter: " + frameNum); - }else{ - console.log("frameNum metadata found: " + frameNum); } @@ -252,10 +266,8 @@ } - var expFrameTree = htmlToExpeditee(gsContent); + var expFrameTree = htmlToExpeditee(gsContent,compute_font,compute_width); var expFrame = JSON.stringify(expFrameTree); - - console.log(expFrame); - + //console.log(expFrame); //alert(expFrame); @@ -277,4 +289,6 @@ params += "&assoc=" + assoc; } + + params += "&compute-font=" + compute_font; var clHtml = urlPostSync(url,params); @@ -417,5 +431,5 @@ my $collect = $gsdl_cgi->clean_param("collect"); my $cl = $gsdl_cgi->clean_param("cl"); - + # Establish collect_dir using defining 'site' along the way if GS3 Index: /gs3-extensions/html-to-expeditee/trunk/src/src/js/html-to-expeditee.js =================================================================== --- /gs3-extensions/html-to-expeditee/trunk/src/src/js/html-to-expeditee.js (revision 26730) +++ /gs3-extensions/html-to-expeditee/trunk/src/src/js/html-to-expeditee.js (revision 26731) @@ -7,4 +7,7 @@ var font_weight; var font_style; + +var compute_font = false; +var compute_width = false; Element.prototype.getElementWidth = function() { @@ -105,19 +108,25 @@ -function htmlToExpeditee(node) -{ +function htmlToExpeditee(node,compFont,compWidth) +{ + compute_font = compFont; + compute_width = compWidth; + var nodePos = getElementPosition(node); var parentStyle = node.getAttribute('style'); //Use these as default values if font info can't be found for text items. - font_family = getStyle(node,'font-family'); - font_size = getStyle(node,'font-size'); - font_color = getStyle(node,'color'); - - console.log("Retrieving node: " + node); - - console.log("Retrieving font family: " + font_family); - console.log("Retrieving font size: " + font_size); - console.log("Retrieving font color: " + font_color); + //and only if the user wants the font computed (otherwise use Expeditee defaults). + if(compute_font){ + font_family = getStyle(node,'font-family'); + font_size = getStyle(node,'font-size'); + font_color = getStyle(node,'color'); + + /*console.log("Retrieving node: " + node); + + console.log("Retrieving font family: " + font_family); + console.log("Retrieving font size: " + font_size); + console.log("Retrieving font color: " + font_color);*/ + } var pxl = nodePos.xl; @@ -156,43 +165,57 @@ if (parent != null) { - //obtain font info for text nodes from their parent nodes. - var new_font_family = getStyle(parent,"font-family"); - var new_font_size = getStyle(parent,"font-size"); - var new_font_color = getStyle(parent,"color"); - - var new_font_weight = getStyle(parent,"font-weight"); - var new_font_style = getStyle(parent,"font-style"); - - if(new_font_family !== undefined && new_font_family !== null) - font_family = new_font_family; - - if(new_font_size !== undefined && new_font_size !== null) - font_size = new_font_size; - - if(new_font_color !== undefined && new_font_color !== null) - font_color = new_font_color; + if(compute_font){ + //obtain font info for text nodes from their parent nodes. + var new_font_family = getStyle(parent,"font-family"); + var new_font_size = getStyle(parent,"font-size"); + var new_font_color = getStyle(parent,"color"); + + var new_font_weight = getStyle(parent,"font-weight"); + var new_font_style = getStyle(parent,"font-style"); + + if(new_font_family !== undefined && new_font_family !== null) + font_family = new_font_family; + + if(new_font_size !== undefined && new_font_size !== null) + font_size = new_font_size; + + if(new_font_color !== undefined && new_font_color !== null) + font_color = new_font_color; - if(new_font_weight !== undefined && new_font_weight !== null) - font_weight = new_font_weight; + //TODO: if parent node is a element, then set style["font-weight"] to be "bold". + if(new_font_weight !== undefined && new_font_weight !== null) + font_weight = new_font_weight; - if(new_font_style !== undefined && new_font_style !== null) - font_style = new_font_style; - - var data = parent.attributes["data"]; - - if (data != null) { + if(new_font_style !== undefined && new_font_style !== null) + font_style = new_font_style; + + var style = {}; + style["font-family"] = font_family; + style["font-size"] = font_size; + style["color"] = font_color; + style["font-weight"] = font_weight; + style["font-style"] = font_style; + + jsonNode.style = style; + } + + if(compute_width){ + var parentPos = getElementPosition(parent); + var parentWidth = parentPos.xr - parentPos.xl; + + /*console.log("parent.xl: " + parentPos.xl); + console.log("parent.xr: " + parentPos.xr); + console.log("parent width: " + parentWidth);*/ + + jsonNode.width = parentWidth; + } + + var data = parent.attributes["data"]; + + if (data != null) { jsonNode.data = data.value; - } - - var style = {}; - style["font-family"] = font_family; - style["font-size"] = font_size; - style["color"] = font_color; - style["font-weight"] = font_weight; - style["font-style"] = font_style; - - //TODO: if parent node is a element, then set style["font-weight"] to be "bold". - - jsonNode.style = style; + } + + } }