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

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.

Related

Flutter Web Get Chrome Extension info from Polkadot.js web3Enable

I am hoping to confer on a strategy for a flutter web app (as can ignore mobile cases here) to get chrome extension info for a Polkadot.js wallet from the Polkadot browser extension.
My first thought is to use dart's JS library and use the Polkadot extension JS package and then try and pull the info from there. However, I'm not sure how to properly use this in flutter as it is a whole package full of dependencies, not just a single JS file. Also it is in TS not JS. Any thoughts here?
Eg., I need a JS file to be able to call this; and for flutter to in turn call the JS file:
import {
web3Enable,
} from '#polkadot/extension-dapp';
By writing out a "bridging" layer, you can do it easily.
Firstly, create a normal javascript (or typescript) application (nothing related to Flutter). You should be able to happily use the polkadot lib in your js/ts code without any problem. You may need to learn a bit about how to develop js code normally (e.g. you can depend on polkadot using npm, etc).
One small thing is that, you should "expose" some object publicly in your js/ts code. For example, your code may look like window.myFancyFunction = function() { call_some_polkadot_function(); }. Of course you can do more things like exposing other functions/objects/...
Then, you can bundle this normal js/ts application into a .js file. This is still very normal for js/ts developers and should have nothing special to deal with here, and you still do not need to touch Flutter at this stage.
Next, load this single-filed .js file when you are loading your Flutter Web application. You may simply do this by editing your Flutter Web's html file and add <script src="my_single_filed_js_mentioned_above.js" />. Notice that, when loading this script, it simply sets window.myFancyFunction and does not do anything more. Still very trivial here, should have no problem.
Lastly, in your Flutter Web code, i.e. Dart code, call that window.myFancyFunction function. For example, Flutter Web : How to run javascript using dart js says you can do import 'dart:js' as js; js.context.callMethod('myFancyFunction', ['some arguments']);

merge large existing web app into Sailjs site

I'm trying to merge large existing web app into sails.js. so I moved the folders into assets and build a custom route , 'GET /': '/assets/client/launch.html' and get 404 when I point my browser to http://localhost:1337/ as the / is correctly redirected to http://localhost:1337/assets/client/launch.html which produces the 404.
Now the file exists in the folder assets/client (and in .tmp), so I am thinking the Sails router is getting in the way.
I would leave the client (70K lines of JS) that generates all the UI dynamically and sailjs server that provides authentication separate and enable CORS but my customer wants client packaged with server. This type of operation is simple in frameworks like ASP.NET MVC but am wondering if Sails is up to the task.
Well, If everything you tried did not work out. There might be another solution ,
First of all since you are talking about sails app I am assuming other bundle must be sails as well ,
So here is what you do-
Change the port for another app that you want to attach to this.
Second whenever you want to go to page on another app simply redirect the client to another port ie
in html or esp put a href tag with different port.
<a href="localhost:PORT/route_to_file">
</a>
I got it working by placing my app into assets where we need to launch from assets/client/index.html as there would be too many dependencies to change. As I said above could not just add a route as Sails must getting in the way. However as in Chapter 3.2.2 of Sails in Action I generated a static asset npm install sails-generate-static --save. then I redirected to assets/client/index.html. As an aside that book is great and would highly recommend it.

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)

Creating dynamic manifest files that work with ipads and iphones

Problem: The browsers within apples ipad and iphone don't seem to like dynamically generated manifest files (we constantly get errors involving either missing images or .aspx pages that can be accessed from the device or "Application Cache manifest could not be fetched"). We originally had a manifest.ashx acting as our manifest that would dynamically create and pull some pieces from the web server for offline app functionality. This process worked fine for the majority of browsers and mobile devices but failed on the apple products.
Thoughts: For some reason safari doesn't seem to register the manifest.ashx correctly (this is where we dynamically create the manifest file) and just gives up on trying to open it. We truly need a dynamic manifest file for the requirements of the project so switching to a static manifest file would not work. Does anyone have any suggestions towards alternative creation methods for dynamic manifest files?
Code:
manifest.ashx
public class Manifest : IHttpHandler
{
public void ProcessRequest( HttpContext context )
{
ManifestGenerator generator = new ManifestGenerator();
context.Response.ContentType = "text/cache-manifest";
//Create the dynamic manifest file here (returns the manifest as a string)
context.Response.Write( generator.GenerateManifest() );
context.Response.Flush();
}
}
Thanks,
Updated Thoughts v1: Leaning towards thinking this maybe a device specific manifest fault as all the other mobile and desktop devices are accessing the app just fine (including being able to go offline). Currently I have moved back to a dynamically generated manifest (within the manifest.ashx) and the ipad / iphone still dies when trying to fetch but it does get further then it did before (error was: "Application Cache update failed, because "file path goes here" could not be fetched"). A strange aside to this is the fact that the desktop version of safari handles the web app just fine (as well as an install of chrome on the ipad had no troubles accessing the site on/off line) while the mobile versions of it do not.
Updated Thoughts v2: Seems that this issue is safari specific as I have the web app running online/offline with chrome for the apple products (iphone/ipad). Still looking for a fix / work around for the safari browsers though...
For Safari/iPad, the manifest file must end with .manifest. Atleast, that's what my tests determined.
So, in order to make this work, you will have to dynamically generate the .manifest file using a HttpHandler and some changes in web.config to do map cache.maifest to the handler. The idea is that the call to the non-existent cache.manifest would actually get mapped to the handler, which would then send back dynamic content.
This is currently the part I'm stuck at, so I cannot help you here yet.

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.