Resource plugin not rendering correctly with https - email

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)

Related

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?

How does sling selectors work?

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)

Android 4.0.4 - WebView - Appcache: wildcard does not work in NETWORK section

I want to clarify in manifest that AJAX-calls to web-services only get executed when online. For that I used the NETWORK section of the manifest:
NETWORK:
/WebServices/*
But this causes calls of the error-callback of the JQuery function $.getJSON at every request even when online.
It seems that the WebView of Android doesn't like the wilcard *. Then when adding all URLs called by AJAX functions it works like expected:
NETWORK:
/WebServices/Typen
/WebServices/Hersteller
...
But that's endless work when developing an webapp. So I decided to put all the functions with AJAX-requests in a separate file. This file now gets an entry in the FALLBACK section of the manifest:
FALLBACK:
js/webServices.js js/ajaxStub.js
Every function contained in webServices.js is implemented again in the fallback file ajaxStub.js while returning default-values or store data to submit to the server.

How to see injected scripts in Chrome Developer tools

I am injecting a partial into a page using $().html(content). Part of the partial is JavaScript code in an inline script block I need to inspect. When I look in the Sources tab in the Chrome Developer Tools it doesn't show the injected content. All it shows is the original source.
Is there a way to gain access to the JavaScript?
Update
I am using Google Chrome 21.0.1180.77 but I also have Google Chrome Canary installed.
I don't have a Sources tab (Elements, Resources, Network, Scripts, Timeline, Profiles, Audits, Console).
The Elements tab always reflects the current state of the DOM, so it will show any injected scripts. EDIT: This appears to be wrong.
There's a Chrome issue about this: http://code.google.com/p/chromium/issues/detail?id=95352
You can add a specially formed comment to the injected JavaScript code, and it will then show up in the Scripts tab (but it still doesn't show up in the Elements tab, for whatever reason):
//# sourceUrl=whatever.js
How to see injected snippets:
In order for injected code to be visible, you will need to add a sourceURL comment to the top of the evaluated script, like one of the following:
//# sourceURL=//domain/file.js
//# sourceURL=http://domain/file.js
//# sourceURL=https://domain/file.js
//# sourceURL=//domain/file
Note, that without the // hinting at the protocol and some domain immediately following, then the injected snippet will not show up under sources by default.
How to see injected snippets without a protocol and domain:
Continuing, with just a file name, like so:
//# sourceURL=file.js
You will have to change the source settings by unchecking Group by folder. See image.

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.