Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Basic functions pass the available tests, lots of more work to do to …

…increase test and devise feature coverage, and streamline the API between the engine and the application
  • Loading branch information...
commit ff0db4838be42b239434993a049f73776778faf7 1 parent e50fde3
@technomage authored
Showing with 1,983 additions and 284 deletions.
  1. +24 −0 Gemfile
  2. +131 −1 Gemfile.lock
  3. +11 −0 README.rdoc
  4. +500 −0 app/assets/javascripts/ember-bootstrap.js
  5. +26 −0 app/assets/javascripts/ember-devise-bootstrap.js.erb
  6. +40 −0 app/assets/javascripts/ember-devise-bootstrap/controllers/password_controller.js
  7. +61 −0 app/assets/javascripts/ember-devise-bootstrap/controllers/sign_in_controller.js
  8. +56 −0 app/assets/javascripts/ember-devise-bootstrap/controllers/sign_up_controller.js
  9. +14 −0 app/assets/javascripts/ember-devise-bootstrap/controllers/user_controller.js
  10. +48 −0 app/assets/javascripts/ember-devise-bootstrap/ember-devise-bootstrap.js
  11. 0  app/assets/javascripts/ember-devise-bootstrap/helpers/.gitkeep
  12. +4 −0 app/assets/javascripts/ember-devise-bootstrap/models/user.js
  13. +45 −0 app/assets/javascripts/ember-devise-bootstrap/states/user_states.js
  14. +13 −0 app/assets/javascripts/ember-devise-bootstrap/templates/forgot_password_form.handlebars
  15. +18 −0 app/assets/javascripts/ember-devise-bootstrap/templates/sign_in_form.handlebars
  16. +18 −0 app/assets/javascripts/ember-devise-bootstrap/templates/sign_up_form.handlebars
  17. +8 −0 app/assets/javascripts/ember-devise-bootstrap/templates/signed_in.handlebars
  18. +17 −0 app/assets/javascripts/ember-devise-bootstrap/templates/signed_out.handlebars
  19. +28 −0 app/assets/javascripts/ember-devise-bootstrap/views/user_views.js
  20. 0  app/assets/stylesheets/{ember-devise-bootstrap/application.css → ember-devise-bootstrap.css}
  21. +29 −0 app/assets/stylesheets/ember-devise-bootstrap/bootstrap_and_overrides.css.less
  22. +4 −0 app/controllers/ember-devise-bootstrap/app_controller.rb
  23. +0 −4 app/controllers/ember-devise-bootstrap/application_controller.rb
  24. +12 −0 app/views/devise/confirmations/new.html.erb
  25. +5 −0 app/views/devise/mailer/confirmation_instructions.html.erb
  26. +8 −0 app/views/devise/mailer/reset_password_instructions.html.erb
  27. +7 −0 app/views/devise/mailer/unlock_instructions.html.erb
  28. +16 −0 app/views/devise/passwords/edit.html.erb
  29. +12 −0 app/views/devise/passwords/new.html.erb
  30. +1 −0  app/views/devise/registrations/create.json.erb
  31. +25 −0 app/views/devise/registrations/edit.html.erb
  32. +18 −0 app/views/devise/registrations/new.html.erb
  33. +17 −0 app/views/devise/sessions/new.html.erb
  34. +25 −0 app/views/devise/shared/_links.erb
  35. +12 −0 app/views/devise/unlocks/new.html.erb
  36. +8 −0 config/cucumber.yml
  37. +3 −0  ember-devise-bootstrap.gemspec
  38. +47 −0 features/sign_in_out.feature
  39. +22 −0 features/step_definitions/basic_steps.rb
  40. +80 −0 features/step_definitions/sign_in_out_steps.rb
  41. +75 −0 features/support/env.rb
  42. +65 −0 lib/tasks/cucumber.rake
  43. +10 −0 script/cucumber
  44. +2 −261 test/dummy/README.rdoc
  45. +0 −15 test/dummy/app/assets/javascripts/application.js
  46. +25 −2 ...vascripts/ember-devise-bootstrap/application.js → test/dummy/app/assets/javascripts/application.js.erb
  47. +1 −0  test/dummy/app/assets/stylesheets/application.css
  48. +4 −0 test/dummy/app/controllers/application_controller.rb
  49. +14 −0 test/dummy/app/controllers/users/omniauth_callbacks_controller.rb
  50. +29 −0 test/dummy/app/models/user.rb
  51. +2 −0  test/dummy/app/views/application/index.html.erb
  52. +27 −0 test/dummy/app/views/layouts/application.html.erb
  53. +4 −0 test/dummy/config/application.rb
  54. +3 −1 test/dummy/config/boot.rb
  55. +222 −0 test/dummy/config/initializers/devise.rb
  56. +7 −0 test/dummy/config/routes.rb
  57. +46 −0 test/dummy/db/migrate/20120521143516_devise_create_users.rb
  58. +34 −0 test/dummy/db/schema.rb
View
24 Gemfile
@@ -7,6 +7,10 @@ gemspec
# jquery-rails is used by the dummy application
gem "jquery-rails"
+gem "devise"
+gem "omniauth-facebook"
+gem "twitter-bootstrap-rails"
+gem "ember-rails"
# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
@@ -15,3 +19,23 @@ gem "jquery-rails"
# To use debugger
# gem 'debugger'
+
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+ gem 'sass-rails', '~> 3.2.3'
+ gem 'coffee-rails', '~> 3.2.1'
+
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
+ # gem 'therubyracer', :platform => :ruby
+
+ gem 'uglifier', '>= 1.0.3'
+end
+
+group :test do
+ gem 'cucumber-rails'
+ gem "rspec-rails"
+ gem "database_cleaner"
+ gem "spork"
+ gem "capybara"
+end
View
132 Gemfile.lock
@@ -2,7 +2,12 @@ PATH
remote: .
specs:
ember-devise-bootstrap (0.0.1)
- rails (~> 3.2.6)
+ devise
+ ember-rails
+ omniauth
+ omniauth-facebook
+ rails (>= 3.2.6)
+ twitter-bootstrap-rails
GEM
remote: http://rubygems.org/
@@ -20,6 +25,8 @@ GEM
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
+ active_model_serializers (0.5.2)
+ activemodel (~> 3.0)
activemodel (3.2.6)
activesupport (= 3.2.6)
builder (~> 3.0.0)
@@ -34,22 +41,93 @@ GEM
activesupport (3.2.6)
i18n (~> 0.6)
multi_json (~> 1.0)
+ addressable (2.2.8)
arel (3.0.2)
+ bcrypt-ruby (3.0.1)
builder (3.0.0)
+ capybara (1.1.2)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (~> 2.0)
+ xpath (~> 0.1.4)
+ childprocess (0.3.2)
+ ffi (~> 1.0.6)
+ coffee-rails (3.2.2)
+ coffee-script (>= 2.2.0)
+ railties (~> 3.2.0)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.3.3)
+ commonjs (0.2.6)
+ cucumber (1.2.1)
+ builder (>= 2.1.2)
+ diff-lcs (>= 1.1.3)
+ gherkin (~> 2.11.0)
+ json (>= 1.4.6)
+ cucumber-rails (1.3.0)
+ capybara (>= 1.1.2)
+ cucumber (>= 1.1.8)
+ nokogiri (>= 1.5.0)
+ database_cleaner (0.8.0)
+ devise (2.1.1)
+ bcrypt-ruby (~> 3.0)
+ orm_adapter (~> 0.1)
+ railties (~> 3.1)
+ warden (~> 1.2.1)
+ diff-lcs (1.1.3)
+ ember-rails (0.6.0)
+ active_model_serializers
+ execjs (>= 1.2)
+ railties (~> 3.1)
erubis (2.7.0)
+ execjs (1.4.0)
+ multi_json (~> 1.0)
+ faraday (0.8.1)
+ multipart-post (~> 1.1)
+ ffi (1.0.11)
+ gherkin (2.11.0)
+ json (>= 1.4.6)
+ hashie (1.2.0)
hike (1.2.1)
+ httpauth (0.1)
i18n (0.6.0)
journey (1.0.4)
jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
json (1.7.3)
+ less (2.2.1)
+ commonjs (~> 0.2.6)
+ less-rails (2.2.3)
+ actionpack (>= 3.1)
+ less (~> 2.2.0)
+ libv8 (3.3.10.4)
+ libwebsocket (0.1.3)
+ addressable
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.18)
multi_json (1.3.6)
+ multipart-post (1.1.5)
+ nokogiri (1.5.4)
+ oauth2 (0.6.1)
+ faraday (~> 0.7)
+ httpauth (~> 0.1)
+ multi_json (~> 1.3)
+ omniauth (1.1.0)
+ hashie (~> 1.2)
+ rack
+ omniauth-facebook (1.3.0)
+ omniauth-oauth2 (~> 1.0.2)
+ omniauth-oauth2 (1.0.2)
+ oauth2 (~> 0.6.0)
+ omniauth (~> 1.0)
+ orm_adapter (0.1.0)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
@@ -76,22 +154,74 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
+ rspec (2.10.0)
+ rspec-core (~> 2.10.0)
+ rspec-expectations (~> 2.10.0)
+ rspec-mocks (~> 2.10.0)
+ rspec-core (2.10.1)
+ rspec-expectations (2.10.0)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.10.1)
+ rspec-rails (2.10.1)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec (~> 2.10.0)
+ rubyzip (0.9.8)
+ sass (3.1.19)
+ sass-rails (3.2.5)
+ railties (~> 3.2.0)
+ sass (>= 3.1.10)
+ tilt (~> 1.3)
+ selenium-webdriver (2.22.2)
+ childprocess (>= 0.2.5)
+ ffi (~> 1.0)
+ libwebsocket (~> 0.1.3)
+ multi_json (~> 1.0)
+ rubyzip
+ spork (0.9.2)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
+ therubyracer (0.10.1)
+ libv8 (~> 3.3.10)
thor (0.15.2)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
+ twitter-bootstrap-rails (2.1.0)
+ actionpack (>= 3.1)
+ less-rails (~> 2.2.2)
+ railties (>= 3.1)
+ therubyracer (~> 0.10.1)
tzinfo (0.3.33)
+ uglifier (1.2.4)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+ warden (1.2.1)
+ rack (>= 1.0)
+ xpath (0.1.4)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
+ capybara
+ coffee-rails (~> 3.2.1)
+ cucumber-rails
+ database_cleaner
+ devise
ember-devise-bootstrap!
+ ember-rails
jquery-rails
+ omniauth-facebook
+ rspec-rails
+ sass-rails (~> 3.2.3)
+ spork
sqlite3
+ twitter-bootstrap-rails
+ uglifier (>= 1.0.3)
View
11 README.rdoc
@@ -2,8 +2,19 @@
This project provides a login UI uising Ember.js and Twitter Bootstrap that
is compatible with Devise.
+At this time the full set of devise views are embedded in this engine. Hopefully this
+will change as all the devise functions are fronted with Ember UI rather than separate
+pages.
+
The first step is to extract this from an existing project and get it working in that
context. This will work for the User resource, then it will be generalized for more
resources.
This project is released under the MIT-LICENSE.
+
+- Notes
+The test cases for this project are all in cucumber which can be invoked from the project root directory. The
+facebook integration for the test app is configured to use a dummy facebook app configured for callbacks on
+127.0.0.1:5555 so any manual testing will need to use a similar URL when using facebook integrations. To keep
+the repository clear of any credentials the test app looks for facebook credentials in the environment variables
+facebook_user and facebook_pass.
View
500 app/assets/javascripts/ember-bootstrap.js
@@ -0,0 +1,500 @@
+
+(function(exports) {
+window.Bootstrap = Ember.Namespace.create();
+
+})({});
+
+
+(function(exports) {
+Bootstrap.Forms = Ember.Namespace.create({
+
+ human: function(value) {
+ if (value == undefined)
+ return;
+
+ // Replace all _ with spaces
+ value = value.replace(/_/, " ");
+ // Capitalize the first letter of every word
+ value = value.replace(/(^|\s)([a-z])/g, function(m,p1,p2){ return p1+p2.toUpperCase(); });
+ return value;
+ }
+});
+
+})({});
+
+
+(function(exports) {
+Bootstrap.Forms.Field = Ember.View.extend({
+ tagName: 'div',
+ template: Ember.Handlebars.compile('<div class="control-group">\
+ {{view view.labelView}}\
+ <div class="controls">\
+ {{view view.inputField}}\
+ {{view view.errorsView}}\
+ </div>\
+ </div>'),
+
+ labelView: Ember.View.extend({
+ tagName: 'label',
+ classNames: ['control-label'],
+ template: Ember.Handlebars.compile('{{view.value}}'),
+
+ value: Ember.computed(function(key, value) {
+ var parent = this.get('parentView');
+
+ if (value && value != parent.get('label')) {
+ parent.set('label', value);
+ } else {
+ value = parent.get('label');
+ }
+
+ return Bootstrap.Forms.human(value);
+ }).property('parentView.label'),
+
+ forBinding: 'value',
+ attributeBindings: ['for']
+ }),
+
+ inputField: Ember.View.extend({
+ classNames: ['ember-bootstrap-extend'],
+ tagName: 'div',
+ template: Ember.Handlebars.compile('This class is not meant to be used directly, but extended.')
+ }),
+
+ errorsView: Ember.View.extend({
+ tagName: 'div',
+ classNames: ['errors', 'help-inline'],
+
+ _updateContent: Ember.observer(function() {
+ parent = this.get('parentView');
+
+ if (parent !== null) {
+ context = parent.get('bindingContext');
+ label = parent.get('label');
+
+ if (context !== null && !context.get('isValid')) {
+ errors = context.get('errors');
+
+ if (errors != null && errors[label] !== null) {
+ parent.$().find('.control-group').addClass('error')
+ this.$().html(errors[label].join(', '));
+ } else {
+ parent.$().find('.control-group').removeClass('error')
+ this.$().html('');
+ }
+ } else {
+ parent.$().find('.control-group').removeClass('error')
+ this.$().html('');
+ }
+ }
+ }, 'parentView.bindingContext.isValid', 'parentView.label')
+ })
+});
+
+})({});
+
+
+(function(exports) {
+Bootstrap.Forms.TextArea = Bootstrap.Forms.Field.extend({
+
+ inputField: Ember.TextArea.extend({
+ valueBinding: 'parentView.value',
+ nameBinding: 'parentView.label',
+ attributeBindings: ['name']
+ })
+});
+
+})({});
+
+
+(function(exports) {
+Bootstrap.Forms.TextField = Bootstrap.Forms.Field.extend({
+
+ inputField: Ember.TextField.extend({
+ valueBinding: 'parentView.value',
+ nameBinding: 'parentView.label',
+ attributeBindings: ['name']
+ })
+});
+
+})({});
+
+
+(function(exports) {
+var get = Ember.get;
+
+var modalPaneTemplate = '\
+<div class="modal-header"> \
+ <a href="#" class="close" rel="close">×</a> \
+ {{view view.headerViewClass}} \
+</div> \
+<div class="modal-body">{{view view.bodyViewClass}}</div> \
+<div class="modal-footer"> \
+ {{#if view.primary}}<a href="#" class="btn btn-primary" rel="primary">{{view.primary}}</a>{{/if}} \
+ {{#if view.secondary}}<a href="#" class="btn btn-secondary" rel="secondary">{{view.secondary}}</a>{{/if}} \
+</div>';
+var modalPaneBackdrop = '<div class="modal-backdrop"></div>';
+
+Bootstrap.ModalPane = Ember.View.extend({
+ classNames: 'modal',
+ template: Ember.Handlebars.compile(modalPaneTemplate),
+ heading: null,
+ message: null,
+ primary: null,
+ secondary: null,
+ showBackdrop: true,
+ headerViewClass: Ember.View.extend({
+ tagName: 'h3',
+ template: Ember.Handlebars.compile('{{view.parentView.heading}}')
+ }),
+ bodyViewClass: Ember.View.extend({
+ tagName: 'p',
+ template: Ember.Handlebars.compile('{{{view.parentView.message}}}')
+ }),
+
+ didInsertElement: function() {
+ if (get(this, 'showBackdrop')) this._appendBackdrop();
+ this._setupDocumentKeyHandler();
+ },
+
+ willDestroyElement: function() {
+ if (this._backdrop) this._backdrop.remove();
+ this._removeDocumentKeyHandler();
+ },
+
+ keyPress: function(event) {
+ if (event.keyCode === 27) {
+ this._triggerCallbackAndDestroy({ close: true }, event);
+ }
+ },
+
+ click: function(event) {
+ var target = $(event.target),
+ targetRel = target.attr('rel');
+ if (targetRel === 'close') {
+ this._triggerCallbackAndDestroy({ close: true }, event);
+ } else if (targetRel == 'primary') {
+ this._triggerCallbackAndDestroy({ primary: true }, event);
+ } else if (targetRel == 'secondary') {
+ this._triggerCallbackAndDestroy({ secondary: true }, event);
+ }
+ },
+
+ _appendBackdrop: function() {
+ var parentLayer = this.$().parent();
+ this._backdrop = $(modalPaneBackdrop).appendTo(parentLayer);
+ },
+
+ _setupDocumentKeyHandler: function() {
+ var cc = this,
+ handler = function(event) {
+ cc.keyPress(event);
+ };
+ jQuery(window.document).bind('keyup', handler);
+ this._keyUpHandler = handler;
+ },
+
+ _removeDocumentKeyHandler: function() {
+ jQuery(window.document).unbind('keyup', this._keyUpHandler);
+ },
+
+ _triggerCallbackAndDestroy: function(options, event) {
+ if (this.callback) this.callback(options, event);
+ this.destroy();
+ }
+});
+
+Bootstrap.ModalPane.reopenClass({
+ popup: function(options) {
+ var modalPane;
+ if (!options) options = {}
+ modalPane = this.create(options);
+ modalPane.append();
+ return modalPane;
+ }
+});
+
+
+})({});
+
+
+(function(exports) {
+var get = Ember.get;
+
+Bootstrap.AlertMessage = Ember.View.extend({
+ classNames: ['alert', 'alert-message'],
+ classNameBindings: 'typeClass',
+ template: Ember.Handlebars.compile('<a class="close" rel="close" href="#">×</a>{{{message}}}'),
+ type: 'warning',
+ message: null,
+ removeAfter: null,
+
+ typeClass: Ember.computed(function() {
+ return 'alert-' + get(this, 'type');
+ }).property('type').cacheable(),
+
+ didInsertElement: function() {
+ var removeAfter = get(this, 'removeAfter');
+ if (removeAfter > 0) {
+ Ember.run.later(this, 'destroy', removeAfter);
+ }
+ },
+
+ click: function(event) {
+ var target = jQuery(event.target),
+ targetRel = target.attr('rel');
+ if (targetRel === 'close') {
+ this.destroy();
+ return false;
+ }
+ }
+});
+
+})({});
+
+
+(function(exports) {
+var get = Ember.get;
+
+Bootstrap.Button = Ember.Button.extend({
+ classNames: ['btn'],
+ classNameBindings: ['typeClass', 'sizeClass', 'disabled'],
+
+ typeClass: Ember.computed(function() {
+ var type = get(this, 'type');
+ return type ? 'btn-' + type : null;
+ }).property('type').cacheable(),
+
+ sizeClass: Ember.computed(function() {
+ var size = get(this, 'size');
+ return size ? 'btn-' + size : null;
+ }).property('size').cacheable()
+});
+
+})({});
+
+
+(function(exports) {
+Bootstrap.ButtonGroup = Ember.CollectionView.extend({
+ classNames: ['btn-group'],
+ itemViewClass: Bootstrap.Button.extend({
+ tagName: 'a',
+ template: Ember.Handlebars.compile('{{view.content}}')
+ })
+});
+
+})({});
+
+
+(function(exports) {
+var get = Ember.get, getPath = Ember.getPath, set = Ember.set;
+
+Bootstrap.ItemSelectionSupport = Ember.Mixin.create({
+ classNameBindings: ['isActive:active'],
+
+ title: Ember.computed(function() {
+ var parentView = get(this, 'parentView'),
+ content = get(this, 'content'),
+ titleKey;
+ if (parentView) {
+ titleKey = get(parentView, 'itemTitleKey');
+ if (titleKey) return get(content, titleKey);
+ }
+ return content;
+ }).property('content', 'parentView').cacheable(),
+
+ value: Ember.computed(function() {
+ var parentView = get(this, 'parentView'),
+ content = get(this, 'content'),
+ valueKey;
+ if (parentView) {
+ valueKey = get(parentView, 'itemValueKey');
+ if (valueKey) return get(content, valueKey);
+ }
+ return content;
+ }).property('content', 'parentView').cacheable(),
+
+ isActive: Ember.computed(function() {
+ var parentView = get(this, 'parentView'),
+ selection, value;
+ if (!parentView) return false;
+ selection = get(parentView, 'selection');
+ value = get(this, 'value');
+ return selection === value;
+ }).property('parentView.selection', 'value').cacheable(),
+
+ click: function(event) {
+ var value = get(this, 'value'),
+ parentView = get(this, 'parentView'),
+ allowsEmptySelection = get(parentView, 'allowsEmptySelection'),
+ selection = get(parentView, 'selection');
+ if (allowsEmptySelection === true && selection === value) {
+ value = null;
+ }
+ set(parentView, 'selection', value);
+ return false;
+ }
+});
+
+})({});
+
+
+(function(exports) {
+var get = Ember.get, set = Ember.set;
+
+Bootstrap.RadioButtonGroup = Bootstrap.ButtonGroup.extend({
+ selection: null,
+ allowsEmptySelection: false,
+
+ init: function() {
+ this._super();
+ var content = get(this, 'content');
+ if (content && get(this, 'allowsEmptySelection') === false) {
+ set(this, 'selection', content.get('firstObject'));
+ }
+ },
+
+ itemViewClass: Em.View.extend(Bootstrap.ItemSelectionSupport, {
+ classNames: 'btn',
+ tagName: 'a',
+ template: Ember.Handlebars.compile('{{view.title}}')
+ })
+});
+
+
+})({});
+
+
+(function(exports) {
+var get = Ember.get, set = Ember.set;
+
+Bootstrap.NavList = Ember.CollectionView.extend({
+ classNames: ['nav', 'nav-list'],
+ tagName: 'ul',
+
+ itemViewClass: Ember.View.extend(Bootstrap.ItemSelectionSupport, {
+ template: Ember.Handlebars.compile("<a href='#'>{{view.title}}</a>")
+ })
+});
+
+})({});
+
+
+(function(exports) {
+Bootstrap.BlockAlertMessage = Bootstrap.AlertMessage.extend({
+ classNames: ['alert', 'alert-block']
+});
+
+})({});
+
+
+(function(exports) {
+Bootstrap.PillItem = Ember.View.extend(Bootstrap.ItemSelectionSupport, {
+ template: Ember.Handlebars.compile('<a href="#">{{title}}</a>')
+});
+
+})({});
+
+
+(function(exports) {
+Bootstrap.Pills = Ember.CollectionView.extend({
+ classNames: ['nav', 'nav-pills'],
+ classNameBindings: ['isStacked:nav-stacked'],
+ tagName: 'ul',
+ itemViewClass: Bootstrap.PillItem,
+ selection: null
+});
+
+})({});
+
+
+(function(exports) {
+Bootstrap.Tabs = Ember.CollectionView.extend({
+ classNames: ['nav', 'nav-tabs'],
+ classNameBindings: ['isStacked:nav-stacked'],
+ tagName: 'ul',
+ itemViewClass: Bootstrap.PillItem,
+ selection: null
+});
+
+})({});
+
+
+(function(exports) {
+var get = Ember.get;
+
+Bootstrap.ProgressBar = Ember.View.extend({
+ classNames: ['progress'],
+ classNameBindings: ['isStriped:progress-striped', 'isAnimated:active'],
+ template: Ember.Handlebars.compile('<div class="bar" {{bindAttr style="style"}}></div>'),
+ isAnimated: false,
+ isStriped: false,
+ progress: 0,
+
+ style: Ember.computed(function() {
+ var progress = get(this, 'progress');
+ return "width:" + progress + "%;";
+ }).property('progress').cacheable()
+});
+
+})({});
+
+
+(function(exports) {
+var get = Ember.get, getPath = Ember.getPath, set = Ember.set;
+
+Bootstrap.TypeSupport = Ember.Mixin.create({
+ template: Ember.Handlebars.compile('{{content}}'),
+ tagName: 'span',
+ content: null,
+ typeName: null,
+ classNameBindings: 'typeClass',
+ type: null, // 'success', 'warning', 'error', 'info' || 'inverse'
+ typeClass: Ember.computed(function() {
+ var type = get(this, 'type'),
+ typeName = get(this, 'typeName');
+ return type ? typeName + '-' + type : null;
+ }).property('type').cacheable()
+});
+
+})({});
+
+
+(function(exports) {
+var get = Ember.get;
+
+Bootstrap.Badge = Ember.View.extend(Bootstrap.TypeSupport, {
+ classNames: 'badge',
+ typeName: 'badge',
+ content: null
+});
+
+})({});
+
+
+(function(exports) {
+var get = Ember.get;
+
+Bootstrap.Label = Ember.View.extend(Bootstrap.TypeSupport, {
+ classNames: 'label',
+ typeName: 'label',
+ content: null
+});
+
+})({});
+
+
+(function(exports) {
+var get = Ember.get;
+
+Bootstrap.Well = Ember.View.extend({
+ template: Ember.Handlebars.compile('{{content}}'),
+ classNames: 'well',
+ content: null
+});
+
+})({});
+
+
+(function(exports) {
+})({});
View
26 app/assets/javascripts/ember-devise-bootstrap.js.erb
@@ -0,0 +1,26 @@
+// This is a manifest file that'll be compiled into application.js.erb, which will include all the files
+// listed below.
+//
+// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
+// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
+//
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
+// GO AFTER THE REQUIRES BELOW.
+//
+//= require jquery
+//= require jquery_ujs
+//= require twitter/bootstrap
+//= require ember
+//= require ember-bootstrap.js
+//= require ember-devise-bootstrap/ember-devise-bootstrap
+//= require_self
+//= require_tree .
+
+
+EmberDeviseBootstrap.signOutPath = <%= Rails.application.routes.url_helpers.destroy_user_session_path.to_json.html_safe %>;
+EmberDeviseBootstrap.signUpPath = <%= Rails.application.routes.url_helpers.user_registration_path.to_json.html_safe %>;
+EmberDeviseBootstrap.signInPath = <%= Rails.application.routes.url_helpers.user_session_path.to_json.html_safe %>;
+EmberDeviseBootstrap.resetPasswordPath = <%= Rails.application.routes.url_helpers.user_password_path.to_json.html_safe %>;
View
40 app/assets/javascripts/ember-devise-bootstrap/controllers/password_controller.js
@@ -0,0 +1,40 @@
+EmberDeviseBootstrap.PasswordController = Ember.Object.extend({
+ email: null,
+
+ signIn: function() {
+ Base.userController.contentStates.goToState('signInContent');
+ return false;
+ },
+
+ resetPassword: function() {
+ try {
+ email = this.get('email');
+ pat = new RegExp(Devise.email_pattern);
+ if (email == null) {
+ alert('Email is required');
+ } else if ( !pat.test(email) ) {
+ alert('Email not correctly formed');
+ } else {
+ $.ajax({
+ url: EmberDeviseBootstrap.get('resetPasswordPath')+'.json',
+ type: 'POST',
+ dataType: 'json',
+ data: $.extend(authParams,{
+ 'user[email]': email}),
+ success: function(data) {
+ alert('Completed password reset request process: '+ JSON.stringify(data));
+ },
+ error: function(jqXHR, textStatus, errorThrown) {
+ alert('Error completing password reset request: '+textStatus+' error: '+errorThrown);
+ }
+ });
+ $("#sign_in_menu").removeClass('open');
+ }
+ } catch (ex) {
+ alert('Error in processing sign in request: '+ex);
+ }
+ return false;
+ }
+});
+
+EmberDeviseBootstrap.passwordController = EmberDeviseBootstrap.PasswordController.create();
View
61 app/assets/javascripts/ember-devise-bootstrap/controllers/sign_in_controller.js
@@ -0,0 +1,61 @@
+EmberDeviseBootstrap.SignInController = Ember.Object.extend({
+ email: null,
+ password: null,
+ rememberMe: false,
+
+ //
+ // This action switches the content of the sign in menu to that for
+ // forgotten password, allowing a reset email to be requested.
+ //
+ forgotPassword: function() {
+ EmberDeviseBootstrap.userController.contentStates.goToState('passwordContent');
+ return false;
+ },
+
+ //
+ // This action performs the sign in request with the provided credentials from the form.
+ //
+ signIn: function() {
+ try {
+ email = this.get('email');
+ password = this.get('password');
+ remember = this.get('rememberMe');
+ pat = new RegExp(Devise.email_pattern);
+ if (email == null) {
+ alert('Email is required');
+ } else if (password == null) {
+ alert('Password and confirmation are required');
+ } else if (password.length < Devise.password_length.min ||
+ password.length > Devise.password_length.max) {
+ alert('Password must be at lest '+Devise.password_length.min+
+ ' and shorter than '+Devise.password_length.max);
+ } else if ( !pat.test(email) ) {
+ alert('Email not correctly formed');
+ } else {
+ $.ajax({
+ url: EmberDeviseBootstrap.get('signInPath')+'.json',
+ type: 'POST',
+ dataType: 'json',
+ data: $.extend(authParams,{
+ 'user[email]': email,
+ 'user[password]': password,
+ 'user[remember_me]': remember}),
+ success: function(data) {
+ //alert('Completed sign up process: '+ JSON.stringify(data));
+ EmberDeviseBootstrap.currentUser.set('email', data.email);
+ EmberDeviseBootstrap.currentUser.set('id', data.id);
+ },
+ error: function(jqXHR, textStatus, errorThrown) {
+ alert('Error completing sign up: '+textStatus+' error: '+errorThrown);
+ }
+ });
+ $("#sign_in_menu").removeClass('open');
+ }
+ } catch (ex) {
+ alert('Error in processing sign in request: '+ex);
+ }
+ return false;
+ }
+});
+
+EmberDeviseBootstrap.signInController = EmberDeviseBootstrap.SignInController.create();
View
56 app/assets/javascripts/ember-devise-bootstrap/controllers/sign_up_controller.js
@@ -0,0 +1,56 @@
+EmberDeviseBootstrap.SignUpController = Ember.Object.extend({
+ email: null,
+ password: null,
+ passwordConfirmation: null,
+
+ //
+ // This action performs the sign up request with the provided
+ // credentials from the form.
+ //
+ signUp: function() {
+ try {
+ email = this.get('email');
+ password = this.get('password');
+ confirm = this.get('passwordConfirmation');
+ pat = new RegExp(Devise.email_pattern);
+ if (email == null) {
+ alert('Email is required');
+ } else if (password == null || confirm == null) {
+ alert('Password and confirmation are required');
+ } else if (password != confirm) {
+ alert('Password and confirmation must match');
+ } else if (password.length < Devise.password_length.min ||
+ password.length > Devise.password_length.max) {
+ alert('Password must be at least '+Devise.password_length.min+
+ ' and shorter than '+Devise.password_length.max);
+ } else if ( !pat.test(email) ) {
+ alert('Email not correctly formed');
+ } else {
+ $.ajax({
+ url: EmberDeviseBootstrap.get('signUpPath')+'.json',
+ type: 'POST',
+ dataType: 'json',
+ data: $.extend(authParams,{
+ 'user[email]': email,
+ 'user[password]': password,
+ 'user[password_confirmation]': confirm}),
+ success: function(data) {
+ //alert('Completed sign up process: '+ JSON.stringify(data));
+ EmberDeviseBootstrap.currentUser.set('email', data.email);
+ EmberDeviseBootstrap.currentUser.set('id', data.id);
+ },
+ error: function(jqXHR, textStatus, errorThrown) {
+ alert('Error completing sign up: '+textStatus+' error: '+errorThrown);
+ }
+ });
+ $("#sign_up_menu").removeClass('open');
+ }
+ } catch (ex) {
+ alert('Error in validation: '+ex);
+ }
+ return false;
+ }
+
+});
+
+EmberDeviseBootstrap.signUpController = EmberDeviseBootstrap.SignUpController.create();
View
14 app/assets/javascripts/ember-devise-bootstrap/controllers/user_controller.js
@@ -0,0 +1,14 @@
+EmberDeviseBootstrap.UserController = Ember.Object.extend({
+ currentUserBinding: "EmberDeviseBootstrap.currentUser",
+ userStates: null
+});
+
+EmberDeviseBootstrap.userController = EmberDeviseBootstrap.UserController.create();
+
+EmberDeviseBootstrap.addObserver('isSignedIn', function() {
+ if (EmberDeviseBootstrap.get('isSignedIn')) {
+ EmberDeviseBootstrap.userController.get('userStates').goToState('signedIn');
+ } else {
+ EmberDeviseBootstrap.userController.get('userStates').goToState('signedOut');
+ }
+});
View
48 app/assets/javascripts/ember-devise-bootstrap/ember-devise-bootstrap.js
@@ -0,0 +1,48 @@
+//= require_self
+//= require_tree ./templates
+//= require_tree ./models
+//= require_tree ./controllers
+//= require_tree ./views
+//= require_tree ./states
+//= require_tree ./helpers
+
+EmberDeviseBootstrap = Ember.Namespace.create({
+ version: '0.0.1',
+ currentUser: {},
+ //
+ // Property indicating if there is a signed in current user
+ //
+ isSignedIn: Ember.computed(function(key, value) {
+ if (arguments.length == 1) {
+ return typeof EmberDeviseBootstrap.get('currentUser') != 'undefined' &&
+ EmberDeviseBootstrap.getPath('currentUser.email') != null;
+ }
+ }).property('currentUser.email'),
+ //
+ // Action method to display account details,
+ // Override in applications with your own function
+ //
+ showAccount: function() {
+ $("#account_menu").removeClass('open');
+ alert('open account action TBD');
+ return false;
+ },
+ //
+ // Action to sign out the current user
+ //
+ signOut: function() {
+ jQuery.ajax({
+ url: EmberDeviseBootstrap.get('signOutPath')+'.json',
+ type: 'DELETE',
+ dataType: 'json',
+ success: function(data) {
+ EmberDeviseBootstrap.currentUser.set('email', null);
+ EmberDeviseBootstrap.currentUser.set('id', null);
+ },
+ error: function(jqXHR, textStatus, errorThrown) {
+ alert('Error completing sign out: '+textStatus+' error: '+errorThrown);
+ }
+ });
+ return false;
+ }
+});
View
0  app/assets/javascripts/ember-devise-bootstrap/helpers/.gitkeep
No changes.
View
4 app/assets/javascripts/ember-devise-bootstrap/models/user.js
@@ -0,0 +1,4 @@
+EmberDeviseBootstrap.User = Ember.Object.extend({
+ email: null,
+ id: null
+});
View
45 app/assets/javascripts/ember-devise-bootstrap/states/user_states.js
@@ -0,0 +1,45 @@
+
+//
+// This state machine tracks the user for signed in and signed out states and
+// controls the contents of the nav bar menu for account management
+//
+EmberDeviseBootstrap.userController.set('userStates', Ember.StateManager.create({
+ rootElement: '#navbar-container',
+
+ initialState: function() {
+ if (EmberDeviseBootstrap.get('isSignedIn')) {
+ return 'signedIn';
+ } else {
+ return 'signedOut';
+ }
+ }.property("EmberDeviseBootstrap.isSignedIn"),
+
+ signedOut: Ember.ViewState.create({
+ view: EmberDeviseBootstrap.SignedOutView.create({}),
+ enter: function(manager, transition) {
+ this._super(manager, transition);
+ if (typeof EmberDeviseBootstrap.getPath('userController.contentStates') !== 'undefined') {
+ EmberDeviseBootstrap.getPath('userController.contentStates').goToState('signInContent');
+ }
+ }
+ }),
+
+ signedIn: Ember.ViewState.create({
+ view: EmberDeviseBootstrap.SignedInView.create({})
+ }),
+}));
+
+//
+// This state machine tracks the content shown in the sign in drop down menu allowing
+// it to show either a sign in form or a forgot password form. Switching between the
+// content states is done in actions on the controller.
+//
+EmberDeviseBootstrap.userController.set('contentStates', Ember.StateManager.create({
+ rootView: EmberDeviseBootstrap.getPath('userController.userStates.signedOut.view'),
+ initialState: "signInContent",
+ signInContent: Ember.State.create({
+ }),
+ passwordContent: Ember.State.create({
+ })
+ })
+);
View
13 app/assets/javascripts/ember-devise-bootstrap/templates/forgot_password_form.handlebars
@@ -0,0 +1,13 @@
+<h2>Forgot your password?</h2><br>
+
+<form accept-charset="UTF-8" action="#" {{action "resetPassword" on="submit" target="EmberDeviseBootstrap.passwordController"}}
+ class="new_user" id="new_user" method="post">
+
+ {{view "Bootstrap.Forms.TextField"
+ label="email" valueBinding="EmberDeviseBootstrap.passwordController.email"}}
+
+ <div><input name="commit" type="submit" value="Send me reset password instructions"></div>
+</form>
+
+<a href="#" {{action "signIn" target="EmberDeviseBootstrap.passwordController"}}>Sign in</a>
+<a href="/users/auth/facebook">Sign in with Facebook</a><br>
View
18 app/assets/javascripts/ember-devise-bootstrap/templates/sign_in_form.handlebars
@@ -0,0 +1,18 @@
+<h2>Sign in</h2><br>
+
+<form accept-charset="UTF-8" {{action "signIn" on="submit" target="EmberDeviseBootstrap.signInController"}}
+ action="#" class="new_user" id="new_user" method="post">
+ {{view "Bootstrap.Forms.TextField"
+ label="email" valueBinding="EmberDeviseBootstrap.signInController.email"}}
+ {{view "Bootstrap.Forms.TextField" label="password"
+ valueBinding="EmberDeviseBootstrap.signInController.password"}}
+ <div style="margin-bottom: 18px">
+ <label for="rememberMe" style="display:inline-block; padding-right: 10px;">Remember Me</label>
+ {{view "Ember.Checkbox" checkedBinding="EmberDeviseBootstrap.signInController.rememberMe" name="rememberMe"}}
+ </div>
+ <div><input name="commit" type="submit" value="Sign In"></div>
+</form>
+
+<a href="#" {{action "forgotPassword" target="EmberDeviseBootstrap.signInController"}}>Forgot your password?</a>
+<a href="/users/auth/facebook">Sign in with Facebook</a>
+
View
18 app/assets/javascripts/ember-devise-bootstrap/templates/sign_up_form.handlebars
@@ -0,0 +1,18 @@
+<h2>Sign up</h2><br>
+
+<form accept-charset="UTF-8" {{action "signUp" on="submit" target="EmberDeviseBootstrap.signUpController"}}
+ action="#" class="new_user" id="new_user" method="post">
+
+ {{view "Bootstrap.Forms.TextField"
+ label="email" valueBinding="EmberDeviseBootstrap.signUpController.email"
+ bindingContextBinding="EmberDeviseBootstrap.signUpController"}}
+ {{view "Bootstrap.Forms.TextField" label="password"
+ valueBinding="EmberDeviseBootstrap.signUpController.password"}}
+ {{view "Bootstrap.Forms.TextField" label="password_confirmation"
+ valueBinding="EmberDeviseBootstrap.signUpController.passwordConfirmation"}}
+
+ <div><input name="commit" type="submit" value="Sign Up"></div>
+</form>
+
+<a href="/users/password/new">Forgot your password?</a>
+<a href="/users/auth/facebook">Sign in with Facebook</a>
View
8 app/assets/javascripts/ember-devise-bootstrap/templates/signed_in.handlebars
@@ -0,0 +1,8 @@
+<li id="account_menu" class="dropdown menu">
+ <a class="dropdown-toggle" href="#" data-toggle="dropdown">{{EmberDeviseBootstrap.currentUser.email}} <b class="caret"></b></a>
+ <ul class="dropdown-menu">
+ <li><a href="#" {{action "showAccount" target="EmberDeviseBootstrap"}}>My Account</a></li>
+ <li class="divider"></li>
+ <li><a href="#" {{action "signOut" target="EmberDeviseBootstrap"}}>Sign Out</a></li>
+ </ul>
+</li>
View
17 app/assets/javascripts/ember-devise-bootstrap/templates/signed_out.handlebars
@@ -0,0 +1,17 @@
+<li id="sign_up_menu" class="dropdown menu">
+ <a class="dropdown-toggle" href="#" data-toggle="dropdown">Sign Up <b class="caret"></b></a>
+ <div class="dropdown-menu" style="padding: 15px">
+ {{view signUpView}}
+ </div>
+</li>
+<li class="divider-vertical"></li>
+<li id="sign_in_menu" class="dropdown menu">
+ <a class="dropdown-toggle" href="#" data-toggle="dropdown">Sign In <b class="caret"></b></a>
+ <div id="sign_in_menu_content" class="dropdown-menu" style="padding: 15px">
+ {{#if isSignInContent}}
+ {{view EmberDeviseBootstrap.SignInContentView}}
+ {{else}}
+ {{view EmberDeviseBootstrap.PasswordContentView}}
+ {{/if}}
+ </div>
+</li>
View
28 app/assets/javascripts/ember-devise-bootstrap/views/user_views.js
@@ -0,0 +1,28 @@
+EmberDeviseBootstrap.SignedInView = Ember.View.extend({
+ templateName: "ember-devise-bootstrap/templates/signed_in",
+ classNames: ['inline', 'nav', 'pull-right'],
+ tagName: 'ul'
+});
+
+EmberDeviseBootstrap.SignedOutView = Ember.View.extend({
+ templateName: "ember-devise-bootstrap/templates/signed_out",
+ classNames: ['inline', 'nav', 'pull-right'],
+ tagName: 'ul',
+
+ signUpView: Ember.View.extend({
+ templateName: "ember-devise-bootstrap/templates/sign_up_form"
+ }),
+
+ isSignInContent: function() {
+ return EmberDeviseBootstrap.userController.getPath('contentStates.currentState.name') == 'signInContent';
+ }.property("EmberDeviseBootstrap.userController.contentStates.currentState.name")
+
+});
+
+EmberDeviseBootstrap.SignInContentView = Ember.View.extend({
+ templateName: "ember-devise-bootstrap/templates/sign_in_form"
+});
+
+EmberDeviseBootstrap.PasswordContentView = Ember.View.extend({
+ templateName: "ember-devise-bootstrap/templates/forgot_password_form"
+});
View
0  ...tylesheets/ember-devise-bootstrap/application.css → app/assets/stylesheets/ember-devise-bootstrap.css
File renamed without changes
View
29 app/assets/stylesheets/ember-devise-bootstrap/bootstrap_and_overrides.css.less
@@ -0,0 +1,29 @@
+@import "twitter/bootstrap/bootstrap";
+body { padding-top: 60px; }
+
+@import "twitter/bootstrap/responsive";
+
+// Set the correct sprite paths
+@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
+@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');
+
+// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
+@fontAwesomeEotPath: asset-path('fontawesome-webfont.eot');
+@fontAwesomeWoffPath: asset-path('fontawesome-webfont.woff');
+@fontAwesomeTtfPath: asset-path('fontawesome-webfont.ttf');
+@fontAwesomeSvgzPath: asset-path('fontawesome-webfont.svgz');
+@fontAwesomeSvgPath: asset-path('fontawesome-webfont.svg');
+
+// Font Awesome
+@import "fontawesome";
+
+// Your custom LESS stylesheets goes here
+//
+// Since bootstrap was imported above you have access to its mixins which
+// you may use and inherit here
+//
+// If you'd like to override bootstrap's own variables, you can do so here as well
+// See http://twitter.github.com/bootstrap/less.html for their names and documentation
+//
+// Example:
+// @linkColor: #ff0000;
View
4 app/controllers/ember-devise-bootstrap/app_controller.rb
@@ -0,0 +1,4 @@
+module EmberDeviseBootstrap
+ class AppController < ::ApplicationController
+ end
+end
View
4 app/controllers/ember-devise-bootstrap/application_controller.rb
@@ -1,4 +0,0 @@
-module EmberDeviseBootstrap
- class ApplicationController < ActionController::Base
- end
-end
View
12 app/views/devise/confirmations/new.html.erb
@@ -0,0 +1,12 @@
+<h2>Resend confirmation instructions</h2>
+
+<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
+ <%= devise_error_messages! %>
+
+ <div><%= f.label :email %><br />
+ <%= f.email_field :email %></div>
+
+ <div><%= f.submit "Resend confirmation instructions" %></div>
+<% end %>
+
+<%= render :partial => "devise/shared/links" %>
View
5 app/views/devise/mailer/confirmation_instructions.html.erb
@@ -0,0 +1,5 @@
+<p>Welcome <%= @resource.email %>!</p>
+
+<p>You can confirm your account email through the link below:</p>
+
+<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
View
8 app/views/devise/mailer/reset_password_instructions.html.erb
@@ -0,0 +1,8 @@
+<p>Hello <%= @resource.email %>!</p>
+
+<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
+
+<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
+
+<p>If you didn't request this, please ignore this email.</p>
+<p>Your password won't change until you access the link above and create a new one.</p>
View
7 app/views/devise/mailer/unlock_instructions.html.erb
@@ -0,0 +1,7 @@
+<p>Hello <%= @resource.email %>!</p>
+
+<p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
+
+<p>Click the link below to unlock your account:</p>
+
+<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
View
16 app/views/devise/passwords/edit.html.erb
@@ -0,0 +1,16 @@
+<h2>Change your password</h2>
+
+<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
+ <%= devise_error_messages! %>
+ <%= f.hidden_field :reset_password_token %>
+
+ <div><%= f.label :password, "New password" %><br />
+ <%= f.password_field :password %></div>
+
+ <div><%= f.label :password_confirmation, "Confirm new password" %><br />
+ <%= f.password_field :password_confirmation %></div>
+
+ <div><%= f.submit "Change my password" %></div>
+<% end %>
+
+<%= render :partial => "devise/shared/links" %>
View
12 app/views/devise/passwords/new.html.erb
@@ -0,0 +1,12 @@
+<h2>Forgot your password?</h2>
+
+<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
+ <%= devise_error_messages! %>
+
+ <div><%= f.label :email %><br />
+ <%= f.email_field :email %></div>
+
+ <div><%= f.submit "Send me reset password instructions" %></div>
+<% end %>
+
+<%= render :partial => "devise/shared/links" %>
View
1  app/views/devise/registrations/create.json.erb
@@ -0,0 +1 @@
+<%= @user.as_json.to_json.html_safe %>
View
25 app/views/devise/registrations/edit.html.erb
@@ -0,0 +1,25 @@
+<h2>Edit <%= resource_name.to_s.humanize %></h2>
+
+<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
+ <%= devise_error_messages! %>
+
+ <div><%= f.label :email %><br />
+ <%= f.email_field :email %></div>
+
+ <div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
+ <%= f.password_field :password, :autocomplete => "off" %></div>
+
+ <div><%= f.label :password_confirmation %><br />
+ <%= f.password_field :password_confirmation %></div>
+
+ <div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
+ <%= f.password_field :current_password %></div>
+
+ <div><%= f.submit "Update" %></div>
+<% end %>
+
+<h3>Cancel my account</h3>
+
+<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
+
+<%= link_to "Back", :back %>
View
18 app/views/devise/registrations/new.html.erb
@@ -0,0 +1,18 @@
+<h2>Sign up</h2>
+
+<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
+ <%= devise_error_messages! %>
+
+ <div><%= f.label :email %><br />
+ <%= f.email_field :email %></div>
+
+ <div><%= f.label :password %><br />
+ <%= f.password_field :password %></div>
+
+ <div><%= f.label :password_confirmation %><br />
+ <%= f.password_field :password_confirmation %></div>
+
+ <div><%= f.submit "Sign up" %></div>
+<% end %>
+
+<%= render :partial => "devise/shared/links" %>
View
17 app/views/devise/sessions/new.html.erb
@@ -0,0 +1,17 @@
+<h2>Sign in</h2>
+
+<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
+ <div><%= f.label :email %><br />
+ <%= f.email_field :email %></div>
+
+ <div><%= f.label :password %><br />
+ <%= f.password_field :password %></div>
+
+ <% if devise_mapping.rememberable? -%>
+ <div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
+ <% end -%>
+
+ <div><%= f.submit "Sign in" %></div>
+<% end %>
+
+<%= render :partial => "devise/shared/links" %>
View
25 app/views/devise/shared/_links.erb
@@ -0,0 +1,25 @@
+<%- if controller_name != 'sessions' %>
+ <%= link_to "Sign in", new_session_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
+ <%= link_to "Sign up", new_registration_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
+ <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
+<% end -%>
+
+<%- if devise_mapping.omniauthable? %>
+ <%- resource_class.omniauth_providers.each do |provider| %>
+ <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
+ <% end -%>
+<% end -%>
View
12 app/views/devise/unlocks/new.html.erb
@@ -0,0 +1,12 @@
+<h2>Resend unlock instructions</h2>
+
+<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
+ <%= devise_error_messages! %>
+
+ <div><%= f.label :email %><br />
+ <%= f.email_field :email %></div>
+
+ <div><%= f.submit "Resend unlock instructions" %></div>
+<% end %>
+
+<%= render :partial => "devise/shared/links" %>
View
8 config/cucumber.yml
@@ -0,0 +1,8 @@
+<%
+rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
+rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
+std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
+%>
+default: <%= std_opts %> features
+wip: --tags @wip:3 --wip features
+rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
View
3  ember-devise-bootstrap.gemspec
@@ -19,6 +19,9 @@ Gem::Specification.new do |s|
s.add_dependency "rails", ">= 3.2.6"
s.add_dependency "ember-rails"
s.add_dependency "twitter-bootstrap-rails"
+ s.add_dependency "devise"
+ s.add_dependency "omniauth"
+ s.add_dependency "omniauth-facebook"
s.add_development_dependency "sqlite3"
end
View
47 features/sign_in_out.feature
@@ -0,0 +1,47 @@
+
+Feature: Users should be able to sign in and out of the system as well as create accounts by signing up for one, and be able to use facebook to sign in and to sign up
+
+ Background:
+ Given no session
+
+ @javascript
+ Scenario: Sign up for an account
+ Given no users are defined
+ And I am on the home page
+ When I open the sign up form
+ And enter credentials for a new account
+ Then I should see the home page without a sign up form showing
+ And I should be able to sign in with the new account
+
+ @javascript
+ Scenario: Sign in using facebook when not already signed in to facebook
+ Given I am not signed in to facebook
+ And I am on the home page
+ When I elect to sign in using facebook
+ Then I should see the facebook sign in page
+ When I enter facebook credentials
+ Then I should see the home page without a sign in form showing
+ And I should be signed into the facebook account for this app
+
+ @javascript
+ Scenario: Sign in using facebook when already signed in to facebook
+ Given I am signed in to facebook
+ Given I am on the home page
+ When I elect to sign in using facebook
+ Then I should see the home page without a sign in form showing
+ And I should be signed into the facebook account for this app
+
+ @javascript
+ Scenario: Request a password reset
+
+ @javascript
+ Scenario: Remember a login across sessions
+
+ # Cases that should fail
+
+ @javascript
+ Scenario: Sign in with a bad email
+
+ @javascript
+ Scenario: Sign in with a bad password
+
View
22 features/step_definitions/basic_steps.rb
@@ -0,0 +1,22 @@
+require "net/http"
+require "uri"
+
+Given /^no session$/ do
+ Capybara.reset_sessions!
+ begin
+ uri = URI.parse("http://localhost:#{Capybara.server_port}")
+ http = Net::HTTP.new(uri.host, uri.port)
+ request = Net::HTTP::Delete.new(destroy_user_session_path)
+ response = http.request(request)
+ rescue => e
+ end
+end
+
+Given /^I am on the home page$/ do
+ visit '/'
+end
+
+When /^sleep (\d+)$/ do | n |
+ sleep n.to_i
+end
+
View
80 features/step_definitions/sign_in_out_steps.rb
@@ -0,0 +1,80 @@
+
+
+Given /^I am not signed in to facebook$/ do
+ visit 'http://www.facebook.com'
+ if page.has_selector?("#userNavigationLabel")
+ acct_menu = page.find("#userNavigationLabel")
+ acct_menu.click
+ click_button "Log Out"
+ end
+end
+
+Given /^I am signed in to facebook$/ do
+ step %Q{I am not signed in to facebook}
+ visit 'http://www.facebook.com'
+ page.find('#email').set(ENV['facebook_user'])
+ page.find('#pass').set(ENV['facebook_pass'])
+ click_button 'Log In'
+end
+
+When /^I elect to sign in using facebook$/ do
+ page.find('li#sign_in_menu a').click
+ click_link "Sign in with Facebook"
+end
+
+Then /^I should see the home page without a sign in form showing$/ do
+ page.should have_no_selector(:css, "#sign_in_menu_content")
+end
+
+When /^I should be signed into the facebook account for this app$/ do
+ #page.should have_selector(:xpath, "//li[id()='account_menu']/a[contains(text(),'#{ENV['facebook_user']}')]")
+ within "#account_menu a" do
+ page.should have_content(ENV['facebook_user'])
+ end
+end
+
+# Facebook dependent steps, if they change their pages these could break
+
+Then /^I should see the facebook sign in page$/ do
+ page.should have_selector(:css, "html#facebook")
+ page.should have_selector(:css, "input#email")
+ page.should have_selector(:css, "input#pass")
+end
+
+When /^I enter facebook credentials$/ do
+ page.find("#email").set(ENV['facebook_user'])
+ page.find('#pass').set(ENV['facebook_pass'])
+ click_button 'Log In'
+end
+
+When /^I open the sign up form$/ do
+ page.find('li#sign_up_menu a').click
+end
+
+When /^enter credentials for a new account$/ do
+ fill_in "email", :with => "user1@test.com"
+ fill_in "password", :with => "password"
+ fill_in "password_confirmation", :with => "password"
+ click_button "Sign Up"
+end
+
+Given /^no users are defined$/ do
+ User.delete_all
+end
+
+Then /^I should see the home page without a sign up form showing$/ do
+ page.should have_no_selector(:css, "#sign_up_menu_content")
+end
+
+When /^I should be able to sign in with the new account$/ do
+ sleep 2
+ page.find('li#account_menu a').click
+ click_link 'Sign Out'
+ page.find('li#sign_in_menu a').click
+ sleep 2
+ fill_in "email", :with => "user1@test.com"
+ fill_in "password", :with => "password"
+ click_button "Sign In"
+ step "I should see the home page without a sign in form showing"
+end
+
View
75 features/support/env.rb
@@ -0,0 +1,75 @@
+
+ENV["RAILS_ENV"] ||= "test"
+ENV["RAILS_ROOT"] = File.expand_path("../../../test/dummy", __FILE__)
+require File.expand_path("../../../test/dummy/config/boot.rb", __FILE__)
+require File.expand_path("../../../test/dummy/config/environment.rb", __FILE__)
+
+# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
+# It is recommended to regenerate this file in the future when you upgrade to a
+# newer version of cucumber-rails. Consider adding your own code to a new file
+# instead of editing this one. Cucumber will automatically load all features/**/*.rb
+# files.
+
+require 'cucumber/rails'
+
+# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
+# order to ease the transition to Capybara we set the default here. If you'd
+# prefer to use XPath just remove this line and adjust any selectors in your
+# steps to use the XPath syntax.
+Capybara.default_selector = :css
+
+require 'cucumber/formatter/pretty'
+class Pretty2 < Cucumber::Formatter::Pretty
+ def before_step step
+ Rails.logger.debug "\n\n@@@@\n@@@@ Step: #{step.name}\n@@@@\n\n"
+ end
+end
+
+# set default port
+Capybara.server_port = 5555
+
+# By default, any exception happening in your Rails application will bubble up
+# to Cucumber so that your scenario will fail. This is a different from how
+# your application behaves in the production environment, where an error page will
+# be rendered instead.
+#
+# Sometimes we want to override this default behaviour and allow Rails to rescue
+# exceptions and display an error page (just like when the app is running in production).
+# Typical scenarios where you want to do this is when you test your error pages.
+# There are two ways to allow Rails to rescue exceptions:
+#
+# 1) Tag your scenario (or feature) with @allow-rescue
+#
+# 2) Set the value below to true. Beware that doing this globally is not
+# recommended as it will mask a lot of errors for you!
+#
+ActionController::Base.allow_rescue = false
+
+# Remove/comment out the lines below if your app doesn't have a database.
+# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
+begin
+ DatabaseCleaner.strategy = :transaction
+rescue NameError
+ raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
+end
+
+# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
+# See the DatabaseCleaner documentation for details. Example:
+#
+# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
+# # { :except => [:widgets] } may not do what you expect here
+# # as tCucumber::Rails::Database.javascript_strategy overrides
+# # this setting.
+# DatabaseCleaner.strategy = :truncation
+# end
+#
+# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
+# DatabaseCleaner.strategy = :transaction
+# end
+#
+
+# Possible values are :truncation and :transaction
+# The :transaction strategy is faster, but might give you threading problems.
+# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
+Cucumber::Rails::Database.javascript_strategy = :truncation
+
View
65 lib/tasks/cucumber.rake
@@ -0,0 +1,65 @@
+# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
+# It is recommended to regenerate this file in the future when you upgrade to a
+# newer version of cucumber-rails. Consider adding your own code to a new file
+# instead of editing this one. Cucumber will automatically load all features/**/*.rb
+# files.
+
+
+unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
+
+vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
+$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
+
+begin
+ require 'cucumber/rake/task'
+
+ namespace :cucumber do
+ Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
+ t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
+ t.fork = true # You may get faster startup if you set this to false
+ t.profile = 'default'
+ end
+
+ Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
+ t.binary = vendored_cucumber_bin
+ t.fork = true # You may get faster startup if you set this to false
+ t.profile = 'wip'
+ end
+
+ Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
+ t.binary = vendored_cucumber_bin
+ t.fork = true # You may get faster startup if you set this to false
+ t.profile = 'rerun'
+ end
+
+ desc 'Run all features'
+ task :all => [:ok, :wip]
+
+ task :statsetup do
+ require 'rails/code_statistics'
+ ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
+ ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
+ end
+ end
+ desc 'Alias for cucumber:ok'
+ task :cucumber => 'cucumber:ok'
+
+ task :default => :cucumber
+
+ task :features => :cucumber do
+ STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
+ end
+
+ # In case we don't have ActiveRecord, append a no-op task that we can depend upon.
+ task 'db:test:prepare' do
+ end
+
+ task :stats => 'cucumber:statsetup'
+rescue LoadError
+ desc 'cucumber rake task not available (cucumber not installed)'
+ task :cucumber do
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
+ end
+end
+
+end
View
10 script/cucumber
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+
+vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
+if vendored_cucumber_bin
+ load File.expand_path(vendored_cucumber_bin)
+else
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
+ require 'cucumber'
+ load Cucumber::BINARY
+end
View
263 test/dummy/README.rdoc
@@ -1,261 +1,2 @@
-== Welcome to Rails
-
-Rails is a web-application framework that includes everything needed to create
-database-backed web applications according to the Model-View-Control pattern.
-
-This pattern splits the view (also called the presentation) into "dumb"
-templates that are primarily responsible for inserting pre-built data in between
-HTML tags. The model contains the "smart" domain objects (such as Account,
-Product, Person, Post) that holds all the business logic and knows how to
-persist themselves to a database. The controller handles the incoming requests
-(such as Save New Account, Update Product, Show Post) by manipulating the model
-and directing data to the view.
-
-In Rails, the model is handled by what's called an object-relational mapping
-layer entitled Active Record. This layer allows you to present the data from
-database rows as objects and embellish these data objects with business logic
-methods. You can read more about Active Record in
-link:files/vendor/rails/activerecord/README.html.
-
-The controller and view are handled by the Action Pack, which handles both
-layers by its two parts: Action View and Action Controller. These two layers
-are bundled in a single package due to their heavy interdependence. This is
-unlike the relationship between the Active Record and Action Pack that is much
-more separate. Each of these packages can be used independently outside of
-Rails. You can read more about Action Pack in
-link:files/vendor/rails/actionpack/README.html.
-
-
-== Getting Started
-
-1. At the command prompt, create a new Rails application:
- <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
-
-2. Change directory to <tt>myapp</tt> and start the web server:
- <tt>cd myapp; rails server</tt> (run with --help for options)
-
-3. Go to http://localhost:3000/ and you'll see:
- "Welcome aboard: You're riding Ruby on Rails!"
-
-4. Follow the guidelines to start developing your application. You can find
-the following resources handy:
-
-* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
-* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
-
-
-== Debugging Rails
-
-Sometimes your application goes wrong. Fortunately there are a lot of tools that
-will help you debug it and get it back on the rails.
-
-First area to check is the application log files. Have "tail -f" commands
-running on the server.log and development.log. Rails will automatically display
-debugging and runtime information to these files. Debugging info will also be
-shown in the browser on requests from 127.0.0.1.
-
-You can also log your own messages directly into the log file from your code
-using the Ruby logger class from inside your controllers. Example:
-
- class WeblogController < ActionController::Base
- def destroy
- @weblog = Weblog.find(params[:id])
- @weblog.destroy
- logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
- end
- end
-
-The result will be a message in your log file along the lines of:
-
- Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
-
-More information on how to use the logger is at http://www.ruby-doc.org/core/
-
-Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
-several books available online as well:
-
-* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
-* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
-
-These two books will bring you up to speed on the Ruby language and also on
-programming in general.
-
-
-== Debugger
-
-Debugger support is available through the debugger command when you start your
-Mongrel or WEBrick server with --debugger. This means that you can break out of
-execution at any point in the code, investigate and change the model, and then,
-resume execution! You need to install ruby-debug to run the server in debugging
-mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
-
- class WeblogController < ActionController::Base
- def index
- @posts = Post.all
- debugger
- end
- end
-
-So the controller will accept the action, run the first line, then present you
-with a IRB prompt in the server window. Here you can do things like:
-
- >> @posts.inspect
- => "[#<Post:0x14a6be8
- @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
- #<Post:0x14a6620
- @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
- >> @posts.first.title = "hello from a debugger"
- => "hello from a debugger"
-
-...and even better, you can examine how your runtime objects actually work:
-
- >> f = @posts.first
- => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
- >> f.
- Display all 152 possibilities? (y or n)
-
-Finally, when you're ready to resume execution, you can enter "cont".
-
-
-== Console
-
-The console is a Ruby shell, which allows you to interact with your
-application's domain model. Here you'll have all parts of the application
-configured, just like it is when the application is running. You can inspect
-domain models, change values, and save to the database. Starting the script
-without arguments will launch it in the development environment.
-
-To start the console, run <tt>rails console</tt> from the application
-directory.
-
-Options:
-
-* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
- made to the database.
-* Passing an environment name as an argument will load the corresponding
- environment. Example: <tt>rails console production</tt>.
-
-To reload your controllers and models after launching the console run
-<tt>reload!</tt>
-
-More information about irb can be found at:
-link:http://www.rubycentral.org/pickaxe/irb.html
-
-
-== dbconsole
-
-You can go to the command line of your database directly through <tt>rails
-dbconsole</tt>. You would be connected to the database with the credentials
-defined in database.yml. Starting the script without arguments will connect you
-to the development database. Passing an argument will connect you to a different
-database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
-PostgreSQL and SQLite 3.
-
-== Description of Contents
-
-The default directory structure of a generated Ruby on Rails application:
-
- |-- app
- | |-- assets
- | |-- images
- | |-- javascripts
- | `-- stylesheets
- | |-- controllers
- | |-- helpers
- | |-- mailers
- | |-- models
- | `-- views
- | `-- layouts
- |-- config
- | |-- environments
- | |-- initializers
- | `-- locales
- |-- db
- |-- doc
- |-- lib
- | `-- tasks
- |-- log
- |-- public
- |-- script
- |-- test
- | |-- fixtures
- | |-- functional
- | |-- integration
- | |-- performance
- | `-- unit
- |-- tmp
- | |-- cache
- | |-- pids
- | |-- sessions
- | `-- sockets
- `-- vendor
- |-- assets
- `-- stylesheets
- `-- plugins
-
-app
- Holds all the code that's specific to this particular application.
-
-app/assets
- Contains subdirectories for images, stylesheets, and JavaScript files.
-
-app/controllers
- Holds controllers that should be named like weblogs_controller.rb for
- automated URL mapping. All controllers should descend from
- ApplicationController which itself descends from ActionController::Base.
-
-app/models
- Holds models that should be named like post.rb. Models descend from
- ActiveRecord::Base by default.
-
-app/views
- Holds the template files for the view that should be named like
- weblogs/index.html.erb for the WeblogsController#index action. All views use
- eRuby syntax by default.
-
-app/views/layouts
- Holds the template files for layouts to be used with views. This models the
- common header/footer method of wrapping views. In your views, define a layout
- using the <tt>layout :default</tt> and create a file named default.html.erb.
- Inside default.html.erb, call <% yield %> to render the view using this
- layout.
-
-app/helpers
- Holds view helpers that should be named like weblogs_helper.rb. These are
- generated for you automatically when using generators for controllers.
- Helpers can be used to wrap functionality for your views into methods.
-
-config
- Configuration files for the Rails environment, the routing map, the database,
- and other dependencies.
-
-db
- Contains the database schema in schema.rb. db/migrate contains all the
- sequence of Migrations for your schema.
-
-doc
- This directory is where your application documentation will be stored when
- generated using <tt>rake doc:app</tt>
-
-lib
- Application specific libraries. Basically, any kind of custom code that
- doesn't belong under controllers, models, or helpers. This directory is in
- the load path.
-
-public
- The directory available for the web server. Also contains the dispatchers and the
- default HTML files. This should be set as the DOCUMENT_ROOT of your web
- server.
-
-script
- Helper scripts for automation and generation.
-
-test
- Unit and functional tests along with fixtures. When using the rails generate
- command, template test files will be generated for you and placed in this
- directory.
-
-vendor
- External libraries that the application depends on. Also includes the plugins
- subdirectory. If the app has frozen rails, those gems also go here, under
- vendor/rails/. This directory is in the load path.
+== Dummy
+This app is a dummy app for testing of the engine.
View
15 test/dummy/app/assets/javascripts/application.js
@@ -1,15 +0,0 @@
-// This is a manifest file that'll be compiled into application.js, which will include all the files
-// listed below.
-//
-// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
-// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
-//
-// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
-// the compiled file.
-//
-// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
-// GO AFTER THE REQUIRES BELOW.
-//
-//= require jquery
-//= require jquery_ujs
-//= require_tree .
View
27 ...javascripts/ember-devise-bootstrap/application.js → test/dummy/app/assets/javascripts/application.js.erb
@@ -10,6 +10,29 @@
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
-//= require jquery
-//= require jquery_ujs
+//= require ember-devise-bootstrap
+//= require_self
//= require_tree .
+
+Dummy = Ember.Application.create({
+ version: '0.0.1'
+});
+
+Dummy.NavController = Ember.Object.extend({
+ navView: Bootstrap.NavList.create({
+ itemTitleKey: 'title',
+ itemValueKey: 'value',
+ contentBinding: "Dummy.navController.pages",
+ selectionBinding: "Dummy.navController.selection"
+ })
+});
+
+Dummy.set('navController', Dummy.NavController.create({
+ pages: [],
+ selection: null,
+}) );
+
+
+jQuery(function() {
+ Dummy.navController.get('navView').appendTo('#nav_container')
+})
View
1  test/dummy/app/assets/stylesheets/application.css
@@ -10,4 +10,5 @@
*
*= require_self
*= require_tree .
+ *= require ember-devise-bootstrap.css
*/
View
4 test/dummy/app/controllers/application_controller.rb
@@ -1,3 +1,7 @@
class ApplicationController < ActionController::Base
protect_from_forgery
+
+ def index
+
+ end
end
View
14 test/dummy/app/controllers/users/omniauth_callbacks_controller.rb
@@ -0,0 +1,14 @@
+class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
+ def facebook
+ # You need to implement the method below in your model
+ @user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)
+
+ if @user.persisted?
+ flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook"
+ sign_in_and_redirect @user, :event => :authentication
+ else
+ session["devise.facebook_data"] = request.env["omniauth.auth"]
+ redirect_to new_user_registration_url
+ end
+ end
+end
View
29 test/dummy/app/models/user.rb
@@ -0,0 +1,29 @@
+class User < ActiveRecord::Base
+ # Include default devise modules. Others available are:
+ # :token_authenticatable, :confirmable,
+ # :lockable, :timeoutable and :omniauthable
+ devise :database_authenticatable, :registerable, :omniauthable,
+ :recoverable, :rememberable, :trackable, :validatable
+
+ # Setup accessible (or protected) attributes for your model
+ attr_accessible :email, :password, :password_confirmation, :remember_me
+ # attr_accessible :title, :body
+
+ # Method to find users based on oauth information
+ def self.find_for_facebook_oauth(access_token, signed_in_resource=nil)
+ data = access_token.extra.raw_info
+ if user = self.find_by_email(data.email)
+ user
+ else # Create a user with a stub password.
+ self.create(:email => data.email, :password => Devise.friendly_token[0,20])
+ end
+ end
+
+ def self.new_with_session(params, session)
+ super.tap do |user|
+ if data = session["devise.facebook_data"] && session["devise.facebook_data"]["extra"]["raw_info"]
+ user.email = data["email"]
+ end
+ end
+ end
+end
View
2  test/dummy/app/views/application/index.html.erb
@@ -0,0 +1,2 @@
+<h1>Index</h1>
+The index action in the application controller for testing the engine
View
27 test/dummy/app/views/layouts/application.html.erb
@@ -3,12 +3,39 @@
<head>
<title>Dummy</title>
<%= stylesheet_link_tag "application", :media => "all" %>
+ <script type="text/javascript">
+ ENV = {VIEW_PRESERVES_CONTEXT: true, CP_DEFAULT_CACHEABLE: true};
+ authParams = {'authenticity_token':'<%= form_authenticity_token %>'};
+ Devise = {
+ password_length: {min:<%= Devise.password_length.min.to_json.html_safe %>,
+ max:<%= Devise.password_length.max.to_json.html_safe %>},
+ email_pattern: <%= '^[^@]+@[^@]+$'.to_json.html_safe %>
+ }
+ </script>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
+<div class="navbar navbar-fixed-top">
+ <div class="navbar-inner">
+ <div id="navbar-container" class="container-fluid">
+ <a class="brand" href="/">EmberDeviseBootstrap</a>
+ <div id="nav_container" class="container-fluid nav-collapse" style="display: inline-block">
+ </div><!--/.nav-collapse -->
+ </div>
+ </div>
+</div>
<%= yield %>
+<script type="text/javascript">
+ jQuery(function() {
+ EmberDeviseBootstrap.set('currentUser', EmberDeviseBootstrap.User.create({
+ email: <%= (current_user.email rescue nil).to_json.html_safe %>,
+ id: <%= (current_user.id rescue nil).to_json.html_safe %>
+ }));
+ })
+</script>
+
</body>
</html>
View
4 test/dummy/config/application.rb
@@ -4,6 +4,7 @@
Bundler.require
require "ember-devise-bootstrap"
+require 'ember-rails'
module Dummy
class Application < Rails::Application
@@ -54,6 +55,9 @@ class Application < Rails::Application
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
+
+ # Configure the ember variant
+ config.ember.variant = 'development'
end
end
View
4 test/dummy/config/boot.rb
@@ -5,6 +5,8 @@
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
+else
+ Rails.logger.error "Gemfile not found"
end
-$:.unshift File.expand_path('../../../../lib', __FILE__)
+$:.unshift File.expand_path('../../../../lib', __FILE__)
View
222 test/dummy/config/initializers/devise.rb
@@ -0,0 +1,222 @@
+# Use this hook to configure devise mailer, warden hooks and so forth.
+# Many of these configuration options can be set straight in your model.
+Devise.setup do |config|
+ # ==> Mailer Configuration
+ # Configure the e-mail address which will be shown in Devise::Mailer,
+ # note that it will be overwritten if you use your own mailer class with default "from" parameter.
+ config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
+
+ # Configure the class responsible to send e-mails.
+ # config.mailer = "Devise::Mailer"
+
+ # ==> ORM configuration
+ # Load and configure the ORM. Supports :active_record (default) and
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
+ # available as additional gems.
+ require 'devise/orm/active_record'
+
+ # ==> Configuration for any authentication mechanism
+ # Configure which keys are used when authenticating a user. The default is
+ # just :email. You can configure it to use [:username, :subdomain], so for
+ # authenticating a user, both parameters are required. Remember that those
+ # parameters are used only when authenticating and not when retrieving from
+ # session. If you need permissions, you should implement that in a before filter.
+ # You can also supply a hash where the value is a boolean determining whether
+ # or not authentication should be aborted when the value is not present.
+ # config.authentication_keys = [ :email ]
+
+ # Configure parameters from the request object used for authentication. Each entry
+ # given should be a request method and it will automatically be passed to the
+ # find_for_authentication method and considered in your model lookup. For instance,
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
+ # config.request_keys = []
+
+ # Configure which authentication keys should be case-insensitive.
+ # These keys will be downcased upon creating or modifying a user and when used
+ # to authenticate or find a user. Default is :email.
+ config.case_insensitive_keys = [ :email ]
+
+ # Configure which authentication keys should have whitespace stripped.
+ # These keys will have whitespace before and after removed upon creating or
+ # modifying a user and when used to authenticate or find a user. Default is :email.
+ config.strip_whitespace_keys = [ :email ]
+
+ # Tell if authentication through request.params is enabled. True by default.
+ # It can be set to an array that will enable params authentication only for the
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
+ # enable it only for database (email + password) authentication.
+ # config.params_authenticatable = true
+
+ # Tell if authentication through HTTP Basic Auth is enabled. False by default.
+ # It can be set to an array that will enable http authentication only for the
+ # given strategies, for example, `config.http_authenticatable = [:token]` will
+ # enable it only for token authentication.
+ # config.http_authenticatable = false
+
+ # If http headers should be returned for AJAX requests. True by default.
+ # config.http_authenticatable_on_xhr = true
+
+ # The realm used in Http Basic Authentication. "Application" by default.
+ # config.http_authentication_realm = "Application"
+
+ # It will change confirmation, password recovery and other workflows
+ # to behave the same regardless if the e-mail provided was right or wrong.
+ # Does not affect registerable.
+ # config.paranoid = true
+
+ # By default Devise will store the user in session. You can skip storage for
+ # :http_auth and :token_auth by adding those symbols to the array below.
+ # Notice that if you are skipping storage for all authentication paths, you
+ # may want to disable generating routes to Devise's sessions controller by
+ # passing :skip => :sessions to `devise_for` in your config/routes.rb
+ config.skip_session_storage = [:http_auth]
+
+ # ==> Configuration for :database_authenticatable
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
+ # using other encryptors, it sets how many times you want the password re-encrypted.
+ #
+ # Limiting the stretches to just one in testing will increase the performance of