Skip Menu |

This queue is for tickets about the XUL-Gui CPAN distribution.

Report information
The Basics
Id: 57645
Status: open
Priority: 0/
Queue: XUL-Gui

People
Owner: ASG [...] cpan.org
Requestors: richard.kandarian [...] lanl.gov
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: XUL::Gui Kudos & request/bug report
Date: Wed, 19 May 2010 14:44:31 -0600
To: bug-xul-gui [...] rt.cpan.org
From: Richard Kandarian <richard.kandarian [...] lanl.gov>
Eric, [Sorry about sending this to the wrong place. I found this address in the man page so I'm sending it here too.] I really like your idea and am planning to use it. I want to create a sort of proxy which modifies web pages taken from the wild to augment them with GUI stuff so I put them in HTML::TreeBuilder and then traverse the tree building a structure very similar to what the display function of XUL::Gui accepts, then I modify it to add my special GUI stuff then I convert it to a string and execute it. (I'm doing this to integrate different services from different web hosts on the same page. I'd really like the resultant web page to look as similar to the original as possible.) But there's a problem illustrated in my modification of your tutorial example here: use XUL::Gui; display( launch=>0, Window title=>'my window', H2('events!'), A(href=>'http://kandarian.com/', P('link text')), # Parses OK and functions # A(href=>'http://kandarian.com/', 'link text'), # Does not parse but should Button( label => 'click me', oncommand => sub { my ($self, $event) = @_; $self->label = 'ouch!'; } ) ); I discovered this problem in 0.40, and I just downloaded 0.51 and executed the above test which acted the same as 0.40: The commented out line does not parse. Am I not doing it the correct way for XUL::Gui? (I have to admit I've not RTFM in meticulous detail, but I have scanned it for clues...) It seems the difference between H2(... and A(... above is the attributes. It seems that when there are attributes plain text cannot be set as a child and it seems that way because after attributes are parsed the content (children) are expected to be objects only. Anyway, I've started to look into fixing this, but you might (probably, I hope?) be able to get it done before I do. Thanks, I really like this module. Richard Kandarian http://www.lanl.gov/cgi-bin/fonelink.pl/085598 Any opinions stated in this message are not expressed on behalf of any individual or entity other than me unless explicitly noted otherwise. My node in the Web: http://www.kandarian.com
Subject: Re: [rt.cpan.org #57645] Proposed fix
Date: Thu, 20 May 2010 11:58:03 -0600
To: bug-XUL-Gui [...] rt.cpan.org
From: Richard Kandarian <richard.kandarian [...] lanl.gov>
Eric, I really did try to find a way to get what I want by means other than modifying your code, and it seemed a very likely suspect was the XUL TextNode element, but it introduces into the rendered page line breaks I don't want. This modification (against 0.51) does what I want as long an my kludged-in tag, Tn (for TextNode), occurs within an HTML element (well, I at least know it will not work at the top level - nothing is rendered): --- ../../../../XUL-Gui-0.51/lib/XUL/Gui.pm 2010-05-10 17:04:44.000000000 -0 600 +++ Gui.pm 2010-05-20 11:32:52.740667300 -0600 @@ -307 +307 @@ - xul => [@Xul], + xul => [@Xul, 'Tn'], @@ -430,0 +431 @@ + 'Tn', @@ -559,0 +561 @@ + *Tn = tag 'Tn'; @@ -1399,0 +1402,4 @@ + if($final && $$self{TAG} eq 'tn'){ + my $val = XUL::Gui::escape $$self{A}{'TEXT'}; + qq{$final.appendChild( document.createTextNode('$val') );}; + }else{ @@ -1402 +1408,2 @@ - push @js, $_->toJS for @{$$self{C}}; + my @children = grep {$$_{TAG} ne 'tn'} @{$$self{C}}; + push @js, $_->toJS for @children; @@ -1418,0 +1426,3 @@ + if($$_{TAG} eq 'tn'){ + push @js, $_->toJS($id); + }else{ @@ -1420,0 +1431 @@ + } @@ -1422,0 +1434 @@ + } It also seems not to mess up your nice, simple design too much. Here is my test case: use XUL::Gui; display( launch=>0, Window title=>'my window', H2('events!'), DIV( Tn('Just some random text before the link '), A(href=>'http://kandarian.com/', Tn('link text')), Tn(' Just some random text after the link '), ), Button( label => 'click me', oncommand => sub { my ($self, $event) = @_; $self->label = 'ouch!'; } ) ); Richard Kandarian http://www.lanl.gov/cgi-bin/fonelink.pl/085598 Any opinions stated in this message are not expressed on behalf of any individual or entity other than me unless explicitly noted otherwise. My node in the Web: http://www.kandarian.com
Richard, Thanks for your interest in my module. I've just released a new version, and it clarifies a bit how text nodes can be added. I am not sure if a `Tn()` function is necessary (of course you are always welcome to make one as a sub/widget). Here is your example code written without any additional functions (using XUL::Gui 0.62): use XUL::Gui; display( Window title=>'my window', H2('events!'), DIV( SPAN('Just some random text before the link '), A(href=>'http://kandarian.com/', TEXT => 'link text'), SPAN(' Just some random text after the link '), ), Button( label => 'click me', oncommand => sub { my ($self, $event) = @_; $self->label = 'ouch!'; } ) ); As you can see, the HTML `SPAN` tag fits in all of the locations where the `Tn()` function would have been used (you could even use it in the `A` tag in place of "TEXT => ..."). So if you wanted to use `Tn()` I would write it as a macro as follows: sub Tn {SPAN "@_"} I think that this resolves your feature request, so I am going to mark this as resolved. Let me know if I missed anything. Eric On Thu May 20 13:58:12 2010, richard.kandarian@lanl.gov wrote: Show quoted text
> Eric, > > I really did try to find a way to get what I want by means other than > modifying your code, and it seemed a very likely suspect was the XUL > TextNode element, but it introduces into the rendered page line breaks I > don't want. > > This modification (against 0.51) does what I want as long an my
kludged-in Show quoted text
> tag, Tn (for TextNode), occurs within an HTML element (well, I at least > know it will not work at the top level - nothing is rendered): > > --- ../../../../XUL-Gui-0.51/lib/XUL/Gui.pm 2010-05-10 > 17:04:44.000000000 -0 > 600 > +++ Gui.pm 2010-05-20 11:32:52.740667300 -0600 > @@ -307 +307 @@ > - xul => [@Xul], > + xul => [@Xul, 'Tn'], > @@ -430,0 +431 @@ > + 'Tn', > @@ -559,0 +561 @@ > + *Tn = tag 'Tn'; > @@ -1399,0 +1402,4 @@ > + if($final && $$self{TAG} eq 'tn'){ > + my $val = XUL::Gui::escape $$self{A}{'TEXT'}; > + qq{$final.appendChild( document.createTextNode('$val') );}; > + }else{ > @@ -1402 +1408,2 @@ > - push @js, $_->toJS for @{$$self{C}}; > + my @children = grep {$$_{TAG} ne 'tn'} @{$$self{C}}; > + push @js, $_->toJS for @children; > @@ -1418,0 +1426,3 @@ > + if($$_{TAG} eq 'tn'){ > + push @js, $_->toJS($id); > + }else{ > @@ -1420,0 +1431 @@ > + } > @@ -1422,0 +1434 @@ > + } > > It also seems not to mess up your nice, simple design too much. > > Here is my test case: > > use XUL::Gui; > > display( > launch=>0, > Window title=>'my window', > H2('events!'), > DIV( > Tn('Just some random text before the link '), > A(href=>'http://kandarian.com/', Tn('link text')), > Tn(' Just some random text after the link '), > ), > Button( > label => 'click me', > oncommand => sub { > my ($self, $event) = @_; > > $self->label = 'ouch!'; > } > ) > ); > > > > Richard Kandarian > http://www.lanl.gov/cgi-bin/fonelink.pl/085598 > Any opinions stated in this message are not expressed on behalf of any > individual or entity other than me unless explicitly noted otherwise. My > node in the Web: http://www.kandarian.com >
Subject: Re: [rt.cpan.org #57645] XUL::Gui Kudos & request/bug report
Date: Mon, 26 Jul 2010 12:37:52 -0600
To: bug-XUL-Gui [...] rt.cpan.org
From: Richard Kandarian <richard.kandarian [...] lanl.gov>
Eric, Thanks for the reply. The example you sent will do what I need so I don't need a Tn tag and won't bother with it anymore. Fixing my HTML page converter to use XUL::Gui 0.62 will be trivial so I'm happy. My feature request was due to an incomplete knowledge of HTML. (I've previously had no use for anything like the SPAN tag writing HTML by hand, and it's name is completely unhelpful when searching for a tool to get the job done. I guess I'm a lazy manual reader.) I still think that XUL::GUI should support HTML the way a browser does including unadorned (or untagged) text, but given that you can SPAN everything it's only a very minor flaw probably not worth distorting your elegant design to fix. At 07:34 AM 7/25/2010, Eric Strom via RT wrote: Show quoted text
><URL: https://rt.cpan.org/Ticket/Display.html?id=57645 > > >Richard, > >Thanks for your interest in my module. I've just released a new >version, and it clarifies a bit how text nodes can be added. I am not >sure if a `Tn()` function is necessary (of course you are always welcome >to make one as a sub/widget). Here is your example code written without >any additional functions (using XUL::Gui 0.62): > >use XUL::Gui; > >display( > Window title=>'my window', > H2('events!'), > DIV( > SPAN('Just some random text before the link '), > A(href=>'http://kandarian.com/', TEXT => 'link text'), > SPAN(' Just some random text after the link '), > ), > Button( > label => 'click me', > oncommand => sub { > my ($self, $event) = @_; > $self->label = 'ouch!'; > } > ) >); > >As you can see, the HTML `SPAN` tag fits in all of the locations where >the `Tn()` function would have been used (you could even use it in the >`A` tag in place of "TEXT => ..."). > >So if you wanted to use `Tn()` I would write it as a macro as follows: > > sub Tn {SPAN "@_"} > >I think that this resolves your feature request, so I am going to mark >this as resolved. Let me know if I missed anything. > >Eric > >On Thu May 20 13:58:12 2010, richard.kandarian@lanl.gov wrote:
> > Eric, > > > > I really did try to find a way to get what I want by means other than > > modifying your code, and it seemed a very likely suspect was the XUL > > TextNode element, but it introduces into the rendered page line breaks I > > don't want. > > > > This modification (against 0.51) does what I want as long an my
>kludged-in
> > tag, Tn (for TextNode), occurs within an HTML element (well, I at least > > know it will not work at the top level - nothing is rendered): > > > > --- ../../../../XUL-Gui-0.51/lib/XUL/Gui.pm 2010-05-10 > > 17:04:44.000000000 -0 > > 600 > > +++ Gui.pm 2010-05-20 11:32:52.740667300 -0600 > > @@ -307 +307 @@ > > - xul => [@Xul], > > + xul => [@Xul, 'Tn'], > > @@ -430,0 +431 @@ > > + 'Tn', > > @@ -559,0 +561 @@ > > + *Tn = tag 'Tn'; > > @@ -1399,0 +1402,4 @@ > > + if($final && $$self{TAG} eq 'tn'){ > > + my $val = XUL::Gui::escape $$self{A}{'TEXT'}; > > + qq{$final.appendChild( document.createTextNode('$val') );}; > > + }else{ > > @@ -1402 +1408,2 @@ > > - push @js, $_->toJS for @{$$self{C}}; > > + my @children = grep {$$_{TAG} ne 'tn'} @{$$self{C}}; > > + push @js, $_->toJS for @children; > > @@ -1418,0 +1426,3 @@ > > + if($$_{TAG} eq 'tn'){ > > + push @js, $_->toJS($id); > > + }else{ > > @@ -1420,0 +1431 @@ > > + } > > @@ -1422,0 +1434 @@ > > + } > > > > It also seems not to mess up your nice, simple design too much. > > > > Here is my test case: > > > > use XUL::Gui; > > > > display( > > launch=>0, > > Window title=>'my window', > > H2('events!'), > > DIV( > > Tn('Just some random text before the link '), > > A(href=>'http://kandarian.com/', Tn('link text')), > > Tn(' Just some random text after the link '), > > ), > > Button( > > label => 'click me', > > oncommand => sub { > > my ($self, $event) = @_; > > > > $self->label = 'ouch!'; > > } > > ) > > ); > > > > > > > > Richard Kandarian > > http://www.lanl.gov/cgi-bin/fonelink.pl/085598 > > Any opinions stated in this message are not expressed on behalf of any > > individual or entity other than me unless explicitly noted otherwise. My > > node in the Web: http://www.kandarian.com > >
Richard Kandarian http://www.lanl.gov/cgi-bin/fonelink.pl/085598 Any opinions stated in this message are not expressed on behalf of any individual or entity other than me unless explicitly noted otherwise. My node in the Web: http://www.kandarian.com