class Pettanr.FoldersController extends Pettanr.AppController\r
\r
- index: () ->\r
+ index: (params) ->\r
list_result = new Pettanr.Folder.Collection({})\r
new Pettanr.FilerRender('folder', list_result, 'default', window.operators)\r
\r
- root: () ->\r
+ root: (params) ->\r
\r
show_html_format: (format) -> \r
\r
- show: (id) ->\r
- console.log(id)\r
+ show: (params) ->\r
+ console.log(params)\r
+ id = params['id']\r
item = new Pettanr.FolderWatch({id: id})\r
_this = this\r
item.fetch({}).done () ->\r
if item.is_remote()\r
- window.router[item.event_name()]() # call action event in router for redirect\r
+ c = item.get('controller_name')\r
+ a = if Pettanr.is_blank(item.get('action_name'))\r
+ 'index'\r
+ else\r
+ item.get('action_name')\r
+ window.router['c_i'](c, a, '') # call action event in router for redirect\r
else\r
list_result = new Pettanr.Folder.Children({id: item.id})\r
new Pettanr.FilerRender('folder', list_result, 'default', window.operators)\r
\r
- count: () ->\r
+ count: (params) ->\r
\r
- folders_new: () ->\r
+ new: (params) ->\r
\r
- edit: () ->\r
+ edit: (params) ->\r
\r
class Pettanr.ScrollsController extends Pettanr.AppController\r
\r
- index: () ->\r
+ index: (params) ->\r
+ list_result = new Pettanr.Scroll.Collection({})\r
+ new Pettanr.FilerRender('scroll', list_result, 'default', window.operators)\r
+ \r
+ by_author: (params) ->\r
+ list_result = new Pettanr.Scroll.Collection({})\r
+ new Pettanr.FilerRender('scroll', list_result, 'default', window.operators)\r
+ \r
+ by_panel: (params) ->\r
list_result = new Pettanr.Scroll.Collection({})\r
new Pettanr.FilerRender('scroll', list_result, 'default', window.operators)\r
\r
show_html_format: (format) -> \r
\r
- show: (id) ->\r
- console.log(id)\r
+ show: (params) ->\r
+ console.log(params)\r
+ id = params['id']\r
item = new Pettanr.Scroll({id: id})\r
_this = this\r
item.fetch({}).done () ->\r
alert(item)\r
\r
- count: () ->\r
+ count: (params) ->\r
\r
- new: () ->\r
+ new: (params) ->\r
\r
- edit: () ->\r
+ edit: (params) ->\r
\r
new Pettanr.FilerRender('folder', list_result, 'default', window.operators)\r
window.router = new Pettanr.Router()\r
Backbone.history.start({pushState: true})\r
- window.router.navigate('scrolls/', true)\r
- window.router.navigate('scrolls/?a=b&c=d', true)\r
- window.router.navigate('scrolls', true)\r
- window.router.navigate('scrolls.json?a=b&c=d', true)\r
- window.router.navigate('scrolls/by_author/1', true)\r
- window.router.navigate('scrolls/by_author/2?a=b&c=d', true)\r
- window.router.navigate('scrolls/by_author/3.json', true)\r
- window.router.navigate('scrolls/by_author/4.json?a=b&c=d', true)\r
+ \r
+ test_router: () ->\r
+ window.router.navigate('folders/98', true)\r
+ window.router.navigate('folders/99?a=b&c=d', true)\r
+ window.router.navigate('folders/100.prof', true)\r
+ window.router.navigate('folders/101.json?a=b&c=d', true)\r
+ window.router.navigate('folders/102/show', true)\r
+ window.router.navigate('folders/103/show?a=b&c=d', true)\r
+ window.router.navigate('folders/104/show.json', true)\r
+ window.router.navigate('folders/105/show.json?a=b&c=d', true)\r
+ window.router.navigate('scrolls/', true)\r
+ window.router.navigate('scrolls/?a=b&c=d', true)\r
+ window.router.navigate('scrolls', true)\r
+ window.router.navigate('scrolls.json', true)\r
+ window.router.navigate('scrolls.json?a=b&c=d', true)\r
+ window.router.navigate('scrolls/by_author/1', true)\r
+ window.router.navigate('scrolls/by_author/2?a=b&c=d', true)\r
+ window.router.navigate('scrolls/by_author/3.json', true)\r
+ window.router.navigate('scrolls/by_author/4.json?a=b&c=d', true)\r
class Pettanr.Folder extends Peta.Owner\r
- url: ''\r
+ url: '/folders/'\r
\r
@singular: () ->\r
'Folder'\r
@url = @url + @id\r
\r
class Pettanr.FolderWatch extends Pettanr.Folder\r
- url: ''\r
initialize: () ->\r
super()\r
@url = @url + '?ref=1'\r
else\r
false\r
\r
+ @is_number: (str) ->\r
+ if typeof(str) != 'number' && typeof(str) != 'string'\r
+ return false\r
+ else\r
+ n = if typeof(str) == 'string'\r
+ parseInt(str)\r
+ else\r
+ str\r
+ isFinite(n)\r
+ \r
@to_s: (str) ->\r
if @is_a_string(str)\r
str\r
_.extend(params, o)\r
params\r
\r
+ fire: (params) ->\r
+ c = Pettanr[Pettanr.camelize(params['controller']) + 'Controller']\r
+ controller = new c\r
+ controller[params['action']](params)\r
+ \r
initialize: () ->\r
+ this['c_i_a'] = (controller, id, action, query_string) ->\r
+ params = this.parse_query_string(query_string)\r
+ params['controller'] = controller\r
+ params['format'] = 'html'\r
+ t = id.split('.')\r
+ if t.length > 1\r
+ params['format'] = t[1]\r
+ id = t[0]\r
+ t = action.split('.')\r
+ if t.length > 1\r
+ params['format'] = t[1]\r
+ action = t[0]\r
+ if Pettanr.is_number(action)\r
+ params['action'] = id\r
+ params['id'] = action\r
+ else\r
+ params['action'] = action\r
+ params['id'] = id\r
+ this.fire(params)\r
+ this['c_i'] = (controller, id, query_string) ->\r
+ params = this.parse_query_string(query_string)\r
+ params['controller'] = controller\r
+ params['format'] = 'html'\r
+ t = id.split('.')\r
+ if t.length > 1\r
+ params['format'] = t[1]\r
+ id = t[0]\r
+ if Pettanr.is_number(id)\r
+ params['action'] = 'show'\r
+ params['id'] = id\r
+ else\r
+ params['action'] = 'index'\r
+ this.fire(params)\r
+ this.route(':controller/:id/:action?*query_string', 'c_i_a')\r
+ this.route(':controller/:id/:action', 'c_i_a')\r
+ this.route(':controller/:id?*query_string', 'c_i')\r
+ this.route(':controller/:id', 'c_i')\r
+ \r
+ hoge: () ->\r
names = _.map Manifest.manifest().controllers, (controller_manifest, controller_name) ->\r
c = Pettanr[Pettanr.camelize(controller_name) + 'Controller']\r
controller = new c\r
show_json_format format
end
else
- if @item.category_id == 10
- redirect_to @item.remote_name
- else
+ if params[:format] == 'prof'
respond_to do |format|
- children_html_format format
show_prof_format format
- children_json_format format
+ end
+ else
+ if @item.category_id == 10
+ redirect_to @item.remote_name
+ else
+ respond_to do |format|
+ children_html_format format
+ children_json_format format
+ end
end
end
end