Apache Camel / String template component / Template Groups - apache-camel

In Apache Camel, is it possible to use template groups (c.f. https://theantlrguy.atlassian.net/wiki/display/ST4/Group+file+syntax) using the string-template component ?
I would like to load a template group file to be able to used the named templates defined there and use them in the template file refered to by a string-template endpoint.
There does not seem to be any means to configure the string-template endpoint or component to define where to load a group file.
Any ideas on whether this is possible or not and if so how ?

Is there a reason for needing the template groups and ST4? According to the String-Template Component page:
string-template:templateName[?options]
Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template.
I would think you could put all your template files in the same folder and treat that as your group.

Related

Is there a way to use a different html template in react based on the url?

I need to use a different HTML template in react based on the URL.
You know the HTML template in the public folder.
Is there a way to use one based on the URL?
Thanks.

Angular Attributes Not recognized by Day CQ Link Checker Transformer

I am using "Day CQ Link Checker Transformer" for URL mapping on a project,
yet I need to transform a link on a button based on angularJS.
But when I try to add Data-navurl on Day CQ Link Checker Transformer,
it does not transform the URL on the web page.
The Link Checker Transformer will not work for Angular applications as your markup is contained within <script> tags. You will need to force the rewriting of the url using a JSP tag library or HTL Sling Model.
UPDATE:
To explain further... the LinkCheckerTransformer works just like any other transformer in the Sling rewriting pipeline, it responds to SAX events from the HTML parser. This means that it may not rewrite all links within your HTML page unless it is configured to generate an event. For example, <input> tags may be used to hold open redirects – these will not be rewritten unless the INPUT tag is added to the HTML parser and input:value is added to the list of rewrite elements. You can try to add SCRIPT tags to the HTML parser but I'm not sure how the parsing would behave...
Day CQ Link Checker Transformer does not check anything on the text level of XML DOM structure. It treats HTML as an XML document and rules are only applied to elements and attributes.
In your case the angular template is part of a <script> element but it is treated as a text and therefore it is skipped.
This is no different from writing a normal JS to inject a link in your page. Link checker will gracefully ignore the script text.

Is there any way of getting CRX content without using OSGI

Is there any way to get CRX content without using OSGI service?
Am looking for an use case to implement a top navigation for a website which is required to read page names and its properties via javascript framework like angular JS.
You could get it as JSON or XML, make a server call to path with extension XML or JSON. JSON allows you depth based selectors to go down the tree hierarchy not sure if its same with XML.
/my/page/path.xml or /my/page/path.<depth>.json, you can get the hostname and port details from the request URI to make the complete URL for the data call.
I would suggest you use the following JSON API's provided by sling to accomplish your task of getting page names and its properties.
Firstly to crawl all the pages under a given path, you need to use the .pages.json selector. For example to get all child pages of /content/company/en_US, perform a JSON GET on
HTTP GET <Host>/content/company/en_US.pages.json
Next for each path returned by the above GET call, you need to grab the _jcr_content.json of the page
(E.g.)
HTTP GET <Host>/content/company/en_US/home/_jcr_content.json
The above JSON call should provide you all the page properties of this particular page.
Please Note: The above method is generic and can be applied to any JCR Path hosted in Sling/AEM. Also typically you cannot get this level of JCR access in a publisher environment due to security rules that might prevent JCR crawling. Hope this helps

Camel Sftp - Download Multiple Files

I am able to successfully download one/all files from a sftp directory using the following uri in canmel route definition
Download all files
"sftp://userName#serverName/directoryName?knownHostsFile=./known_hosts&privateKeyFile=./id_rsa&proxy=#proxy&noop=true"
Download one file
"sftp://userName#serverName/directoryName?knownHostsFile=./known_hosts&privateKeyFile=./id_rsa&proxy=#proxy&noop=true&fileName=one.txt"
My requirement is to download a specific list of files = one.text, two.text.
How can I pass list of fileNames to the Camel route? Preferablly I am looking for a solution where in I can specify something like the below
"sftp://userName#serverName/directoryName?knownHostsFile=./known_hosts&privateKeyFile=./id_rsa&proxy=#proxy&noop=true&fileName=one.txt,two.txt"
The Camel FTP component extends the File component and many of the options from file is also applicable for the FTP component, so read this page
http://camel.apache.org/file2
You can for example use include to specify a regular expression that matches the files you want. Or implement a custom filter class and use the filter option, etc.

Underscore.js template on Java server

I'm building a single page web app when Backbone.js is my MV* framework. It requires Underscore.js so I wan't to use it as my template engine.
I set the template result as the view content to display in it's render function:
this.el.append( compiledTemplate );
I wonder about the right way to implement the template code:
Should it be a JS code that produce an HTML text?
Should it be an HTML file with a script tag to include the JS code?
How can I separate the display from the logic?
How can I write my CSS in a separate file (not in JS file)?
Well... this is what the Underscore template engine is, isn't it? so, no, your template should be HTML with interpolate tags.
Normally it is a DOM element whose content is the template, and, yes, it is used to be a script tag.
Force your self to only use interpolate Model attributes in your templates. You can pass especial pre-calculated attributes if you use any kind of Decorator technique.
There is not any Backbone or Underscore restriction to you not include your external CSS files as usual.

Resources