juneau-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sblackmon <sblack...@apache.org>
Subject Re: Simplifying title and description on HTML pages.
Date Mon, 10 Jul 2017 18:47:40 GMT
Perfect.  Thanks!


On July 10, 2017 at 1:22:58 PM, James Bognar (jamesbognar@gmail.com) wrote:

You can do that today!  

@RestResource(  
htmldoc=@HtmlDoc(  
widgets={  
MyHeader.class  
},  
header={  
"$W{MyHeader}"  
}  
)  
)  

Then your widget can be defined to load from resources.  

public class MyHeader extends Widget {  
@Override  
public String getScript(RestRequest req) throws Exception {  
return loadScript("MyHeader.js");  
}  
@Override  
public String getStyle(RestRequest req) throws Exception {  
return loadStyle("MyHeader.css");  
}  
@Override  
public String getHtml(RestRequest req) throws Exception {  
return loadHtml("MyHeader.html");  
}  
}  

The loadX() methods strips off comments (e.g. apache license headers) from  
the files for you.  

You can embed any of the various other variables inside the files as well  
(e.g. $L{}, $R{}, etc....) since the $W variables are recursively resolved  
(just like any other variable).  


On Mon, Jul 10, 2017 at 1:49 PM, sblackmon <sblackmon@apache.org> wrote:  

> +1 for more flexibility in the header region.  
>  
> Might it make sense to let developers put HTML with expressions in  
> separate resource files and specify the class path resource with an  
> annotation field, to make the fragments easier to re-use?  
>  
> Or perhaps support Widget classes as values for header, footer, aside,  
> etc…?  
>  
> On July 10, 2017 at 12:14:21 PM, James Bognar (jamesbognar@apache.org)  
> wrote:  
>  
> There's a change I'd like to make to the way the page header is specified  
> on the HTML views.  
>  
> It's rather complicated right now. The Title and Description in the header  
> is added as <h1> and <h2> tags in the HtmlDocTemplateBasic class.  
> The title comes from @HtmlDoc.title() or @RestResource.title() if not  
> specified (or the resource bundle or swagger file)  
> The description comes from @HtmlDoc.description() or  
> @RestMethod.description() if not specified (or the resource bundle or  
> swagger file).  
>  
> What I'd like to do is eliminate @HtmlDoc.title()/description()  
> /branding(),  
> and just add the following default value to the header() annotation on  
> RestServletDefault:  
> @RestResource(  
> htmldoc=@HtmlDoc(  
> header={  
> "<h1>$R{RestServlet.servletTitle}</h1>",  
> "<h2>$R{RestServlet.methodSummary}</h2>",  
> "<a href='http://juneau.apache.org'><img  
> src='$U{servlet:/htdocs/juneau.png}'></a>"  
> }  
> )  
> )  
>  
> This simplifies the logic and I believe makes it easier to understand and  
> override in subclasses.  
>  

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message