How does sling selectors work? - aem

I am working on HTTP caching and to implement cache busting, I am using ACS Versioned ClientLibs. Now this works fine for js file when it is part of clientlib. For example <script src="/etc/designs/myapp/clientlibs/base.js"> works. But when I try to access an individual js within the library it doesnt work. For example <script src="/etc/designs/myapp/clientlibs/base/js/app1.js"> fails. The reason is the MD5 hash added as sling selector gets resolved when it is a clientlib js. But selector is not getting resolved when calling js individually. </base.hash.js> works but </base/js/app1.hash.js> fails.
How does AEM know to resolve selectors when calling clientlibs and doesnt do when calling individual js?
And the reason I need selectors to work specifically is, as per PageSpeed, most proxies donot cache static references with ? param. And asks to remove the query params. So I cant add query param for cache busting.

/etc/designs/myapp/clientlibs/base is a
cq:ClientLibraryResource
/etc/designs/myapp/clientlibs/base/js/app.js is a nt:file resource.
There is no resource .../base/js/app this you can't request this resource w a selector (app.hash.js)

Related

Claudia.js jasmine post/put body key

I'm using claudia-api-builder and attempting to write tests using jasmine-node. I'm using the proxyRouter on my API using this tutorial https://claudiajs.com/tutorials/testing-locally.html, and I can pass path parameters fine as demonstrated. However, I can't find what the key is for the body of the request.
For example it says
You can fill in the other properties (eg queryStringParameters)
according to what the test expects
But I can't find anywhere that lists the possible properties. The API Gateway Proxy Object link also doesn't seem to go to anything useful, as the sample doesn't seem to include a body.
Does anybody know what the key I should be using is? Thanks!
Worked it out - somewhat embarrassingly it's just body.

Umbraco with Windsor Castle error after adding nuPickers plugin

With an existing Umbraco site running fine we added the nuPickers plugin which does not seem to like Castle. In the browser console we are seeing a lot of 404 / 500 errors being generated for the embedded resources within the plugin. (The plugin is a single DLL with css and js files embedded in it.)
The site continues running fine (back and front ends), except for the plugin.
The Event log is showing: "No component for supporting the service nuPickers.EmbeddedResourceController was found"
We have tried route.ignoreroute in our route config, and also adding a handler in web.config, both unsuccessfully, as we do not think the resource requests should be getting to castle?
Any help or pointers gratefully accepted!
Just in case anyone comes across this ticket, we 'solved' this by
Getting all of the embedded resources, (html, js & css - not the classes)
Physically placing them inside the App_plugins folder in the correct structure (as they were being requested),
Renaming the js and css files (by adding the .nu after the file
extension), and,
Adding the following mime types into the web.config
mimeMap fileExtension=".css.nu" mimeType="text/css"
mimeMap fileExtension=".js.nu" mimeType="application/javascript"
Then, everything seems to work - but there MUST be a better solution, surely?

Resource plugin not rendering correctly with https

I'm attempting to use groovyPageRenderer.render() to render a temple with a model, so that I can email this rendered HTML using sendMail {}. Some of the banners we have include images and we add them using something like:
${resource(dir: 'images/email', file: 'background_body.gif', absolute: true)}
This is all good, and works fine in development. However, we wish to run the application over https, and despite setting grails.serverURL to "https://ourwebsite.com" (as indicated by the docs for Closure resource in ApplicationTagLib.groovy [from the grails-plugin-gsp]), it still tries to render the resources as available via http (which isn't available), only via https.
Based on this comment from the Resources plugin source, it appears that the plugin's resource() tag doesn't correctly support the attr absolute. If you're running Grails v2.0 or above, Grails' LinkGenerator may be a workaround. It's injected as grailsLinkGenerator, and can be invoked this way: grailsLinkGenerator.resource(dir: '...', file: '...', absolute: true)

JStreeGrid Microsoft JScript runtime error: Object doesn't support this property or method

I'm using the JSTreeGrid in an ASP.NET application. The implementation of the JSTreeGrid works fine in the application in which it was designed in tested. However when I moved it over to another application I recieved the following error message below:
Microsoft JScript runtime error: Object doesn't support this property or method
When I initially moved the implementation over I discovered and corrected issues related to the new application forms utilizing Masterpages. The container names were concatenated to the div tags and the scripts were not finding the declared div tag IDs specified in the script. The application that I moved it from did not use Masterpages. I feel resonably certain that the error is related.
The error occurs in the _prepare_grid: function in the jstreegrid script when obj.each(function () section of script is run.
Any insight would be appreciated. Thanks
When you use master pages the Client ID of your DOM elements ia manupulated by the server.
This is due to the chace that you will use the same id both in the master page and in your derived page... when calling Jquery function i would guess that you use id selector i.e. $('#someID').doSomething() ...
When using master one of the solutions is to use the following selector as an exmaple:
$('[id$=myButton]').click(function(){ alert('button clicked'); });
This means that Jquery will select the element with an ID attribute that end with 'myButton'.
for more information follow this post.
How to use JQuery with Master Pages?

Making GWT application crawlable by a search engine

I want to use the #! token to make my GWT application crawlable, as described here:
http://code.google.com/web/ajaxcrawling/
There is a GWT sample app available online that uses this, for example:
http://gwt.google.com/samples/Showcase/Showcase.html#!CwRadioButton
Will serve the following static webpage to the googlebot:
http://gwt.google.com/samples/Showcase/Showcase.html?_escaped_fragment_=CwRadioButton
I want my GWT app to do something similar. In short, I'd like to serve a different flavor of the page whenever the _escaped_fragment_ parameter is found in the URL.
What should I modify in order for the server to serve something else (a static page, or a page dynamically generated through a headless browser like HTML Unit)? I'm guessing it could be the web.xml file, but I'm not sure.
(Note: I thought of checking the Showcase app provided with the GWT SDK, but unfortunately it doesn't seem to support serving static files on _escaped_fragment_ and it doesn't use the #! token..)
If you want to use web.xml, then I think it won't work with a servlet-mapping, because the url-patterns ignore the get parameters. (Not 100% sure, if there is another way to make this possible.)
You could of course map Showcase.html to a servlet, and in that servlet decide what to do, based on the get parameter "_escaped_fragment_". But it's a little bit expensive to call a Servlet just to serve a static page for the majority of the requests (not too bad, but still. You could set cache headers, if you're sure that it doesn't change).
Or you could have an Apache or something in front of your server - but I understand, I wouldn't like to have to do that either. Maybe your JavaEE server (which one are you using BTW?) provides some mechanism for URL filtering before the request gets passed on to the web container - I'd like to know that, too!
Found my answer! The Showcase sample supporting crawlable hyperlinks is in the following branch:
http://code.google.com/p/google-web-toolkit/source/browse/branches/crawlability/samples/showcase/?r=7726
It defines a filter in the web.xml to redirect URLs with the _escaped_fragment_ token to the output of HTML Unit.