Permalink
Browse files

added refinery support

  • Loading branch information...
1 parent b307146 commit 5e43ab1781db8c037e51cbd80e3c32b46d29fe37 @dickeyxxx committed Dec 13, 2011
View
@@ -12,7 +12,13 @@ PATH
remote: .
specs:
messaging (0.0.1)
+ carrierwave
+ devise
+ haml
+ jquery-rails
rails (~> 3.1.3)
+ simple_form
+ sunspot_rails
GEM
remote: http://rubygems.org/
@@ -1,4 +1,9 @@
module Messaging
class ApplicationController < ActionController::Base
+ before_filter :authenticate_messaging_user!
+
+ def current_user
+ current_messaging_user
+ end
end
end
@@ -1,5 +1,5 @@
module Messaging
- class MessagesController < ApplicationController
+ class MessagesController < Messaging::ApplicationController
def index
@box = params[:box] || 'inbox'
@messages = current_user.mailbox.inbox if @box == 'inbox'
@@ -28,7 +28,7 @@ def recipients
def recipients=(string='')
@recipient_list = []
string.split(',').each do |s|
- @recipient_list << User.find_by_email!(s.strip) unless s.blank?
+ @recipient_list << MessagingUser.find_by_email!(s.strip) unless s.blank?
end
end
end
@@ -27,7 +27,7 @@
.container_12
.grid_12
%h1 Messaging
- = link_to "Sign out", '/users/sign_out', method: :delete, class: 'sign-out'
+ = link_to "Sign out", '/messaging_users/sign_out', method: :delete, class: 'sign-out'
- if notice
#notice
.container_12
@@ -2,7 +2,7 @@
#compose
= simple_form_for @message do |f|
= f.label :recipients, required: false
- = f.input_field :recipients, data: { autocomplete_source: User.all.map(&:name) }
+ = f.input_field :recipients, data: { autocomplete_source: MessagingUser.all.map(&:name) }
= f.label :subject, required: false
= f.input_field :subject
= f.label :body, required: false
@@ -1,5 +1,5 @@
#actions
- - if @conversation.is_trashed?(current_user)
+ - if @conversation.is_trashed?(current_messaging_user)
= link_to "Untrash", untrash_message_path(@conversation), class: :button, method: :post
- else
= link_to "Trash", trash_message_path(@conversation), class: :button, method: :delete
@@ -0,0 +1,34 @@
+module Messaging
+ module Generators
+ class DeviseGenerator < Rails::Generators::NamedBase
+ desc "Uses Devise for authentication"
+
+ argument :name, :type => :string, :default => "MessagingUser"
+
+
+ def self.source_root
+ @_messaging_source_root ||= File.expand_path("../templates", __FILE__)
+ end
+
+ def install_devise
+ require 'devise'
+ if File.exists?(File.join(destination_root, "config", "initializers", "devise.rb"))
+ log :generate, "No need to install devise, already done."
+ else
+ log :generate, "devise:install"
+ invoke "devise:install"
+ end
+ end
+
+ def create_user
+ invoke "devise", [name]
+ end
+
+ def copy_model
+ template 'messaging_user.rb.erb', 'app/models/messaging_user.rb'
+ end
+
+ end
+ end
+end
+
@@ -0,0 +1,23 @@
+class MessagingUser < ActiveRecord::Base
+ # Include default devise modules. Others available are:
+ # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
+ devise :database_authenticatable, :registerable,
+ :recoverable, :rememberable, :trackable, :validatable
+
+ # Setup accessible (or protected) attributes for your model
+ attr_accessible :email, :password, :password_confirmation, :remember_me
+
+ acts_as_messageable
+
+ def name
+ self.to_s
+ end
+
+ def mailboxer_email(message)
+ email
+ end
+
+ def to_s
+ email
+ end
+end
@@ -0,0 +1,8 @@
+class Messaging::InstallGenerator < Rails::Generators::Base #:nodoc:
+
+ hook_for :users, :default => "devise", :desc => "User generator to run. Skip with --skip-users"
+
+ def create_migration_file
+ generate 'mailboxer:install'
+ end
+end
View
@@ -1,4 +1,8 @@
require "messaging/engine"
+require 'haml'
+require 'carrierwave'
+require 'sunspot_rails'
+require 'simple_form'
module Messaging
end
View
@@ -17,7 +17,12 @@ Gem::Specification.new do |s|
s.test_files = Dir["test/**/*"]
s.add_dependency "rails", "~> 3.1.3"
- # s.add_dependency "jquery-rails"
+ s.add_dependency "devise"
+ s.add_dependency "simple_form"
+ s.add_dependency "carrierwave"
+ s.add_dependency "sunspot_rails"
+ s.add_dependency "jquery-rails"
+ s.add_dependency "haml"
s.add_development_dependency "sqlite3"
end
@@ -0,0 +1,23 @@
+class MessagingUser < ActiveRecord::Base
+ # Include default devise modules. Others available are:
+ # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
+ devise :database_authenticatable, :registerable,
+ :recoverable, :rememberable, :trackable, :validatable
+
+ # Setup accessible (or protected) attributes for your model
+ attr_accessible :email, :password, :password_confirmation, :remember_me
+
+ acts_as_messageable
+
+ def name
+ self.to_s
+ end
+
+ def mailboxer_email(message)
+ email
+ end
+
+ def to_s
+ email
+ end
+end
@@ -9,4 +9,4 @@
#Configures the methods needed by mailboxer
#config.email_method = :mailboxer_email
#config.name_method = :name
-end
+end
@@ -1,5 +1,7 @@
Rails.application.routes.draw do
+ devise_for :messaging_users
+
devise_for :users
mount Messaging::Engine => "/messaging"
@@ -0,0 +1,25 @@
+class DeviseCreateMessagingUsers < ActiveRecord::Migration
+ def change
+ create_table(:messaging_users) do |t|
+ t.database_authenticatable :null => false
+ t.recoverable
+ t.rememberable
+ t.trackable
+
+ # t.encryptable
+ # t.confirmable
+ # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
+ # t.token_authenticatable
+
+
+ t.timestamps
+ end
+
+ add_index :messaging_users, :email, :unique => true
+ add_index :messaging_users, :reset_password_token, :unique => true
+ # add_index :messaging_users, :confirmation_token, :unique => true
+ # add_index :messaging_users, :unlock_token, :unique => true
+ # add_index :messaging_users, :authentication_token, :unique => true
+ end
+
+end
@@ -11,14 +11,41 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20111205020919) do
+ActiveRecord::Schema.define(:version => 20111213052240) do
create_table "conversations", :force => true do |t|
t.string "subject", :default => ""
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
+ create_table "messaging_message_drafts", :force => true do |t|
+ t.integer "user_id"
+ t.string "recipients"
+ t.string "subject"
+ t.string "body"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ create_table "messaging_users", :force => true do |t|
+ t.string "email", :default => "", :null => false
+ t.string "encrypted_password", :limit => 128, :default => "", :null => false
+ t.string "reset_password_token"
+ t.datetime "reset_password_sent_at"
+ t.datetime "remember_created_at"
+ t.integer "sign_in_count", :default => 0
+ t.datetime "current_sign_in_at"
+ t.datetime "last_sign_in_at"
+ t.string "current_sign_in_ip"
+ t.string "last_sign_in_ip"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "messaging_users", ["email"], :name => "index_messaging_users_on_email", :unique => true
+ add_index "messaging_users", ["reset_password_token"], :name => "index_messaging_users_on_reset_password_token", :unique => true
+
create_table "notifications", :force => true do |t|
t.string "type"
t.text "body"
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class MessagingUserTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end

0 comments on commit 5e43ab1

Please sign in to comment.