Skip to content

Instantly share code, notes, and snippets.

@d4tocchini
Created August 6, 2011 05:04
Show Gist options
  • Save d4tocchini/1129035 to your computer and use it in GitHub Desktop.
Save d4tocchini/1129035 to your computer and use it in GitHub Desktop.
RW.Pages API
$ = jQuery
# Wrap in Closure to avoid global variables.
$ ->
RW.Pages = new RW.p.PageCollection()
RW.Pages.add [
{
id: 'home'
pageLevel: 0
routes: ['']
routeHandler: () ->
LOG 'ROUTE //// home'
@show()
RW.URL.setTitle( RW.WallSettings.get('title') )
title: () ->
return RW.WallSettings.get('title')
editable: true
#backgroundTemplateId
}
{
id: 'search'
pageLevel: 1
routes: ['search/:term']
routeHandler: (term) ->
RW.URL.setTitle(term+' / Search / Rituwall' )
@show()
templateId: 'adminSearch_template'
}
{
id: 'filterTiles'
pageLevel: -1
routes: ['tiles/:property-:value']
routeHandler: (property, value) ->
LOG 'ROUTE //// filterTiles'
RW.URL.setTitle( RW.WallSettings.get('title') )
if property = 'categories'
value = {id: value}
RW.Tiles.filter(value, property)
}
{
id: 'adminTitle'
pageLevel: 1
routes: ['admin/title', 'admin/title/']
routeHandler: () ->
RW.URL.setTitle( 'Wall Settings / Rituwall' )
@show()
view: RW.WallTitleView_admin
templateId: 'admin_wall_title'
}
{
id: 'announceTile'
pageLevel: 2
routes: ['tiles/:id-type=:type/edit/announce', 'tiles/:id/edit/announce' , 'tiles/:id/edit/announce', 'tiles/:id/announce']
routeHandler: (id = 'new', name) ->
if id is 'new'
alert 'cant announce new tile yet...'
###
else
_tileType = RW.Tiles.current.get('type')
RW.Streams.current.set
'tileType': _tileType
'tileTitle': RW.Tiles.current.get('title') #'A Really Cool ' + RW.Tiles.current.get('type') + ' by ' + RW.Admin.get('username')
'tileContent': 'this is a summary of the Rituwall post that is not yet automated' #RW.Tiles.current.get('content')
###
@show()
RW.URL.setTitle('Announcing Tile / Rituwall')
RW.Tiles.setCurrent( id )
view: RW.p.AnnounceTile_view
templateId: 'announceTile_template'
}
{
id: 'streamTile'
pageLevel: 2
routes: ['tiles/:id-type=:type/edit/stream', 'tiles/:id/edit/stream', 'tiles/:id/stream']
routeHandler: (id = 'new', type) ->
if type
RW.Tiles.setCurrent( id, {type:type} )
else
RW.Tiles.setCurrent( id )
RW.URL.setTitle('Streaming New '+type+' / Rituwall')
@show()
templateId: 'streamTile_template'
view: RW.p.ModelSelectionView
viewOptions:
isDragAndDrop: false
data:
model: 'RW.Tiles.current'
collection: 'RW.Streams'
modelAttribute: 'streamTo'
}
{
id: 'stream'
pageLevel: 2
routes: ['streams/:id-:name', 'streams/:id']
routeHandler: (id = 'new', name) ->
RW.Streams.setCurrent( id )
RW.Streams.current.set
'tileType':RW.Tiles.current.get('type')
'tileTitle': RW.Tiles.current.get('title') #'A Really Cool ' + RW.Tiles.current.get('type') + ' by ' + RW.Admin.get('username')
'tileContent': 'this is a summary of the Rituwall post that is not yet automated' #RW.Tiles.current.get('content')
@show()
templateId: 'stream_edit_page'
view: RW.p.Stream_edit_view
}
{
id: 'categorizeTile'
pageLevel: 2
routes: ['tiles/:id-type=:type/edit/categorize', 'tiles/:id/edit/categorize', 'tiles/:id/categorize']
routeHandler: (id = 'new', type) ->
LOG 'ROUTE //// categorizeTile / id: ' + id
if (id is 'new') and type
RW.Tiles.setCurrent( 'new', {type:type} )
else
RW.Tiles.setCurrent( id )
RW.URL.setTitle('Categorizing '+type+' / Rituwall')
@show()
templateId: 'category_indexEdit_template'
view: RW.p.ModelSelectionView
viewOptions:
isDragAndDrop: true
data:
model: 'RW.Tiles.current'
collection: 'RW.Categories'
modelAttribute: 'categories'
}
{
id: 'categories'
pageLevel: 2
routes: ['admin/categories', 'tiles/categories']
routeHandler: (id = 'new', type) ->
LOG 'ROUTE //// categories / id: ' + id
if (id is 'new') and type
RW.Tiles.setCurrent( 'new', {type:type} )
else
RW.Tiles.setCurrent( id )
RW.URL.setTitle('Categories / Rituwall')
@show()
templateId: 'category_indexEdit_template'
view: RW.p.ModelSelectionView
viewOptions:
isDragAndDrop: true
data:
model: 'RW.Tiles.current'
collection: 'RW.Categories'
modelAttribute: 'categories'
}
{
id: 'category'
pageLevel: 2
routes: ['categories/:id-:name', 'categories/:id']
routeHandler: (id = 'new', name = 'new') ->
LOG 'ROUTE //// editCategory / id: ' + id
RW.Categories.setCurrent( id )
RW.URL.setTitle( 'Categories / Rituwall' )
@show()
templateId: 'category_edit_template'
view: RW.Category_edit_view
}
{
id: 'addTile'
pageLevel: 1
routes: ['admin/add', 'admin/add/', 'tiles/add', 'admin/tiles/add']
routeHandler: () ->
LOG 'ROUTE //// addTile / id: '
RW.URL.setTitle( 'Add New Tile / Rituwall' )
@show()
editable: false
templateId: 'admin_add_template'
}
{
id: 'wallConfig'
pageLevel: 1
routes: ['admin/wall', 'admin/wall/', 'edit']
routeHandler: () ->
LOG 'ROUTE //// wallConfig / id: '
RW.URL.setTitle( 'Wall Settings / Rituwall' )
@show()
templateId: 'wallConfig_template'
}
{
id: 'appearance'
pageLevel: 1
routes: ['admin/appearance', 'admin/appearance/']
routeHandler: () ->
LOG 'ROUTE //// wallConfig / id: '
RW.URL.setTitle( 'Wall Settings / Rituwall' )
@show()
templateId: 'admin_appearance'
backgroundTemplateId: 'page_bg_clear'
}
{
id: 'userConfig'
pageLevel: 1
routes: ['admin/me', 'admin/me/']
routeHandler: () ->
LOG 'ROUTE //// userConfig / id: '
RW.URL.setTitle( 'User Settings / Rituwall' )
@show()
editable: false
templateId: 'userConfig_template'
}
{
id: 'tileAdmin'
pageLevel: 1
editable: false
previewable: true
view: RW.Tile_edit_view
templateId: 'admin_tile_article_template'
routes: ['tiles/:id-type=:type/edit', 'tiles/:id/edit']
routeHandler: (id = 'new', type) ->
if (id is 'new') and type
RW.Tiles.setCurrent( 'new', {type:type} )
else
RW.Tiles.setCurrent( id )
tileType = RW.Tiles.current.get('type')
@set
templateId: 'admin_tile_'+tileType+'_template'
RW.URL.setTitle('Editing '+tileType+' / Rituwall')
@show()
}
{
id: 'tile'
pageLevel: 1
editable: true
view: RW.TilePageView
templateId: 'tile_article_template'
routes: ['tiles/:id-type=:type', 'tiles/:id']
routeHandler: (id, type = 'article') ->
if (id is 'new')
RW.Tiles.setCurrent( 'new', {type:type} )
@set
templateId: 'admin_tile_' + RW.Tiles.current.get('type') + '_template'
RW.URL.setTitle('New '+type+' / Rituwall')
RW.Pages.get('tileAdmin').show()
else if id
RW.Tiles.setCurrent( id )
@set
templateId: 'tile_' + RW.Tiles.current.get?('type') + '_template'
RW.URL.setTitle( RW.Tiles.current.get?('title') + ' / Rituwall' )
@show()
}
]
return this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment