backtastic 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/.gitignore +10 -0
  2. data/Gemfile +4 -0
  3. data/README.md +72 -0
  4. data/Rakefile +1 -0
  5. data/backtastic.gemspec +28 -0
  6. data/example/.gitignore +15 -0
  7. data/example/Gemfile +44 -0
  8. data/example/README.rdoc +261 -0
  9. data/example/Rakefile +7 -0
  10. data/example/app/assets/images/rails.png +0 -0
  11. data/example/app/assets/javascripts/application.js.coffee +22 -0
  12. data/example/app/assets/javascripts/backbone/example.js.coffee +15 -0
  13. data/example/app/assets/javascripts/backbone/models/.gitkeep +0 -0
  14. data/example/app/assets/javascripts/backbone/models/occupation.coffee +7 -0
  15. data/example/app/assets/javascripts/backbone/models/people.coffee +7 -0
  16. data/example/app/assets/javascripts/backbone/models/thing.coffee +1 -0
  17. data/example/app/assets/javascripts/backbone/routers/.gitkeep +0 -0
  18. data/example/app/assets/javascripts/backbone/routers/people_router.coffee +27 -0
  19. data/example/app/assets/javascripts/backbone/templates/.gitkeep +0 -0
  20. data/example/app/assets/javascripts/backbone/views/.gitkeep +0 -0
  21. data/example/app/assets/javascripts/backbone/views/edit_person_view.coffee +21 -0
  22. data/example/app/assets/javascripts/backbone/views/example_form_view.coffee +2 -0
  23. data/example/app/assets/javascripts/backbone/views/people_view.coffee +6 -0
  24. data/example/app/assets/javascripts/bootstrap.js.coffee +4 -0
  25. data/example/app/assets/stylesheets/application.css +13 -0
  26. data/example/app/assets/stylesheets/bootstrap_and_overrides.css.less +30 -0
  27. data/example/app/assets/templates/edit_person_view_template.jst.hamlc +13 -0
  28. data/example/app/assets/templates/example_form_view_template.jst.hamlc +2 -0
  29. data/example/app/assets/templates/people_view_template.jst.hamlc +6 -0
  30. data/example/app/controllers/application_controller.rb +3 -0
  31. data/example/app/controllers/occupations_controller.rb +3 -0
  32. data/example/app/controllers/people_controller.rb +3 -0
  33. data/example/app/helpers/application_helper.rb +2 -0
  34. data/example/app/mailers/.gitkeep +0 -0
  35. data/example/app/models/.gitkeep +0 -0
  36. data/example/app/models/occupation.rb +2 -0
  37. data/example/app/models/person.rb +5 -0
  38. data/example/app/views/layouts/application.html.erb +75 -0
  39. data/example/app/views/people/index.html.erb +7 -0
  40. data/example/config.ru +4 -0
  41. data/example/config/application.rb +59 -0
  42. data/example/config/boot.rb +6 -0
  43. data/example/config/database.yml +25 -0
  44. data/example/config/environment.rb +5 -0
  45. data/example/config/environments/development.rb +37 -0
  46. data/example/config/environments/production.rb +67 -0
  47. data/example/config/environments/test.rb +37 -0
  48. data/example/config/initializers/backtrace_silencers.rb +7 -0
  49. data/example/config/initializers/inflections.rb +15 -0
  50. data/example/config/initializers/mime_types.rb +5 -0
  51. data/example/config/initializers/secret_token.rb +7 -0
  52. data/example/config/initializers/session_store.rb +8 -0
  53. data/example/config/initializers/wrap_parameters.rb +14 -0
  54. data/example/config/locales/en.yml +5 -0
  55. data/example/config/routes.rb +62 -0
  56. data/example/db/migrate/20120429172946_create_people.rb +12 -0
  57. data/example/db/migrate/20120526164853_create_occupations.rb +9 -0
  58. data/example/db/schema.rb +31 -0
  59. data/example/db/seeds.rb +7 -0
  60. data/example/doc/README_FOR_APP +2 -0
  61. data/example/lib/assets/.gitkeep +0 -0
  62. data/example/lib/tasks/.gitkeep +0 -0
  63. data/example/log/.gitkeep +0 -0
  64. data/example/public/404.html +26 -0
  65. data/example/public/422.html +26 -0
  66. data/example/public/500.html +25 -0
  67. data/example/public/favicon.ico +0 -0
  68. data/example/public/index.html +241 -0
  69. data/example/public/robots.txt +5 -0
  70. data/example/script/rails +6 -0
  71. data/example/spec/javascripts/spec.js.coffee +7 -0
  72. data/example/spec/javascripts/views/edit_person_view_spec.coffee +39 -0
  73. data/example/spec/javascripts/views/example_form_view_spec.coffee +12 -0
  74. data/example/spec/javascripts/views/select_field_view_spec.coffee +28 -0
  75. data/example/spec/javascripts/views/text_field_view_spec.coffee +17 -0
  76. data/example/vendor/assets/javascripts/.gitkeep +0 -0
  77. data/example/vendor/assets/stylesheets/.gitkeep +0 -0
  78. data/example/vendor/plugins/.gitkeep +0 -0
  79. data/lib/assets/javascripts/backtastic.coffee +13 -0
  80. data/lib/assets/javascripts/templates/select_field_template.jst.hamlc +4 -0
  81. data/lib/assets/javascripts/templates/text_field_template.jst.hamlc +2 -0
  82. data/lib/assets/javascripts/views/backtastic_view.coffee +12 -0
  83. data/lib/assets/javascripts/views/date_field_view.coffee +12 -0
  84. data/lib/assets/javascripts/views/form_field_view.coffee +23 -0
  85. data/lib/assets/javascripts/views/form_view.coffee +38 -0
  86. data/lib/assets/javascripts/views/select_field_view.coffee +8 -0
  87. data/lib/assets/javascripts/views/text_field_view.coffee +4 -0
  88. data/lib/backtastic.rb +9 -0
  89. data/lib/backtastic/version.rb +3 -0
  90. data/vendor/assets/javascripts/bootstrap-datepicker.js +401 -0
  91. data/vendor/assets/javascripts/jquery.serializeObject.js.coffee +19 -0
  92. data/vendor/assets/stylesheets/datepicker.less +122 -0
  93. metadata +182 -0
@@ -0,0 +1,22 @@
1
+ # This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ # listed below.
3
+ #
4
+ # Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ # or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ #
7
+ # It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ # the compiled file.
9
+ #
10
+ # WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ # GO AFTER THE REQUIRES BELOW.
12
+ #
13
+ #= require jquery
14
+ #= require jquery_ujs
15
+ #= require twitter/bootstrap
16
+ #= require underscore
17
+ #= require backbone
18
+ #= require backbone_rails_sync
19
+ #= require backbone_datalink
20
+ #= require_tree ../templates
21
+ #= require backtastic
22
+ #= require backbone/example
@@ -0,0 +1,15 @@
1
+ #= require_self
2
+ #= require_tree ./templates
3
+ #= require_tree ./models
4
+ #= require_tree ./views
5
+ #= require_tree ./routers
6
+
7
+ window.Example =
8
+ Models: {}
9
+ Collections: {}
10
+ Routers: {}
11
+ Views: {}
12
+
13
+ $ ->
14
+ new Example.Routers.PeopleRouter()
15
+ Backbone.history.start()
@@ -0,0 +1,7 @@
1
+ class Example.Models.Occupation extends Backbone.Model
2
+ urlRoot: "/occupations"
3
+
4
+ class Example.Collections.OccupationsCollection extends Backbone.Collection
5
+ model: Example.Models.Occupation
6
+
7
+ url: "/occupations"
@@ -0,0 +1,7 @@
1
+ class Example.Models.Person extends Backbone.Model
2
+ urlRoot: "/people"
3
+
4
+ class Example.Collections.PeopleCollection extends Backbone.Collection
5
+ model: Example.Models.Person
6
+
7
+ url: "/people"
@@ -0,0 +1 @@
1
+ class Example.Models.Thing extends Backbone.Model
@@ -0,0 +1,27 @@
1
+ class Example.Routers.PeopleRouter extends Backbone.Router
2
+ constructor: ->
3
+ super
4
+ @people = new Example.Collections.PeopleCollection(peopleJson)
5
+ @occupations = new Example.Collections.OccupationsCollection(occupationsJson)
6
+ @people.on "sync", => @navigate "people/list", trigger: true
7
+ @peopleView = new Example.Views.PeopleView(collection: @people, el: $("#people_view"))
8
+ @editPersonView = new Example.Views.EditPersonView(el: $("#edit_person"), occupations: @occupations)
9
+ @showPeople()
10
+
11
+ routes:
12
+ "people/new": "newPerson"
13
+ "people/list": "showPeople"
14
+ "people/:id/edit": "editPerson"
15
+
16
+ showPeople: ->
17
+ @peopleView.render()
18
+ @editPersonView.close()
19
+
20
+ newPerson: ->
21
+ person = new Example.Models.Person
22
+ @people.add person, silent: true
23
+ @editPersonView.edit(person)
24
+
25
+ editPerson: (id)->
26
+ @editPersonView.edit @people.get(id)
27
+
@@ -0,0 +1,21 @@
1
+ class Example.Views.EditPersonView extends Backtastic.Views.FormView
2
+ template: JST["edit_person_view_template"]
3
+
4
+ constructor: (options)->
5
+ super
6
+ @occupations = options.occupations
7
+
8
+ events:
9
+ "submit form": "save"
10
+
11
+ render: ->
12
+ super
13
+ @$el.addClass "modal"
14
+
15
+ edit: (person)->
16
+ @model = person
17
+ @render()
18
+ @$el.modal "show"
19
+
20
+ close: ->
21
+ @$el.modal "hide"
@@ -0,0 +1,2 @@
1
+ class Example.Views.FormView extends Backtastic.Views.FormView
2
+ template: JST["example_form_view_template"]
@@ -0,0 +1,6 @@
1
+ class Example.Views.PeopleView extends Backtastic.View
2
+ template: JST["people_view_template"]
3
+
4
+ constructor: (options)->
5
+ super
6
+ @collection.bind "sync", => @render()
@@ -0,0 +1,4 @@
1
+ jQuery ->
2
+ $("a[rel=popover]").popover()
3
+ $(".tooltip").tooltip()
4
+ $("a[rel=tooltip]").tooltip()
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,30 @@
1
+ @import "twitter/bootstrap/bootstrap";
2
+ body { padding-top: 60px; }
3
+
4
+ @import "twitter/bootstrap/responsive";
5
+
6
+ // Set the correct sprite paths
7
+ @iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
8
+ @iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');
9
+
10
+ // Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
11
+ @fontAwesomeEotPath: asset-path('fontawesome-webfont.eot');
12
+ @fontAwesomeWoffPath: asset-path('fontawesome-webfont.woff');
13
+ @fontAwesomeTtfPath: asset-path('fontawesome-webfont.ttf');
14
+ @fontAwesomeSvgzPath: asset-path('fontawesome-webfont.svgz');
15
+ @fontAwesomeSvgPath: asset-path('fontawesome-webfont.svg');
16
+
17
+ // Font Awesome
18
+ @import "fontawesome";
19
+
20
+ // Your custom LESS stylesheets goes here
21
+ //
22
+ // Since bootstrap was imported above you have access to its mixins which
23
+ // you may use and inherit here
24
+ //
25
+ // If you'd like to override bootstrap's own variables, you can do so here as well
26
+ // See http://twitter.github.com/bootstrap/less.html for their names and documentation
27
+ //
28
+ // Example:
29
+ // @linkColor: #ff0000;
30
+
@@ -0,0 +1,13 @@
1
+ .modal-header
2
+ %a{class: "close", href: "#people/list"} x
3
+ %h3 New Person
4
+ %form.person-form
5
+ .modal-body
6
+ %fieldset
7
+ = @textField(field: "first_name", label: "First Name")
8
+ = @textField(field: "last_name", label: "Last Name")
9
+ = @dateField(field: "birth_date", label: "Birth Date", format: "yyyy-mm-dd")
10
+ = @selectField(field: "occupation_id", label: "Occupation", collection: @occupations)
11
+ .modal-footer
12
+ %input{type: "submit", value: "Save", class: "btn btn-primary"}
13
+
@@ -0,0 +1,2 @@
1
+ %form
2
+ = @textField field: "name"
@@ -0,0 +1,6 @@
1
+ %ul
2
+ - for person in @collection.models
3
+ %li
4
+ %a{href: '#people/#{person.id}/edit'}= person.get("first_name")
5
+
6
+ %a{href: "#people/new"} Add Person
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,3 @@
1
+ class OccupationsController < InheritedResources::Base
2
+ respond_to :html, :json
3
+ end
@@ -0,0 +1,3 @@
1
+ class PeopleController < InheritedResources::Base
2
+ respond_to :html, :json
3
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ class Occupation < ActiveRecord::Base
2
+ end
@@ -0,0 +1,5 @@
1
+ class Person < ActiveRecord::Base
2
+ validates_presence_of :first_name
3
+
4
+ belongs_to :occupation
5
+ end
@@ -0,0 +1,75 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title><%= content_for?(:title) ? yield(:title) : "Example" %></title>
7
+ <%= csrf_meta_tags %>
8
+
9
+ <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
10
+ <!--[if lt IE 9]>
11
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
12
+ <![endif]-->
13
+
14
+ <%= stylesheet_link_tag "application", :media => "all" %>
15
+
16
+ <link href="images/favicon.ico" rel="shortcut icon">
17
+ <link href="images/apple-touch-icon.png" rel="apple-touch-icon">
18
+ <link href="images/apple-touch-icon-72x72.png" rel="apple-touch-icon" sizes="72x72">
19
+ <link href="images/apple-touch-icon-114x114.png" rel="apple-touch-icon" sizes="114x114">
20
+ </head>
21
+ <body>
22
+
23
+ <div class="navbar navbar-fixed-top">
24
+ <div class="navbar-inner">
25
+ <div class="container">
26
+ <a class="btn btn-navbar" data-target=".nav-collapse" data-toggle="collapse">
27
+ <span class="icon-bar"></span>
28
+ <span class="icon-bar"></span>
29
+ <span class="icon-bar"></span>
30
+ </a>
31
+ <a class="brand" href="#">Example</a>
32
+ <div class="container nav-collapse">
33
+ <ul class="nav">
34
+ <li><%= link_to "Link1", "/path1" %></li>
35
+ <li><%= link_to "Link2", "/path2" %></li>
36
+ <li><%= link_to "Link3", "/path3" %></li>
37
+ </ul>
38
+ </div><!--/.nav-collapse -->
39
+ </div>
40
+ </div>
41
+ </div>
42
+
43
+ <div class="container">
44
+ <div class="content">
45
+ <div class="row">
46
+ <div class="span9">
47
+ <%= yield %>
48
+ </div>
49
+ <div class="span3">
50
+ <div class="well sidebar-nav">
51
+ <h3>Sidebar</h3>
52
+ <ul class="nav nav-list">
53
+ <li class="nav-header">Sidebar</li>
54
+ <li><%= link_to "Link1", "/path1" %></li>
55
+ <li><%= link_to "Link2", "/path2" %></li>
56
+ <li><%= link_to "Link3", "/path3" %></li>
57
+ </ul>
58
+ </div><!--/.well -->
59
+ </div><!--/span-->
60
+ </div><!--/row-->
61
+ </div><!--/content-->
62
+
63
+ <footer>
64
+ <p>&copy; Company 2012</p>
65
+ </footer>
66
+
67
+ </div> <!-- /container -->
68
+
69
+ <!-- Javascripts
70
+ ================================================== -->
71
+ <!-- Placed at the end of the document so the pages load faster -->
72
+ <%= javascript_include_tag "application" %>
73
+
74
+ </body>
75
+ </html>
@@ -0,0 +1,7 @@
1
+ <div id="people_view"></div>
2
+ <div id="edit_person"></div>
3
+ <script>
4
+ var peopleJson = <%= @people.to_json.html_safe %>;
5
+ var occupationsJson = <%= Occupation.all.to_json.html_safe %>;
6
+ </script>
7
+
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Example::Application
@@ -0,0 +1,59 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ if defined?(Bundler)
6
+ # If you precompile assets before deploying to production, use this line
7
+ Bundler.require(*Rails.groups(:assets => %w(development test)))
8
+ # If you want your assets lazily compiled in production, use this line
9
+ # Bundler.require(:default, :assets, Rails.env)
10
+ end
11
+
12
+ module Example
13
+ class Application < Rails::Application
14
+ # Settings in config/environments/* take precedence over those specified here.
15
+ # Application configuration should go into files in config/initializers
16
+ # -- all .rb files in that directory are automatically loaded.
17
+
18
+ # Custom directories with classes and modules you want to be autoloadable.
19
+ # config.autoload_paths += %W(#{config.root}/extras)
20
+
21
+ # Only load the plugins named here, in the order given (default is alphabetical).
22
+ # :all can be used as a placeholder for all plugins not explicitly named.
23
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
24
+
25
+ # Activate observers that should always be running.
26
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
27
+
28
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
29
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
30
+ # config.time_zone = 'Central Time (US & Canada)'
31
+
32
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
33
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
34
+ # config.i18n.default_locale = :de
35
+
36
+ # Configure the default encoding used in templates for Ruby 1.9.
37
+ config.encoding = "utf-8"
38
+
39
+ # Configure sensitive parameters which will be filtered from the log file.
40
+ config.filter_parameters += [:password]
41
+
42
+ # Use SQL instead of Active Record's schema dumper when creating the database.
43
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
44
+ # like if you have constraints or database-specific column types
45
+ # config.active_record.schema_format = :sql
46
+
47
+ # Enforce whitelist mode for mass assignment.
48
+ # This will create an empty whitelist of attributes available for mass-assignment for all models
49
+ # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
50
+ # parameters by using an attr_accessible or attr_protected declaration.
51
+ # config.active_record.whitelist_attributes = true
52
+
53
+ # Enable the asset pipeline
54
+ config.assets.enabled = true
55
+
56
+ # Version of your assets, change this if you want to expire all your assets
57
+ config.assets.version = '1.0'
58
+ end
59
+ end
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
+
6
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Example::Application.initialize!
@@ -0,0 +1,37 @@
1
+ Example::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger
20
+ config.active_support.deprecation = :log
21
+
22
+ # Only use best-standards-support built into browsers
23
+ config.action_dispatch.best_standards_support = :builtin
24
+
25
+ # Raise exception on mass assignment protection for Active Record models
26
+ config.active_record.mass_assignment_sanitizer = :strict
27
+
28
+ # Log the query plan for queries taking more than this (works
29
+ # with SQLite, MySQL, and PostgreSQL)
30
+ config.active_record.auto_explain_threshold_in_seconds = 0.5
31
+
32
+ # Do not compress assets
33
+ config.assets.compress = false
34
+
35
+ # Expands the lines which load the assets
36
+ config.assets.debug = true
37
+ end