a.join('; ')\r
\r
@url: (controller_name, action_name, params) ->\r
- controller = Manifest.manifest().controllers[controller_name]\r
- action = controller.actions[action_name]\r
- action.url(params)\r
+ if controller = Manifest.manifest().controllers[controller_name]\r
+ # convert from manifest\r
+ action = controller.actions[action_name]\r
+ action.url(params)\r
+ else\r
+ # has no manifest\r
+ controller_name + '/' + action_name\r
+ \r
+ @params_to_url: (params) ->\r
+ return '' if params['controller'] == 'folders' and params['action'] == 'root'\r
+ @url(params['controller'], params['action'], params)\r
+ \r
+ @is_sns: () ->\r
+ Manifest.manifest().magic_numbers.run_mode != 0\r
\r
class Pettanr.AppHelper\r
@manifest: () ->\r
I18n.t(Manifest.manifest().system_resources.select_items[name][index][0])\r
\r
@distance_of_time_in_words_to_now: (datetime) ->\r
- datetime\r
+ if Pettanr.is_blank(datetime)\r
+ ''\r
+ else\r
+ $.timeago(datetime)\r
+ \r
\r
- @cache = {}\r
+ @cache = null # set by main\r
@credits = {}\r
\r
- class Pettanr.FilerCollection extends Backbone.Collection\r
- \r
- initialize: (models, options) ->\r
- @model = options['model']\r
- @action = options['action']\r
- @params = options['params']\r
- \r
- @url = '/' + @action.url(@params)\r
- \r
- class Pettanr.AppController\r
- constructor: () ->\r
- @params = {}\r
- @operators = window.operators\r
- \r
- set_model: () ->\r
- @my_controller = Manifest.manifest().controllers[@params['controller']]\r
- @my_action = @my_controller.actions[@params['action']]\r
- @my_model = Manifest.manifest().models[@my_action.item_name]\r
- @my_model_class = @my_model.classify()\r
- \r
- set_list: () ->\r
- @set_model()\r
- @my_list_model = Manifest.manifest().models[@my_action.item_name]\r
- @my_list_model_class = @my_list_model.classify()\r
- @list = Locmare.ListGroup.list(@my_action.item_name, @my_action.name)\r
- \r
- set_show: () ->\r
- @set_model()\r
- @item = new @my_model_class({id: @params['id']})\r
- \r
- filer_list: () ->\r
- @set_list()\r
- _this = this\r
- @list.open(@operators, @params, @my_action, {}, (page_status) ->\r
- pager = new Locmare.FilerModule.DefaultPager({page_status: page_status})\r
- f = new Locmare.Filer({\r
- el: "#pettanr",\r
- item_name: _this.my_list_model_class.item_name(), \r
- items: _this.list.models, \r
- pager: pager, \r
- operators: _this.operators\r
- })\r
- )\r
- false\r
- \r
- set_play: () ->\r
- @set_list()\r
- @binder_controller = Manifest.manifest().controllers[@params['controller']]\r
- @binder_model = Manifest.manifest().models[@binder_controller.item_name]\r
- @binder_model_class = @binder_model.classify()\r
- @item = new @binder_model_class({id: @params['id']})\r
- \r
- play_list: () ->\r
- _this = this\r
- opt = {\r
- id: @params['id'], \r
- offset: @params['offset'], \r
- count: @params['count'], \r
- page: @params['page'], \r
- page_size: @params['page_size']\r
- }\r
- @item.fetch({cache: true}).done ->\r
- _this.list.open(_this.operators, opt, _this.my_action, {}, (page_status) ->\r
- console.log _this.list.models\r
- )\r
- false\r
- \r
- show_prof: () ->\r
- _this = this\r
- @item.fetch({cache: true}).done ->\r
- _this.item.boosts 'post'\r
- profiler = new Locmare.Profiler({\r
- item_name: _this.item.item_name(), \r
- item: _this.item, \r
- operators: _this.operators\r
- })\r
- $("#pettanr").html(profiler.render().el)\r
- _this.redraw_title(_this.params)\r
- \r
- set_new: () ->\r
- @set_model()\r
- @item = new @my_model_class({id: @params['id']})\r
- @item.boosts 'post'\r
- # Backbone.Model has defaults property\r
- #@item.supply_default()\r
- \r
- set_edit: () ->\r
- @set_model()\r
- @item = new @my_model_class({id: @params['id']})\r
- _this = this\r
- @item.fetch({cache: true}).done ->\r
- _this.item.boosts 'post'\r
- _this.render_form()\r
- \r
- render_form: () ->\r
- @form = new Locmare.Form({\r
- form_name: @item.item_name(), \r
- item: @item, \r
- mounted: true, \r
- submit: 'default', \r
- operators: @operators,\r
- action: '/' + @item.table_name() + '/' + Pettanr.to_s(@item.get('id'))\r
- })\r
- $("#pettanr").html(@form.render().el)\r
- \r
- form_new: () ->\r
- @set_new()\r
- @render_form()\r
- \r
- form_edit: () ->\r
- @set_edit()\r
- \r
- redraw_title: (params, str = null) ->\r
- t = str || I18n.t(params['controller'] + '.' + params['action'] + '.title')\r
- site_caption = Manifest.manifest().magic_numbers.profile.users.caption\r
- $(document).attr('title', t + ' - ' + site_caption)\r
- \r
- class Pettanr.FilerRender\r
- constructor: (item_name, list_result, pager_type, operators) ->\r
- @item_name = item_name\r
- @list_result = list_result\r
- @pager_type = pager_type\r
- @operators = operators\r
- _this = this\r
- @list_result.fetch({cache: true}).done () ->\r
- _this.render()\r
- \r
- render: () ->\r
- items = @list_result.models\r
- f = new Locmare.Filer({\r
- item_name: @item_name, \r
- items: items, \r
- list_result: @list_result, \r
- pager_type: @pager_type, \r
- operators: @operators\r
- })\r
- $("#pettanr").html(f.render().el)\r
-\r
#>> https://gist.github.com/davidjbeveridge/3813724\r
@xeach: (arr, func, index=0) ->\r
if index < arr.length then [ func(arr[index], index), @xeach(arr, func, index + 1)... ] else []\r