On Oct 30, 2011, at 5:45 AM, Romain Manni-Bucau wrote:

> i updated generated example template...is it still relevant to keep this
> site?

We'll definitely need the parts that create the zip files.  And for the longest 
time we've been wanting to create IDE project files, so maybe we can start 
doing that at some point as well (not critical immediately, but an idea of the 
future of the setup).

We'll also definitely need the "smart" index.  That's just too cool not to keep 
and improve.  Not sure how we'll want to work it in just yet.  Java is not 
installed on the CMS.

If we can't run our index generation code right on the CMS, then the next 
thought is to generate it with the setup we have now and have the CMS download 
it.  It wouldn't be downloading whole pages, but chunks of html, xml or 
javascript.

So here for example is where I tried to use Java to generate the list of APIs 
used for each example:

    sub example {
        my %args = @_;
        my $filepath = "content$args{path}";
    
        read_text_file($filepath, \%args);
    
        $args{path} =~ s/README\.md(text)?$/index\.html/;
        $args{base} = _base($args{path});
        $args{breadcrumbs} = _breadcrumbs($args{path}, $args{base});
        $args{zipurl} = _zipurl($args{path});
        $args{apis} = `java -jar lib/cms-tools-r1195124.jar $filepath`;
    
        my $template_path = "templates/$args{template}";
    
        my $rendered = Dotiac::DTL->new($template_path)->render(\%args);
    
        return ($rendered, 'html', \%args);
    }

That java command generates content like this:

    <ul>
    <li><a 
href="http://download.oracle.com/javaee/6/api/javax/annotation/Resource.html";>javax.annotation.Resource</a></li>
    <li><a 
href="http://download.oracle.com/javaee/6/api/javax/annotation/security/RunAs.html";>javax.annotation.security.RunAs</a></li>
    <li><a 
href="http://download.oracle.com/javaee/6/api/javax/decorator/Decorator.html";>javax.decorator.Decorator</a></li>
    <li><a 
href="http://download.oracle.com/javaee/6/api/javax/decorator/Delegate.html";>javax.decorator.Delegate</a></li>
    <li><a 
href="http://download.oracle.com/javaee/6/api/javax/ejb/ApplicationException.html";>javax.ejb.ApplicationException</a></li>
    <li><a 
href="http://download.oracle.com/javaee/6/api/javax/ejb/EJB.html";>javax.ejb.EJB</a></li>
    <li><a 
href="http://download.oracle.com/javaee/6/api/javax/ejb/SessionContext.html";>javax.ejb.SessionContext</a></li>
    <li><a 
href="http://download.oracle.com/javaee/6/api/javax/ejb/Stateless.html";>javax.ejb.Stateless</a></li>
    <li><a 
href="http://download.oracle.com/javaee/6/api/javax/ejb/embeddable/EJBContainer.html";>javax.ejb.embeddable.EJBContainer</a></li>
    <li><a 
href="http://download.oracle.com/javaee/6/api/javax/enterprise/inject/Produces.html";>javax.enterprise.inject.Produces</a></li>
    <li><a 
href="http://download.oracle.com/javaee/6/api/javax/inject/Inject.html";>javax.inject.Inject</a></li>
    </ul>

We then pull that into the examples page like so `examples.html`

    {% extends "basic.html" %}
    
    {% block content %}
    
    <div class="row">
        <div class="span8">
            <small>{{ breadcrumbs|safe }}</small><br>
        </div>
        <div class="span8">
            <div class="pull-right">
                <small><a href="{{ zipurl }}">download example</a>
            </div>
        </div>
    </div>
    
    <div class="page-header">
    <h1>{{ headers.title }}</h1>
    </div>
    
    {{ content|markdown }}
    
    <div class="page-header">&nbsp;</div>
    <h4>APIs Used</h4>
    {{ apis|safe }}
    
    {% endblock %}

Note the `{{ apis|safe }}` which matches `$args{apis}` in `examples` sub.

If we can't run that `java -jar lib/cms-tools-r1195124.jar $filepath` command 
on the CMS, we can just make a our current examples setup in buildbot generate 
that, write it to a file and copy it to ci.apache.org then instead of `java 
-jar lib/cms-tools-r1195124.jar $filepath` we `wget …` (or better, use LWP to 
download it).

So either way, we'll get the job done in java using our tools.


-David

Reply via email to