YUI3: How to bundle dependencies for offline deployment? - deployment

I am building a web application using YUI3 and with it it's "Loader" and "App" components. I separate my application into different modules with YUI.add(). All is going well so far.
However, the application is going to be run off-line (distributed as a .zip file or so), with no access to the YUI CDN. I am looking for a way to neatly bundle all my dependencies without shipping the many megabytes that is YUI3.
Is there a best-practice way to bundle only the dependencies I need for my application?
The closest thing I found to this is http://yuilibrary.com/yui/docs/yui/loader-resolve.html , but I feel there must be a easier way than to write something myself. I am willing to restructure my sources should I need to, or switch to using Builder or Shifter if that helps.

Related

Flutter/Dart: Communication between features in Clean Architecure

I'm new to flutter/dart and I'm trying to create a little application using a Clean Architecture design.
I read some blogs and several presentations of Uncle Bob's Clean Architecture before starting to code to get the most of it and now it's time to implement it.
I guess my application could be divided in 3 main features :
authentication
classes (get access to lessons/quizzes on specific subjects)
admin (manage user, create lessons etc..)
I started to implement the authentication feature following the clean pattern, that's to say with a domain, data and presentation layer and I guess I did it quite well. It's (almost) fully tested (I'm trying to do some TDD) and seems to work as I wanted.
Now comes the problem. I want to implement the classes feature. I wish it could be independent of the authentication but it's not the case... The classes feature need to get the authenticated user from the authentication feature. I searched a lot on the internet but I can't find how to implement Clean Architecture with multiple features that need to share some data.
So there are my 2 questions:
How to pass data from a feature to another ?
How to inject dependency in a feature that need data from another feature ? (I used get_it for the authentication feature and inject all dependencies in the main() method before building the app. Since it did not need any external data it worked well. Now it's seem not possible to do the same for the classes feature since it first needs to get some data from the authentication feature).
Thanks in advance for your answers.
Along with your 3 features you should add another called core and inside that folder you can add stuffs that need to be shared. It worked for me . Good luck
One option is if you instantiate classes after the user has already logged in, you can pass that data in as a constructor parameter.
More generally, Provider is probably the best dependency injection tool for flutter. If you "provide" the authentication class to the widget tree for the rest of the app, you can say at any point below it, Provider.of(context) to access it and any public field it has.
Hope you're still working on Flutter projects after that long time.
I've been fiddling around with Uncle Bob's Clean architecture, and I managed to implement it in Flutter few months ago.
It's perfect, it separates your code into components (modules if you're coming from a native Android development environment) and isolates your data sources, so if you want to change the way you make API requests for example, you'll only need to change the remote data source part in your app, and all your application should work as expected.
I have made a test app using Clean Architecture I just uploaded on github and added a humble readme that describes the basic architecture and components of the app, I'll work on written articles describing the code very soon.
For now you can access the repo from here
I'm trying to find an answer to this for some time now... My solution was to create some transformation methods in the model class. For example, I have an ProductModel in the home feature file (from where i can add products to the cart), and an ProductInOrderHistoryModel in the order history feature file. So in the ProductInOrderHistoryModel file I have a method called toProductModel that gets an instance of ProductInOrderHistoryModel and transform to a ProductModel. That way I can add a product to the cart directly from my history order page.
Probably it's not the best solution, and the Uncle Bom would be really mad at me. But it was how I manage to solve my problem...

Web development, protecting application code

I'm looking at some (PHP) Frameworks, and I just noticed this in the Laravel documentation:
Like most web-development frameworks, Laravel is designed to protect your application code, bundles, and local storage by placing only files that are necessarily public in the web server's DocumentRoot. This prevents some types of server misconfiguration from making your code (including database passwords and other configuration data) accessible through the web server. It's best to be safe.
I'm familiar with CodeIgniter and CakePHP, as far as I know, these two frameworks don't do this. Should you really split it up and place your core logic outside of the webroot? In my experience, most clients use shared hosting and are not able to change their VirtualHost settings.
What kind of misconfiguration could you possibly do that would output your passwords? When developing, should you really do this?
Yes, keeping only those files which should be publicly accessible in DocumentRoot is a best practice for web application security. Consider:
Every file which is private would need a rule configured with the web server to explicitly block it.
Anyone adding files to the project needs to consider web server security settings. Simply keeping the files in separate directories makes it obvious what's public. And developers don't need to change security configurations.
Separating executable code and static files is a good practice anyway.
Not blocking access to PHP scripts can cause unintended consequences. For example, you may have a script to update some DB records when run manually at the command line, so someone simply guessing a script name can run it over the internet.
Monitoring for and cleaning malicious code written to the public directory is much easier if the real application logic is elsewhere. See Wordpress breakins for an example.
CakePHP supports this - see deployment:
CakePHP applications should have the document root set to the
application’s app/webroot. This makes the application and
configuration files inaccessible through a URL.

best way to embed LIGHTWEIGHT GWT 'widgets' into websites

I know this is similar to other topics, but I've not yet found a satisfactory answer.
I have a GWT / GAEJ application that essentially allows users to interact with the web app as if it were a desktop app. i.e. they login, and use the application in full-html mode (i.e. the GWT app occupies the entire html page). They are typically power users and so don't mind a few seconds dowload / login time when starting to use the app. Typically they might stay logged in for several hours.
I would also like to make available some small subsets of functionality, pointing to the same Back end, as widgets to be included in OTHER existing websites. I know one of the features of GWT is that you can either embed your GWT into existing html pages or go full page.
My question is how do I partition the GWT components into small tidy parcels so that only the relevant bits are downloaded for these embedded 'widgets' whist not having to duplicate my backend code. (for example I could create a new GWT project write only my small widget and copy the server side code - but I really don't want to do this!) Each widget still needs to interact with the same backend so none of them will be stand alone GWT. Communication is GWT-RPC.
anyone done this?
Seems like you want to split your GWT stuff into multiple GWT modules that you want to later combine in possibly more than one project. One way is having a multi-module maven setup (gwt-maven-plugin), there's no need to copy/paste code.

Updating iOS resource files remotely

I have an app on the App Store that needs to have its resource data files updated periodically (every 2-3 months). So far, I've just been deploying a new version of the app to the App Store every time I need to do this, but the fact that I have to wait a week or two for the changes to become live is cumbersome.
Theoretically, I was thinking of creating a new "version_control.txt" resource file which tracks the version numbers of every other resource file. Periodically, the app would check its version_control.txt against a version up on some web server, and then download any files that need to be updated.
Do there exist any frameworks or SDKs to handle all of this for me, or do I have to write everything myself? Is there a better solution?
You can't update the resources in your app bundle without updating the entire application. However, there's no problem with having your app retrieve resources from a web server and save them in your app's Documents folder. From there, it's simple to have the app look for its resources in the Documents folder before looking in its own bundle.
I don't know of any frameworks that manage resource versions for you. There's not a lot of work involved, and each app likely has its own requirements, so I'm not sure that a framework would help that much. If your web server supports it, you could request the resource file(s) each time your app runs, but add the if-modified-since header so that you only download a new copy if the version on the server is newer than the one your app already has.
I also had similar problems. I had tried to download some custom files from my ftp domain but that really didn't work very well. Not only I had to pay for the bandwidth, the users weren't very happy about it. The coding complicated considerably. Now, I've decided to update periodically via AppStore. The users are more satisfied since they see updates, but they don't understand is that only a couple of resources have been updated.
PS: I'm not aware of any SDK or framework for it. But you don't need it, you just need to download some files...

How do I sync an offline web app (HTML+JS+CSS) with my server?

Do I need to implement my own sync methods in order to make an offline web app (html+css+js) stay up to date with changes made on the server (and viceversa)? I'm using MySQL on the server side.
I read Two-way sync between iPhone application and web application with some pointers but I think they're talking about native applications when they mention CFUUIDCreate and I wander if this is possible for the Web.
Does someone have some code to share or maybe can point me in the right direction?
Thank you!
P.S.: I hope my english is not that rusty ;)
To store static contents on the client-side, as Jethro Larson said, the Application Cache Manifest is the way to go to cache the static contents of your website (HTML, CSS, JS and images).
To handle dynamically generated contents offline, you can use javascript templates. There are several solutions for this.
To sync the two databases, there is a project called persistence.js (persistencejs.org) which is a javascript library which offers a unique API to work with WebSQL databases, Local Storage, etc. They have a plugin for this library called persistence.sync (persistencejs.org/plugin/sync) which syncs the remote database with the server's one. It consists of POST and GET requests to a specific url that you can configure (for example yourapp.dev/sync). They have an example back-end written in node.js and here is one for Rails. It's simple to understand and persistence.sync is well documented.
Look at the offline cache:
http://www.webreference.com/authoring/languages/html/HTML5-Application-Caching/
http://www.google.com/search?q=offline+cache+html5
http://www.slideshare.net/search/slideshow?q=offline+cache