chaplinjs / chaplin

HTML5 application architecture using Backbone.js
http://chaplinjs.org
Other
2.85k stars 232 forks source link

How to get the example application: Facebook Likes Browser running? #3

Closed crussi closed 12 years ago

crussi commented 12 years ago

First off, thank you so much for releasing this code and for the excellent write up. I've been using backbone.js, require.js, coffee script, jquery, etc. on a single page application for about 6 months. I am embarrassed to say that I can't seem to get your sample app running. I'm working in Windows 7 environment. Basically, I took the download and put the index.html file (along with all folders) and copied them to my default web site. I added the line 127.0.0.1 chaplin.moviepilot.com to my hosts file. I navigated to chaplin.moviepilot.com and I got the page to render, but, it was chock full of errors. I apologize, I'm not at home right now, so, I don't have access to the exact errors. But, I'm curious, am I going about it the right way? I am excited and eager to start working with Chaplin. I've tried Marionette and found it too difficult to migrate to AMD (requirejs). I was so happy to see your sample app and I'm busy studying it to see how I can get it to work.

Also, you mentioned in your writeup about including backbone, underscore as regular scripts tags. I was able to get around this and use them as AMD modules with this nice plugin called use.js. It is written by one of the core backbone JavaScript engineers tbranyen https://github.com/tbranyen/use.js. Just thought I would mention it. It worked out well.

Chaplin looks great and really does fill a need that became evident to me the more I worked with backbone.

Best regards, Chris

molily commented 12 years ago

Thanks for trying out Chaplin! It would be helpful if you could hand in some of the error messages. I suppose RequireJS might have thrown some errors because the js path is hard-coded. I think at the moment the stuff has to be accessed exactly using the http://chaplin.moviepilot.com/ URL.

I’ll try to set up the things on my Win7 machine this evening, maybe I can reproduce some errors.

Regarding the RequireJS packaging, the README is already mentioning wrap.js (need to fix that link). I think in the long run we should use either this or use.js. I hesitated to do so maily because long dependency lists look terrible in CoffeeScript. ;-)

crussi commented 12 years ago

Thank you so much for your response. I am getting a clearer picture of the error as I get more familiar with the code. Here is the title of the main error:

HTTP Error 404.3 - Not Found The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

And I can see from the detailed section that it might have something to do with the handlebar template likes.hbs:

Module StaticFileModule Notification ExecuteRequestHandler Handler StaticFile Error Code 0x80070032 Requested URL http://chaplin.moviepilot.com:80/js/templates/likes.hbs?bust=1330699288393 Physical Path C:\inetpub\wwwroot\js\templates\likes.hbs Logon Method Anonymous Logon User Anonymous

The rest of the errors similar to the one listed above. I guess the views can't be rendered because of the MIME type. Maybe I need to add a new MIME type. So, I added:

.hbs text/plain

:-) yea! It works!

So far the code has been really easy to understand and organized nicely. I like how you introduced the concept of a controller, which is missing in backbone. There are a lot of very nice features to make coding an application easier. I like the implementation of service providers. But, I am finding the concept of "loading sdk" a little difficult to understand. I will continue to go over the code, I'm sure things will resolve themselves.

Thanks again for making this framework available and for the excellent write up on the concepts behind it.

Best regards, Chris

molily commented 12 years ago

I’m glad you found the cause of the problem, and thanks for sharing the solution.

You’re right, loadSDK probably isn’t the best naming here. I don’t like the term “SDK” for an external JavaScript library. We used it mainly because Facebook is promoting it’s all.js as “JavaScript SDK” like they do it with their PHP SDK, iOS SDK, Android SDK etc. Since other providers like Google and Twitter do not use this naming we are likely to change the method name.

BTW, we’re planning to add ServiceProviders for Twitter and Google to the example app. We still have to think about APIs we might query if one is not logging in with Facebook. Maybe the moviepilot.com API with JSONP will be used (showing top read stories or so).

crussi commented 12 years ago

Hi Mathias, Thanks for your response and now that you've explained the use of the term SDK, it is becoming clearer. I am stepping through the code module by module. I am rebuilding the app so that I understand it best. I have to say that things are really clicking for me. Unlike Marionette, your use of AMD modules makes snapping together an application quite intuitive. I have also learned a few things, such as freezing an object and strict mode. I do not mean to impose and I know you're busy building applications, but, there is one more thing that is new to me and unclear. I see the use of _(...).defaults(...) e.g.

Include Backbone event methods for

global Publish/Subscribe

_(mediator).defaults Backbone.Events

When I look at Underscore's library they do not show an example of the use of defaults being as follows:

    _.defaults(iceCream, {flavor : "vanilla", sprinkles : "lots"});

Am I correct to think that _(...).defaults(...) is a way to inject the methods from one object into another? Sort of like extends?

I have to admit that the fluid updates of the "wall posts" list is quite impressive. Also, I'm finding the code quite pleasant to read and the structuring seems to be very much like what I am used to in my current applications. I am anxious to study the code more!

I think it is a great idea to introduce alternate service providers. One good case for alternate providers is that many employers, such as the one I work for, block "anything" connecting to Facebook or Twitter in any way. I know that chaplin.movieplot.com depends on Facebook connectivity, but, I am speaking more to the point that applications are best to provide alternate service providers.

As I study the code, I hope to give back in some way. I'm not there yet, but, I plan to keep studying the Chaplin architecture.

Best regards, Chris

On Sat, Mar 3, 2012 at 4:57 AM, Mathias Schfer < reply@reply.github.com

wrote:

Im glad you found the cause of the problem, and thanks for sharing the solution.

Youre right, loadSDK probably isnt the best naming here. I dont like the term SDK for an external JavaScript library. We used it mainly because Facebook is promoting its all.js as JavaScript SDK like they do it with their PHP SDK, iOS SDK, Android SDK etc. Since other providers like Google and Twitter do not use this naming we are likely to change the method name.

BTW, were planning ServiceProviders for Twitter and Google to the example app. We still have to think about APIs we might query if one is not logging in with Facebook. Maybe the moviepilot.com API with JSONP will be used (showing top read stories or so).


Reply to this email directly or view it on GitHub: https://github.com/moviepilot/chaplin/issues/3#issuecomment-4300511