Skip to content

Instantly share code, notes, and snippets.

@loopj
Created November 5, 2011 03:08
Show Gist options
  • Save loopj/1341041 to your computer and use it in GitHub Desktop.
Save loopj/1341041 to your computer and use it in GitHub Desktop.
#
# Requirements for js framework
#
# - Cache Page "chrome", javascripts, css, templates in app-cache
# - Optionally
# - Load json data from android/ios client (eg. android Parcelable data)
# - Load json data immediately from cache, if present
# - Load json data from http json endpoint, store to cache
# - Update view elements when associated model data changes (knockout.js?)
# - Support for refreshing data from server on demand
# - Support for feed pagination
# - Mobile-friendly data bindings, for passing object json payloads to android/ios client on click
# - Debuggable, exception handler friendly
#
#
# Proposition:
#
# Templates are defined in the html endpoint in
# <script type="text/x-handlebars-template" data-template="blah"> blocks.
# All templates will then be loaded into a Heyzap::templates object for use
# in the views below.
#
#
# Will build a bunch of base classes, namely:
# - Heyzap.View (A single page view, like "game details" or "sdk registration")
# - Heyzap.FeedView (A single feed view, like "people playing" or "game chat")
# - Heyzap.FeedToggleView (A multiple feed view, like "activity")
# - Heyzap.SearchableFeedView (Maybe in future?)
#
# These classes will handle data binding, templating, rendering, fetching data
# from urls etc
#
# Examples of the proposed "dsl" follow:
#
#
# Activity stream, with toggles and filters, pulls data from cache and fixed url
# view will be magically rendered and updated when items change
#
class Activity extends Heyzap.FeedToggleView
# The container to inject html into
el: "#container"
# The base url to load json from
url: "/in_game_api/v1_mobile/get_stream_main"
# Any common additional params to send with requests
params: {}
# Which toggles to show, params will be merged into request
toggles:
"Friends": {stream_filter: "friends"}
"Everyone": {stream_filter: "everyone"}
# The name of the empty filter
emptyFilter: "Most Recent"
# Which filters to show, params will be merged into request
filters:
"Active Discussions": {stream_type: "tip"}
"Check-ins": {stream_type: "checkin"}
"Badges": {stream_type: "badge"}
"Bosses": {stream_type: "badge"}
# Template selector, given an object, how do we work out which template to use
templateSelector: (obj) ->
obj.stream_type
#
# Game chat/activity stream, data will be injected in from socket.io by using
# Heyzap.FeedView#addItem, view will be magically rendered and updated when
# items change
#
class GameChat extends Heyzap.FeedView
# The container to inject html into
el: "#container"
# Template selector, given an object, how do we work out which template to use
templateSelector: (obj) ->
obj.message_data
#
# Game details page, pulls data from cache and fixed url
# view will be magically rendered and updated when items change
# We don't need to explicitly specify which template to use, since we'll only
# have one in the markup
#
class GameDetails extends Heyzap.View
# The container to inject html into
el: "#container"
# The url to load json object from
url: "/in_game_api/v1_mobile/get_game?package=blah"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment