Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tried to implement appcache mechanism.. needs some work for dev vs prod #388

Merged
merged 6 commits into from
Mar 9, 2015
Merged

tried to implement appcache mechanism.. needs some work for dev vs prod #388

merged 6 commits into from
Mar 9, 2015

Conversation

Shoelace
Copy link
Contributor

start of offline feature for #150

also fixed grunt to use grunt-mxmlc for swf compiling.. needed to add npm packages also.

other npm packages updted at the same time.

did get 1 error in app/scripts/services/statistics.coffee which may or may not be related. (session object did not exist)

have a look and see what you think.

@erosson
Copy link
Member

erosson commented Feb 24, 2015

didn't realize there was a grunt-mxmlc. that would've been a lot easier to set up - thank you!

I'd like to read more about appcache before merging this - kind of worried that it'll interfere with updates, if version.json's cached or something. Doesn't look like this can be hidden behind a debug-flag, unfortunately.

@Shoelace
Copy link
Contributor Author

yeah .. no i wasnts expectign you to merge this as it it.. mayeb i shoudl have just posted a link to my branch instead of a pull request.

it was more so you could see what i've done.. and pinch bits like the grunt-mxmlc if you thought that was better.

FYI a few things i discovered tring to get eth flash to compile..

  • needed flash/flex sdk installed.. there is a npm module for that
  • needed java installed to run the mxmlc compiler.

according to the various doco.. the offline cache gets checked everytime the manifest file changes.
and thats actual changes.. not just being touched.. which is why it has the timestamp in it.

you can register a callback the get notified of changed.. so you can put up a 'a new version is available.. please update' message

links:
http://www.w3schools.com/html/html5_app_cache.asp
http://www.html5rocks.com/en/tutorials/appcache/beginner/

this has a good example i mnigth pinch.
http://blog.iterativ.ch/2014/09/04/create-offline-web-applications-with-angularjs/

and 2 angular appache thingys. migth be the best way to go
https://github.com/chrisalexander/angular-appcache
https://gist.github.com/amatiasq/7709598

@Shoelace
Copy link
Contributor Author

okay.. im actually mostly happy with this now..
the only part i am not happy with is the gruntfile integration. but maybe you can fix that.

description off offline changes:
added new bower module: appcache-nanny
add app/views/appcache-loader.html (from appcache-nanny)
add helper functions to controllers/header.coffee
add span/button in index.html
initialize appcachenanny in app.coffee

in debug it chekc every 10 seconds.. otherwise it checks the cache for updates every 30seconds.

you can kind of control if its active or not.
if the manifest.appcache file does not exists.. nothing happens

@Shoelace
Copy link
Contributor Author

i just changed it so this is now only on in debug mode..

the only catch is if you turn debug mode off.. you need to remove teh manifest.appcache file

NB:
in chome you can view cache in chrome://appcache-internals/
firefox details here http://flailingmonkey.com/application-cache-not-a-douchebag/

@erosson
Copy link
Member

erosson commented Feb 28, 2015

Just letting you know I haven't forgotten about this or your other pull request, have just been focused elsewhere - will get to this soon, sorry for the delay.

@erosson erosson mentioned this pull request Mar 9, 2015
@erosson
Copy link
Member

erosson commented Mar 9, 2015

Merging this with a new env.isAppcacheEnabled param added to grunt, enabled in dev and disabled in prod. Looks like you had prod commented out, but I didn't notice until after adding the switch (oops!), and putting it in the gruntfile makes it easy to find if I'm rushing to shut this off for some reason.

Hiding the loader in an iframe to make it prod/dev-toggleable is a nice trick. :)

I still haven't done the research/testing I need to be confident turning this on in prod - created #469.

},
prod: {
files:{
'./.tmp/storage.swf' : ['./jsflash/prod/Storage.as']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prod built to ./dist before this change, not to ./.tmp. would've broken saved games for lots of kongregate users if I didn't catch this; careful!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay.. i'm still not entirely clear on the whole dist vs .tmp thing works.. im still learning about grunt/bower/npm etc...

i'll try and be more careful if i make more build related changes..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick explanation: grunt serve compiles to and serves stuff from .tmp. The production distribution is a copy of everything in the dist folder after running grunt build, which includes some (but not all) things copied from .tmp.

This setup comes from generator-angular, I didn't write it: https://github.com/yeoman/generator-angular

@erosson erosson merged commit f985634 into swarmsim:master Mar 9, 2015
@Shoelace Shoelace deleted the appcache branch March 9, 2015 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants