You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by Diwaker Gupta <di...@gmail.com> on 2005/06/05 11:16:04 UTC

pdf-link and txt-link in views

Hi Thorsten and list,

Has anyone got pdf-link and txt-link contracts working in views? I
tried them out today. The pdf-link contract doesn't even run -- I get
the following exception:

X [0]                                     linkmap.html  BROKEN:
javax.xml.transform.TransformerException: ElemTemplateElement error:
pdf-link-body

With the txt-link, the build goes fine, but the txt pages are just
never generated. Also, the txt-link target just generates a whole
bunch of Javascript in the generated page:

<div id="export-link"><script language="Javascript" type="text/javascript">
&#9;function printit() {
&#9;  if (window.print) {
&#9;    window.focus();
&#9;    window.print();
&#9;  }
&#9;}
&#9;        </script><script language="Javascript" type="text/javascript">
&#9;var NS = (navigator.appName == "Netscape");
&#9;var VERSION = parseInt(navigator.appVersion);
&#9;if (VERSION &gt; 3) {
&#9;  document.write('<div title="Print this Page" class="txt">');
&#9;  document.write('  <a class="dida" href="javascript:printit()">');
&#9;  document.write('    <img alt="print - icon"
src="skin/images/printer.gif" class="skin" />');
&#9;  document.write('    <br />');
&#9;  document.write('  PRINT</a>');
&#9;  document.write('</div>');
&#9;}
&#9;        </script>

I'm still looking into it.

Also, I would recommend changing the div tag for "notes" and "warning"
from "frame note" to "frame-note" for example. I just don't like the
space because its inconvinient when writing CSS rules. The change is
trivial:

Index: main/webapp/skins/common/xslt/html/document2html.xsl
===================================================================
--- main/webapp/skins/common/xslt/html/document2html.xsl       
(revision 180076)
+++ main/webapp/skins/common/xslt/html/document2html.xsl        (working copy)
@@ -137,7 +137,7 @@

   <xsl:template match="note | warning | fixme">
     <xsl:apply-templates select="@id"/>
-    <div class="frame {local-name()}">
+    <div class="frame-{local-name()}">
       <div class="label">
         <xsl:choose>
           <!-- FIXME: i18n Transformer here -->

cheers,
Diwaker
-- 
Diwaker Gupta
http://resolute.ucsd.edu/diwaker

Re: pdf-link and txt-link in views

Posted by Thorsten Scherler <th...@apache.org>.
On Sun, 2005-06-05 at 11:52 -0700, Diwaker Gupta wrote:
> > I added the real txt-link into trunk. Thx for the report.
> 
> > Muchas gracias
> 
> de nada :)
> 
> Couple of suggestions:
> 
> o keep the contracts consistent. For instance, the div tag in pdf-link
> has an id of 'pdf', while the one in txt-link has a _class_ of
> 'podlink'
> 

You are absolutely right with the above said.

You and I started more or less at the same time in not using <div/>'s at
all in our contracts (last-published.ft and last-published-net.ft).

Here we used e.g. last-published-net.ft:
<xsl:template name="last-published-net-body">
 <xsl:variable name="date"
select="document('http://xobjex.com/service/date.xsl')/date"/>
  <xsl:variable name="dt" select="$date/utc/@rfc-822"/>
  <i18n:text >Last Published:</i18n:text>&#160; <xsl:value-of
select="$dt"/>
</xsl:template>

Which returns a string. This string then can be styled by the designer
because we said: designer != contract author

The designer is using forrest:view to create a style-container (hook)
and place the contract(s) into them. 
<forrest:hook name="last-published-tagline">
 <forrest:contract name="last-published-net"/>
</forrest:hook>

Which will then be transformed (with my locales) to:
<div id="last-published-tagline">
 Ăšltimo publicado:&nbsp;Sun 05 Jun 2005 11:00:54 PM CEST
</div>

In short:
<forrest:hook/> = <div/>
<forrest:contract/> = string | markup

Then the designer needs to add the new css definitions for
#last-published-tagline to the skin.css and the site has the new
design. 

To focus on returning only a string where possible makes the contract
usable in a wider range of formats and gives the designer better control
over the design.

> o since we expect only one pdf-link and txt-link per page, I suggest
> removing the class attribute from txt-link and simply giving it an id
> of 'txt-link' (and change id in pdf-link to 'pdf-link')
> 
> o whats with the class 'dida' in those contracts? :)
> 

I agree it is better to return pure content from the contracts and drop
the default divs, that are now in the contracts.

NOW:
<xsl:template name="txt-link-body">
 <div class="podlink" title="Plain Text Documentation">
   <a href="{$filename-noext}.txt" class="dida"> <img class="skin" 
            src="{$skin-img-dir}/txtdoc.png" alt="TXT - icon" /><br/>
TXT</a>
 </div>
</xsl:template>

Better:
<xsl:template name="txt-link-body">
 <a href="{$filename-noext}.txt" class="format" title="Plain Text
Documentation"> <img class="skin" 
            src="{$skin-img-dir}/txtdoc.png" alt="TXT - icon" /><br/>
TXT</a>
</xsl:template>

dida - I do not no. It is there since pelt. ;-) I would suggest "format"
to indicate that is a link to another format of the current document.

WDYT about dropping the divs in contracts where possible?

> Great work!
> 

Cheers and thanks to you.

salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: pdf-link and txt-link in views

Posted by Diwaker Gupta <di...@gmail.com>.
> I added the real txt-link into trunk. Thx for the report.

> Muchas gracias

de nada :)

Couple of suggestions:

o keep the contracts consistent. For instance, the div tag in pdf-link
has an id of 'pdf', while the one in txt-link has a _class_ of
'podlink'

o since we expect only one pdf-link and txt-link per page, I suggest
removing the class attribute from txt-link and simply giving it an id
of 'txt-link' (and change id in pdf-link to 'pdf-link')

o whats with the class 'dida' in those contracts? :)

Great work!

-- 
Diwaker Gupta
http://resolute.ucsd.edu/diwaker

Re: pdf-link and txt-link in views

Posted by Thorsten Scherler <th...@apache.org>.
On Sun, 2005-06-05 at 11:56 -0700, Diwaker Gupta wrote:
> Forgot one more thing:
> 
> The *-link contracts currently generate a <br/> tag after the link. I
> don't think this is a good idea, since it interferes with the layout.
> Ideally, we can just leave the div tags and let the skin authors worry
> about the placement.
> 

See the other mail. I agree.

The only question is when we dropping the <br/> (which we should!)
should we surround the caption with a div like:
<a href="{$filename-noext}.txt" class="format"> <img class="skin" 
            src="{$skin-img-dir}/txtdoc.png" alt="TXT - icon" /><div
class="caption">TXT</div></a>

Otherwise the designer do not have a change to reproduce the same effect
like <br/> or do I miss something?

salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: pdf-link and txt-link in views

Posted by Diwaker Gupta <di...@gmail.com>.
Forgot one more thing:

The *-link contracts currently generate a <br/> tag after the link. I
don't think this is a good idea, since it interferes with the layout.
Ideally, we can just leave the div tags and let the skin authors worry
about the placement.

-- 
Diwaker Gupta
http://resolute.ucsd.edu/diwaker

Re: pdf-link and txt-link in views

Posted by Thorsten Scherler <th...@apache.org>.
On Sun, 2005-06-05 at 14:37 +0200, Thorsten Scherler wrote:
> On Sun, 2005-06-05 at 02:16 -0700, Diwaker Gupta wrote:
> > Hi Thorsten and list,
> > 
> > Has anyone got pdf-link and txt-link contracts working in views? I
> > tried them out today. The pdf-link contract doesn't even run -- I get
> > the following exception:
> > 
> > X [0]                                     linkmap.html  BROKEN:
> > javax.xml.transform.TransformerException: ElemTemplateElement error:
> > pdf-link-body
> > 
> 
> Did you add org.apache.forrest.plugin.output.pdf to required plugins?
> 
> ...but yeah this contracts are buggy. I will re-factor that code ASAP
> (will go now out for lunch). ;-)
> 

It was really buggy. Thx for reporting it.

> The pdf-link within the content-contract is working, but I am in the
> middle of refactoring this contract to better extract the features added
> by the document2html.xsl. This link and the other are on my list. ;-)
> 

Maybe I find some time later for the content-main contract.

> > With the txt-link, the build goes fine, but the txt pages are just
> > never generated. Also, the txt-link target just generates a whole
> > bunch of Javascript in the generated page:
> > 
> > <div id="export-link"><script language="Javascript"
> type="text/javascript">
> > &#9;function printit() {
> > &#9;  if (window.print) {
> > &#9;    window.focus();
> > &#9;    window.print();
> > &#9;  }
> > &#9;}
> > &#9;        </script><script language="Javascript"
> type="text/javascript">
> > &#9;var NS = (navigator.appName == "Netscape");
> > &#9;var VERSION = parseInt(navigator.appVersion);
> > &#9;if (VERSION &gt; 3) {
> > &#9;  document.write('<div title="Print this Page" class="txt">');
> > &#9;  document.write('  <a class="dida"
> href="javascript:printit()">');
> > &#9;  document.write('    <img alt="print - icon"
> > src="skin/images/printer.gif" class="skin" />');
> > &#9;  document.write('    <br />');
> > &#9;  document.write('  PRINT</a>');
> > &#9;  document.write('</div>');
> > &#9;}
> > &#9;        </script>
> > 
> > I'm still looking into it.
> 
> Yeah I will re-factor that ASAP. It is direct copy of pelt. ;-)
> 

Actually that belongs to the print-link contract, but I did not manage
to make the print-link contract work for me, so I did not committed that
again.

I added the real txt-link into trunk. Thx for the report.

> > 
> > Also, I would recommend changing the div tag for "notes" and "warning"
> > from "frame note" to "frame-note" for example. I just don't like the
> > space because its inconvinient when writing CSS rules. The change is
> > trivial:
> > 
> > Index: main/webapp/skins/common/xslt/html/document2html.xsl
> > ===================================================================
> > --- main/webapp/skins/common/xslt/html/document2html.xsl       
> > (revision 180076)
> > +++ main/webapp/skins/common/xslt/html/document2html.xsl
> (working copy)
> > @@ -137,7 +137,7 @@
> > 
> >    <xsl:template match="note | warning | fixme">
> >      <xsl:apply-templates select="@id"/>
> > -    <div class="frame {local-name()}">
> > +    <div class="frame-{local-name()}">
> >        <div class="label">
> >          <xsl:choose>
> >            <!-- FIXME: i18n Transformer here -->
> > 
> 
> I will look on that. Have to go now.
> 

I committed that but I have not controlled the side effects of this
change. We have to keep an eye on this change I do not know how many
css-files we may have to change as well.

> > cheers,
> > Diwaker
> 

Muchas gracias

> salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: pdf-link and txt-link in views

Posted by Thorsten Scherler <th...@apache.org>.
On Sun, 2005-06-05 at 02:16 -0700, Diwaker Gupta wrote:
> Hi Thorsten and list,
> 
> Has anyone got pdf-link and txt-link contracts working in views? I
> tried them out today. The pdf-link contract doesn't even run -- I get
> the following exception:
> 
> X [0]                                     linkmap.html  BROKEN:
> javax.xml.transform.TransformerException: ElemTemplateElement error:
> pdf-link-body
> 

Did you add org.apache.forrest.plugin.output.pdf to required plugins?

...but yeah this contracts are buggy. I will re-factor that code ASAP
(will go now out for lunch). ;-)

The pdf-link within the content-contract is working, but I am in the
middle of refactoring this contract to better extract the features added
by the document2html.xsl. This link and the other are on my list. ;-)

> With the txt-link, the build goes fine, but the txt pages are just
> never generated. Also, the txt-link target just generates a whole
> bunch of Javascript in the generated page:
> 
> <div id="export-link"><script language="Javascript"
type="text/javascript">
> &#9;function printit() {
> &#9;  if (window.print) {
> &#9;    window.focus();
> &#9;    window.print();
> &#9;  }
> &#9;}
> &#9;        </script><script language="Javascript"
type="text/javascript">
> &#9;var NS = (navigator.appName == "Netscape");
> &#9;var VERSION = parseInt(navigator.appVersion);
> &#9;if (VERSION &gt; 3) {
> &#9;  document.write('<div title="Print this Page" class="txt">');
> &#9;  document.write('  <a class="dida"
href="javascript:printit()">');
> &#9;  document.write('    <img alt="print - icon"
> src="skin/images/printer.gif" class="skin" />');
> &#9;  document.write('    <br />');
> &#9;  document.write('  PRINT</a>');
> &#9;  document.write('</div>');
> &#9;}
> &#9;        </script>
> 
> I'm still looking into it.

Yeah I will re-factor that ASAP. It is direct copy of pelt. ;-)

> 
> Also, I would recommend changing the div tag for "notes" and "warning"
> from "frame note" to "frame-note" for example. I just don't like the
> space because its inconvinient when writing CSS rules. The change is
> trivial:
> 
> Index: main/webapp/skins/common/xslt/html/document2html.xsl
> ===================================================================
> --- main/webapp/skins/common/xslt/html/document2html.xsl       
> (revision 180076)
> +++ main/webapp/skins/common/xslt/html/document2html.xsl
(working copy)
> @@ -137,7 +137,7 @@
> 
>    <xsl:template match="note | warning | fixme">
>      <xsl:apply-templates select="@id"/>
> -    <div class="frame {local-name()}">
> +    <div class="frame-{local-name()}">
>        <div class="label">
>          <xsl:choose>
>            <!-- FIXME: i18n Transformer here -->
> 

I will look on that. Have to go now.

> cheers,
> Diwaker

salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)