Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:chaplinjs/facebook-example
Browse files Browse the repository at this point in the history
Conflicts:
	coffee/controllers/likes_controller.coffee
	coffee/controllers/navigation_controller.coffee
	coffee/controllers/posts_controller.coffee
	coffee/controllers/session_controller.coffee
	coffee/controllers/sidebar_controller.coffee
	coffee/lib/services/facebook.coffee
	coffee/lib/services/google.coffee
	coffee/lib/services/service_provider.coffee
	coffee/lib/support.coffee
	coffee/lib/utils.coffee
	coffee/lib/view_helper.coffee
	coffee/models/like.coffee
	coffee/models/likes.coffee
	coffee/models/navigation.coffee
	coffee/models/post.coffee
	coffee/models/posts.coffee
	coffee/models/user.coffee
	coffee/views/compact_like_view.coffee
	coffee/views/full_like_view.coffee
	coffee/views/likes_view.coffee
	coffee/views/login_view.coffee
	coffee/views/navigation_view.coffee
	coffee/views/post_view.coffee
	coffee/views/posts_view.coffee
	coffee/views/sidebar_view.coffee
	index.html
  • Loading branch information
karellm committed May 13, 2012
2 parents c88d5b2 + adbcd61 commit ea35375
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 2 deletions.
52 changes: 52 additions & 0 deletions coffee/facebook_browser.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
define [
'chaplin/mediator'
'chaplin/application'
'controllers/session_controller'
'controllers/navigation_controller'
'controllers/sidebar_controller'
'routes'
], (mediator, Application, SessionController, NavigationController, SidebarController, routes) ->
'use strict'

# The application object
class FacebookBrowser extends Application

# Set your application name here so the document title is set to
# “Controller title – Site title” (see ApplicationView#adjustTitle)
title: 'Chaplin Example Application with Facebook login'

initialize: ->
###console.debug 'ExampleApplication#initialize'###

# This creates the ApplicationController and ApplicationView
super

@initControllers()
@initMediator()
# Register all routes and start routing
@initRouter routes

initControllers: ->

# Instantiate common controllers
# ------------------------------

# These controllers are active during the whole application runtime.
new SessionController()
new NavigationController()
new SidebarController()

# Create aditional mediator properties
# ------------------------------------

initMediator: ->
# Create a user property
mediator.user = null
# Seal the mediator
mediator.seal()

# Finish
# ------

# Freeze the application instance to prevent further changes
Object.freeze? this
10 changes: 10 additions & 0 deletions coffee/views/collection_view.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
define [
'views/view',
'chaplin/views/collection_view'
], (View, ChaplinCollectionView) ->
'use strict'

class CollectionView extends ChaplinCollectionView

# Borrow the method from the View prototype
getTemplateFunction: View::getTemplateFunction
39 changes: 39 additions & 0 deletions coffee/views/view.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
define [
'handlebars',
'chaplin/views/view',
'lib/view_helper' # Just load the view helpers, no return value
], (Handlebars, ChaplinView) ->
'use strict'

class View extends ChaplinView

getTemplateFunction: ->

# Template compilation
# --------------------

# This demo uses Handlebars templates to render views.
# The template is loaded with Require.JS and stored as string on
# the view prototype. On rendering, it is compiled on the
# client-side. The compiled template function replaces the string
# on the view prototype.
#
# In the end you might want to precompile the templates to JavaScript
# functions on the server-side and just load the JavaScript code.
# Several precompilers create a global JST hash which stores the
# template functions. You can get the function by the template name:
#
# templateFunc = JST[@templateName]

template = @template

if typeof template is 'string'
# Compile the template string to a function and save it
# on the prototype. This is a workaround since an instance
# shouldn’t change its prototype normally.
templateFunc = Handlebars.compile template
@constructor::template = templateFunc
else
templateFunc = template

templateFunc
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ <h1>Chaplin Example Application</h1>
urlArgs: 'bust=' + (new Date()).getTime()
});
// Bootstrap the application
require(['facebook_application'], function (FacebookApplication) {
var app = new FacebookApplication();
require(['facebook_browser'], function (FacebookBrowser) {
var app = new FacebookBrowser();
app.initialize();
});
</script>
Expand Down

0 comments on commit ea35375

Please sign in to comment.