tbone 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/VERSION +1 -1
  2. data/app/assets/javascripts/bootstrap.js.coffee +2 -2
  3. data/app/assets/javascripts/collections/paginated.js.coffee +4 -1
  4. data/app/assets/javascripts/views/common/confirm_view.js.coffee +2 -1
  5. data/app/assets/javascripts/views/common/form_view.js.coffee +1 -1
  6. data/app/controllers/home_controller.rb +7 -0
  7. data/app/controllers/tokens_controller.rb +4 -0
  8. data/app/helpers/tbone_helper.rb +1 -1
  9. data/lib/generators/tbone/backbone_model/backbone_model_generator.rb +24 -0
  10. data/lib/generators/tbone/backbone_model/templates/collection.coffee.erb +11 -0
  11. data/lib/generators/tbone/backbone_model/templates/model.coffee.erb +4 -0
  12. data/lib/generators/tbone/rabl_views/rabl_views_generator.rb +24 -0
  13. data/lib/generators/tbone/rabl_views/templates/index.rabl.erb +11 -0
  14. data/lib/generators/tbone/rabl_views/templates/show.rabl.erb +2 -0
  15. data/lib/generators/tbone/scaffold/scaffold_generator.rb +35 -0
  16. data/lib/generators/tbone/scaffold_backbone_router/scaffold_backbone_router_generator.rb +37 -0
  17. data/lib/generators/tbone/scaffold_backbone_router/templates/confirm.hamljs.erb +10 -0
  18. data/lib/generators/tbone/scaffold_backbone_router/templates/edit_view.coffee.erb +16 -0
  19. data/lib/generators/tbone/scaffold_backbone_router/templates/form.hamljs.erb +12 -0
  20. data/lib/generators/tbone/scaffold_backbone_router/templates/index.hamljs.erb +14 -0
  21. data/lib/generators/tbone/scaffold_backbone_router/templates/index_view.coffee.erb +41 -0
  22. data/lib/generators/tbone/scaffold_backbone_router/templates/new_view.coffee.erb +15 -0
  23. data/lib/generators/tbone/scaffold_backbone_router/templates/object.hamljs.erb +10 -0
  24. data/lib/generators/tbone/scaffold_backbone_router/templates/object_view.coffee.erb +30 -0
  25. data/lib/generators/tbone/scaffold_backbone_router/templates/router.coffee.erb +52 -0
  26. data/lib/generators/tbone/scaffold_backbone_router/templates/show.hamljs.erb +15 -0
  27. data/lib/generators/tbone/scaffold_backbone_router/templates/show_view.coffee.erb +41 -0
  28. data/lib/generators/tbone/scaffold_controller/scaffold_controller_generator.rb +21 -0
  29. data/lib/generators/tbone/scaffold_controller/templates/controller.rb.erb +49 -0
  30. data/lib/tbone/engine.rb +3 -0
  31. data/lib/tbone.rb +13 -0
  32. data/tbone.gemspec +23 -2
  33. metadata +30 -9
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,10 +5,10 @@ define [], ->
5
5
  Routers: {}
6
6
  Helpers: {}
7
7
  Views: {
8
- Posts: {}
9
8
  Common: {}
10
9
  Sessions: {}
11
10
  Tokens: {}
12
11
  Passwords: {}
13
12
  Confirmations: {}
14
- }
13
+ },
14
+ Params: __params
@@ -1,7 +1,10 @@
1
1
  define ['backbone'], (Backbone) ->
2
2
  class PaginatedCollection extends Backbone.Collection
3
3
  constructor: (args) ->
4
- super(this.parse(args))
4
+ if args?
5
+ super(this.parse(args))
6
+ else
7
+ super
5
8
 
6
9
  initialize: ->
7
10
  # _.bindAll this, "parse", "url", "pageInfo", "nextPage", "previousPage"
@@ -14,7 +14,8 @@ define [
14
14
  "click .no": "reject"
15
15
 
16
16
  render: ->
17
- @modal = $(@template())
17
+ template = if @options.template? then @options.template else @template
18
+ @modal = $(template())
18
19
  $(@el).html(@modal)
19
20
  @modal.modal({ backdrop: true }).modal('show')
20
21
  return this
@@ -6,7 +6,7 @@ define [
6
6
  ], ($, Backbone, App, AlertView) ->
7
7
 
8
8
  class App.Views.Common.FormView extends AlertView
9
- events:
9
+ events: ->
10
10
  "submit": "save"
11
11
 
12
12
  initialize: ->
@@ -1,4 +1,11 @@
1
1
  class HomeController < ApplicationController
2
2
  def index
3
+ path = File.expand_path('config/tbone_params.rb', Rails.root)
4
+ if File.exists? path
5
+ params = eval(File.open(path).read)
6
+ Tbone.configure do |c|
7
+ c.add_params params
8
+ end
9
+ end
3
10
  end
4
11
  end
@@ -1,4 +1,8 @@
1
1
  class TokensController < ApplicationController
2
+ before_filter :set_token
3
+ def set_token
4
+ @token = form_authenticity_token
5
+ end
2
6
  def show
3
7
  @token
4
8
  end
@@ -1,5 +1,5 @@
1
1
  module TboneHelper
2
2
  def tbone_include_tag(name)
3
- javascript_tag("var vars = #{ render(file: "#{name}.json.rabl") }")
3
+ javascript_tag("var __params = #{ Tbone.config.params.to_json }")
4
4
  end
5
5
  end
@@ -0,0 +1,24 @@
1
+ require 'rails/generators'
2
+
3
+ module Tbone
4
+ module Generators
5
+ class BackboneModelGenerator < ::Rails::Generators::NamedBase
6
+ source_root File.expand_path("../templates", __FILE__)
7
+ desc "This generator generates simple T-bone generator"
8
+ def create_controller
9
+ template "model.coffee.erb", "app/assets/javascripts/models/#{single_name}.js.coffee"
10
+ template "collection.coffee.erb", "app/assets/javascripts/collections/#{plural_name}.js.coffee"
11
+ end
12
+ private
13
+ def class_name
14
+ name
15
+ end
16
+ def plural_name
17
+ name.underscore.pluralize
18
+ end
19
+ def single_name
20
+ name.underscore
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ define [
2
+ 'underscore'
3
+ 'backbone'
4
+ 'bootstrap'
5
+ 'models/<%= single_name %>'
6
+ 'collections/paginated'
7
+ ],
8
+ (_, Backbone, App, <%= class_name %>, PaginatedCollection) ->
9
+ class App.Collections.<%= class_name.pluralize %> extends PaginatedCollection
10
+ model: <%= class_name %>
11
+ baseUrl: '/<%= plural_name %>'
@@ -0,0 +1,4 @@
1
+ define ['underscore', 'backbone', 'bootstrap'], (_, Backbone, App) ->
2
+ class App.Models.<%= class_name %> extends Backbone.Model
3
+ paramRoot: '<%= single_name %>'
4
+ urlRoot: '/<%= plural_name %>'
@@ -0,0 +1,24 @@
1
+ require 'rails/generators'
2
+
3
+ module Tbone
4
+ module Generators
5
+ class RablViewsGenerator < ::Rails::Generators::NamedBase
6
+ source_root File.expand_path("../templates", __FILE__)
7
+ desc "This generator generates simple rabl views"
8
+ def create_views
9
+ template "index.rabl.erb", "app/views/#{plural_name}/index.json.rabl"
10
+ template "show.rabl.erb", "app/views/#{plural_name}/show.json.rabl"
11
+ end
12
+ private
13
+ def class_name
14
+ name
15
+ end
16
+ def plural_name
17
+ name.underscore.pluralize
18
+ end
19
+ def single_name
20
+ name.underscore
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ object false
2
+ @<%= plural_name %> ||= locals[:object][:page]
3
+ node(:current_page) { @<%= plural_name %>.current_page }
4
+ node(:total_items) { @<%= plural_name %>.total_count }
5
+ node(:per_page) { @<%= plural_name %>.limit_value }
6
+ node(:total_pages) { (@<%= plural_name %>.offset_value / @<%= plural_name %>.limit_value) + 1 }
7
+ node :items do
8
+ @<%= plural_name %>.map do |p|
9
+ partial '<%= plural_name %>/show', object: p, root: false
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ object @<%= single_name %>
2
+ attributes :id
@@ -0,0 +1,35 @@
1
+ require 'rails/generators'
2
+
3
+ module Tbone
4
+ module Generators
5
+ class ScaffoldGenerator < ::Rails::Generators::NamedBase
6
+ source_root File.expand_path("../templates", __FILE__)
7
+ desc "This generator generates simple T-bone router"
8
+ def create_model
9
+ generate "model #{class_name}"
10
+ end
11
+ def create_controller
12
+ generate "tbone:scaffold_controller #{class_name}"
13
+ end
14
+ def create_rabl_views
15
+ generate "tbone:rabl_views #{class_name}"
16
+ end
17
+ def create_backbone_model
18
+ generate "tbone:backbone_model #{class_name}"
19
+ end
20
+ def create_router
21
+ generate "tbone:scaffold_backbone_router #{class_name}"
22
+ end
23
+ private
24
+ def class_name
25
+ name
26
+ end
27
+ def plural_name
28
+ name.underscore.pluralize
29
+ end
30
+ def single_name
31
+ name.underscore
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,37 @@
1
+ require 'rails/generators'
2
+
3
+ module Tbone
4
+ module Generators
5
+ class ScaffoldBackboneRouterGenerator < ::Rails::Generators::NamedBase
6
+ source_root File.expand_path("../templates", __FILE__)
7
+ desc "This generator generates simple T-bone router"
8
+ def create_router
9
+ template "router.coffee.erb", "app/assets/javascripts/routers/#{plural_name}_router.js.coffee"
10
+ end
11
+ def create_views
12
+ template "new_view.coffee.erb", "app/assets/javascripts/views/#{plural_name}/new_view.js.coffee"
13
+ template "edit_view.coffee.erb", "app/assets/javascripts/views/#{plural_name}/edit_view.js.coffee"
14
+ template "show_view.coffee.erb", "app/assets/javascripts/views/#{plural_name}/show_view.js.coffee"
15
+ template "index_view.coffee.erb", "app/assets/javascripts/views/#{plural_name}/index_view.js.coffee"
16
+ template "object_view.coffee.erb", "app/assets/javascripts/views/#{plural_name}/#{single_name}_view.js.coffee"
17
+ end
18
+ def create_templates
19
+ template "form.hamljs.erb", "app/assets/javascripts/templates/#{plural_name}/form.jst.hamljs"
20
+ template "index.hamljs.erb", "app/assets/javascripts/templates/#{plural_name}/index.jst.hamljs"
21
+ template "show.hamljs.erb", "app/assets/javascripts/templates/#{plural_name}/show.jst.hamljs"
22
+ template "object.hamljs.erb", "app/assets/javascripts/templates/#{plural_name}/#{single_name}.jst.hamljs"
23
+ template "confirm.hamljs.erb", "app/assets/javascripts/templates/#{plural_name}/confirm.jst.hamljs"
24
+ end
25
+ private
26
+ def class_name
27
+ name
28
+ end
29
+ def plural_name
30
+ name.underscore.pluralize
31
+ end
32
+ def single_name
33
+ name.underscore
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,10 @@
1
+ #modal-from-dom.modal.hide.fade
2
+ .modal-header
3
+ %a.close{href: "#"} ×
4
+ %h3 Delete
5
+ .modal-body
6
+ %p You are about to delete this <%= single_name %>, this procedure is irreversible.
7
+ %p Do you want to proceed?
8
+ .modal-footer
9
+ %a.btn.danger.yes Yes
10
+ %a.btn.secondary.no No
@@ -0,0 +1,16 @@
1
+ define [
2
+ 'jquery'
3
+ 'backbone'
4
+ 'bootstrap'
5
+ 'views/common/form_view'
6
+ 'templates/<%= plural_name %>/form'
7
+ 'i18n'
8
+ ], ($, Backbone, App, FormView) ->
9
+
10
+ class App.Views.<%= class_name.pluralize %>.EditView extends FormView
11
+ template: JST["templates/<%= plural_name %>/form"]
12
+
13
+ success: (<%= single_name %>) ->
14
+ @model = <%= single_name %>
15
+ @addSuccessAlert(I18n.t '<%= plural_name %>.updated')
16
+ window.location.hash = "/<%= plural_name %>/#{@model.id}"
@@ -0,0 +1,12 @@
1
+ %form
2
+ %fieldset
3
+ %legend= this.model.isNew() ? I18n.t('<%= plural_name %>.new') : I18n.t('<%= plural_name %>.new')
4
+
5
+ # .control-group
6
+ # %label.control-label{for: "field"} Field:
7
+ # .controls
8
+ # %input.span6{name: "field", type: "text", value: field || '' }
9
+
10
+ .form-actions
11
+ %input.btn.btn-primary{type: "submit"}
12
+ %a.btn{href: "#/<%= plural_name %>/index"}= I18n.t('back')
@@ -0,0 +1,14 @@
1
+ %h1 Список докторов
2
+
3
+ %table#<%= plural_name %>-table.table.table-striped
4
+ %thead
5
+ %tr
6
+ %th Id
7
+ %th
8
+ %tbody
9
+
10
+
11
+ %br
12
+ %a.btn.btn-primary{href: "#/<%= plural_name %>/new"}= I18n.t('<%= plural_name %>.new')
13
+ %br
14
+ %br
@@ -0,0 +1,41 @@
1
+ define [
2
+ 'jquery'
3
+ 'backbone'
4
+ 'bootstrap'
5
+ 'views/<%= plural_name %>/<% single_name %>_view'
6
+ 'views/common/pager_view'
7
+ 'views/common/alert_view'
8
+ 'templates/<%= plural_name %>/index'
9
+ ], ($, Backbone, App, <% class_name %>View, PagerView, AlertView) ->
10
+
11
+ class App.Views.<% class_name.pluralize %>.IndexView extends AlertView
12
+ template: JST["templates/<%= plural_name %>/index"]
13
+
14
+ initialize: ->
15
+ @collection.on('reset', @render, this)
16
+
17
+ addAll: ->
18
+ @collection.each(@addOne, this)
19
+
20
+ addPager: ->
21
+ view = new PagerView({collection: @collection, urlPrefix: '#<%= plural_name %>/index?page='})
22
+ $(@el).find("table").after(view.render().el)
23
+
24
+
25
+ addOne: (<% single_name %>) ->
26
+ view = new <% class_name %>View({model: <% single_name %>})
27
+ $(@el).find("tbody").append(view.render().el)
28
+
29
+ render: ->
30
+ $(@el).html(@template())
31
+ @addAll()
32
+ @addPager()
33
+ @renderAlerts()
34
+
35
+ return this
36
+
37
+ close: ->
38
+ super
39
+ @collection.off('reset', @render, this)
40
+ @remove()
41
+ @off()
@@ -0,0 +1,15 @@
1
+ define [
2
+ 'jquery'
3
+ 'backbone'
4
+ 'bootstrap'
5
+ 'views/common/form_view'
6
+ 'templates/<%= plural_name %>/form'
7
+ 'i18n'
8
+ ], ($, Backbone, App, FormView) ->
9
+
10
+ class App.Views.<% class_name.pluralize %>.NewView extends FormView
11
+ template: JST["templates/<%= plural_name %>/form"]
12
+ success: (<% single_name %>) ->
13
+ @model = <% single_name %>
14
+ @addSuccessAlert(I18n.t '<%= plural_name %>.created')
15
+ window.location.hash = "/<%= plural_name %>/#{@model.id}"
@@ -0,0 +1,10 @@
1
+ %td!= id
2
+
3
+ - var show_link = "#/<%= plural_name %>/" + id
4
+ - var edit_link = "#/<%= plural_name %>/" + id + "/edit"
5
+ - var destroy_link = "#/<%= plural_name %>/" + id + "/destroy"
6
+
7
+ %td
8
+ %a.btn.btn-min1{href: show_link}= I18n.t('show')
9
+ %a.btn.btn-min1{href: edit_link}= I18n.t('edit')
10
+ %a.destroy.btn.btn-min1.btn-danger.confirm{href: destroy_link}= I18n.t('destroy')
@@ -0,0 +1,30 @@
1
+ define [
2
+ 'jquery'
3
+ 'backbone'
4
+ 'bootstrap'
5
+ 'views/common/confirm_view'
6
+ 'templates/<%= plural_name %>/<% single_name %>'
7
+ 'templates/<%= plural_name %>/confirm'
8
+ ], ($, Backbone, App, ConfirmView) ->
9
+ class App.Views.<% class_name.pluralize %>.<% class_name %>View extends Backbone.View
10
+ template: JST["templates/<%= plural_name %>/<% single_name %>"]
11
+
12
+ events:
13
+ "click .destroy" : "destroy"
14
+
15
+ tagName: "tr"
16
+
17
+ destroy: ->
18
+ view = new ConfirmView(template: JST['templates/<%= plural_name %>/confirm'])
19
+ view.on('accept', ->
20
+ @model.destroy()
21
+ this.remove()
22
+ @addSuccessAlert(I18n.t '<%= plural_name %>.destroyed')
23
+ , this)
24
+ $(@el).append(view.render().el)
25
+
26
+ return false
27
+
28
+ render: ->
29
+ $(@el).html(@template(@model.toJSON()))
30
+ return this
@@ -0,0 +1,52 @@
1
+ define [
2
+ 'backbone'
3
+ 'bootstrap'
4
+ 'helpers/layout'
5
+ 'views/<%= plural_name %>/index_view'
6
+ 'views/<%= plural_name %>/new_view'
7
+ 'views/<%= plural_name %>/show_view'
8
+ 'views/<%= plural_name %>/edit_view'
9
+ ], (Backbone, App, Layout) ->
10
+ class App.Routers.<%= class_name.pluralize %>Router extends Backbone.Router
11
+ routes:
12
+ "<%= plural_name %>/new" : "new<%= class_name %>"
13
+ "<%= plural_name %>/index" : "index"
14
+ "<%= plural_name %>/index?page=:page" : "index"
15
+ "<%= plural_name %>/:id/edit" : "edit"
16
+ "<%= plural_name %>/:id" : "show"
17
+ "<%= plural_name %>.*" : "index"
18
+
19
+ initialize: (options) ->
20
+ @<% plural_name %> = options.collection
21
+
22
+ new<% class_name %>: ->
23
+ view = require 'views/<% plural_name %>/new_view'
24
+ @view = new view(collection: @<% plural_name %>, model: new @<% plural_name %>.model())
25
+ Layout.setContent(@view)
26
+
27
+ index: (page = 1) ->
28
+ @<% plural_name %>.setPage(page)
29
+ View = require 'views/<% plural_name %>/index_view'
30
+ @view = new View(collection: @<% plural_name %>)
31
+ Layout.setContent(@view)
32
+
33
+ show: (id) ->
34
+ View = require 'views/<% plural_name %>/show_view'
35
+ <% single_name %> = this.get<% class_name %> id, (<% single_name %>) ->
36
+ @view = new View(model: <% single_name %>)
37
+ Layout.setContent(@view)
38
+
39
+ edit: (id) ->
40
+ View = require 'views/<% plural_name %>/edit_view'
41
+ this.get<% class_name %> id, (<% single_name %>) ->
42
+ @view = new View(model: <% single_name %>)
43
+ Layout.setContent(@view)
44
+
45
+ get<% class_name %>: (id, handler) ->
46
+ <% single_name %> = @<% plural_name %>.get(id)
47
+ if <% single_name %>?
48
+ handler(<% single_name %>)
49
+ else
50
+ <% single_name %> = new @<% plural_name %>.model()
51
+ <% single_name %>.id = id
52
+ <% single_name %>.fetch(success: handler)
@@ -0,0 +1,15 @@
1
+ %p
2
+ %strong Id:
3
+ %br
4
+ = id
5
+
6
+ - var index_link = "#/<%= plural_name %>/index"
7
+ - var edit_link = "#/<%= plural_name %>/" + id + "/edit"
8
+ - var destroy_link = "#/<%= plural_name %>/" + id + "/destroy"
9
+
10
+ .form-actions
11
+ .btn-toolbar
12
+ .btn-group
13
+ %a.btn{href: index_link}= I18n.t('back')
14
+ %a.btn{href: edit_link}= I18n.t('edit')
15
+ %a.destroy.btn.btn-danger{href: destroy_link}= I18n.t('destroy')
@@ -0,0 +1,41 @@
1
+ define [
2
+ 'jquery'
3
+ 'backbone'
4
+ 'bootstrap'
5
+ 'views/common/confirm_view'
6
+ 'views/common/alert_view'
7
+ 'templates/<%= plural_name %>/show'
8
+ 'templates/<%= plural_name %>/confirm'
9
+ ], ($, Backbone, App, ConfirmView, AlertView) ->
10
+
11
+ class App.Views.<% class_name.pluralize %>.ShowView extends AlertView
12
+ template: JST["templates/<%= plural_name %>/show"]
13
+
14
+ events:
15
+ "click .destroy" : "destroy"
16
+
17
+ initialize: ->
18
+ @model.on('change', @render, this)
19
+
20
+ destroy: ->
21
+ view = new ConfirmView(template: JST['templates/<%= plural_name %>/confirm'])
22
+ view.on('accept', ->
23
+ @model.destroy()
24
+ this.remove()
25
+ @addSuccessAlert(I18n.t '<%= plural_name %>.destroyed')
26
+ window.location.hash = "/<%= plural_name %>/index"
27
+ , this)
28
+ $(@el).append(view.render().el)
29
+
30
+ return false
31
+
32
+ render: ->
33
+ $(@el).html(@template(@model.toJSON()))
34
+ @renderAlerts()
35
+ return this
36
+
37
+ close: ->
38
+ super
39
+ @model.off('change', @render, this)
40
+ @remove()
41
+ @off()
@@ -0,0 +1,21 @@
1
+ require 'rails/generators'
2
+
3
+ module Tbone
4
+ module Generators
5
+ class ScaffoldControllerGenerator < ::Rails::Generators::NamedBase
6
+
7
+ source_root File.expand_path("../templates", __FILE__)
8
+ desc "This generator generates simple T-bone generator"
9
+ def create_controller
10
+ template "controller.rb.erb", "app/controllers/#{plural_name}_controller.rb"
11
+ end
12
+ private
13
+ def class_name
14
+ name
15
+ end
16
+ def plural_name
17
+ name.underscore.pluralize
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,49 @@
1
+ class <%= class_name.pluralize %>Controller < ApplicationController
2
+ # GET /<%= plural_name %>.json
3
+ def index
4
+ @<%= plural_name %> = <%= class_name %>.page(params[:page])
5
+ end
6
+
7
+ # GET /<%= plural_name %>/1.json
8
+ def show
9
+ @<%= plural_name.singularize %> = <%= class_name %>.find(params[:id])
10
+ end
11
+
12
+ # GET /<%= plural_name %>/new.json
13
+ def new
14
+ @<%= plural_name.singularize %> = <%= class_name %>.new
15
+ end
16
+
17
+ # GET /<%= plural_name %>/1/edit
18
+ def edit
19
+ @<%= plural_name.singularize %> = <%= class_name %>.find(params[:id])
20
+ end
21
+
22
+ # POST /<%= plural_name %>.json
23
+ def create
24
+ @<%= plural_name.singularize %> = <%= class_name %>.new(params[:<%= plural_name.singularize %>])
25
+
26
+ if @<%= plural_name.singularize %>.save
27
+ render action: "show", status: :created, location: @<%= plural_name.singularize %>
28
+ else
29
+ render json: @<%= plural_name.singularize %>.errors, status: :unprocessable_entity
30
+ end
31
+ end
32
+
33
+ # PUT /<%= plural_name %>/1.json
34
+ def update
35
+ @<%= plural_name.singularize %> = <%= class_name %>.find(params[:id])
36
+ if @<%= plural_name.singularize %>.update_attributes(params[:<%= plural_name.singularize %>])
37
+ render action: "show"
38
+ else
39
+ render json: @<%= plural_name.singularize %>.errors, status: :unprocessable_entity
40
+ end
41
+ end
42
+
43
+ # DELETE /<%= plural_name %>/1.json
44
+ def destroy
45
+ @<%= plural_name.singularize %> = <%= class_name %>.find(params[:id])
46
+ @<%= plural_name.singularize %>.destroy
47
+ head :no_content
48
+ end
49
+ end
data/lib/tbone/engine.rb CHANGED
@@ -36,6 +36,9 @@ module Tbone
36
36
  conf['shim']['bootstrap-popover'] << 'bootstrap-tooltip'
37
37
  conf['shim']['bootstrap'] = jquery_plugs
38
38
  app.config.requirejs.user_config.deep_merge!(conf)
39
+ Rabl.configure do |config|
40
+ config.include_json_root = false
41
+ end
39
42
  end
40
43
  end
41
44
  end
data/lib/tbone.rb CHANGED
@@ -1,3 +1,16 @@
1
1
  module Tbone
2
2
  require 'tbone/engine' if defined?(Rails)
3
+ def self.configure(&block)
4
+ self.config.instance_eval(&block)
5
+ end
6
+ def self.config
7
+ @config ||= Config.new
8
+ end
9
+ class Config
10
+ attr_reader :params
11
+ def add_params(p)
12
+ @params ||= {}
13
+ @params.merge!(p)
14
+ end
15
+ end
3
16
  end
data/tbone.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tbone}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Pavel Tatarsky}]
12
- s.date = %q{2012-06-25}
12
+ s.date = %q{2012-07-08}
13
13
  s.description = %q{Library for mixing together requirejs backbone and twitter bootstrap}
14
14
  s.email = %q{fazzzenda@mail.ru}
15
15
  s.extra_rdoc_files = [
@@ -49,9 +49,30 @@ Gem::Specification.new do |s|
49
49
  "app/views/home/index.html.haml",
50
50
  "app/views/tokens/show.json.rabl",
51
51
  "config/routes.rb",
52
+ "lib/generators/tbone/backbone_model/backbone_model_generator.rb",
53
+ "lib/generators/tbone/backbone_model/templates/collection.coffee.erb",
54
+ "lib/generators/tbone/backbone_model/templates/model.coffee.erb",
52
55
  "lib/generators/tbone/install/install_generator.rb",
53
56
  "lib/generators/tbone/install/templates/application.json.rabl",
54
57
  "lib/generators/tbone/install/templates/requirejs.yml",
58
+ "lib/generators/tbone/rabl_views/rabl_views_generator.rb",
59
+ "lib/generators/tbone/rabl_views/templates/index.rabl.erb",
60
+ "lib/generators/tbone/rabl_views/templates/show.rabl.erb",
61
+ "lib/generators/tbone/scaffold/scaffold_generator.rb",
62
+ "lib/generators/tbone/scaffold_backbone_router/scaffold_backbone_router_generator.rb",
63
+ "lib/generators/tbone/scaffold_backbone_router/templates/confirm.hamljs.erb",
64
+ "lib/generators/tbone/scaffold_backbone_router/templates/edit_view.coffee.erb",
65
+ "lib/generators/tbone/scaffold_backbone_router/templates/form.hamljs.erb",
66
+ "lib/generators/tbone/scaffold_backbone_router/templates/index.hamljs.erb",
67
+ "lib/generators/tbone/scaffold_backbone_router/templates/index_view.coffee.erb",
68
+ "lib/generators/tbone/scaffold_backbone_router/templates/new_view.coffee.erb",
69
+ "lib/generators/tbone/scaffold_backbone_router/templates/object.hamljs.erb",
70
+ "lib/generators/tbone/scaffold_backbone_router/templates/object_view.coffee.erb",
71
+ "lib/generators/tbone/scaffold_backbone_router/templates/router.coffee.erb",
72
+ "lib/generators/tbone/scaffold_backbone_router/templates/show.hamljs.erb",
73
+ "lib/generators/tbone/scaffold_backbone_router/templates/show_view.coffee.erb",
74
+ "lib/generators/tbone/scaffold_controller/scaffold_controller_generator.rb",
75
+ "lib/generators/tbone/scaffold_controller/templates/controller.rb.erb",
55
76
  "lib/tbone.rb",
56
77
  "lib/tbone/engine.rb",
57
78
  "tbone.gemspec",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tbone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-25 00:00:00.000000000 Z
12
+ date: 2012-07-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
16
- requirement: &70246368068660 !ruby/object:Gem::Requirement
16
+ requirement: &70112086859280 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70246368068660
24
+ version_requirements: *70112086859280
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70246367735520 !ruby/object:Gem::Requirement
27
+ requirement: &70112086858140 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70246367735520
35
+ version_requirements: *70112086858140
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &70246367733780 !ruby/object:Gem::Requirement
38
+ requirement: &70112086856380 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70246367733780
46
+ version_requirements: *70112086856380
47
47
  description: Library for mixing together requirejs backbone and twitter bootstrap
48
48
  email: fazzzenda@mail.ru
49
49
  executables: []
@@ -84,9 +84,30 @@ files:
84
84
  - app/views/home/index.html.haml
85
85
  - app/views/tokens/show.json.rabl
86
86
  - config/routes.rb
87
+ - lib/generators/tbone/backbone_model/backbone_model_generator.rb
88
+ - lib/generators/tbone/backbone_model/templates/collection.coffee.erb
89
+ - lib/generators/tbone/backbone_model/templates/model.coffee.erb
87
90
  - lib/generators/tbone/install/install_generator.rb
88
91
  - lib/generators/tbone/install/templates/application.json.rabl
89
92
  - lib/generators/tbone/install/templates/requirejs.yml
93
+ - lib/generators/tbone/rabl_views/rabl_views_generator.rb
94
+ - lib/generators/tbone/rabl_views/templates/index.rabl.erb
95
+ - lib/generators/tbone/rabl_views/templates/show.rabl.erb
96
+ - lib/generators/tbone/scaffold/scaffold_generator.rb
97
+ - lib/generators/tbone/scaffold_backbone_router/scaffold_backbone_router_generator.rb
98
+ - lib/generators/tbone/scaffold_backbone_router/templates/confirm.hamljs.erb
99
+ - lib/generators/tbone/scaffold_backbone_router/templates/edit_view.coffee.erb
100
+ - lib/generators/tbone/scaffold_backbone_router/templates/form.hamljs.erb
101
+ - lib/generators/tbone/scaffold_backbone_router/templates/index.hamljs.erb
102
+ - lib/generators/tbone/scaffold_backbone_router/templates/index_view.coffee.erb
103
+ - lib/generators/tbone/scaffold_backbone_router/templates/new_view.coffee.erb
104
+ - lib/generators/tbone/scaffold_backbone_router/templates/object.hamljs.erb
105
+ - lib/generators/tbone/scaffold_backbone_router/templates/object_view.coffee.erb
106
+ - lib/generators/tbone/scaffold_backbone_router/templates/router.coffee.erb
107
+ - lib/generators/tbone/scaffold_backbone_router/templates/show.hamljs.erb
108
+ - lib/generators/tbone/scaffold_backbone_router/templates/show_view.coffee.erb
109
+ - lib/generators/tbone/scaffold_controller/scaffold_controller_generator.rb
110
+ - lib/generators/tbone/scaffold_controller/templates/controller.rb.erb
90
111
  - lib/tbone.rb
91
112
  - lib/tbone/engine.rb
92
113
  - tbone.gemspec
@@ -107,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
128
  version: '0'
108
129
  segments:
109
130
  - 0
110
- hash: -2619129301492417490
131
+ hash: 1657973681414455746
111
132
  required_rubygems_version: !ruby/object:Gem::Requirement
112
133
  none: false
113
134
  requirements: